pdf.combined.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 48);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  84. var FONT_IDENTITY_MATRIX = [
  85. 0.001,
  86. 0,
  87. 0,
  88. 0.001,
  89. 0,
  90. 0
  91. ];
  92. var TextRenderingMode = {
  93. FILL: 0,
  94. STROKE: 1,
  95. FILL_STROKE: 2,
  96. INVISIBLE: 3,
  97. FILL_ADD_TO_PATH: 4,
  98. STROKE_ADD_TO_PATH: 5,
  99. FILL_STROKE_ADD_TO_PATH: 6,
  100. ADD_TO_PATH: 7,
  101. FILL_STROKE_MASK: 3,
  102. ADD_TO_PATH_FLAG: 4
  103. };
  104. var ImageKind = {
  105. GRAYSCALE_1BPP: 1,
  106. RGB_24BPP: 2,
  107. RGBA_32BPP: 3
  108. };
  109. var AnnotationType = {
  110. TEXT: 1,
  111. LINK: 2,
  112. FREETEXT: 3,
  113. LINE: 4,
  114. SQUARE: 5,
  115. CIRCLE: 6,
  116. POLYGON: 7,
  117. POLYLINE: 8,
  118. HIGHLIGHT: 9,
  119. UNDERLINE: 10,
  120. SQUIGGLY: 11,
  121. STRIKEOUT: 12,
  122. STAMP: 13,
  123. CARET: 14,
  124. INK: 15,
  125. POPUP: 16,
  126. FILEATTACHMENT: 17,
  127. SOUND: 18,
  128. MOVIE: 19,
  129. WIDGET: 20,
  130. SCREEN: 21,
  131. PRINTERMARK: 22,
  132. TRAPNET: 23,
  133. WATERMARK: 24,
  134. THREED: 25,
  135. REDACT: 26
  136. };
  137. var AnnotationFlag = {
  138. INVISIBLE: 0x01,
  139. HIDDEN: 0x02,
  140. PRINT: 0x04,
  141. NOZOOM: 0x08,
  142. NOROTATE: 0x10,
  143. NOVIEW: 0x20,
  144. READONLY: 0x40,
  145. LOCKED: 0x80,
  146. TOGGLENOVIEW: 0x100,
  147. LOCKEDCONTENTS: 0x200
  148. };
  149. var AnnotationFieldFlag = {
  150. READONLY: 0x0000001,
  151. REQUIRED: 0x0000002,
  152. NOEXPORT: 0x0000004,
  153. MULTILINE: 0x0001000,
  154. PASSWORD: 0x0002000,
  155. NOTOGGLETOOFF: 0x0004000,
  156. RADIO: 0x0008000,
  157. PUSHBUTTON: 0x0010000,
  158. COMBO: 0x0020000,
  159. EDIT: 0x0040000,
  160. SORT: 0x0080000,
  161. FILESELECT: 0x0100000,
  162. MULTISELECT: 0x0200000,
  163. DONOTSPELLCHECK: 0x0400000,
  164. DONOTSCROLL: 0x0800000,
  165. COMB: 0x1000000,
  166. RICHTEXT: 0x2000000,
  167. RADIOSINUNISON: 0x2000000,
  168. COMMITONSELCHANGE: 0x4000000
  169. };
  170. var AnnotationBorderStyleType = {
  171. SOLID: 1,
  172. DASHED: 2,
  173. BEVELED: 3,
  174. INSET: 4,
  175. UNDERLINE: 5
  176. };
  177. var StreamType = {
  178. UNKNOWN: 0,
  179. FLATE: 1,
  180. LZW: 2,
  181. DCT: 3,
  182. JPX: 4,
  183. JBIG: 5,
  184. A85: 6,
  185. AHX: 7,
  186. CCF: 8,
  187. RL: 9
  188. };
  189. var FontType = {
  190. UNKNOWN: 0,
  191. TYPE1: 1,
  192. TYPE1C: 2,
  193. CIDFONTTYPE0: 3,
  194. CIDFONTTYPE0C: 4,
  195. TRUETYPE: 5,
  196. CIDFONTTYPE2: 6,
  197. TYPE3: 7,
  198. OPENTYPE: 8,
  199. TYPE0: 9,
  200. MMTYPE1: 10
  201. };
  202. var VERBOSITY_LEVELS = {
  203. errors: 0,
  204. warnings: 1,
  205. infos: 5
  206. };
  207. var OPS = {
  208. dependency: 1,
  209. setLineWidth: 2,
  210. setLineCap: 3,
  211. setLineJoin: 4,
  212. setMiterLimit: 5,
  213. setDash: 6,
  214. setRenderingIntent: 7,
  215. setFlatness: 8,
  216. setGState: 9,
  217. save: 10,
  218. restore: 11,
  219. transform: 12,
  220. moveTo: 13,
  221. lineTo: 14,
  222. curveTo: 15,
  223. curveTo2: 16,
  224. curveTo3: 17,
  225. closePath: 18,
  226. rectangle: 19,
  227. stroke: 20,
  228. closeStroke: 21,
  229. fill: 22,
  230. eoFill: 23,
  231. fillStroke: 24,
  232. eoFillStroke: 25,
  233. closeFillStroke: 26,
  234. closeEOFillStroke: 27,
  235. endPath: 28,
  236. clip: 29,
  237. eoClip: 30,
  238. beginText: 31,
  239. endText: 32,
  240. setCharSpacing: 33,
  241. setWordSpacing: 34,
  242. setHScale: 35,
  243. setLeading: 36,
  244. setFont: 37,
  245. setTextRenderingMode: 38,
  246. setTextRise: 39,
  247. moveText: 40,
  248. setLeadingMoveText: 41,
  249. setTextMatrix: 42,
  250. nextLine: 43,
  251. showText: 44,
  252. showSpacedText: 45,
  253. nextLineShowText: 46,
  254. nextLineSetSpacingShowText: 47,
  255. setCharWidth: 48,
  256. setCharWidthAndBounds: 49,
  257. setStrokeColorSpace: 50,
  258. setFillColorSpace: 51,
  259. setStrokeColor: 52,
  260. setStrokeColorN: 53,
  261. setFillColor: 54,
  262. setFillColorN: 55,
  263. setStrokeGray: 56,
  264. setFillGray: 57,
  265. setStrokeRGBColor: 58,
  266. setFillRGBColor: 59,
  267. setStrokeCMYKColor: 60,
  268. setFillCMYKColor: 61,
  269. shadingFill: 62,
  270. beginInlineImage: 63,
  271. beginImageData: 64,
  272. endInlineImage: 65,
  273. paintXObject: 66,
  274. markPoint: 67,
  275. markPointProps: 68,
  276. beginMarkedContent: 69,
  277. beginMarkedContentProps: 70,
  278. endMarkedContent: 71,
  279. beginCompat: 72,
  280. endCompat: 73,
  281. paintFormXObjectBegin: 74,
  282. paintFormXObjectEnd: 75,
  283. beginGroup: 76,
  284. endGroup: 77,
  285. beginAnnotations: 78,
  286. endAnnotations: 79,
  287. beginAnnotation: 80,
  288. endAnnotation: 81,
  289. paintJpegXObject: 82,
  290. paintImageMaskXObject: 83,
  291. paintImageMaskXObjectGroup: 84,
  292. paintImageXObject: 85,
  293. paintInlineImageXObject: 86,
  294. paintInlineImageXObjectGroup: 87,
  295. paintImageXObjectRepeat: 88,
  296. paintImageMaskXObjectRepeat: 89,
  297. paintSolidColorImageMask: 90,
  298. constructPath: 91
  299. };
  300. var verbosity = VERBOSITY_LEVELS.warnings;
  301. function setVerbosityLevel(level) {
  302. verbosity = level;
  303. }
  304. function getVerbosityLevel() {
  305. return verbosity;
  306. }
  307. function info(msg) {
  308. if (verbosity >= VERBOSITY_LEVELS.infos) {
  309. console.log('Info: ' + msg);
  310. }
  311. }
  312. function warn(msg) {
  313. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  314. console.log('Warning: ' + msg);
  315. }
  316. }
  317. function deprecated(details) {
  318. console.log('Deprecated API usage: ' + details);
  319. }
  320. function error(msg) {
  321. if (verbosity >= VERBOSITY_LEVELS.errors) {
  322. console.log('Error: ' + msg);
  323. console.log(backtrace());
  324. }
  325. throw new Error(msg);
  326. }
  327. function backtrace() {
  328. try {
  329. throw new Error();
  330. } catch (e) {
  331. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  332. }
  333. }
  334. function assert(cond, msg) {
  335. if (!cond) {
  336. error(msg);
  337. }
  338. }
  339. var UNSUPPORTED_FEATURES = {
  340. unknown: 'unknown',
  341. forms: 'forms',
  342. javaScript: 'javaScript',
  343. smask: 'smask',
  344. shadingPattern: 'shadingPattern',
  345. font: 'font'
  346. };
  347. function isSameOrigin(baseUrl, otherUrl) {
  348. try {
  349. var base = new URL(baseUrl);
  350. if (!base.origin || base.origin === 'null') {
  351. return false;
  352. }
  353. } catch (e) {
  354. return false;
  355. }
  356. var other = new URL(otherUrl, base);
  357. return base.origin === other.origin;
  358. }
  359. function isValidProtocol(url) {
  360. if (!url) {
  361. return false;
  362. }
  363. switch (url.protocol) {
  364. case 'http:':
  365. case 'https:':
  366. case 'ftp:':
  367. case 'mailto:':
  368. case 'tel:':
  369. return true;
  370. default:
  371. return false;
  372. }
  373. }
  374. function createValidAbsoluteUrl(url, baseUrl) {
  375. if (!url) {
  376. return null;
  377. }
  378. try {
  379. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  380. if (isValidProtocol(absoluteUrl)) {
  381. return absoluteUrl;
  382. }
  383. } catch (ex) {
  384. }
  385. return null;
  386. }
  387. function shadow(obj, prop, value) {
  388. Object.defineProperty(obj, prop, {
  389. value: value,
  390. enumerable: true,
  391. configurable: true,
  392. writable: false
  393. });
  394. return value;
  395. }
  396. function getLookupTableFactory(initializer) {
  397. var lookup;
  398. return function () {
  399. if (initializer) {
  400. lookup = Object.create(null);
  401. initializer(lookup);
  402. initializer = null;
  403. }
  404. return lookup;
  405. };
  406. }
  407. var PasswordResponses = {
  408. NEED_PASSWORD: 1,
  409. INCORRECT_PASSWORD: 2
  410. };
  411. var PasswordException = function PasswordExceptionClosure() {
  412. function PasswordException(msg, code) {
  413. this.name = 'PasswordException';
  414. this.message = msg;
  415. this.code = code;
  416. }
  417. PasswordException.prototype = new Error();
  418. PasswordException.constructor = PasswordException;
  419. return PasswordException;
  420. }();
  421. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  422. function UnknownErrorException(msg, details) {
  423. this.name = 'UnknownErrorException';
  424. this.message = msg;
  425. this.details = details;
  426. }
  427. UnknownErrorException.prototype = new Error();
  428. UnknownErrorException.constructor = UnknownErrorException;
  429. return UnknownErrorException;
  430. }();
  431. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  432. function InvalidPDFException(msg) {
  433. this.name = 'InvalidPDFException';
  434. this.message = msg;
  435. }
  436. InvalidPDFException.prototype = new Error();
  437. InvalidPDFException.constructor = InvalidPDFException;
  438. return InvalidPDFException;
  439. }();
  440. var MissingPDFException = function MissingPDFExceptionClosure() {
  441. function MissingPDFException(msg) {
  442. this.name = 'MissingPDFException';
  443. this.message = msg;
  444. }
  445. MissingPDFException.prototype = new Error();
  446. MissingPDFException.constructor = MissingPDFException;
  447. return MissingPDFException;
  448. }();
  449. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  450. function UnexpectedResponseException(msg, status) {
  451. this.name = 'UnexpectedResponseException';
  452. this.message = msg;
  453. this.status = status;
  454. }
  455. UnexpectedResponseException.prototype = new Error();
  456. UnexpectedResponseException.constructor = UnexpectedResponseException;
  457. return UnexpectedResponseException;
  458. }();
  459. var NotImplementedException = function NotImplementedExceptionClosure() {
  460. function NotImplementedException(msg) {
  461. this.message = msg;
  462. }
  463. NotImplementedException.prototype = new Error();
  464. NotImplementedException.prototype.name = 'NotImplementedException';
  465. NotImplementedException.constructor = NotImplementedException;
  466. return NotImplementedException;
  467. }();
  468. var MissingDataException = function MissingDataExceptionClosure() {
  469. function MissingDataException(begin, end) {
  470. this.begin = begin;
  471. this.end = end;
  472. this.message = 'Missing data [' + begin + ', ' + end + ')';
  473. }
  474. MissingDataException.prototype = new Error();
  475. MissingDataException.prototype.name = 'MissingDataException';
  476. MissingDataException.constructor = MissingDataException;
  477. return MissingDataException;
  478. }();
  479. var XRefParseException = function XRefParseExceptionClosure() {
  480. function XRefParseException(msg) {
  481. this.message = msg;
  482. }
  483. XRefParseException.prototype = new Error();
  484. XRefParseException.prototype.name = 'XRefParseException';
  485. XRefParseException.constructor = XRefParseException;
  486. return XRefParseException;
  487. }();
  488. var NullCharactersRegExp = /\x00/g;
  489. function removeNullCharacters(str) {
  490. if (typeof str !== 'string') {
  491. warn('The argument for removeNullCharacters must be a string.');
  492. return str;
  493. }
  494. return str.replace(NullCharactersRegExp, '');
  495. }
  496. function bytesToString(bytes) {
  497. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  498. var length = bytes.length;
  499. var MAX_ARGUMENT_COUNT = 8192;
  500. if (length < MAX_ARGUMENT_COUNT) {
  501. return String.fromCharCode.apply(null, bytes);
  502. }
  503. var strBuf = [];
  504. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  505. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  506. var chunk = bytes.subarray(i, chunkEnd);
  507. strBuf.push(String.fromCharCode.apply(null, chunk));
  508. }
  509. return strBuf.join('');
  510. }
  511. function stringToBytes(str) {
  512. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  513. var length = str.length;
  514. var bytes = new Uint8Array(length);
  515. for (var i = 0; i < length; ++i) {
  516. bytes[i] = str.charCodeAt(i) & 0xFF;
  517. }
  518. return bytes;
  519. }
  520. function arrayByteLength(arr) {
  521. if (arr.length !== undefined) {
  522. return arr.length;
  523. }
  524. assert(arr.byteLength !== undefined);
  525. return arr.byteLength;
  526. }
  527. function arraysToBytes(arr) {
  528. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  529. return arr[0];
  530. }
  531. var resultLength = 0;
  532. var i, ii = arr.length;
  533. var item, itemLength;
  534. for (i = 0; i < ii; i++) {
  535. item = arr[i];
  536. itemLength = arrayByteLength(item);
  537. resultLength += itemLength;
  538. }
  539. var pos = 0;
  540. var data = new Uint8Array(resultLength);
  541. for (i = 0; i < ii; i++) {
  542. item = arr[i];
  543. if (!(item instanceof Uint8Array)) {
  544. if (typeof item === 'string') {
  545. item = stringToBytes(item);
  546. } else {
  547. item = new Uint8Array(item);
  548. }
  549. }
  550. itemLength = item.byteLength;
  551. data.set(item, pos);
  552. pos += itemLength;
  553. }
  554. return data;
  555. }
  556. function string32(value) {
  557. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  558. }
  559. function log2(x) {
  560. var n = 1, i = 0;
  561. while (x > n) {
  562. n <<= 1;
  563. i++;
  564. }
  565. return i;
  566. }
  567. function readInt8(data, start) {
  568. return data[start] << 24 >> 24;
  569. }
  570. function readUint16(data, offset) {
  571. return data[offset] << 8 | data[offset + 1];
  572. }
  573. function readUint32(data, offset) {
  574. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  575. }
  576. function isLittleEndian() {
  577. var buffer8 = new Uint8Array(2);
  578. buffer8[0] = 1;
  579. var buffer16 = new Uint16Array(buffer8.buffer);
  580. return buffer16[0] === 1;
  581. }
  582. function isEvalSupported() {
  583. try {
  584. new Function('');
  585. return true;
  586. } catch (e) {
  587. return false;
  588. }
  589. }
  590. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  591. function Uint32ArrayView(buffer, length) {
  592. this.buffer = buffer;
  593. this.byteLength = buffer.length;
  594. this.length = length === undefined ? this.byteLength >> 2 : length;
  595. ensureUint32ArrayViewProps(this.length);
  596. }
  597. Uint32ArrayView.prototype = Object.create(null);
  598. var uint32ArrayViewSetters = 0;
  599. function createUint32ArrayProp(index) {
  600. return {
  601. get: function () {
  602. var buffer = this.buffer, offset = index << 2;
  603. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  604. },
  605. set: function (value) {
  606. var buffer = this.buffer, offset = index << 2;
  607. buffer[offset] = value & 255;
  608. buffer[offset + 1] = value >> 8 & 255;
  609. buffer[offset + 2] = value >> 16 & 255;
  610. buffer[offset + 3] = value >>> 24 & 255;
  611. }
  612. };
  613. }
  614. function ensureUint32ArrayViewProps(length) {
  615. while (uint32ArrayViewSetters < length) {
  616. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  617. uint32ArrayViewSetters++;
  618. }
  619. }
  620. return Uint32ArrayView;
  621. }();
  622. exports.Uint32ArrayView = Uint32ArrayView;
  623. var IDENTITY_MATRIX = [
  624. 1,
  625. 0,
  626. 0,
  627. 1,
  628. 0,
  629. 0
  630. ];
  631. var Util = function UtilClosure() {
  632. function Util() {
  633. }
  634. var rgbBuf = [
  635. 'rgb(',
  636. 0,
  637. ',',
  638. 0,
  639. ',',
  640. 0,
  641. ')'
  642. ];
  643. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  644. rgbBuf[1] = r;
  645. rgbBuf[3] = g;
  646. rgbBuf[5] = b;
  647. return rgbBuf.join('');
  648. };
  649. Util.transform = function Util_transform(m1, m2) {
  650. return [
  651. m1[0] * m2[0] + m1[2] * m2[1],
  652. m1[1] * m2[0] + m1[3] * m2[1],
  653. m1[0] * m2[2] + m1[2] * m2[3],
  654. m1[1] * m2[2] + m1[3] * m2[3],
  655. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  656. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  657. ];
  658. };
  659. Util.applyTransform = function Util_applyTransform(p, m) {
  660. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  661. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  662. return [
  663. xt,
  664. yt
  665. ];
  666. };
  667. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  668. var d = m[0] * m[3] - m[1] * m[2];
  669. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  670. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  671. return [
  672. xt,
  673. yt
  674. ];
  675. };
  676. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  677. var p1 = Util.applyTransform(r, m);
  678. var p2 = Util.applyTransform(r.slice(2, 4), m);
  679. var p3 = Util.applyTransform([
  680. r[0],
  681. r[3]
  682. ], m);
  683. var p4 = Util.applyTransform([
  684. r[2],
  685. r[1]
  686. ], m);
  687. return [
  688. Math.min(p1[0], p2[0], p3[0], p4[0]),
  689. Math.min(p1[1], p2[1], p3[1], p4[1]),
  690. Math.max(p1[0], p2[0], p3[0], p4[0]),
  691. Math.max(p1[1], p2[1], p3[1], p4[1])
  692. ];
  693. };
  694. Util.inverseTransform = function Util_inverseTransform(m) {
  695. var d = m[0] * m[3] - m[1] * m[2];
  696. return [
  697. m[3] / d,
  698. -m[1] / d,
  699. -m[2] / d,
  700. m[0] / d,
  701. (m[2] * m[5] - m[4] * m[3]) / d,
  702. (m[4] * m[1] - m[5] * m[0]) / d
  703. ];
  704. };
  705. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  706. return [
  707. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  708. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  709. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  710. ];
  711. };
  712. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  713. var transpose = [
  714. m[0],
  715. m[2],
  716. m[1],
  717. m[3]
  718. ];
  719. var a = m[0] * transpose[0] + m[1] * transpose[2];
  720. var b = m[0] * transpose[1] + m[1] * transpose[3];
  721. var c = m[2] * transpose[0] + m[3] * transpose[2];
  722. var d = m[2] * transpose[1] + m[3] * transpose[3];
  723. var first = (a + d) / 2;
  724. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  725. var sx = first + second || 1;
  726. var sy = first - second || 1;
  727. return [
  728. Math.sqrt(sx),
  729. Math.sqrt(sy)
  730. ];
  731. };
  732. Util.normalizeRect = function Util_normalizeRect(rect) {
  733. var r = rect.slice(0);
  734. if (rect[0] > rect[2]) {
  735. r[0] = rect[2];
  736. r[2] = rect[0];
  737. }
  738. if (rect[1] > rect[3]) {
  739. r[1] = rect[3];
  740. r[3] = rect[1];
  741. }
  742. return r;
  743. };
  744. Util.intersect = function Util_intersect(rect1, rect2) {
  745. function compare(a, b) {
  746. return a - b;
  747. }
  748. var orderedX = [
  749. rect1[0],
  750. rect1[2],
  751. rect2[0],
  752. rect2[2]
  753. ].sort(compare), orderedY = [
  754. rect1[1],
  755. rect1[3],
  756. rect2[1],
  757. rect2[3]
  758. ].sort(compare), result = [];
  759. rect1 = Util.normalizeRect(rect1);
  760. rect2 = Util.normalizeRect(rect2);
  761. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  762. result[0] = orderedX[1];
  763. result[2] = orderedX[2];
  764. } else {
  765. return false;
  766. }
  767. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  768. result[1] = orderedY[1];
  769. result[3] = orderedY[2];
  770. } else {
  771. return false;
  772. }
  773. return result;
  774. };
  775. Util.sign = function Util_sign(num) {
  776. return num < 0 ? -1 : 1;
  777. };
  778. var ROMAN_NUMBER_MAP = [
  779. '',
  780. 'C',
  781. 'CC',
  782. 'CCC',
  783. 'CD',
  784. 'D',
  785. 'DC',
  786. 'DCC',
  787. 'DCCC',
  788. 'CM',
  789. '',
  790. 'X',
  791. 'XX',
  792. 'XXX',
  793. 'XL',
  794. 'L',
  795. 'LX',
  796. 'LXX',
  797. 'LXXX',
  798. 'XC',
  799. '',
  800. 'I',
  801. 'II',
  802. 'III',
  803. 'IV',
  804. 'V',
  805. 'VI',
  806. 'VII',
  807. 'VIII',
  808. 'IX'
  809. ];
  810. Util.toRoman = function Util_toRoman(number, lowerCase) {
  811. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  812. var pos, romanBuf = [];
  813. while (number >= 1000) {
  814. number -= 1000;
  815. romanBuf.push('M');
  816. }
  817. pos = number / 100 | 0;
  818. number %= 100;
  819. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  820. pos = number / 10 | 0;
  821. number %= 10;
  822. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  823. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  824. var romanStr = romanBuf.join('');
  825. return lowerCase ? romanStr.toLowerCase() : romanStr;
  826. };
  827. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  828. Array.prototype.push.apply(arr1, arr2);
  829. };
  830. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  831. Array.prototype.unshift.apply(arr1, arr2);
  832. };
  833. Util.extendObj = function extendObj(obj1, obj2) {
  834. for (var key in obj2) {
  835. obj1[key] = obj2[key];
  836. }
  837. };
  838. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  839. while (dict && !dict.has(name)) {
  840. dict = dict.get('Parent');
  841. }
  842. if (!dict) {
  843. return null;
  844. }
  845. return getArray ? dict.getArray(name) : dict.get(name);
  846. };
  847. Util.inherit = function Util_inherit(sub, base, prototype) {
  848. sub.prototype = Object.create(base.prototype);
  849. sub.prototype.constructor = sub;
  850. for (var prop in prototype) {
  851. sub.prototype[prop] = prototype[prop];
  852. }
  853. };
  854. Util.loadScript = function Util_loadScript(src, callback) {
  855. var script = document.createElement('script');
  856. var loaded = false;
  857. script.setAttribute('src', src);
  858. if (callback) {
  859. script.onload = function () {
  860. if (!loaded) {
  861. callback();
  862. }
  863. loaded = true;
  864. };
  865. }
  866. document.getElementsByTagName('head')[0].appendChild(script);
  867. };
  868. return Util;
  869. }();
  870. var PageViewport = function PageViewportClosure() {
  871. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  872. this.viewBox = viewBox;
  873. this.scale = scale;
  874. this.rotation = rotation;
  875. this.offsetX = offsetX;
  876. this.offsetY = offsetY;
  877. var centerX = (viewBox[2] + viewBox[0]) / 2;
  878. var centerY = (viewBox[3] + viewBox[1]) / 2;
  879. var rotateA, rotateB, rotateC, rotateD;
  880. rotation = rotation % 360;
  881. rotation = rotation < 0 ? rotation + 360 : rotation;
  882. switch (rotation) {
  883. case 180:
  884. rotateA = -1;
  885. rotateB = 0;
  886. rotateC = 0;
  887. rotateD = 1;
  888. break;
  889. case 90:
  890. rotateA = 0;
  891. rotateB = 1;
  892. rotateC = 1;
  893. rotateD = 0;
  894. break;
  895. case 270:
  896. rotateA = 0;
  897. rotateB = -1;
  898. rotateC = -1;
  899. rotateD = 0;
  900. break;
  901. default:
  902. rotateA = 1;
  903. rotateB = 0;
  904. rotateC = 0;
  905. rotateD = -1;
  906. break;
  907. }
  908. if (dontFlip) {
  909. rotateC = -rotateC;
  910. rotateD = -rotateD;
  911. }
  912. var offsetCanvasX, offsetCanvasY;
  913. var width, height;
  914. if (rotateA === 0) {
  915. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  916. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  917. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  918. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  919. } else {
  920. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  921. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  922. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  923. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  924. }
  925. this.transform = [
  926. rotateA * scale,
  927. rotateB * scale,
  928. rotateC * scale,
  929. rotateD * scale,
  930. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  931. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  932. ];
  933. this.width = width;
  934. this.height = height;
  935. this.fontScale = scale;
  936. }
  937. PageViewport.prototype = {
  938. clone: function PageViewPort_clone(args) {
  939. args = args || {};
  940. var scale = 'scale' in args ? args.scale : this.scale;
  941. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  942. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  943. },
  944. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  945. return Util.applyTransform([
  946. x,
  947. y
  948. ], this.transform);
  949. },
  950. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  951. var tl = Util.applyTransform([
  952. rect[0],
  953. rect[1]
  954. ], this.transform);
  955. var br = Util.applyTransform([
  956. rect[2],
  957. rect[3]
  958. ], this.transform);
  959. return [
  960. tl[0],
  961. tl[1],
  962. br[0],
  963. br[1]
  964. ];
  965. },
  966. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  967. return Util.applyInverseTransform([
  968. x,
  969. y
  970. ], this.transform);
  971. }
  972. };
  973. return PageViewport;
  974. }();
  975. var PDFStringTranslateTable = [
  976. 0,
  977. 0,
  978. 0,
  979. 0,
  980. 0,
  981. 0,
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0x2D8,
  1001. 0x2C7,
  1002. 0x2C6,
  1003. 0x2D9,
  1004. 0x2DD,
  1005. 0x2DB,
  1006. 0x2DA,
  1007. 0x2DC,
  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. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0x2022,
  1105. 0x2020,
  1106. 0x2021,
  1107. 0x2026,
  1108. 0x2014,
  1109. 0x2013,
  1110. 0x192,
  1111. 0x2044,
  1112. 0x2039,
  1113. 0x203A,
  1114. 0x2212,
  1115. 0x2030,
  1116. 0x201E,
  1117. 0x201C,
  1118. 0x201D,
  1119. 0x2018,
  1120. 0x2019,
  1121. 0x201A,
  1122. 0x2122,
  1123. 0xFB01,
  1124. 0xFB02,
  1125. 0x141,
  1126. 0x152,
  1127. 0x160,
  1128. 0x178,
  1129. 0x17D,
  1130. 0x131,
  1131. 0x142,
  1132. 0x153,
  1133. 0x161,
  1134. 0x17E,
  1135. 0,
  1136. 0x20AC
  1137. ];
  1138. function stringToPDFString(str) {
  1139. var i, n = str.length, strBuf = [];
  1140. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1141. for (i = 2; i < n; i += 2) {
  1142. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1143. }
  1144. } else {
  1145. for (i = 0; i < n; ++i) {
  1146. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1147. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1148. }
  1149. }
  1150. return strBuf.join('');
  1151. }
  1152. function stringToUTF8String(str) {
  1153. return decodeURIComponent(escape(str));
  1154. }
  1155. function utf8StringToString(str) {
  1156. return unescape(encodeURIComponent(str));
  1157. }
  1158. function isEmptyObj(obj) {
  1159. for (var key in obj) {
  1160. return false;
  1161. }
  1162. return true;
  1163. }
  1164. function isBool(v) {
  1165. return typeof v === 'boolean';
  1166. }
  1167. function isInt(v) {
  1168. return typeof v === 'number' && (v | 0) === v;
  1169. }
  1170. function isNum(v) {
  1171. return typeof v === 'number';
  1172. }
  1173. function isString(v) {
  1174. return typeof v === 'string';
  1175. }
  1176. function isArray(v) {
  1177. return v instanceof Array;
  1178. }
  1179. function isArrayBuffer(v) {
  1180. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1181. }
  1182. function isSpace(ch) {
  1183. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1184. }
  1185. function createPromiseCapability() {
  1186. var capability = {};
  1187. capability.promise = new Promise(function (resolve, reject) {
  1188. capability.resolve = resolve;
  1189. capability.reject = reject;
  1190. });
  1191. return capability;
  1192. }
  1193. (function PromiseClosure() {
  1194. if (globalScope.Promise) {
  1195. if (typeof globalScope.Promise.all !== 'function') {
  1196. globalScope.Promise.all = function (iterable) {
  1197. var count = 0, results = [], resolve, reject;
  1198. var promise = new globalScope.Promise(function (resolve_, reject_) {
  1199. resolve = resolve_;
  1200. reject = reject_;
  1201. });
  1202. iterable.forEach(function (p, i) {
  1203. count++;
  1204. p.then(function (result) {
  1205. results[i] = result;
  1206. count--;
  1207. if (count === 0) {
  1208. resolve(results);
  1209. }
  1210. }, reject);
  1211. });
  1212. if (count === 0) {
  1213. resolve(results);
  1214. }
  1215. return promise;
  1216. };
  1217. }
  1218. if (typeof globalScope.Promise.resolve !== 'function') {
  1219. globalScope.Promise.resolve = function (value) {
  1220. return new globalScope.Promise(function (resolve) {
  1221. resolve(value);
  1222. });
  1223. };
  1224. }
  1225. if (typeof globalScope.Promise.reject !== 'function') {
  1226. globalScope.Promise.reject = function (reason) {
  1227. return new globalScope.Promise(function (resolve, reject) {
  1228. reject(reason);
  1229. });
  1230. };
  1231. }
  1232. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  1233. globalScope.Promise.prototype.catch = function (onReject) {
  1234. return globalScope.Promise.prototype.then(undefined, onReject);
  1235. };
  1236. }
  1237. return;
  1238. }
  1239. var STATUS_PENDING = 0;
  1240. var STATUS_RESOLVED = 1;
  1241. var STATUS_REJECTED = 2;
  1242. var REJECTION_TIMEOUT = 500;
  1243. var HandlerManager = {
  1244. handlers: [],
  1245. running: false,
  1246. unhandledRejections: [],
  1247. pendingRejectionCheck: false,
  1248. scheduleHandlers: function scheduleHandlers(promise) {
  1249. if (promise._status === STATUS_PENDING) {
  1250. return;
  1251. }
  1252. this.handlers = this.handlers.concat(promise._handlers);
  1253. promise._handlers = [];
  1254. if (this.running) {
  1255. return;
  1256. }
  1257. this.running = true;
  1258. setTimeout(this.runHandlers.bind(this), 0);
  1259. },
  1260. runHandlers: function runHandlers() {
  1261. var RUN_TIMEOUT = 1;
  1262. var timeoutAt = Date.now() + RUN_TIMEOUT;
  1263. while (this.handlers.length > 0) {
  1264. var handler = this.handlers.shift();
  1265. var nextStatus = handler.thisPromise._status;
  1266. var nextValue = handler.thisPromise._value;
  1267. try {
  1268. if (nextStatus === STATUS_RESOLVED) {
  1269. if (typeof handler.onResolve === 'function') {
  1270. nextValue = handler.onResolve(nextValue);
  1271. }
  1272. } else if (typeof handler.onReject === 'function') {
  1273. nextValue = handler.onReject(nextValue);
  1274. nextStatus = STATUS_RESOLVED;
  1275. if (handler.thisPromise._unhandledRejection) {
  1276. this.removeUnhandeledRejection(handler.thisPromise);
  1277. }
  1278. }
  1279. } catch (ex) {
  1280. nextStatus = STATUS_REJECTED;
  1281. nextValue = ex;
  1282. }
  1283. handler.nextPromise._updateStatus(nextStatus, nextValue);
  1284. if (Date.now() >= timeoutAt) {
  1285. break;
  1286. }
  1287. }
  1288. if (this.handlers.length > 0) {
  1289. setTimeout(this.runHandlers.bind(this), 0);
  1290. return;
  1291. }
  1292. this.running = false;
  1293. },
  1294. addUnhandledRejection: function addUnhandledRejection(promise) {
  1295. this.unhandledRejections.push({
  1296. promise: promise,
  1297. time: Date.now()
  1298. });
  1299. this.scheduleRejectionCheck();
  1300. },
  1301. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  1302. promise._unhandledRejection = false;
  1303. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1304. if (this.unhandledRejections[i].promise === promise) {
  1305. this.unhandledRejections.splice(i);
  1306. i--;
  1307. }
  1308. }
  1309. },
  1310. scheduleRejectionCheck: function scheduleRejectionCheck() {
  1311. if (this.pendingRejectionCheck) {
  1312. return;
  1313. }
  1314. this.pendingRejectionCheck = true;
  1315. setTimeout(function rejectionCheck() {
  1316. this.pendingRejectionCheck = false;
  1317. var now = Date.now();
  1318. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1319. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  1320. var unhandled = this.unhandledRejections[i].promise._value;
  1321. var msg = 'Unhandled rejection: ' + unhandled;
  1322. if (unhandled.stack) {
  1323. msg += '\n' + unhandled.stack;
  1324. }
  1325. warn(msg);
  1326. this.unhandledRejections.splice(i);
  1327. i--;
  1328. }
  1329. }
  1330. if (this.unhandledRejections.length) {
  1331. this.scheduleRejectionCheck();
  1332. }
  1333. }.bind(this), REJECTION_TIMEOUT);
  1334. }
  1335. };
  1336. var Promise = function Promise(resolver) {
  1337. this._status = STATUS_PENDING;
  1338. this._handlers = [];
  1339. try {
  1340. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  1341. } catch (e) {
  1342. this._reject(e);
  1343. }
  1344. };
  1345. Promise.all = function Promise_all(promises) {
  1346. var resolveAll, rejectAll;
  1347. var deferred = new Promise(function (resolve, reject) {
  1348. resolveAll = resolve;
  1349. rejectAll = reject;
  1350. });
  1351. var unresolved = promises.length;
  1352. var results = [];
  1353. if (unresolved === 0) {
  1354. resolveAll(results);
  1355. return deferred;
  1356. }
  1357. function reject(reason) {
  1358. if (deferred._status === STATUS_REJECTED) {
  1359. return;
  1360. }
  1361. results = [];
  1362. rejectAll(reason);
  1363. }
  1364. for (var i = 0, ii = promises.length; i < ii; ++i) {
  1365. var promise = promises[i];
  1366. var resolve = function (i) {
  1367. return function (value) {
  1368. if (deferred._status === STATUS_REJECTED) {
  1369. return;
  1370. }
  1371. results[i] = value;
  1372. unresolved--;
  1373. if (unresolved === 0) {
  1374. resolveAll(results);
  1375. }
  1376. };
  1377. }(i);
  1378. if (Promise.isPromise(promise)) {
  1379. promise.then(resolve, reject);
  1380. } else {
  1381. resolve(promise);
  1382. }
  1383. }
  1384. return deferred;
  1385. };
  1386. Promise.isPromise = function Promise_isPromise(value) {
  1387. return value && typeof value.then === 'function';
  1388. };
  1389. Promise.resolve = function Promise_resolve(value) {
  1390. return new Promise(function (resolve) {
  1391. resolve(value);
  1392. });
  1393. };
  1394. Promise.reject = function Promise_reject(reason) {
  1395. return new Promise(function (resolve, reject) {
  1396. reject(reason);
  1397. });
  1398. };
  1399. Promise.prototype = {
  1400. _status: null,
  1401. _value: null,
  1402. _handlers: null,
  1403. _unhandledRejection: null,
  1404. _updateStatus: function Promise__updateStatus(status, value) {
  1405. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  1406. return;
  1407. }
  1408. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  1409. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  1410. return;
  1411. }
  1412. this._status = status;
  1413. this._value = value;
  1414. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  1415. this._unhandledRejection = true;
  1416. HandlerManager.addUnhandledRejection(this);
  1417. }
  1418. HandlerManager.scheduleHandlers(this);
  1419. },
  1420. _resolve: function Promise_resolve(value) {
  1421. this._updateStatus(STATUS_RESOLVED, value);
  1422. },
  1423. _reject: function Promise_reject(reason) {
  1424. this._updateStatus(STATUS_REJECTED, reason);
  1425. },
  1426. then: function Promise_then(onResolve, onReject) {
  1427. var nextPromise = new Promise(function (resolve, reject) {
  1428. this.resolve = resolve;
  1429. this.reject = reject;
  1430. });
  1431. this._handlers.push({
  1432. thisPromise: this,
  1433. onResolve: onResolve,
  1434. onReject: onReject,
  1435. nextPromise: nextPromise
  1436. });
  1437. HandlerManager.scheduleHandlers(this);
  1438. return nextPromise;
  1439. },
  1440. catch: function Promise_catch(onReject) {
  1441. return this.then(undefined, onReject);
  1442. }
  1443. };
  1444. globalScope.Promise = Promise;
  1445. }());
  1446. (function WeakMapClosure() {
  1447. if (globalScope.WeakMap) {
  1448. return;
  1449. }
  1450. var id = 0;
  1451. function WeakMap() {
  1452. this.id = '$weakmap' + id++;
  1453. }
  1454. WeakMap.prototype = {
  1455. has: function (obj) {
  1456. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  1457. },
  1458. get: function (obj, defaultValue) {
  1459. return this.has(obj) ? obj[this.id] : defaultValue;
  1460. },
  1461. set: function (obj, value) {
  1462. Object.defineProperty(obj, this.id, {
  1463. value: value,
  1464. enumerable: false,
  1465. configurable: true
  1466. });
  1467. },
  1468. delete: function (obj) {
  1469. delete obj[this.id];
  1470. }
  1471. };
  1472. globalScope.WeakMap = WeakMap;
  1473. }());
  1474. var StatTimer = function StatTimerClosure() {
  1475. function rpad(str, pad, length) {
  1476. while (str.length < length) {
  1477. str += pad;
  1478. }
  1479. return str;
  1480. }
  1481. function StatTimer() {
  1482. this.started = Object.create(null);
  1483. this.times = [];
  1484. this.enabled = true;
  1485. }
  1486. StatTimer.prototype = {
  1487. time: function StatTimer_time(name) {
  1488. if (!this.enabled) {
  1489. return;
  1490. }
  1491. if (name in this.started) {
  1492. warn('Timer is already running for ' + name);
  1493. }
  1494. this.started[name] = Date.now();
  1495. },
  1496. timeEnd: function StatTimer_timeEnd(name) {
  1497. if (!this.enabled) {
  1498. return;
  1499. }
  1500. if (!(name in this.started)) {
  1501. warn('Timer has not been started for ' + name);
  1502. }
  1503. this.times.push({
  1504. 'name': name,
  1505. 'start': this.started[name],
  1506. 'end': Date.now()
  1507. });
  1508. delete this.started[name];
  1509. },
  1510. toString: function StatTimer_toString() {
  1511. var i, ii;
  1512. var times = this.times;
  1513. var out = '';
  1514. var longest = 0;
  1515. for (i = 0, ii = times.length; i < ii; ++i) {
  1516. var name = times[i]['name'];
  1517. if (name.length > longest) {
  1518. longest = name.length;
  1519. }
  1520. }
  1521. for (i = 0, ii = times.length; i < ii; ++i) {
  1522. var span = times[i];
  1523. var duration = span.end - span.start;
  1524. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1525. }
  1526. return out;
  1527. }
  1528. };
  1529. return StatTimer;
  1530. }();
  1531. var createBlob = function createBlob(data, contentType) {
  1532. if (typeof Blob !== 'undefined') {
  1533. return new Blob([data], { type: contentType });
  1534. }
  1535. warn('The "Blob" constructor is not supported.');
  1536. };
  1537. var createObjectURL = function createObjectURLClosure() {
  1538. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1539. return function createObjectURL(data, contentType, forceDataSchema) {
  1540. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1541. var blob = createBlob(data, contentType);
  1542. return URL.createObjectURL(blob);
  1543. }
  1544. var buffer = 'data:' + contentType + ';base64,';
  1545. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1546. var b1 = data[i] & 0xFF;
  1547. var b2 = data[i + 1] & 0xFF;
  1548. var b3 = data[i + 2] & 0xFF;
  1549. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1550. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1551. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1552. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1553. }
  1554. return buffer;
  1555. };
  1556. }();
  1557. function MessageHandler(sourceName, targetName, comObj) {
  1558. this.sourceName = sourceName;
  1559. this.targetName = targetName;
  1560. this.comObj = comObj;
  1561. this.callbackIndex = 1;
  1562. this.postMessageTransfers = true;
  1563. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1564. var ah = this.actionHandler = Object.create(null);
  1565. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1566. var data = event.data;
  1567. if (data.targetName !== this.sourceName) {
  1568. return;
  1569. }
  1570. if (data.isReply) {
  1571. var callbackId = data.callbackId;
  1572. if (data.callbackId in callbacksCapabilities) {
  1573. var callback = callbacksCapabilities[callbackId];
  1574. delete callbacksCapabilities[callbackId];
  1575. if ('error' in data) {
  1576. callback.reject(data.error);
  1577. } else {
  1578. callback.resolve(data.data);
  1579. }
  1580. } else {
  1581. error('Cannot resolve callback ' + callbackId);
  1582. }
  1583. } else if (data.action in ah) {
  1584. var action = ah[data.action];
  1585. if (data.callbackId) {
  1586. var sourceName = this.sourceName;
  1587. var targetName = data.sourceName;
  1588. Promise.resolve().then(function () {
  1589. return action[0].call(action[1], data.data);
  1590. }).then(function (result) {
  1591. comObj.postMessage({
  1592. sourceName: sourceName,
  1593. targetName: targetName,
  1594. isReply: true,
  1595. callbackId: data.callbackId,
  1596. data: result
  1597. });
  1598. }, function (reason) {
  1599. if (reason instanceof Error) {
  1600. reason = reason + '';
  1601. }
  1602. comObj.postMessage({
  1603. sourceName: sourceName,
  1604. targetName: targetName,
  1605. isReply: true,
  1606. callbackId: data.callbackId,
  1607. error: reason
  1608. });
  1609. });
  1610. } else {
  1611. action[0].call(action[1], data.data);
  1612. }
  1613. } else {
  1614. error('Unknown action from worker: ' + data.action);
  1615. }
  1616. }.bind(this);
  1617. comObj.addEventListener('message', this._onComObjOnMessage);
  1618. }
  1619. MessageHandler.prototype = {
  1620. on: function messageHandlerOn(actionName, handler, scope) {
  1621. var ah = this.actionHandler;
  1622. if (ah[actionName]) {
  1623. error('There is already an actionName called "' + actionName + '"');
  1624. }
  1625. ah[actionName] = [
  1626. handler,
  1627. scope
  1628. ];
  1629. },
  1630. send: function messageHandlerSend(actionName, data, transfers) {
  1631. var message = {
  1632. sourceName: this.sourceName,
  1633. targetName: this.targetName,
  1634. action: actionName,
  1635. data: data
  1636. };
  1637. this.postMessage(message, transfers);
  1638. },
  1639. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1640. var callbackId = this.callbackIndex++;
  1641. var message = {
  1642. sourceName: this.sourceName,
  1643. targetName: this.targetName,
  1644. action: actionName,
  1645. data: data,
  1646. callbackId: callbackId
  1647. };
  1648. var capability = createPromiseCapability();
  1649. this.callbacksCapabilities[callbackId] = capability;
  1650. try {
  1651. this.postMessage(message, transfers);
  1652. } catch (e) {
  1653. capability.reject(e);
  1654. }
  1655. return capability.promise;
  1656. },
  1657. postMessage: function (message, transfers) {
  1658. if (transfers && this.postMessageTransfers) {
  1659. this.comObj.postMessage(message, transfers);
  1660. } else {
  1661. this.comObj.postMessage(message);
  1662. }
  1663. },
  1664. destroy: function () {
  1665. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1666. }
  1667. };
  1668. function loadJpegStream(id, imageUrl, objs) {
  1669. var img = new Image();
  1670. img.onload = function loadJpegStream_onloadClosure() {
  1671. objs.resolve(id, img);
  1672. };
  1673. img.onerror = function loadJpegStream_onerrorClosure() {
  1674. objs.resolve(id, null);
  1675. warn('Error during JPEG image loading');
  1676. };
  1677. img.src = imageUrl;
  1678. }
  1679. (function checkURLConstructor(scope) {
  1680. var hasWorkingUrl = false;
  1681. try {
  1682. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  1683. var u = new URL('b', 'http://a');
  1684. u.pathname = 'c%20d';
  1685. hasWorkingUrl = u.href === 'http://a/c%20d';
  1686. }
  1687. } catch (e) {
  1688. }
  1689. if (hasWorkingUrl) {
  1690. return;
  1691. }
  1692. var relative = Object.create(null);
  1693. relative['ftp'] = 21;
  1694. relative['file'] = 0;
  1695. relative['gopher'] = 70;
  1696. relative['http'] = 80;
  1697. relative['https'] = 443;
  1698. relative['ws'] = 80;
  1699. relative['wss'] = 443;
  1700. var relativePathDotMapping = Object.create(null);
  1701. relativePathDotMapping['%2e'] = '.';
  1702. relativePathDotMapping['.%2e'] = '..';
  1703. relativePathDotMapping['%2e.'] = '..';
  1704. relativePathDotMapping['%2e%2e'] = '..';
  1705. function isRelativeScheme(scheme) {
  1706. return relative[scheme] !== undefined;
  1707. }
  1708. function invalid() {
  1709. clear.call(this);
  1710. this._isInvalid = true;
  1711. }
  1712. function IDNAToASCII(h) {
  1713. if (h === '') {
  1714. invalid.call(this);
  1715. }
  1716. return h.toLowerCase();
  1717. }
  1718. function percentEscape(c) {
  1719. var unicode = c.charCodeAt(0);
  1720. if (unicode > 0x20 && unicode < 0x7F && [
  1721. 0x22,
  1722. 0x23,
  1723. 0x3C,
  1724. 0x3E,
  1725. 0x3F,
  1726. 0x60
  1727. ].indexOf(unicode) === -1) {
  1728. return c;
  1729. }
  1730. return encodeURIComponent(c);
  1731. }
  1732. function percentEscapeQuery(c) {
  1733. var unicode = c.charCodeAt(0);
  1734. if (unicode > 0x20 && unicode < 0x7F && [
  1735. 0x22,
  1736. 0x23,
  1737. 0x3C,
  1738. 0x3E,
  1739. 0x60
  1740. ].indexOf(unicode) === -1) {
  1741. return c;
  1742. }
  1743. return encodeURIComponent(c);
  1744. }
  1745. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  1746. function parse(input, stateOverride, base) {
  1747. function err(message) {
  1748. errors.push(message);
  1749. }
  1750. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  1751. loop:
  1752. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  1753. var c = input[cursor];
  1754. switch (state) {
  1755. case 'scheme start':
  1756. if (c && ALPHA.test(c)) {
  1757. buffer += c.toLowerCase();
  1758. state = 'scheme';
  1759. } else if (!stateOverride) {
  1760. buffer = '';
  1761. state = 'no scheme';
  1762. continue;
  1763. } else {
  1764. err('Invalid scheme.');
  1765. break loop;
  1766. }
  1767. break;
  1768. case 'scheme':
  1769. if (c && ALPHANUMERIC.test(c)) {
  1770. buffer += c.toLowerCase();
  1771. } else if (c === ':') {
  1772. this._scheme = buffer;
  1773. buffer = '';
  1774. if (stateOverride) {
  1775. break loop;
  1776. }
  1777. if (isRelativeScheme(this._scheme)) {
  1778. this._isRelative = true;
  1779. }
  1780. if (this._scheme === 'file') {
  1781. state = 'relative';
  1782. } else if (this._isRelative && base && base._scheme === this._scheme) {
  1783. state = 'relative or authority';
  1784. } else if (this._isRelative) {
  1785. state = 'authority first slash';
  1786. } else {
  1787. state = 'scheme data';
  1788. }
  1789. } else if (!stateOverride) {
  1790. buffer = '';
  1791. cursor = 0;
  1792. state = 'no scheme';
  1793. continue;
  1794. } else if (EOF === c) {
  1795. break loop;
  1796. } else {
  1797. err('Code point not allowed in scheme: ' + c);
  1798. break loop;
  1799. }
  1800. break;
  1801. case 'scheme data':
  1802. if (c === '?') {
  1803. this._query = '?';
  1804. state = 'query';
  1805. } else if (c === '#') {
  1806. this._fragment = '#';
  1807. state = 'fragment';
  1808. } else {
  1809. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  1810. this._schemeData += percentEscape(c);
  1811. }
  1812. }
  1813. break;
  1814. case 'no scheme':
  1815. if (!base || !isRelativeScheme(base._scheme)) {
  1816. err('Missing scheme.');
  1817. invalid.call(this);
  1818. } else {
  1819. state = 'relative';
  1820. continue;
  1821. }
  1822. break;
  1823. case 'relative or authority':
  1824. if (c === '/' && input[cursor + 1] === '/') {
  1825. state = 'authority ignore slashes';
  1826. } else {
  1827. err('Expected /, got: ' + c);
  1828. state = 'relative';
  1829. continue;
  1830. }
  1831. break;
  1832. case 'relative':
  1833. this._isRelative = true;
  1834. if ('file' !== this._scheme) {
  1835. this._scheme = base._scheme;
  1836. }
  1837. if (EOF === c) {
  1838. this._host = base._host;
  1839. this._port = base._port;
  1840. this._path = base._path.slice();
  1841. this._query = base._query;
  1842. this._username = base._username;
  1843. this._password = base._password;
  1844. break loop;
  1845. } else if (c === '/' || c === '\\') {
  1846. if (c === '\\') {
  1847. err('\\ is an invalid code point.');
  1848. }
  1849. state = 'relative slash';
  1850. } else if (c === '?') {
  1851. this._host = base._host;
  1852. this._port = base._port;
  1853. this._path = base._path.slice();
  1854. this._query = '?';
  1855. this._username = base._username;
  1856. this._password = base._password;
  1857. state = 'query';
  1858. } else if (c === '#') {
  1859. this._host = base._host;
  1860. this._port = base._port;
  1861. this._path = base._path.slice();
  1862. this._query = base._query;
  1863. this._fragment = '#';
  1864. this._username = base._username;
  1865. this._password = base._password;
  1866. state = 'fragment';
  1867. } else {
  1868. var nextC = input[cursor + 1];
  1869. var nextNextC = input[cursor + 2];
  1870. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  1871. this._host = base._host;
  1872. this._port = base._port;
  1873. this._username = base._username;
  1874. this._password = base._password;
  1875. this._path = base._path.slice();
  1876. this._path.pop();
  1877. }
  1878. state = 'relative path';
  1879. continue;
  1880. }
  1881. break;
  1882. case 'relative slash':
  1883. if (c === '/' || c === '\\') {
  1884. if (c === '\\') {
  1885. err('\\ is an invalid code point.');
  1886. }
  1887. if (this._scheme === 'file') {
  1888. state = 'file host';
  1889. } else {
  1890. state = 'authority ignore slashes';
  1891. }
  1892. } else {
  1893. if ('file' !== this._scheme) {
  1894. this._host = base._host;
  1895. this._port = base._port;
  1896. this._username = base._username;
  1897. this._password = base._password;
  1898. }
  1899. state = 'relative path';
  1900. continue;
  1901. }
  1902. break;
  1903. case 'authority first slash':
  1904. if (c === '/') {
  1905. state = 'authority second slash';
  1906. } else {
  1907. err('Expected \'/\', got: ' + c);
  1908. state = 'authority ignore slashes';
  1909. continue;
  1910. }
  1911. break;
  1912. case 'authority second slash':
  1913. state = 'authority ignore slashes';
  1914. if ('/' !== c) {
  1915. err('Expected \'/\', got: ' + c);
  1916. continue;
  1917. }
  1918. break;
  1919. case 'authority ignore slashes':
  1920. if ('/' !== c && '\\' !== c) {
  1921. state = 'authority';
  1922. continue;
  1923. } else {
  1924. err('Expected authority, got: ' + c);
  1925. }
  1926. break;
  1927. case 'authority':
  1928. if (c === '@') {
  1929. if (seenAt) {
  1930. err('@ already seen.');
  1931. buffer += '%40';
  1932. }
  1933. seenAt = true;
  1934. for (var i = 0; i < buffer.length; i++) {
  1935. var cp = buffer[i];
  1936. if (cp === '\t' || cp === '\n' || cp === '\r') {
  1937. err('Invalid whitespace in authority.');
  1938. continue;
  1939. }
  1940. if (cp === ':' && this._password === null) {
  1941. this._password = '';
  1942. continue;
  1943. }
  1944. var tempC = percentEscape(cp);
  1945. if (null !== this._password) {
  1946. this._password += tempC;
  1947. } else {
  1948. this._username += tempC;
  1949. }
  1950. }
  1951. buffer = '';
  1952. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1953. cursor -= buffer.length;
  1954. buffer = '';
  1955. state = 'host';
  1956. continue;
  1957. } else {
  1958. buffer += c;
  1959. }
  1960. break;
  1961. case 'file host':
  1962. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1963. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  1964. state = 'relative path';
  1965. } else if (buffer.length === 0) {
  1966. state = 'relative path start';
  1967. } else {
  1968. this._host = IDNAToASCII.call(this, buffer);
  1969. buffer = '';
  1970. state = 'relative path start';
  1971. }
  1972. continue;
  1973. } else if (c === '\t' || c === '\n' || c === '\r') {
  1974. err('Invalid whitespace in file host.');
  1975. } else {
  1976. buffer += c;
  1977. }
  1978. break;
  1979. case 'host':
  1980. case 'hostname':
  1981. if (c === ':' && !seenBracket) {
  1982. this._host = IDNAToASCII.call(this, buffer);
  1983. buffer = '';
  1984. state = 'port';
  1985. if (stateOverride === 'hostname') {
  1986. break loop;
  1987. }
  1988. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1989. this._host = IDNAToASCII.call(this, buffer);
  1990. buffer = '';
  1991. state = 'relative path start';
  1992. if (stateOverride) {
  1993. break loop;
  1994. }
  1995. continue;
  1996. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  1997. if (c === '[') {
  1998. seenBracket = true;
  1999. } else if (c === ']') {
  2000. seenBracket = false;
  2001. }
  2002. buffer += c;
  2003. } else {
  2004. err('Invalid code point in host/hostname: ' + c);
  2005. }
  2006. break;
  2007. case 'port':
  2008. if (/[0-9]/.test(c)) {
  2009. buffer += c;
  2010. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  2011. if ('' !== buffer) {
  2012. var temp = parseInt(buffer, 10);
  2013. if (temp !== relative[this._scheme]) {
  2014. this._port = temp + '';
  2015. }
  2016. buffer = '';
  2017. }
  2018. if (stateOverride) {
  2019. break loop;
  2020. }
  2021. state = 'relative path start';
  2022. continue;
  2023. } else if (c === '\t' || c === '\n' || c === '\r') {
  2024. err('Invalid code point in port: ' + c);
  2025. } else {
  2026. invalid.call(this);
  2027. }
  2028. break;
  2029. case 'relative path start':
  2030. if (c === '\\') {
  2031. err('\'\\\' not allowed in path.');
  2032. }
  2033. state = 'relative path';
  2034. if ('/' !== c && '\\' !== c) {
  2035. continue;
  2036. }
  2037. break;
  2038. case 'relative path':
  2039. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  2040. if (c === '\\') {
  2041. err('\\ not allowed in relative path.');
  2042. }
  2043. var tmp;
  2044. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  2045. buffer = tmp;
  2046. }
  2047. if (buffer === '..') {
  2048. this._path.pop();
  2049. if ('/' !== c && '\\' !== c) {
  2050. this._path.push('');
  2051. }
  2052. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  2053. this._path.push('');
  2054. } else if ('.' !== buffer) {
  2055. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  2056. buffer = buffer[0] + ':';
  2057. }
  2058. this._path.push(buffer);
  2059. }
  2060. buffer = '';
  2061. if (c === '?') {
  2062. this._query = '?';
  2063. state = 'query';
  2064. } else if (c === '#') {
  2065. this._fragment = '#';
  2066. state = 'fragment';
  2067. }
  2068. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2069. buffer += percentEscape(c);
  2070. }
  2071. break;
  2072. case 'query':
  2073. if (!stateOverride && c === '#') {
  2074. this._fragment = '#';
  2075. state = 'fragment';
  2076. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2077. this._query += percentEscapeQuery(c);
  2078. }
  2079. break;
  2080. case 'fragment':
  2081. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2082. this._fragment += c;
  2083. }
  2084. break;
  2085. }
  2086. cursor++;
  2087. }
  2088. }
  2089. function clear() {
  2090. this._scheme = '';
  2091. this._schemeData = '';
  2092. this._username = '';
  2093. this._password = null;
  2094. this._host = '';
  2095. this._port = '';
  2096. this._path = [];
  2097. this._query = '';
  2098. this._fragment = '';
  2099. this._isInvalid = false;
  2100. this._isRelative = false;
  2101. }
  2102. function JURL(url, base) {
  2103. if (base !== undefined && !(base instanceof JURL)) {
  2104. base = new JURL(String(base));
  2105. }
  2106. this._url = url;
  2107. clear.call(this);
  2108. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  2109. parse.call(this, input, null, base);
  2110. }
  2111. JURL.prototype = {
  2112. toString: function () {
  2113. return this.href;
  2114. },
  2115. get href() {
  2116. if (this._isInvalid) {
  2117. return this._url;
  2118. }
  2119. var authority = '';
  2120. if ('' !== this._username || null !== this._password) {
  2121. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  2122. }
  2123. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  2124. },
  2125. set href(href) {
  2126. clear.call(this);
  2127. parse.call(this, href);
  2128. },
  2129. get protocol() {
  2130. return this._scheme + ':';
  2131. },
  2132. set protocol(protocol) {
  2133. if (this._isInvalid) {
  2134. return;
  2135. }
  2136. parse.call(this, protocol + ':', 'scheme start');
  2137. },
  2138. get host() {
  2139. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  2140. },
  2141. set host(host) {
  2142. if (this._isInvalid || !this._isRelative) {
  2143. return;
  2144. }
  2145. parse.call(this, host, 'host');
  2146. },
  2147. get hostname() {
  2148. return this._host;
  2149. },
  2150. set hostname(hostname) {
  2151. if (this._isInvalid || !this._isRelative) {
  2152. return;
  2153. }
  2154. parse.call(this, hostname, 'hostname');
  2155. },
  2156. get port() {
  2157. return this._port;
  2158. },
  2159. set port(port) {
  2160. if (this._isInvalid || !this._isRelative) {
  2161. return;
  2162. }
  2163. parse.call(this, port, 'port');
  2164. },
  2165. get pathname() {
  2166. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  2167. },
  2168. set pathname(pathname) {
  2169. if (this._isInvalid || !this._isRelative) {
  2170. return;
  2171. }
  2172. this._path = [];
  2173. parse.call(this, pathname, 'relative path start');
  2174. },
  2175. get search() {
  2176. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  2177. },
  2178. set search(search) {
  2179. if (this._isInvalid || !this._isRelative) {
  2180. return;
  2181. }
  2182. this._query = '?';
  2183. if (search[0] === '?') {
  2184. search = search.slice(1);
  2185. }
  2186. parse.call(this, search, 'query');
  2187. },
  2188. get hash() {
  2189. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  2190. },
  2191. set hash(hash) {
  2192. if (this._isInvalid) {
  2193. return;
  2194. }
  2195. this._fragment = '#';
  2196. if (hash[0] === '#') {
  2197. hash = hash.slice(1);
  2198. }
  2199. parse.call(this, hash, 'fragment');
  2200. },
  2201. get origin() {
  2202. var host;
  2203. if (this._isInvalid || !this._scheme) {
  2204. return '';
  2205. }
  2206. switch (this._scheme) {
  2207. case 'data':
  2208. case 'file':
  2209. case 'javascript':
  2210. case 'mailto':
  2211. return 'null';
  2212. }
  2213. host = this.host;
  2214. if (!host) {
  2215. return '';
  2216. }
  2217. return this._scheme + '://' + host;
  2218. }
  2219. };
  2220. var OriginalURL = scope.URL;
  2221. if (OriginalURL) {
  2222. JURL.createObjectURL = function (blob) {
  2223. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  2224. };
  2225. JURL.revokeObjectURL = function (url) {
  2226. OriginalURL.revokeObjectURL(url);
  2227. };
  2228. }
  2229. scope.URL = JURL;
  2230. }(globalScope));
  2231. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  2232. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  2233. exports.OPS = OPS;
  2234. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  2235. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  2236. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  2237. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  2238. exports.AnnotationFlag = AnnotationFlag;
  2239. exports.AnnotationType = AnnotationType;
  2240. exports.FontType = FontType;
  2241. exports.ImageKind = ImageKind;
  2242. exports.InvalidPDFException = InvalidPDFException;
  2243. exports.MessageHandler = MessageHandler;
  2244. exports.MissingDataException = MissingDataException;
  2245. exports.MissingPDFException = MissingPDFException;
  2246. exports.NotImplementedException = NotImplementedException;
  2247. exports.PageViewport = PageViewport;
  2248. exports.PasswordException = PasswordException;
  2249. exports.PasswordResponses = PasswordResponses;
  2250. exports.StatTimer = StatTimer;
  2251. exports.StreamType = StreamType;
  2252. exports.TextRenderingMode = TextRenderingMode;
  2253. exports.UnexpectedResponseException = UnexpectedResponseException;
  2254. exports.UnknownErrorException = UnknownErrorException;
  2255. exports.Util = Util;
  2256. exports.XRefParseException = XRefParseException;
  2257. exports.arrayByteLength = arrayByteLength;
  2258. exports.arraysToBytes = arraysToBytes;
  2259. exports.assert = assert;
  2260. exports.bytesToString = bytesToString;
  2261. exports.createBlob = createBlob;
  2262. exports.createPromiseCapability = createPromiseCapability;
  2263. exports.createObjectURL = createObjectURL;
  2264. exports.deprecated = deprecated;
  2265. exports.error = error;
  2266. exports.getLookupTableFactory = getLookupTableFactory;
  2267. exports.getVerbosityLevel = getVerbosityLevel;
  2268. exports.globalScope = globalScope;
  2269. exports.info = info;
  2270. exports.isArray = isArray;
  2271. exports.isArrayBuffer = isArrayBuffer;
  2272. exports.isBool = isBool;
  2273. exports.isEmptyObj = isEmptyObj;
  2274. exports.isInt = isInt;
  2275. exports.isNum = isNum;
  2276. exports.isString = isString;
  2277. exports.isSpace = isSpace;
  2278. exports.isSameOrigin = isSameOrigin;
  2279. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  2280. exports.isLittleEndian = isLittleEndian;
  2281. exports.isEvalSupported = isEvalSupported;
  2282. exports.loadJpegStream = loadJpegStream;
  2283. exports.log2 = log2;
  2284. exports.readInt8 = readInt8;
  2285. exports.readUint16 = readUint16;
  2286. exports.readUint32 = readUint32;
  2287. exports.removeNullCharacters = removeNullCharacters;
  2288. exports.setVerbosityLevel = setVerbosityLevel;
  2289. exports.shadow = shadow;
  2290. exports.string32 = string32;
  2291. exports.stringToBytes = stringToBytes;
  2292. exports.stringToPDFString = stringToPDFString;
  2293. exports.stringToUTF8String = stringToUTF8String;
  2294. exports.utf8StringToString = utf8StringToString;
  2295. exports.warn = warn;
  2296. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(26)))
  2297. /***/ }),
  2298. /* 1 */
  2299. /***/ (function(module, exports, __w_pdfjs_require__) {
  2300. "use strict";
  2301. var sharedUtil = __w_pdfjs_require__(0);
  2302. var isArray = sharedUtil.isArray;
  2303. var EOF = {};
  2304. var Name = function NameClosure() {
  2305. function Name(name) {
  2306. this.name = name;
  2307. }
  2308. Name.prototype = {};
  2309. var nameCache = Object.create(null);
  2310. Name.get = function Name_get(name) {
  2311. var nameValue = nameCache[name];
  2312. return nameValue ? nameValue : nameCache[name] = new Name(name);
  2313. };
  2314. return Name;
  2315. }();
  2316. var Cmd = function CmdClosure() {
  2317. function Cmd(cmd) {
  2318. this.cmd = cmd;
  2319. }
  2320. Cmd.prototype = {};
  2321. var cmdCache = Object.create(null);
  2322. Cmd.get = function Cmd_get(cmd) {
  2323. var cmdValue = cmdCache[cmd];
  2324. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  2325. };
  2326. return Cmd;
  2327. }();
  2328. var Dict = function DictClosure() {
  2329. var nonSerializable = function nonSerializableClosure() {
  2330. return nonSerializable;
  2331. };
  2332. function Dict(xref) {
  2333. this.map = Object.create(null);
  2334. this.xref = xref;
  2335. this.objId = null;
  2336. this.suppressEncryption = false;
  2337. this.__nonSerializable__ = nonSerializable;
  2338. }
  2339. Dict.prototype = {
  2340. assignXref: function Dict_assignXref(newXref) {
  2341. this.xref = newXref;
  2342. },
  2343. get: function Dict_get(key1, key2, key3) {
  2344. var value;
  2345. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2346. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2347. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2348. }
  2349. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2350. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2351. }
  2352. value = this.map[key3] || null;
  2353. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2354. },
  2355. getAsync: function Dict_getAsync(key1, key2, key3) {
  2356. var value;
  2357. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2358. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2359. if (xref) {
  2360. return xref.fetchIfRefAsync(value, suppressEncryption);
  2361. }
  2362. return Promise.resolve(value);
  2363. }
  2364. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2365. if (xref) {
  2366. return xref.fetchIfRefAsync(value, suppressEncryption);
  2367. }
  2368. return Promise.resolve(value);
  2369. }
  2370. value = this.map[key3] || null;
  2371. if (xref) {
  2372. return xref.fetchIfRefAsync(value, suppressEncryption);
  2373. }
  2374. return Promise.resolve(value);
  2375. },
  2376. getArray: function Dict_getArray(key1, key2, key3) {
  2377. var value = this.get(key1, key2, key3);
  2378. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2379. if (!isArray(value) || !xref) {
  2380. return value;
  2381. }
  2382. value = value.slice();
  2383. for (var i = 0, ii = value.length; i < ii; i++) {
  2384. if (!isRef(value[i])) {
  2385. continue;
  2386. }
  2387. value[i] = xref.fetch(value[i], suppressEncryption);
  2388. }
  2389. return value;
  2390. },
  2391. getRaw: function Dict_getRaw(key) {
  2392. return this.map[key];
  2393. },
  2394. getKeys: function Dict_getKeys() {
  2395. return Object.keys(this.map);
  2396. },
  2397. set: function Dict_set(key, value) {
  2398. this.map[key] = value;
  2399. },
  2400. has: function Dict_has(key) {
  2401. return key in this.map;
  2402. },
  2403. forEach: function Dict_forEach(callback) {
  2404. for (var key in this.map) {
  2405. callback(key, this.get(key));
  2406. }
  2407. }
  2408. };
  2409. Dict.empty = new Dict(null);
  2410. Dict.merge = function Dict_merge(xref, dictArray) {
  2411. var mergedDict = new Dict(xref);
  2412. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  2413. var dict = dictArray[i];
  2414. if (!isDict(dict)) {
  2415. continue;
  2416. }
  2417. for (var keyName in dict.map) {
  2418. if (mergedDict.map[keyName]) {
  2419. continue;
  2420. }
  2421. mergedDict.map[keyName] = dict.map[keyName];
  2422. }
  2423. }
  2424. return mergedDict;
  2425. };
  2426. return Dict;
  2427. }();
  2428. var Ref = function RefClosure() {
  2429. function Ref(num, gen) {
  2430. this.num = num;
  2431. this.gen = gen;
  2432. }
  2433. Ref.prototype = {
  2434. toString: function Ref_toString() {
  2435. var str = this.num + 'R';
  2436. if (this.gen !== 0) {
  2437. str += this.gen;
  2438. }
  2439. return str;
  2440. }
  2441. };
  2442. return Ref;
  2443. }();
  2444. var RefSet = function RefSetClosure() {
  2445. function RefSet() {
  2446. this.dict = Object.create(null);
  2447. }
  2448. RefSet.prototype = {
  2449. has: function RefSet_has(ref) {
  2450. return ref.toString() in this.dict;
  2451. },
  2452. put: function RefSet_put(ref) {
  2453. this.dict[ref.toString()] = true;
  2454. },
  2455. remove: function RefSet_remove(ref) {
  2456. delete this.dict[ref.toString()];
  2457. }
  2458. };
  2459. return RefSet;
  2460. }();
  2461. var RefSetCache = function RefSetCacheClosure() {
  2462. function RefSetCache() {
  2463. this.dict = Object.create(null);
  2464. }
  2465. RefSetCache.prototype = {
  2466. get: function RefSetCache_get(ref) {
  2467. return this.dict[ref.toString()];
  2468. },
  2469. has: function RefSetCache_has(ref) {
  2470. return ref.toString() in this.dict;
  2471. },
  2472. put: function RefSetCache_put(ref, obj) {
  2473. this.dict[ref.toString()] = obj;
  2474. },
  2475. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  2476. this.dict[ref.toString()] = this.get(aliasRef);
  2477. },
  2478. forEach: function RefSetCache_forEach(fn, thisArg) {
  2479. for (var i in this.dict) {
  2480. fn.call(thisArg, this.dict[i]);
  2481. }
  2482. },
  2483. clear: function RefSetCache_clear() {
  2484. this.dict = Object.create(null);
  2485. }
  2486. };
  2487. return RefSetCache;
  2488. }();
  2489. function isEOF(v) {
  2490. return v === EOF;
  2491. }
  2492. function isName(v, name) {
  2493. return v instanceof Name && (name === undefined || v.name === name);
  2494. }
  2495. function isCmd(v, cmd) {
  2496. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2497. }
  2498. function isDict(v, type) {
  2499. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  2500. }
  2501. function isRef(v) {
  2502. return v instanceof Ref;
  2503. }
  2504. function isRefsEqual(v1, v2) {
  2505. return v1.num === v2.num && v1.gen === v2.gen;
  2506. }
  2507. function isStream(v) {
  2508. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  2509. }
  2510. exports.EOF = EOF;
  2511. exports.Cmd = Cmd;
  2512. exports.Dict = Dict;
  2513. exports.Name = Name;
  2514. exports.Ref = Ref;
  2515. exports.RefSet = RefSet;
  2516. exports.RefSetCache = RefSetCache;
  2517. exports.isEOF = isEOF;
  2518. exports.isCmd = isCmd;
  2519. exports.isDict = isDict;
  2520. exports.isName = isName;
  2521. exports.isRef = isRef;
  2522. exports.isRefsEqual = isRefsEqual;
  2523. exports.isStream = isStream;
  2524. /***/ }),
  2525. /* 2 */
  2526. /***/ (function(module, exports, __w_pdfjs_require__) {
  2527. "use strict";
  2528. var sharedUtil = __w_pdfjs_require__(0);
  2529. var corePrimitives = __w_pdfjs_require__(1);
  2530. var coreJbig2 = __w_pdfjs_require__(36);
  2531. var coreJpg = __w_pdfjs_require__(37);
  2532. var coreJpx = __w_pdfjs_require__(18);
  2533. var Util = sharedUtil.Util;
  2534. var error = sharedUtil.error;
  2535. var info = sharedUtil.info;
  2536. var isInt = sharedUtil.isInt;
  2537. var isArray = sharedUtil.isArray;
  2538. var createObjectURL = sharedUtil.createObjectURL;
  2539. var shadow = sharedUtil.shadow;
  2540. var isSpace = sharedUtil.isSpace;
  2541. var Dict = corePrimitives.Dict;
  2542. var isDict = corePrimitives.isDict;
  2543. var isStream = corePrimitives.isStream;
  2544. var Jbig2Image = coreJbig2.Jbig2Image;
  2545. var JpegImage = coreJpg.JpegImage;
  2546. var JpxImage = coreJpx.JpxImage;
  2547. var Stream = function StreamClosure() {
  2548. function Stream(arrayBuffer, start, length, dict) {
  2549. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2550. this.start = start || 0;
  2551. this.pos = this.start;
  2552. this.end = start + length || this.bytes.length;
  2553. this.dict = dict;
  2554. }
  2555. Stream.prototype = {
  2556. get length() {
  2557. return this.end - this.start;
  2558. },
  2559. get isEmpty() {
  2560. return this.length === 0;
  2561. },
  2562. getByte: function Stream_getByte() {
  2563. if (this.pos >= this.end) {
  2564. return -1;
  2565. }
  2566. return this.bytes[this.pos++];
  2567. },
  2568. getUint16: function Stream_getUint16() {
  2569. var b0 = this.getByte();
  2570. var b1 = this.getByte();
  2571. if (b0 === -1 || b1 === -1) {
  2572. return -1;
  2573. }
  2574. return (b0 << 8) + b1;
  2575. },
  2576. getInt32: function Stream_getInt32() {
  2577. var b0 = this.getByte();
  2578. var b1 = this.getByte();
  2579. var b2 = this.getByte();
  2580. var b3 = this.getByte();
  2581. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2582. },
  2583. getBytes: function Stream_getBytes(length) {
  2584. var bytes = this.bytes;
  2585. var pos = this.pos;
  2586. var strEnd = this.end;
  2587. if (!length) {
  2588. return bytes.subarray(pos, strEnd);
  2589. }
  2590. var end = pos + length;
  2591. if (end > strEnd) {
  2592. end = strEnd;
  2593. }
  2594. this.pos = end;
  2595. return bytes.subarray(pos, end);
  2596. },
  2597. peekByte: function Stream_peekByte() {
  2598. var peekedByte = this.getByte();
  2599. this.pos--;
  2600. return peekedByte;
  2601. },
  2602. peekBytes: function Stream_peekBytes(length) {
  2603. var bytes = this.getBytes(length);
  2604. this.pos -= bytes.length;
  2605. return bytes;
  2606. },
  2607. skip: function Stream_skip(n) {
  2608. if (!n) {
  2609. n = 1;
  2610. }
  2611. this.pos += n;
  2612. },
  2613. reset: function Stream_reset() {
  2614. this.pos = this.start;
  2615. },
  2616. moveStart: function Stream_moveStart() {
  2617. this.start = this.pos;
  2618. },
  2619. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  2620. return new Stream(this.bytes.buffer, start, length, dict);
  2621. }
  2622. };
  2623. return Stream;
  2624. }();
  2625. var StringStream = function StringStreamClosure() {
  2626. function StringStream(str) {
  2627. var length = str.length;
  2628. var bytes = new Uint8Array(length);
  2629. for (var n = 0; n < length; ++n) {
  2630. bytes[n] = str.charCodeAt(n);
  2631. }
  2632. Stream.call(this, bytes);
  2633. }
  2634. StringStream.prototype = Stream.prototype;
  2635. return StringStream;
  2636. }();
  2637. var DecodeStream = function DecodeStreamClosure() {
  2638. var emptyBuffer = new Uint8Array(0);
  2639. function DecodeStream(maybeMinBufferLength) {
  2640. this.pos = 0;
  2641. this.bufferLength = 0;
  2642. this.eof = false;
  2643. this.buffer = emptyBuffer;
  2644. this.minBufferLength = 512;
  2645. if (maybeMinBufferLength) {
  2646. while (this.minBufferLength < maybeMinBufferLength) {
  2647. this.minBufferLength *= 2;
  2648. }
  2649. }
  2650. }
  2651. DecodeStream.prototype = {
  2652. get isEmpty() {
  2653. while (!this.eof && this.bufferLength === 0) {
  2654. this.readBlock();
  2655. }
  2656. return this.bufferLength === 0;
  2657. },
  2658. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  2659. var buffer = this.buffer;
  2660. if (requested <= buffer.byteLength) {
  2661. return buffer;
  2662. }
  2663. var size = this.minBufferLength;
  2664. while (size < requested) {
  2665. size *= 2;
  2666. }
  2667. var buffer2 = new Uint8Array(size);
  2668. buffer2.set(buffer);
  2669. return this.buffer = buffer2;
  2670. },
  2671. getByte: function DecodeStream_getByte() {
  2672. var pos = this.pos;
  2673. while (this.bufferLength <= pos) {
  2674. if (this.eof) {
  2675. return -1;
  2676. }
  2677. this.readBlock();
  2678. }
  2679. return this.buffer[this.pos++];
  2680. },
  2681. getUint16: function DecodeStream_getUint16() {
  2682. var b0 = this.getByte();
  2683. var b1 = this.getByte();
  2684. if (b0 === -1 || b1 === -1) {
  2685. return -1;
  2686. }
  2687. return (b0 << 8) + b1;
  2688. },
  2689. getInt32: function DecodeStream_getInt32() {
  2690. var b0 = this.getByte();
  2691. var b1 = this.getByte();
  2692. var b2 = this.getByte();
  2693. var b3 = this.getByte();
  2694. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2695. },
  2696. getBytes: function DecodeStream_getBytes(length) {
  2697. var end, pos = this.pos;
  2698. if (length) {
  2699. this.ensureBuffer(pos + length);
  2700. end = pos + length;
  2701. while (!this.eof && this.bufferLength < end) {
  2702. this.readBlock();
  2703. }
  2704. var bufEnd = this.bufferLength;
  2705. if (end > bufEnd) {
  2706. end = bufEnd;
  2707. }
  2708. } else {
  2709. while (!this.eof) {
  2710. this.readBlock();
  2711. }
  2712. end = this.bufferLength;
  2713. }
  2714. this.pos = end;
  2715. return this.buffer.subarray(pos, end);
  2716. },
  2717. peekByte: function DecodeStream_peekByte() {
  2718. var peekedByte = this.getByte();
  2719. this.pos--;
  2720. return peekedByte;
  2721. },
  2722. peekBytes: function DecodeStream_peekBytes(length) {
  2723. var bytes = this.getBytes(length);
  2724. this.pos -= bytes.length;
  2725. return bytes;
  2726. },
  2727. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  2728. var end = start + length;
  2729. while (this.bufferLength <= end && !this.eof) {
  2730. this.readBlock();
  2731. }
  2732. return new Stream(this.buffer, start, length, dict);
  2733. },
  2734. skip: function DecodeStream_skip(n) {
  2735. if (!n) {
  2736. n = 1;
  2737. }
  2738. this.pos += n;
  2739. },
  2740. reset: function DecodeStream_reset() {
  2741. this.pos = 0;
  2742. },
  2743. getBaseStreams: function DecodeStream_getBaseStreams() {
  2744. if (this.str && this.str.getBaseStreams) {
  2745. return this.str.getBaseStreams();
  2746. }
  2747. return [];
  2748. }
  2749. };
  2750. return DecodeStream;
  2751. }();
  2752. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  2753. function StreamsSequenceStream(streams) {
  2754. this.streams = streams;
  2755. DecodeStream.call(this, null);
  2756. }
  2757. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  2758. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  2759. var streams = this.streams;
  2760. if (streams.length === 0) {
  2761. this.eof = true;
  2762. return;
  2763. }
  2764. var stream = streams.shift();
  2765. var chunk = stream.getBytes();
  2766. var bufferLength = this.bufferLength;
  2767. var newLength = bufferLength + chunk.length;
  2768. var buffer = this.ensureBuffer(newLength);
  2769. buffer.set(chunk, bufferLength);
  2770. this.bufferLength = newLength;
  2771. };
  2772. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  2773. var baseStreams = [];
  2774. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  2775. var stream = this.streams[i];
  2776. if (stream.getBaseStreams) {
  2777. Util.appendToArray(baseStreams, stream.getBaseStreams());
  2778. }
  2779. }
  2780. return baseStreams;
  2781. };
  2782. return StreamsSequenceStream;
  2783. }();
  2784. var FlateStream = function FlateStreamClosure() {
  2785. var codeLenCodeMap = new Int32Array([
  2786. 16,
  2787. 17,
  2788. 18,
  2789. 0,
  2790. 8,
  2791. 7,
  2792. 9,
  2793. 6,
  2794. 10,
  2795. 5,
  2796. 11,
  2797. 4,
  2798. 12,
  2799. 3,
  2800. 13,
  2801. 2,
  2802. 14,
  2803. 1,
  2804. 15
  2805. ]);
  2806. var lengthDecode = new Int32Array([
  2807. 0x00003,
  2808. 0x00004,
  2809. 0x00005,
  2810. 0x00006,
  2811. 0x00007,
  2812. 0x00008,
  2813. 0x00009,
  2814. 0x0000a,
  2815. 0x1000b,
  2816. 0x1000d,
  2817. 0x1000f,
  2818. 0x10011,
  2819. 0x20013,
  2820. 0x20017,
  2821. 0x2001b,
  2822. 0x2001f,
  2823. 0x30023,
  2824. 0x3002b,
  2825. 0x30033,
  2826. 0x3003b,
  2827. 0x40043,
  2828. 0x40053,
  2829. 0x40063,
  2830. 0x40073,
  2831. 0x50083,
  2832. 0x500a3,
  2833. 0x500c3,
  2834. 0x500e3,
  2835. 0x00102,
  2836. 0x00102,
  2837. 0x00102
  2838. ]);
  2839. var distDecode = new Int32Array([
  2840. 0x00001,
  2841. 0x00002,
  2842. 0x00003,
  2843. 0x00004,
  2844. 0x10005,
  2845. 0x10007,
  2846. 0x20009,
  2847. 0x2000d,
  2848. 0x30011,
  2849. 0x30019,
  2850. 0x40021,
  2851. 0x40031,
  2852. 0x50041,
  2853. 0x50061,
  2854. 0x60081,
  2855. 0x600c1,
  2856. 0x70101,
  2857. 0x70181,
  2858. 0x80201,
  2859. 0x80301,
  2860. 0x90401,
  2861. 0x90601,
  2862. 0xa0801,
  2863. 0xa0c01,
  2864. 0xb1001,
  2865. 0xb1801,
  2866. 0xc2001,
  2867. 0xc3001,
  2868. 0xd4001,
  2869. 0xd6001
  2870. ]);
  2871. var fixedLitCodeTab = [
  2872. new Int32Array([
  2873. 0x70100,
  2874. 0x80050,
  2875. 0x80010,
  2876. 0x80118,
  2877. 0x70110,
  2878. 0x80070,
  2879. 0x80030,
  2880. 0x900c0,
  2881. 0x70108,
  2882. 0x80060,
  2883. 0x80020,
  2884. 0x900a0,
  2885. 0x80000,
  2886. 0x80080,
  2887. 0x80040,
  2888. 0x900e0,
  2889. 0x70104,
  2890. 0x80058,
  2891. 0x80018,
  2892. 0x90090,
  2893. 0x70114,
  2894. 0x80078,
  2895. 0x80038,
  2896. 0x900d0,
  2897. 0x7010c,
  2898. 0x80068,
  2899. 0x80028,
  2900. 0x900b0,
  2901. 0x80008,
  2902. 0x80088,
  2903. 0x80048,
  2904. 0x900f0,
  2905. 0x70102,
  2906. 0x80054,
  2907. 0x80014,
  2908. 0x8011c,
  2909. 0x70112,
  2910. 0x80074,
  2911. 0x80034,
  2912. 0x900c8,
  2913. 0x7010a,
  2914. 0x80064,
  2915. 0x80024,
  2916. 0x900a8,
  2917. 0x80004,
  2918. 0x80084,
  2919. 0x80044,
  2920. 0x900e8,
  2921. 0x70106,
  2922. 0x8005c,
  2923. 0x8001c,
  2924. 0x90098,
  2925. 0x70116,
  2926. 0x8007c,
  2927. 0x8003c,
  2928. 0x900d8,
  2929. 0x7010e,
  2930. 0x8006c,
  2931. 0x8002c,
  2932. 0x900b8,
  2933. 0x8000c,
  2934. 0x8008c,
  2935. 0x8004c,
  2936. 0x900f8,
  2937. 0x70101,
  2938. 0x80052,
  2939. 0x80012,
  2940. 0x8011a,
  2941. 0x70111,
  2942. 0x80072,
  2943. 0x80032,
  2944. 0x900c4,
  2945. 0x70109,
  2946. 0x80062,
  2947. 0x80022,
  2948. 0x900a4,
  2949. 0x80002,
  2950. 0x80082,
  2951. 0x80042,
  2952. 0x900e4,
  2953. 0x70105,
  2954. 0x8005a,
  2955. 0x8001a,
  2956. 0x90094,
  2957. 0x70115,
  2958. 0x8007a,
  2959. 0x8003a,
  2960. 0x900d4,
  2961. 0x7010d,
  2962. 0x8006a,
  2963. 0x8002a,
  2964. 0x900b4,
  2965. 0x8000a,
  2966. 0x8008a,
  2967. 0x8004a,
  2968. 0x900f4,
  2969. 0x70103,
  2970. 0x80056,
  2971. 0x80016,
  2972. 0x8011e,
  2973. 0x70113,
  2974. 0x80076,
  2975. 0x80036,
  2976. 0x900cc,
  2977. 0x7010b,
  2978. 0x80066,
  2979. 0x80026,
  2980. 0x900ac,
  2981. 0x80006,
  2982. 0x80086,
  2983. 0x80046,
  2984. 0x900ec,
  2985. 0x70107,
  2986. 0x8005e,
  2987. 0x8001e,
  2988. 0x9009c,
  2989. 0x70117,
  2990. 0x8007e,
  2991. 0x8003e,
  2992. 0x900dc,
  2993. 0x7010f,
  2994. 0x8006e,
  2995. 0x8002e,
  2996. 0x900bc,
  2997. 0x8000e,
  2998. 0x8008e,
  2999. 0x8004e,
  3000. 0x900fc,
  3001. 0x70100,
  3002. 0x80051,
  3003. 0x80011,
  3004. 0x80119,
  3005. 0x70110,
  3006. 0x80071,
  3007. 0x80031,
  3008. 0x900c2,
  3009. 0x70108,
  3010. 0x80061,
  3011. 0x80021,
  3012. 0x900a2,
  3013. 0x80001,
  3014. 0x80081,
  3015. 0x80041,
  3016. 0x900e2,
  3017. 0x70104,
  3018. 0x80059,
  3019. 0x80019,
  3020. 0x90092,
  3021. 0x70114,
  3022. 0x80079,
  3023. 0x80039,
  3024. 0x900d2,
  3025. 0x7010c,
  3026. 0x80069,
  3027. 0x80029,
  3028. 0x900b2,
  3029. 0x80009,
  3030. 0x80089,
  3031. 0x80049,
  3032. 0x900f2,
  3033. 0x70102,
  3034. 0x80055,
  3035. 0x80015,
  3036. 0x8011d,
  3037. 0x70112,
  3038. 0x80075,
  3039. 0x80035,
  3040. 0x900ca,
  3041. 0x7010a,
  3042. 0x80065,
  3043. 0x80025,
  3044. 0x900aa,
  3045. 0x80005,
  3046. 0x80085,
  3047. 0x80045,
  3048. 0x900ea,
  3049. 0x70106,
  3050. 0x8005d,
  3051. 0x8001d,
  3052. 0x9009a,
  3053. 0x70116,
  3054. 0x8007d,
  3055. 0x8003d,
  3056. 0x900da,
  3057. 0x7010e,
  3058. 0x8006d,
  3059. 0x8002d,
  3060. 0x900ba,
  3061. 0x8000d,
  3062. 0x8008d,
  3063. 0x8004d,
  3064. 0x900fa,
  3065. 0x70101,
  3066. 0x80053,
  3067. 0x80013,
  3068. 0x8011b,
  3069. 0x70111,
  3070. 0x80073,
  3071. 0x80033,
  3072. 0x900c6,
  3073. 0x70109,
  3074. 0x80063,
  3075. 0x80023,
  3076. 0x900a6,
  3077. 0x80003,
  3078. 0x80083,
  3079. 0x80043,
  3080. 0x900e6,
  3081. 0x70105,
  3082. 0x8005b,
  3083. 0x8001b,
  3084. 0x90096,
  3085. 0x70115,
  3086. 0x8007b,
  3087. 0x8003b,
  3088. 0x900d6,
  3089. 0x7010d,
  3090. 0x8006b,
  3091. 0x8002b,
  3092. 0x900b6,
  3093. 0x8000b,
  3094. 0x8008b,
  3095. 0x8004b,
  3096. 0x900f6,
  3097. 0x70103,
  3098. 0x80057,
  3099. 0x80017,
  3100. 0x8011f,
  3101. 0x70113,
  3102. 0x80077,
  3103. 0x80037,
  3104. 0x900ce,
  3105. 0x7010b,
  3106. 0x80067,
  3107. 0x80027,
  3108. 0x900ae,
  3109. 0x80007,
  3110. 0x80087,
  3111. 0x80047,
  3112. 0x900ee,
  3113. 0x70107,
  3114. 0x8005f,
  3115. 0x8001f,
  3116. 0x9009e,
  3117. 0x70117,
  3118. 0x8007f,
  3119. 0x8003f,
  3120. 0x900de,
  3121. 0x7010f,
  3122. 0x8006f,
  3123. 0x8002f,
  3124. 0x900be,
  3125. 0x8000f,
  3126. 0x8008f,
  3127. 0x8004f,
  3128. 0x900fe,
  3129. 0x70100,
  3130. 0x80050,
  3131. 0x80010,
  3132. 0x80118,
  3133. 0x70110,
  3134. 0x80070,
  3135. 0x80030,
  3136. 0x900c1,
  3137. 0x70108,
  3138. 0x80060,
  3139. 0x80020,
  3140. 0x900a1,
  3141. 0x80000,
  3142. 0x80080,
  3143. 0x80040,
  3144. 0x900e1,
  3145. 0x70104,
  3146. 0x80058,
  3147. 0x80018,
  3148. 0x90091,
  3149. 0x70114,
  3150. 0x80078,
  3151. 0x80038,
  3152. 0x900d1,
  3153. 0x7010c,
  3154. 0x80068,
  3155. 0x80028,
  3156. 0x900b1,
  3157. 0x80008,
  3158. 0x80088,
  3159. 0x80048,
  3160. 0x900f1,
  3161. 0x70102,
  3162. 0x80054,
  3163. 0x80014,
  3164. 0x8011c,
  3165. 0x70112,
  3166. 0x80074,
  3167. 0x80034,
  3168. 0x900c9,
  3169. 0x7010a,
  3170. 0x80064,
  3171. 0x80024,
  3172. 0x900a9,
  3173. 0x80004,
  3174. 0x80084,
  3175. 0x80044,
  3176. 0x900e9,
  3177. 0x70106,
  3178. 0x8005c,
  3179. 0x8001c,
  3180. 0x90099,
  3181. 0x70116,
  3182. 0x8007c,
  3183. 0x8003c,
  3184. 0x900d9,
  3185. 0x7010e,
  3186. 0x8006c,
  3187. 0x8002c,
  3188. 0x900b9,
  3189. 0x8000c,
  3190. 0x8008c,
  3191. 0x8004c,
  3192. 0x900f9,
  3193. 0x70101,
  3194. 0x80052,
  3195. 0x80012,
  3196. 0x8011a,
  3197. 0x70111,
  3198. 0x80072,
  3199. 0x80032,
  3200. 0x900c5,
  3201. 0x70109,
  3202. 0x80062,
  3203. 0x80022,
  3204. 0x900a5,
  3205. 0x80002,
  3206. 0x80082,
  3207. 0x80042,
  3208. 0x900e5,
  3209. 0x70105,
  3210. 0x8005a,
  3211. 0x8001a,
  3212. 0x90095,
  3213. 0x70115,
  3214. 0x8007a,
  3215. 0x8003a,
  3216. 0x900d5,
  3217. 0x7010d,
  3218. 0x8006a,
  3219. 0x8002a,
  3220. 0x900b5,
  3221. 0x8000a,
  3222. 0x8008a,
  3223. 0x8004a,
  3224. 0x900f5,
  3225. 0x70103,
  3226. 0x80056,
  3227. 0x80016,
  3228. 0x8011e,
  3229. 0x70113,
  3230. 0x80076,
  3231. 0x80036,
  3232. 0x900cd,
  3233. 0x7010b,
  3234. 0x80066,
  3235. 0x80026,
  3236. 0x900ad,
  3237. 0x80006,
  3238. 0x80086,
  3239. 0x80046,
  3240. 0x900ed,
  3241. 0x70107,
  3242. 0x8005e,
  3243. 0x8001e,
  3244. 0x9009d,
  3245. 0x70117,
  3246. 0x8007e,
  3247. 0x8003e,
  3248. 0x900dd,
  3249. 0x7010f,
  3250. 0x8006e,
  3251. 0x8002e,
  3252. 0x900bd,
  3253. 0x8000e,
  3254. 0x8008e,
  3255. 0x8004e,
  3256. 0x900fd,
  3257. 0x70100,
  3258. 0x80051,
  3259. 0x80011,
  3260. 0x80119,
  3261. 0x70110,
  3262. 0x80071,
  3263. 0x80031,
  3264. 0x900c3,
  3265. 0x70108,
  3266. 0x80061,
  3267. 0x80021,
  3268. 0x900a3,
  3269. 0x80001,
  3270. 0x80081,
  3271. 0x80041,
  3272. 0x900e3,
  3273. 0x70104,
  3274. 0x80059,
  3275. 0x80019,
  3276. 0x90093,
  3277. 0x70114,
  3278. 0x80079,
  3279. 0x80039,
  3280. 0x900d3,
  3281. 0x7010c,
  3282. 0x80069,
  3283. 0x80029,
  3284. 0x900b3,
  3285. 0x80009,
  3286. 0x80089,
  3287. 0x80049,
  3288. 0x900f3,
  3289. 0x70102,
  3290. 0x80055,
  3291. 0x80015,
  3292. 0x8011d,
  3293. 0x70112,
  3294. 0x80075,
  3295. 0x80035,
  3296. 0x900cb,
  3297. 0x7010a,
  3298. 0x80065,
  3299. 0x80025,
  3300. 0x900ab,
  3301. 0x80005,
  3302. 0x80085,
  3303. 0x80045,
  3304. 0x900eb,
  3305. 0x70106,
  3306. 0x8005d,
  3307. 0x8001d,
  3308. 0x9009b,
  3309. 0x70116,
  3310. 0x8007d,
  3311. 0x8003d,
  3312. 0x900db,
  3313. 0x7010e,
  3314. 0x8006d,
  3315. 0x8002d,
  3316. 0x900bb,
  3317. 0x8000d,
  3318. 0x8008d,
  3319. 0x8004d,
  3320. 0x900fb,
  3321. 0x70101,
  3322. 0x80053,
  3323. 0x80013,
  3324. 0x8011b,
  3325. 0x70111,
  3326. 0x80073,
  3327. 0x80033,
  3328. 0x900c7,
  3329. 0x70109,
  3330. 0x80063,
  3331. 0x80023,
  3332. 0x900a7,
  3333. 0x80003,
  3334. 0x80083,
  3335. 0x80043,
  3336. 0x900e7,
  3337. 0x70105,
  3338. 0x8005b,
  3339. 0x8001b,
  3340. 0x90097,
  3341. 0x70115,
  3342. 0x8007b,
  3343. 0x8003b,
  3344. 0x900d7,
  3345. 0x7010d,
  3346. 0x8006b,
  3347. 0x8002b,
  3348. 0x900b7,
  3349. 0x8000b,
  3350. 0x8008b,
  3351. 0x8004b,
  3352. 0x900f7,
  3353. 0x70103,
  3354. 0x80057,
  3355. 0x80017,
  3356. 0x8011f,
  3357. 0x70113,
  3358. 0x80077,
  3359. 0x80037,
  3360. 0x900cf,
  3361. 0x7010b,
  3362. 0x80067,
  3363. 0x80027,
  3364. 0x900af,
  3365. 0x80007,
  3366. 0x80087,
  3367. 0x80047,
  3368. 0x900ef,
  3369. 0x70107,
  3370. 0x8005f,
  3371. 0x8001f,
  3372. 0x9009f,
  3373. 0x70117,
  3374. 0x8007f,
  3375. 0x8003f,
  3376. 0x900df,
  3377. 0x7010f,
  3378. 0x8006f,
  3379. 0x8002f,
  3380. 0x900bf,
  3381. 0x8000f,
  3382. 0x8008f,
  3383. 0x8004f,
  3384. 0x900ff
  3385. ]),
  3386. 9
  3387. ];
  3388. var fixedDistCodeTab = [
  3389. new Int32Array([
  3390. 0x50000,
  3391. 0x50010,
  3392. 0x50008,
  3393. 0x50018,
  3394. 0x50004,
  3395. 0x50014,
  3396. 0x5000c,
  3397. 0x5001c,
  3398. 0x50002,
  3399. 0x50012,
  3400. 0x5000a,
  3401. 0x5001a,
  3402. 0x50006,
  3403. 0x50016,
  3404. 0x5000e,
  3405. 0x00000,
  3406. 0x50001,
  3407. 0x50011,
  3408. 0x50009,
  3409. 0x50019,
  3410. 0x50005,
  3411. 0x50015,
  3412. 0x5000d,
  3413. 0x5001d,
  3414. 0x50003,
  3415. 0x50013,
  3416. 0x5000b,
  3417. 0x5001b,
  3418. 0x50007,
  3419. 0x50017,
  3420. 0x5000f,
  3421. 0x00000
  3422. ]),
  3423. 5
  3424. ];
  3425. function FlateStream(str, maybeLength) {
  3426. this.str = str;
  3427. this.dict = str.dict;
  3428. var cmf = str.getByte();
  3429. var flg = str.getByte();
  3430. if (cmf === -1 || flg === -1) {
  3431. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  3432. }
  3433. if ((cmf & 0x0f) !== 0x08) {
  3434. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  3435. }
  3436. if (((cmf << 8) + flg) % 31 !== 0) {
  3437. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  3438. }
  3439. if (flg & 0x20) {
  3440. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  3441. }
  3442. this.codeSize = 0;
  3443. this.codeBuf = 0;
  3444. DecodeStream.call(this, maybeLength);
  3445. }
  3446. FlateStream.prototype = Object.create(DecodeStream.prototype);
  3447. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  3448. var str = this.str;
  3449. var codeSize = this.codeSize;
  3450. var codeBuf = this.codeBuf;
  3451. var b;
  3452. while (codeSize < bits) {
  3453. if ((b = str.getByte()) === -1) {
  3454. error('Bad encoding in flate stream');
  3455. }
  3456. codeBuf |= b << codeSize;
  3457. codeSize += 8;
  3458. }
  3459. b = codeBuf & (1 << bits) - 1;
  3460. this.codeBuf = codeBuf >> bits;
  3461. this.codeSize = codeSize -= bits;
  3462. return b;
  3463. };
  3464. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  3465. var str = this.str;
  3466. var codes = table[0];
  3467. var maxLen = table[1];
  3468. var codeSize = this.codeSize;
  3469. var codeBuf = this.codeBuf;
  3470. var b;
  3471. while (codeSize < maxLen) {
  3472. if ((b = str.getByte()) === -1) {
  3473. break;
  3474. }
  3475. codeBuf |= b << codeSize;
  3476. codeSize += 8;
  3477. }
  3478. var code = codes[codeBuf & (1 << maxLen) - 1];
  3479. var codeLen = code >> 16;
  3480. var codeVal = code & 0xffff;
  3481. if (codeLen < 1 || codeSize < codeLen) {
  3482. error('Bad encoding in flate stream');
  3483. }
  3484. this.codeBuf = codeBuf >> codeLen;
  3485. this.codeSize = codeSize - codeLen;
  3486. return codeVal;
  3487. };
  3488. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  3489. var n = lengths.length;
  3490. var maxLen = 0;
  3491. var i;
  3492. for (i = 0; i < n; ++i) {
  3493. if (lengths[i] > maxLen) {
  3494. maxLen = lengths[i];
  3495. }
  3496. }
  3497. var size = 1 << maxLen;
  3498. var codes = new Int32Array(size);
  3499. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  3500. for (var val = 0; val < n; ++val) {
  3501. if (lengths[val] === len) {
  3502. var code2 = 0;
  3503. var t = code;
  3504. for (i = 0; i < len; ++i) {
  3505. code2 = code2 << 1 | t & 1;
  3506. t >>= 1;
  3507. }
  3508. for (i = code2; i < size; i += skip) {
  3509. codes[i] = len << 16 | val;
  3510. }
  3511. ++code;
  3512. }
  3513. }
  3514. }
  3515. return [
  3516. codes,
  3517. maxLen
  3518. ];
  3519. };
  3520. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  3521. var buffer, len;
  3522. var str = this.str;
  3523. var hdr = this.getBits(3);
  3524. if (hdr & 1) {
  3525. this.eof = true;
  3526. }
  3527. hdr >>= 1;
  3528. if (hdr === 0) {
  3529. var b;
  3530. if ((b = str.getByte()) === -1) {
  3531. error('Bad block header in flate stream');
  3532. }
  3533. var blockLen = b;
  3534. if ((b = str.getByte()) === -1) {
  3535. error('Bad block header in flate stream');
  3536. }
  3537. blockLen |= b << 8;
  3538. if ((b = str.getByte()) === -1) {
  3539. error('Bad block header in flate stream');
  3540. }
  3541. var check = b;
  3542. if ((b = str.getByte()) === -1) {
  3543. error('Bad block header in flate stream');
  3544. }
  3545. check |= b << 8;
  3546. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  3547. error('Bad uncompressed block length in flate stream');
  3548. }
  3549. this.codeBuf = 0;
  3550. this.codeSize = 0;
  3551. var bufferLength = this.bufferLength;
  3552. buffer = this.ensureBuffer(bufferLength + blockLen);
  3553. var end = bufferLength + blockLen;
  3554. this.bufferLength = end;
  3555. if (blockLen === 0) {
  3556. if (str.peekByte() === -1) {
  3557. this.eof = true;
  3558. }
  3559. } else {
  3560. for (var n = bufferLength; n < end; ++n) {
  3561. if ((b = str.getByte()) === -1) {
  3562. this.eof = true;
  3563. break;
  3564. }
  3565. buffer[n] = b;
  3566. }
  3567. }
  3568. return;
  3569. }
  3570. var litCodeTable;
  3571. var distCodeTable;
  3572. if (hdr === 1) {
  3573. litCodeTable = fixedLitCodeTab;
  3574. distCodeTable = fixedDistCodeTab;
  3575. } else if (hdr === 2) {
  3576. var numLitCodes = this.getBits(5) + 257;
  3577. var numDistCodes = this.getBits(5) + 1;
  3578. var numCodeLenCodes = this.getBits(4) + 4;
  3579. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  3580. var i;
  3581. for (i = 0; i < numCodeLenCodes; ++i) {
  3582. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  3583. }
  3584. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  3585. len = 0;
  3586. i = 0;
  3587. var codes = numLitCodes + numDistCodes;
  3588. var codeLengths = new Uint8Array(codes);
  3589. var bitsLength, bitsOffset, what;
  3590. while (i < codes) {
  3591. var code = this.getCode(codeLenCodeTab);
  3592. if (code === 16) {
  3593. bitsLength = 2;
  3594. bitsOffset = 3;
  3595. what = len;
  3596. } else if (code === 17) {
  3597. bitsLength = 3;
  3598. bitsOffset = 3;
  3599. what = len = 0;
  3600. } else if (code === 18) {
  3601. bitsLength = 7;
  3602. bitsOffset = 11;
  3603. what = len = 0;
  3604. } else {
  3605. codeLengths[i++] = len = code;
  3606. continue;
  3607. }
  3608. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  3609. while (repeatLength-- > 0) {
  3610. codeLengths[i++] = what;
  3611. }
  3612. }
  3613. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  3614. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  3615. } else {
  3616. error('Unknown block type in flate stream');
  3617. }
  3618. buffer = this.buffer;
  3619. var limit = buffer ? buffer.length : 0;
  3620. var pos = this.bufferLength;
  3621. while (true) {
  3622. var code1 = this.getCode(litCodeTable);
  3623. if (code1 < 256) {
  3624. if (pos + 1 >= limit) {
  3625. buffer = this.ensureBuffer(pos + 1);
  3626. limit = buffer.length;
  3627. }
  3628. buffer[pos++] = code1;
  3629. continue;
  3630. }
  3631. if (code1 === 256) {
  3632. this.bufferLength = pos;
  3633. return;
  3634. }
  3635. code1 -= 257;
  3636. code1 = lengthDecode[code1];
  3637. var code2 = code1 >> 16;
  3638. if (code2 > 0) {
  3639. code2 = this.getBits(code2);
  3640. }
  3641. len = (code1 & 0xffff) + code2;
  3642. code1 = this.getCode(distCodeTable);
  3643. code1 = distDecode[code1];
  3644. code2 = code1 >> 16;
  3645. if (code2 > 0) {
  3646. code2 = this.getBits(code2);
  3647. }
  3648. var dist = (code1 & 0xffff) + code2;
  3649. if (pos + len >= limit) {
  3650. buffer = this.ensureBuffer(pos + len);
  3651. limit = buffer.length;
  3652. }
  3653. for (var k = 0; k < len; ++k, ++pos) {
  3654. buffer[pos] = buffer[pos - dist];
  3655. }
  3656. }
  3657. };
  3658. return FlateStream;
  3659. }();
  3660. var PredictorStream = function PredictorStreamClosure() {
  3661. function PredictorStream(str, maybeLength, params) {
  3662. if (!isDict(params)) {
  3663. return str;
  3664. }
  3665. var predictor = this.predictor = params.get('Predictor') || 1;
  3666. if (predictor <= 1) {
  3667. return str;
  3668. }
  3669. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  3670. error('Unsupported predictor: ' + predictor);
  3671. }
  3672. if (predictor === 2) {
  3673. this.readBlock = this.readBlockTiff;
  3674. } else {
  3675. this.readBlock = this.readBlockPng;
  3676. }
  3677. this.str = str;
  3678. this.dict = str.dict;
  3679. var colors = this.colors = params.get('Colors') || 1;
  3680. var bits = this.bits = params.get('BitsPerComponent') || 8;
  3681. var columns = this.columns = params.get('Columns') || 1;
  3682. this.pixBytes = colors * bits + 7 >> 3;
  3683. this.rowBytes = columns * colors * bits + 7 >> 3;
  3684. DecodeStream.call(this, maybeLength);
  3685. return this;
  3686. }
  3687. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  3688. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  3689. var rowBytes = this.rowBytes;
  3690. var bufferLength = this.bufferLength;
  3691. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3692. var bits = this.bits;
  3693. var colors = this.colors;
  3694. var rawBytes = this.str.getBytes(rowBytes);
  3695. this.eof = !rawBytes.length;
  3696. if (this.eof) {
  3697. return;
  3698. }
  3699. var inbuf = 0, outbuf = 0;
  3700. var inbits = 0, outbits = 0;
  3701. var pos = bufferLength;
  3702. var i;
  3703. if (bits === 1 && colors === 1) {
  3704. for (i = 0; i < rowBytes; ++i) {
  3705. var c = rawBytes[i] ^ inbuf;
  3706. c ^= c >> 1;
  3707. c ^= c >> 2;
  3708. c ^= c >> 4;
  3709. inbuf = (c & 1) << 7;
  3710. buffer[pos++] = c;
  3711. }
  3712. } else if (bits === 8) {
  3713. for (i = 0; i < colors; ++i) {
  3714. buffer[pos++] = rawBytes[i];
  3715. }
  3716. for (; i < rowBytes; ++i) {
  3717. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  3718. pos++;
  3719. }
  3720. } else {
  3721. var compArray = new Uint8Array(colors + 1);
  3722. var bitMask = (1 << bits) - 1;
  3723. var j = 0, k = bufferLength;
  3724. var columns = this.columns;
  3725. for (i = 0; i < columns; ++i) {
  3726. for (var kk = 0; kk < colors; ++kk) {
  3727. if (inbits < bits) {
  3728. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  3729. inbits += 8;
  3730. }
  3731. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  3732. inbits -= bits;
  3733. outbuf = outbuf << bits | compArray[kk];
  3734. outbits += bits;
  3735. if (outbits >= 8) {
  3736. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  3737. outbits -= 8;
  3738. }
  3739. }
  3740. }
  3741. if (outbits > 0) {
  3742. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  3743. }
  3744. }
  3745. this.bufferLength += rowBytes;
  3746. };
  3747. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  3748. var rowBytes = this.rowBytes;
  3749. var pixBytes = this.pixBytes;
  3750. var predictor = this.str.getByte();
  3751. var rawBytes = this.str.getBytes(rowBytes);
  3752. this.eof = !rawBytes.length;
  3753. if (this.eof) {
  3754. return;
  3755. }
  3756. var bufferLength = this.bufferLength;
  3757. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3758. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  3759. if (prevRow.length === 0) {
  3760. prevRow = new Uint8Array(rowBytes);
  3761. }
  3762. var i, j = bufferLength, up, c;
  3763. switch (predictor) {
  3764. case 0:
  3765. for (i = 0; i < rowBytes; ++i) {
  3766. buffer[j++] = rawBytes[i];
  3767. }
  3768. break;
  3769. case 1:
  3770. for (i = 0; i < pixBytes; ++i) {
  3771. buffer[j++] = rawBytes[i];
  3772. }
  3773. for (; i < rowBytes; ++i) {
  3774. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  3775. j++;
  3776. }
  3777. break;
  3778. case 2:
  3779. for (i = 0; i < rowBytes; ++i) {
  3780. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  3781. }
  3782. break;
  3783. case 3:
  3784. for (i = 0; i < pixBytes; ++i) {
  3785. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  3786. }
  3787. for (; i < rowBytes; ++i) {
  3788. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  3789. j++;
  3790. }
  3791. break;
  3792. case 4:
  3793. for (i = 0; i < pixBytes; ++i) {
  3794. up = prevRow[i];
  3795. c = rawBytes[i];
  3796. buffer[j++] = up + c;
  3797. }
  3798. for (; i < rowBytes; ++i) {
  3799. up = prevRow[i];
  3800. var upLeft = prevRow[i - pixBytes];
  3801. var left = buffer[j - pixBytes];
  3802. var p = left + up - upLeft;
  3803. var pa = p - left;
  3804. if (pa < 0) {
  3805. pa = -pa;
  3806. }
  3807. var pb = p - up;
  3808. if (pb < 0) {
  3809. pb = -pb;
  3810. }
  3811. var pc = p - upLeft;
  3812. if (pc < 0) {
  3813. pc = -pc;
  3814. }
  3815. c = rawBytes[i];
  3816. if (pa <= pb && pa <= pc) {
  3817. buffer[j++] = left + c;
  3818. } else if (pb <= pc) {
  3819. buffer[j++] = up + c;
  3820. } else {
  3821. buffer[j++] = upLeft + c;
  3822. }
  3823. }
  3824. break;
  3825. default:
  3826. error('Unsupported predictor: ' + predictor);
  3827. }
  3828. this.bufferLength += rowBytes;
  3829. };
  3830. return PredictorStream;
  3831. }();
  3832. var JpegStream = function JpegStreamClosure() {
  3833. function JpegStream(stream, maybeLength, dict, params) {
  3834. var ch;
  3835. while ((ch = stream.getByte()) !== -1) {
  3836. if (ch === 0xFF) {
  3837. stream.skip(-1);
  3838. break;
  3839. }
  3840. }
  3841. this.stream = stream;
  3842. this.maybeLength = maybeLength;
  3843. this.dict = dict;
  3844. this.params = params;
  3845. DecodeStream.call(this, maybeLength);
  3846. }
  3847. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3848. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3849. get: function JpegStream_bytes() {
  3850. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3851. },
  3852. configurable: true
  3853. });
  3854. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3855. if (this.bufferLength) {
  3856. return;
  3857. }
  3858. var jpegImage = new JpegImage();
  3859. var decodeArr = this.dict.getArray('Decode', 'D');
  3860. if (this.forceRGB && isArray(decodeArr)) {
  3861. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3862. var decodeArrLength = decodeArr.length;
  3863. var transform = new Int32Array(decodeArrLength);
  3864. var transformNeeded = false;
  3865. var maxValue = (1 << bitsPerComponent) - 1;
  3866. for (var i = 0; i < decodeArrLength; i += 2) {
  3867. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3868. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3869. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3870. transformNeeded = true;
  3871. }
  3872. }
  3873. if (transformNeeded) {
  3874. jpegImage.decodeTransform = transform;
  3875. }
  3876. }
  3877. if (isDict(this.params)) {
  3878. var colorTransform = this.params.get('ColorTransform');
  3879. if (isInt(colorTransform)) {
  3880. jpegImage.colorTransform = colorTransform;
  3881. }
  3882. }
  3883. jpegImage.parse(this.bytes);
  3884. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3885. this.buffer = data;
  3886. this.bufferLength = data.length;
  3887. this.eof = true;
  3888. };
  3889. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3890. this.ensureBuffer();
  3891. return this.buffer;
  3892. };
  3893. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3894. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3895. };
  3896. return JpegStream;
  3897. }();
  3898. var JpxStream = function JpxStreamClosure() {
  3899. function JpxStream(stream, maybeLength, dict, params) {
  3900. this.stream = stream;
  3901. this.maybeLength = maybeLength;
  3902. this.dict = dict;
  3903. this.params = params;
  3904. DecodeStream.call(this, maybeLength);
  3905. }
  3906. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3907. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3908. get: function JpxStream_bytes() {
  3909. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3910. },
  3911. configurable: true
  3912. });
  3913. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3914. if (this.bufferLength) {
  3915. return;
  3916. }
  3917. var jpxImage = new JpxImage();
  3918. jpxImage.parse(this.bytes);
  3919. var width = jpxImage.width;
  3920. var height = jpxImage.height;
  3921. var componentsCount = jpxImage.componentsCount;
  3922. var tileCount = jpxImage.tiles.length;
  3923. if (tileCount === 1) {
  3924. this.buffer = jpxImage.tiles[0].items;
  3925. } else {
  3926. var data = new Uint8Array(width * height * componentsCount);
  3927. for (var k = 0; k < tileCount; k++) {
  3928. var tileComponents = jpxImage.tiles[k];
  3929. var tileWidth = tileComponents.width;
  3930. var tileHeight = tileComponents.height;
  3931. var tileLeft = tileComponents.left;
  3932. var tileTop = tileComponents.top;
  3933. var src = tileComponents.items;
  3934. var srcPosition = 0;
  3935. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3936. var imgRowSize = width * componentsCount;
  3937. var tileRowSize = tileWidth * componentsCount;
  3938. for (var j = 0; j < tileHeight; j++) {
  3939. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3940. data.set(rowBytes, dataPosition);
  3941. srcPosition += tileRowSize;
  3942. dataPosition += imgRowSize;
  3943. }
  3944. }
  3945. this.buffer = data;
  3946. }
  3947. this.bufferLength = this.buffer.length;
  3948. this.eof = true;
  3949. };
  3950. return JpxStream;
  3951. }();
  3952. var Jbig2Stream = function Jbig2StreamClosure() {
  3953. function Jbig2Stream(stream, maybeLength, dict, params) {
  3954. this.stream = stream;
  3955. this.maybeLength = maybeLength;
  3956. this.dict = dict;
  3957. this.params = params;
  3958. DecodeStream.call(this, maybeLength);
  3959. }
  3960. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3961. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3962. get: function Jbig2Stream_bytes() {
  3963. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3964. },
  3965. configurable: true
  3966. });
  3967. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3968. if (this.bufferLength) {
  3969. return;
  3970. }
  3971. var jbig2Image = new Jbig2Image();
  3972. var chunks = [];
  3973. if (isDict(this.params)) {
  3974. var globalsStream = this.params.get('JBIG2Globals');
  3975. if (isStream(globalsStream)) {
  3976. var globals = globalsStream.getBytes();
  3977. chunks.push({
  3978. data: globals,
  3979. start: 0,
  3980. end: globals.length
  3981. });
  3982. }
  3983. }
  3984. chunks.push({
  3985. data: this.bytes,
  3986. start: 0,
  3987. end: this.bytes.length
  3988. });
  3989. var data = jbig2Image.parseChunks(chunks);
  3990. var dataLength = data.length;
  3991. for (var i = 0; i < dataLength; i++) {
  3992. data[i] ^= 0xFF;
  3993. }
  3994. this.buffer = data;
  3995. this.bufferLength = dataLength;
  3996. this.eof = true;
  3997. };
  3998. return Jbig2Stream;
  3999. }();
  4000. var DecryptStream = function DecryptStreamClosure() {
  4001. function DecryptStream(str, maybeLength, decrypt) {
  4002. this.str = str;
  4003. this.dict = str.dict;
  4004. this.decrypt = decrypt;
  4005. this.nextChunk = null;
  4006. this.initialized = false;
  4007. DecodeStream.call(this, maybeLength);
  4008. }
  4009. var chunkSize = 512;
  4010. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  4011. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  4012. var chunk;
  4013. if (this.initialized) {
  4014. chunk = this.nextChunk;
  4015. } else {
  4016. chunk = this.str.getBytes(chunkSize);
  4017. this.initialized = true;
  4018. }
  4019. if (!chunk || chunk.length === 0) {
  4020. this.eof = true;
  4021. return;
  4022. }
  4023. this.nextChunk = this.str.getBytes(chunkSize);
  4024. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  4025. var decrypt = this.decrypt;
  4026. chunk = decrypt(chunk, !hasMoreData);
  4027. var bufferLength = this.bufferLength;
  4028. var i, n = chunk.length;
  4029. var buffer = this.ensureBuffer(bufferLength + n);
  4030. for (i = 0; i < n; i++) {
  4031. buffer[bufferLength++] = chunk[i];
  4032. }
  4033. this.bufferLength = bufferLength;
  4034. };
  4035. return DecryptStream;
  4036. }();
  4037. var Ascii85Stream = function Ascii85StreamClosure() {
  4038. function Ascii85Stream(str, maybeLength) {
  4039. this.str = str;
  4040. this.dict = str.dict;
  4041. this.input = new Uint8Array(5);
  4042. if (maybeLength) {
  4043. maybeLength = 0.8 * maybeLength;
  4044. }
  4045. DecodeStream.call(this, maybeLength);
  4046. }
  4047. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  4048. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  4049. var TILDA_CHAR = 0x7E;
  4050. var Z_LOWER_CHAR = 0x7A;
  4051. var EOF = -1;
  4052. var str = this.str;
  4053. var c = str.getByte();
  4054. while (isSpace(c)) {
  4055. c = str.getByte();
  4056. }
  4057. if (c === EOF || c === TILDA_CHAR) {
  4058. this.eof = true;
  4059. return;
  4060. }
  4061. var bufferLength = this.bufferLength, buffer;
  4062. var i;
  4063. if (c === Z_LOWER_CHAR) {
  4064. buffer = this.ensureBuffer(bufferLength + 4);
  4065. for (i = 0; i < 4; ++i) {
  4066. buffer[bufferLength + i] = 0;
  4067. }
  4068. this.bufferLength += 4;
  4069. } else {
  4070. var input = this.input;
  4071. input[0] = c;
  4072. for (i = 1; i < 5; ++i) {
  4073. c = str.getByte();
  4074. while (isSpace(c)) {
  4075. c = str.getByte();
  4076. }
  4077. input[i] = c;
  4078. if (c === EOF || c === TILDA_CHAR) {
  4079. break;
  4080. }
  4081. }
  4082. buffer = this.ensureBuffer(bufferLength + i - 1);
  4083. this.bufferLength += i - 1;
  4084. if (i < 5) {
  4085. for (; i < 5; ++i) {
  4086. input[i] = 0x21 + 84;
  4087. }
  4088. this.eof = true;
  4089. }
  4090. var t = 0;
  4091. for (i = 0; i < 5; ++i) {
  4092. t = t * 85 + (input[i] - 0x21);
  4093. }
  4094. for (i = 3; i >= 0; --i) {
  4095. buffer[bufferLength + i] = t & 0xFF;
  4096. t >>= 8;
  4097. }
  4098. }
  4099. };
  4100. return Ascii85Stream;
  4101. }();
  4102. var AsciiHexStream = function AsciiHexStreamClosure() {
  4103. function AsciiHexStream(str, maybeLength) {
  4104. this.str = str;
  4105. this.dict = str.dict;
  4106. this.firstDigit = -1;
  4107. if (maybeLength) {
  4108. maybeLength = 0.5 * maybeLength;
  4109. }
  4110. DecodeStream.call(this, maybeLength);
  4111. }
  4112. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  4113. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  4114. var UPSTREAM_BLOCK_SIZE = 8000;
  4115. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  4116. if (!bytes.length) {
  4117. this.eof = true;
  4118. return;
  4119. }
  4120. var maxDecodeLength = bytes.length + 1 >> 1;
  4121. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  4122. var bufferLength = this.bufferLength;
  4123. var firstDigit = this.firstDigit;
  4124. for (var i = 0, ii = bytes.length; i < ii; i++) {
  4125. var ch = bytes[i], digit;
  4126. if (ch >= 0x30 && ch <= 0x39) {
  4127. digit = ch & 0x0F;
  4128. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4129. digit = (ch & 0x0F) + 9;
  4130. } else if (ch === 0x3E) {
  4131. this.eof = true;
  4132. break;
  4133. } else {
  4134. continue;
  4135. }
  4136. if (firstDigit < 0) {
  4137. firstDigit = digit;
  4138. } else {
  4139. buffer[bufferLength++] = firstDigit << 4 | digit;
  4140. firstDigit = -1;
  4141. }
  4142. }
  4143. if (firstDigit >= 0 && this.eof) {
  4144. buffer[bufferLength++] = firstDigit << 4;
  4145. firstDigit = -1;
  4146. }
  4147. this.firstDigit = firstDigit;
  4148. this.bufferLength = bufferLength;
  4149. };
  4150. return AsciiHexStream;
  4151. }();
  4152. var RunLengthStream = function RunLengthStreamClosure() {
  4153. function RunLengthStream(str, maybeLength) {
  4154. this.str = str;
  4155. this.dict = str.dict;
  4156. DecodeStream.call(this, maybeLength);
  4157. }
  4158. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  4159. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  4160. var repeatHeader = this.str.getBytes(2);
  4161. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  4162. this.eof = true;
  4163. return;
  4164. }
  4165. var buffer;
  4166. var bufferLength = this.bufferLength;
  4167. var n = repeatHeader[0];
  4168. if (n < 128) {
  4169. buffer = this.ensureBuffer(bufferLength + n + 1);
  4170. buffer[bufferLength++] = repeatHeader[1];
  4171. if (n > 0) {
  4172. var source = this.str.getBytes(n);
  4173. buffer.set(source, bufferLength);
  4174. bufferLength += n;
  4175. }
  4176. } else {
  4177. n = 257 - n;
  4178. var b = repeatHeader[1];
  4179. buffer = this.ensureBuffer(bufferLength + n + 1);
  4180. for (var i = 0; i < n; i++) {
  4181. buffer[bufferLength++] = b;
  4182. }
  4183. }
  4184. this.bufferLength = bufferLength;
  4185. };
  4186. return RunLengthStream;
  4187. }();
  4188. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  4189. var ccittEOL = -2;
  4190. var ccittEOF = -1;
  4191. var twoDimPass = 0;
  4192. var twoDimHoriz = 1;
  4193. var twoDimVert0 = 2;
  4194. var twoDimVertR1 = 3;
  4195. var twoDimVertL1 = 4;
  4196. var twoDimVertR2 = 5;
  4197. var twoDimVertL2 = 6;
  4198. var twoDimVertR3 = 7;
  4199. var twoDimVertL3 = 8;
  4200. var twoDimTable = [
  4201. [
  4202. -1,
  4203. -1
  4204. ],
  4205. [
  4206. -1,
  4207. -1
  4208. ],
  4209. [
  4210. 7,
  4211. twoDimVertL3
  4212. ],
  4213. [
  4214. 7,
  4215. twoDimVertR3
  4216. ],
  4217. [
  4218. 6,
  4219. twoDimVertL2
  4220. ],
  4221. [
  4222. 6,
  4223. twoDimVertL2
  4224. ],
  4225. [
  4226. 6,
  4227. twoDimVertR2
  4228. ],
  4229. [
  4230. 6,
  4231. twoDimVertR2
  4232. ],
  4233. [
  4234. 4,
  4235. twoDimPass
  4236. ],
  4237. [
  4238. 4,
  4239. twoDimPass
  4240. ],
  4241. [
  4242. 4,
  4243. twoDimPass
  4244. ],
  4245. [
  4246. 4,
  4247. twoDimPass
  4248. ],
  4249. [
  4250. 4,
  4251. twoDimPass
  4252. ],
  4253. [
  4254. 4,
  4255. twoDimPass
  4256. ],
  4257. [
  4258. 4,
  4259. twoDimPass
  4260. ],
  4261. [
  4262. 4,
  4263. twoDimPass
  4264. ],
  4265. [
  4266. 3,
  4267. twoDimHoriz
  4268. ],
  4269. [
  4270. 3,
  4271. twoDimHoriz
  4272. ],
  4273. [
  4274. 3,
  4275. twoDimHoriz
  4276. ],
  4277. [
  4278. 3,
  4279. twoDimHoriz
  4280. ],
  4281. [
  4282. 3,
  4283. twoDimHoriz
  4284. ],
  4285. [
  4286. 3,
  4287. twoDimHoriz
  4288. ],
  4289. [
  4290. 3,
  4291. twoDimHoriz
  4292. ],
  4293. [
  4294. 3,
  4295. twoDimHoriz
  4296. ],
  4297. [
  4298. 3,
  4299. twoDimHoriz
  4300. ],
  4301. [
  4302. 3,
  4303. twoDimHoriz
  4304. ],
  4305. [
  4306. 3,
  4307. twoDimHoriz
  4308. ],
  4309. [
  4310. 3,
  4311. twoDimHoriz
  4312. ],
  4313. [
  4314. 3,
  4315. twoDimHoriz
  4316. ],
  4317. [
  4318. 3,
  4319. twoDimHoriz
  4320. ],
  4321. [
  4322. 3,
  4323. twoDimHoriz
  4324. ],
  4325. [
  4326. 3,
  4327. twoDimHoriz
  4328. ],
  4329. [
  4330. 3,
  4331. twoDimVertL1
  4332. ],
  4333. [
  4334. 3,
  4335. twoDimVertL1
  4336. ],
  4337. [
  4338. 3,
  4339. twoDimVertL1
  4340. ],
  4341. [
  4342. 3,
  4343. twoDimVertL1
  4344. ],
  4345. [
  4346. 3,
  4347. twoDimVertL1
  4348. ],
  4349. [
  4350. 3,
  4351. twoDimVertL1
  4352. ],
  4353. [
  4354. 3,
  4355. twoDimVertL1
  4356. ],
  4357. [
  4358. 3,
  4359. twoDimVertL1
  4360. ],
  4361. [
  4362. 3,
  4363. twoDimVertL1
  4364. ],
  4365. [
  4366. 3,
  4367. twoDimVertL1
  4368. ],
  4369. [
  4370. 3,
  4371. twoDimVertL1
  4372. ],
  4373. [
  4374. 3,
  4375. twoDimVertL1
  4376. ],
  4377. [
  4378. 3,
  4379. twoDimVertL1
  4380. ],
  4381. [
  4382. 3,
  4383. twoDimVertL1
  4384. ],
  4385. [
  4386. 3,
  4387. twoDimVertL1
  4388. ],
  4389. [
  4390. 3,
  4391. twoDimVertL1
  4392. ],
  4393. [
  4394. 3,
  4395. twoDimVertR1
  4396. ],
  4397. [
  4398. 3,
  4399. twoDimVertR1
  4400. ],
  4401. [
  4402. 3,
  4403. twoDimVertR1
  4404. ],
  4405. [
  4406. 3,
  4407. twoDimVertR1
  4408. ],
  4409. [
  4410. 3,
  4411. twoDimVertR1
  4412. ],
  4413. [
  4414. 3,
  4415. twoDimVertR1
  4416. ],
  4417. [
  4418. 3,
  4419. twoDimVertR1
  4420. ],
  4421. [
  4422. 3,
  4423. twoDimVertR1
  4424. ],
  4425. [
  4426. 3,
  4427. twoDimVertR1
  4428. ],
  4429. [
  4430. 3,
  4431. twoDimVertR1
  4432. ],
  4433. [
  4434. 3,
  4435. twoDimVertR1
  4436. ],
  4437. [
  4438. 3,
  4439. twoDimVertR1
  4440. ],
  4441. [
  4442. 3,
  4443. twoDimVertR1
  4444. ],
  4445. [
  4446. 3,
  4447. twoDimVertR1
  4448. ],
  4449. [
  4450. 3,
  4451. twoDimVertR1
  4452. ],
  4453. [
  4454. 3,
  4455. twoDimVertR1
  4456. ],
  4457. [
  4458. 1,
  4459. twoDimVert0
  4460. ],
  4461. [
  4462. 1,
  4463. twoDimVert0
  4464. ],
  4465. [
  4466. 1,
  4467. twoDimVert0
  4468. ],
  4469. [
  4470. 1,
  4471. twoDimVert0
  4472. ],
  4473. [
  4474. 1,
  4475. twoDimVert0
  4476. ],
  4477. [
  4478. 1,
  4479. twoDimVert0
  4480. ],
  4481. [
  4482. 1,
  4483. twoDimVert0
  4484. ],
  4485. [
  4486. 1,
  4487. twoDimVert0
  4488. ],
  4489. [
  4490. 1,
  4491. twoDimVert0
  4492. ],
  4493. [
  4494. 1,
  4495. twoDimVert0
  4496. ],
  4497. [
  4498. 1,
  4499. twoDimVert0
  4500. ],
  4501. [
  4502. 1,
  4503. twoDimVert0
  4504. ],
  4505. [
  4506. 1,
  4507. twoDimVert0
  4508. ],
  4509. [
  4510. 1,
  4511. twoDimVert0
  4512. ],
  4513. [
  4514. 1,
  4515. twoDimVert0
  4516. ],
  4517. [
  4518. 1,
  4519. twoDimVert0
  4520. ],
  4521. [
  4522. 1,
  4523. twoDimVert0
  4524. ],
  4525. [
  4526. 1,
  4527. twoDimVert0
  4528. ],
  4529. [
  4530. 1,
  4531. twoDimVert0
  4532. ],
  4533. [
  4534. 1,
  4535. twoDimVert0
  4536. ],
  4537. [
  4538. 1,
  4539. twoDimVert0
  4540. ],
  4541. [
  4542. 1,
  4543. twoDimVert0
  4544. ],
  4545. [
  4546. 1,
  4547. twoDimVert0
  4548. ],
  4549. [
  4550. 1,
  4551. twoDimVert0
  4552. ],
  4553. [
  4554. 1,
  4555. twoDimVert0
  4556. ],
  4557. [
  4558. 1,
  4559. twoDimVert0
  4560. ],
  4561. [
  4562. 1,
  4563. twoDimVert0
  4564. ],
  4565. [
  4566. 1,
  4567. twoDimVert0
  4568. ],
  4569. [
  4570. 1,
  4571. twoDimVert0
  4572. ],
  4573. [
  4574. 1,
  4575. twoDimVert0
  4576. ],
  4577. [
  4578. 1,
  4579. twoDimVert0
  4580. ],
  4581. [
  4582. 1,
  4583. twoDimVert0
  4584. ],
  4585. [
  4586. 1,
  4587. twoDimVert0
  4588. ],
  4589. [
  4590. 1,
  4591. twoDimVert0
  4592. ],
  4593. [
  4594. 1,
  4595. twoDimVert0
  4596. ],
  4597. [
  4598. 1,
  4599. twoDimVert0
  4600. ],
  4601. [
  4602. 1,
  4603. twoDimVert0
  4604. ],
  4605. [
  4606. 1,
  4607. twoDimVert0
  4608. ],
  4609. [
  4610. 1,
  4611. twoDimVert0
  4612. ],
  4613. [
  4614. 1,
  4615. twoDimVert0
  4616. ],
  4617. [
  4618. 1,
  4619. twoDimVert0
  4620. ],
  4621. [
  4622. 1,
  4623. twoDimVert0
  4624. ],
  4625. [
  4626. 1,
  4627. twoDimVert0
  4628. ],
  4629. [
  4630. 1,
  4631. twoDimVert0
  4632. ],
  4633. [
  4634. 1,
  4635. twoDimVert0
  4636. ],
  4637. [
  4638. 1,
  4639. twoDimVert0
  4640. ],
  4641. [
  4642. 1,
  4643. twoDimVert0
  4644. ],
  4645. [
  4646. 1,
  4647. twoDimVert0
  4648. ],
  4649. [
  4650. 1,
  4651. twoDimVert0
  4652. ],
  4653. [
  4654. 1,
  4655. twoDimVert0
  4656. ],
  4657. [
  4658. 1,
  4659. twoDimVert0
  4660. ],
  4661. [
  4662. 1,
  4663. twoDimVert0
  4664. ],
  4665. [
  4666. 1,
  4667. twoDimVert0
  4668. ],
  4669. [
  4670. 1,
  4671. twoDimVert0
  4672. ],
  4673. [
  4674. 1,
  4675. twoDimVert0
  4676. ],
  4677. [
  4678. 1,
  4679. twoDimVert0
  4680. ],
  4681. [
  4682. 1,
  4683. twoDimVert0
  4684. ],
  4685. [
  4686. 1,
  4687. twoDimVert0
  4688. ],
  4689. [
  4690. 1,
  4691. twoDimVert0
  4692. ],
  4693. [
  4694. 1,
  4695. twoDimVert0
  4696. ],
  4697. [
  4698. 1,
  4699. twoDimVert0
  4700. ],
  4701. [
  4702. 1,
  4703. twoDimVert0
  4704. ],
  4705. [
  4706. 1,
  4707. twoDimVert0
  4708. ],
  4709. [
  4710. 1,
  4711. twoDimVert0
  4712. ]
  4713. ];
  4714. var whiteTable1 = [
  4715. [
  4716. -1,
  4717. -1
  4718. ],
  4719. [
  4720. 12,
  4721. ccittEOL
  4722. ],
  4723. [
  4724. -1,
  4725. -1
  4726. ],
  4727. [
  4728. -1,
  4729. -1
  4730. ],
  4731. [
  4732. -1,
  4733. -1
  4734. ],
  4735. [
  4736. -1,
  4737. -1
  4738. ],
  4739. [
  4740. -1,
  4741. -1
  4742. ],
  4743. [
  4744. -1,
  4745. -1
  4746. ],
  4747. [
  4748. -1,
  4749. -1
  4750. ],
  4751. [
  4752. -1,
  4753. -1
  4754. ],
  4755. [
  4756. -1,
  4757. -1
  4758. ],
  4759. [
  4760. -1,
  4761. -1
  4762. ],
  4763. [
  4764. -1,
  4765. -1
  4766. ],
  4767. [
  4768. -1,
  4769. -1
  4770. ],
  4771. [
  4772. -1,
  4773. -1
  4774. ],
  4775. [
  4776. -1,
  4777. -1
  4778. ],
  4779. [
  4780. 11,
  4781. 1792
  4782. ],
  4783. [
  4784. 11,
  4785. 1792
  4786. ],
  4787. [
  4788. 12,
  4789. 1984
  4790. ],
  4791. [
  4792. 12,
  4793. 2048
  4794. ],
  4795. [
  4796. 12,
  4797. 2112
  4798. ],
  4799. [
  4800. 12,
  4801. 2176
  4802. ],
  4803. [
  4804. 12,
  4805. 2240
  4806. ],
  4807. [
  4808. 12,
  4809. 2304
  4810. ],
  4811. [
  4812. 11,
  4813. 1856
  4814. ],
  4815. [
  4816. 11,
  4817. 1856
  4818. ],
  4819. [
  4820. 11,
  4821. 1920
  4822. ],
  4823. [
  4824. 11,
  4825. 1920
  4826. ],
  4827. [
  4828. 12,
  4829. 2368
  4830. ],
  4831. [
  4832. 12,
  4833. 2432
  4834. ],
  4835. [
  4836. 12,
  4837. 2496
  4838. ],
  4839. [
  4840. 12,
  4841. 2560
  4842. ]
  4843. ];
  4844. var whiteTable2 = [
  4845. [
  4846. -1,
  4847. -1
  4848. ],
  4849. [
  4850. -1,
  4851. -1
  4852. ],
  4853. [
  4854. -1,
  4855. -1
  4856. ],
  4857. [
  4858. -1,
  4859. -1
  4860. ],
  4861. [
  4862. 8,
  4863. 29
  4864. ],
  4865. [
  4866. 8,
  4867. 29
  4868. ],
  4869. [
  4870. 8,
  4871. 30
  4872. ],
  4873. [
  4874. 8,
  4875. 30
  4876. ],
  4877. [
  4878. 8,
  4879. 45
  4880. ],
  4881. [
  4882. 8,
  4883. 45
  4884. ],
  4885. [
  4886. 8,
  4887. 46
  4888. ],
  4889. [
  4890. 8,
  4891. 46
  4892. ],
  4893. [
  4894. 7,
  4895. 22
  4896. ],
  4897. [
  4898. 7,
  4899. 22
  4900. ],
  4901. [
  4902. 7,
  4903. 22
  4904. ],
  4905. [
  4906. 7,
  4907. 22
  4908. ],
  4909. [
  4910. 7,
  4911. 23
  4912. ],
  4913. [
  4914. 7,
  4915. 23
  4916. ],
  4917. [
  4918. 7,
  4919. 23
  4920. ],
  4921. [
  4922. 7,
  4923. 23
  4924. ],
  4925. [
  4926. 8,
  4927. 47
  4928. ],
  4929. [
  4930. 8,
  4931. 47
  4932. ],
  4933. [
  4934. 8,
  4935. 48
  4936. ],
  4937. [
  4938. 8,
  4939. 48
  4940. ],
  4941. [
  4942. 6,
  4943. 13
  4944. ],
  4945. [
  4946. 6,
  4947. 13
  4948. ],
  4949. [
  4950. 6,
  4951. 13
  4952. ],
  4953. [
  4954. 6,
  4955. 13
  4956. ],
  4957. [
  4958. 6,
  4959. 13
  4960. ],
  4961. [
  4962. 6,
  4963. 13
  4964. ],
  4965. [
  4966. 6,
  4967. 13
  4968. ],
  4969. [
  4970. 6,
  4971. 13
  4972. ],
  4973. [
  4974. 7,
  4975. 20
  4976. ],
  4977. [
  4978. 7,
  4979. 20
  4980. ],
  4981. [
  4982. 7,
  4983. 20
  4984. ],
  4985. [
  4986. 7,
  4987. 20
  4988. ],
  4989. [
  4990. 8,
  4991. 33
  4992. ],
  4993. [
  4994. 8,
  4995. 33
  4996. ],
  4997. [
  4998. 8,
  4999. 34
  5000. ],
  5001. [
  5002. 8,
  5003. 34
  5004. ],
  5005. [
  5006. 8,
  5007. 35
  5008. ],
  5009. [
  5010. 8,
  5011. 35
  5012. ],
  5013. [
  5014. 8,
  5015. 36
  5016. ],
  5017. [
  5018. 8,
  5019. 36
  5020. ],
  5021. [
  5022. 8,
  5023. 37
  5024. ],
  5025. [
  5026. 8,
  5027. 37
  5028. ],
  5029. [
  5030. 8,
  5031. 38
  5032. ],
  5033. [
  5034. 8,
  5035. 38
  5036. ],
  5037. [
  5038. 7,
  5039. 19
  5040. ],
  5041. [
  5042. 7,
  5043. 19
  5044. ],
  5045. [
  5046. 7,
  5047. 19
  5048. ],
  5049. [
  5050. 7,
  5051. 19
  5052. ],
  5053. [
  5054. 8,
  5055. 31
  5056. ],
  5057. [
  5058. 8,
  5059. 31
  5060. ],
  5061. [
  5062. 8,
  5063. 32
  5064. ],
  5065. [
  5066. 8,
  5067. 32
  5068. ],
  5069. [
  5070. 6,
  5071. 1
  5072. ],
  5073. [
  5074. 6,
  5075. 1
  5076. ],
  5077. [
  5078. 6,
  5079. 1
  5080. ],
  5081. [
  5082. 6,
  5083. 1
  5084. ],
  5085. [
  5086. 6,
  5087. 1
  5088. ],
  5089. [
  5090. 6,
  5091. 1
  5092. ],
  5093. [
  5094. 6,
  5095. 1
  5096. ],
  5097. [
  5098. 6,
  5099. 1
  5100. ],
  5101. [
  5102. 6,
  5103. 12
  5104. ],
  5105. [
  5106. 6,
  5107. 12
  5108. ],
  5109. [
  5110. 6,
  5111. 12
  5112. ],
  5113. [
  5114. 6,
  5115. 12
  5116. ],
  5117. [
  5118. 6,
  5119. 12
  5120. ],
  5121. [
  5122. 6,
  5123. 12
  5124. ],
  5125. [
  5126. 6,
  5127. 12
  5128. ],
  5129. [
  5130. 6,
  5131. 12
  5132. ],
  5133. [
  5134. 8,
  5135. 53
  5136. ],
  5137. [
  5138. 8,
  5139. 53
  5140. ],
  5141. [
  5142. 8,
  5143. 54
  5144. ],
  5145. [
  5146. 8,
  5147. 54
  5148. ],
  5149. [
  5150. 7,
  5151. 26
  5152. ],
  5153. [
  5154. 7,
  5155. 26
  5156. ],
  5157. [
  5158. 7,
  5159. 26
  5160. ],
  5161. [
  5162. 7,
  5163. 26
  5164. ],
  5165. [
  5166. 8,
  5167. 39
  5168. ],
  5169. [
  5170. 8,
  5171. 39
  5172. ],
  5173. [
  5174. 8,
  5175. 40
  5176. ],
  5177. [
  5178. 8,
  5179. 40
  5180. ],
  5181. [
  5182. 8,
  5183. 41
  5184. ],
  5185. [
  5186. 8,
  5187. 41
  5188. ],
  5189. [
  5190. 8,
  5191. 42
  5192. ],
  5193. [
  5194. 8,
  5195. 42
  5196. ],
  5197. [
  5198. 8,
  5199. 43
  5200. ],
  5201. [
  5202. 8,
  5203. 43
  5204. ],
  5205. [
  5206. 8,
  5207. 44
  5208. ],
  5209. [
  5210. 8,
  5211. 44
  5212. ],
  5213. [
  5214. 7,
  5215. 21
  5216. ],
  5217. [
  5218. 7,
  5219. 21
  5220. ],
  5221. [
  5222. 7,
  5223. 21
  5224. ],
  5225. [
  5226. 7,
  5227. 21
  5228. ],
  5229. [
  5230. 7,
  5231. 28
  5232. ],
  5233. [
  5234. 7,
  5235. 28
  5236. ],
  5237. [
  5238. 7,
  5239. 28
  5240. ],
  5241. [
  5242. 7,
  5243. 28
  5244. ],
  5245. [
  5246. 8,
  5247. 61
  5248. ],
  5249. [
  5250. 8,
  5251. 61
  5252. ],
  5253. [
  5254. 8,
  5255. 62
  5256. ],
  5257. [
  5258. 8,
  5259. 62
  5260. ],
  5261. [
  5262. 8,
  5263. 63
  5264. ],
  5265. [
  5266. 8,
  5267. 63
  5268. ],
  5269. [
  5270. 8,
  5271. 0
  5272. ],
  5273. [
  5274. 8,
  5275. 0
  5276. ],
  5277. [
  5278. 8,
  5279. 320
  5280. ],
  5281. [
  5282. 8,
  5283. 320
  5284. ],
  5285. [
  5286. 8,
  5287. 384
  5288. ],
  5289. [
  5290. 8,
  5291. 384
  5292. ],
  5293. [
  5294. 5,
  5295. 10
  5296. ],
  5297. [
  5298. 5,
  5299. 10
  5300. ],
  5301. [
  5302. 5,
  5303. 10
  5304. ],
  5305. [
  5306. 5,
  5307. 10
  5308. ],
  5309. [
  5310. 5,
  5311. 10
  5312. ],
  5313. [
  5314. 5,
  5315. 10
  5316. ],
  5317. [
  5318. 5,
  5319. 10
  5320. ],
  5321. [
  5322. 5,
  5323. 10
  5324. ],
  5325. [
  5326. 5,
  5327. 10
  5328. ],
  5329. [
  5330. 5,
  5331. 10
  5332. ],
  5333. [
  5334. 5,
  5335. 10
  5336. ],
  5337. [
  5338. 5,
  5339. 10
  5340. ],
  5341. [
  5342. 5,
  5343. 10
  5344. ],
  5345. [
  5346. 5,
  5347. 10
  5348. ],
  5349. [
  5350. 5,
  5351. 10
  5352. ],
  5353. [
  5354. 5,
  5355. 10
  5356. ],
  5357. [
  5358. 5,
  5359. 11
  5360. ],
  5361. [
  5362. 5,
  5363. 11
  5364. ],
  5365. [
  5366. 5,
  5367. 11
  5368. ],
  5369. [
  5370. 5,
  5371. 11
  5372. ],
  5373. [
  5374. 5,
  5375. 11
  5376. ],
  5377. [
  5378. 5,
  5379. 11
  5380. ],
  5381. [
  5382. 5,
  5383. 11
  5384. ],
  5385. [
  5386. 5,
  5387. 11
  5388. ],
  5389. [
  5390. 5,
  5391. 11
  5392. ],
  5393. [
  5394. 5,
  5395. 11
  5396. ],
  5397. [
  5398. 5,
  5399. 11
  5400. ],
  5401. [
  5402. 5,
  5403. 11
  5404. ],
  5405. [
  5406. 5,
  5407. 11
  5408. ],
  5409. [
  5410. 5,
  5411. 11
  5412. ],
  5413. [
  5414. 5,
  5415. 11
  5416. ],
  5417. [
  5418. 5,
  5419. 11
  5420. ],
  5421. [
  5422. 7,
  5423. 27
  5424. ],
  5425. [
  5426. 7,
  5427. 27
  5428. ],
  5429. [
  5430. 7,
  5431. 27
  5432. ],
  5433. [
  5434. 7,
  5435. 27
  5436. ],
  5437. [
  5438. 8,
  5439. 59
  5440. ],
  5441. [
  5442. 8,
  5443. 59
  5444. ],
  5445. [
  5446. 8,
  5447. 60
  5448. ],
  5449. [
  5450. 8,
  5451. 60
  5452. ],
  5453. [
  5454. 9,
  5455. 1472
  5456. ],
  5457. [
  5458. 9,
  5459. 1536
  5460. ],
  5461. [
  5462. 9,
  5463. 1600
  5464. ],
  5465. [
  5466. 9,
  5467. 1728
  5468. ],
  5469. [
  5470. 7,
  5471. 18
  5472. ],
  5473. [
  5474. 7,
  5475. 18
  5476. ],
  5477. [
  5478. 7,
  5479. 18
  5480. ],
  5481. [
  5482. 7,
  5483. 18
  5484. ],
  5485. [
  5486. 7,
  5487. 24
  5488. ],
  5489. [
  5490. 7,
  5491. 24
  5492. ],
  5493. [
  5494. 7,
  5495. 24
  5496. ],
  5497. [
  5498. 7,
  5499. 24
  5500. ],
  5501. [
  5502. 8,
  5503. 49
  5504. ],
  5505. [
  5506. 8,
  5507. 49
  5508. ],
  5509. [
  5510. 8,
  5511. 50
  5512. ],
  5513. [
  5514. 8,
  5515. 50
  5516. ],
  5517. [
  5518. 8,
  5519. 51
  5520. ],
  5521. [
  5522. 8,
  5523. 51
  5524. ],
  5525. [
  5526. 8,
  5527. 52
  5528. ],
  5529. [
  5530. 8,
  5531. 52
  5532. ],
  5533. [
  5534. 7,
  5535. 25
  5536. ],
  5537. [
  5538. 7,
  5539. 25
  5540. ],
  5541. [
  5542. 7,
  5543. 25
  5544. ],
  5545. [
  5546. 7,
  5547. 25
  5548. ],
  5549. [
  5550. 8,
  5551. 55
  5552. ],
  5553. [
  5554. 8,
  5555. 55
  5556. ],
  5557. [
  5558. 8,
  5559. 56
  5560. ],
  5561. [
  5562. 8,
  5563. 56
  5564. ],
  5565. [
  5566. 8,
  5567. 57
  5568. ],
  5569. [
  5570. 8,
  5571. 57
  5572. ],
  5573. [
  5574. 8,
  5575. 58
  5576. ],
  5577. [
  5578. 8,
  5579. 58
  5580. ],
  5581. [
  5582. 6,
  5583. 192
  5584. ],
  5585. [
  5586. 6,
  5587. 192
  5588. ],
  5589. [
  5590. 6,
  5591. 192
  5592. ],
  5593. [
  5594. 6,
  5595. 192
  5596. ],
  5597. [
  5598. 6,
  5599. 192
  5600. ],
  5601. [
  5602. 6,
  5603. 192
  5604. ],
  5605. [
  5606. 6,
  5607. 192
  5608. ],
  5609. [
  5610. 6,
  5611. 192
  5612. ],
  5613. [
  5614. 6,
  5615. 1664
  5616. ],
  5617. [
  5618. 6,
  5619. 1664
  5620. ],
  5621. [
  5622. 6,
  5623. 1664
  5624. ],
  5625. [
  5626. 6,
  5627. 1664
  5628. ],
  5629. [
  5630. 6,
  5631. 1664
  5632. ],
  5633. [
  5634. 6,
  5635. 1664
  5636. ],
  5637. [
  5638. 6,
  5639. 1664
  5640. ],
  5641. [
  5642. 6,
  5643. 1664
  5644. ],
  5645. [
  5646. 8,
  5647. 448
  5648. ],
  5649. [
  5650. 8,
  5651. 448
  5652. ],
  5653. [
  5654. 8,
  5655. 512
  5656. ],
  5657. [
  5658. 8,
  5659. 512
  5660. ],
  5661. [
  5662. 9,
  5663. 704
  5664. ],
  5665. [
  5666. 9,
  5667. 768
  5668. ],
  5669. [
  5670. 8,
  5671. 640
  5672. ],
  5673. [
  5674. 8,
  5675. 640
  5676. ],
  5677. [
  5678. 8,
  5679. 576
  5680. ],
  5681. [
  5682. 8,
  5683. 576
  5684. ],
  5685. [
  5686. 9,
  5687. 832
  5688. ],
  5689. [
  5690. 9,
  5691. 896
  5692. ],
  5693. [
  5694. 9,
  5695. 960
  5696. ],
  5697. [
  5698. 9,
  5699. 1024
  5700. ],
  5701. [
  5702. 9,
  5703. 1088
  5704. ],
  5705. [
  5706. 9,
  5707. 1152
  5708. ],
  5709. [
  5710. 9,
  5711. 1216
  5712. ],
  5713. [
  5714. 9,
  5715. 1280
  5716. ],
  5717. [
  5718. 9,
  5719. 1344
  5720. ],
  5721. [
  5722. 9,
  5723. 1408
  5724. ],
  5725. [
  5726. 7,
  5727. 256
  5728. ],
  5729. [
  5730. 7,
  5731. 256
  5732. ],
  5733. [
  5734. 7,
  5735. 256
  5736. ],
  5737. [
  5738. 7,
  5739. 256
  5740. ],
  5741. [
  5742. 4,
  5743. 2
  5744. ],
  5745. [
  5746. 4,
  5747. 2
  5748. ],
  5749. [
  5750. 4,
  5751. 2
  5752. ],
  5753. [
  5754. 4,
  5755. 2
  5756. ],
  5757. [
  5758. 4,
  5759. 2
  5760. ],
  5761. [
  5762. 4,
  5763. 2
  5764. ],
  5765. [
  5766. 4,
  5767. 2
  5768. ],
  5769. [
  5770. 4,
  5771. 2
  5772. ],
  5773. [
  5774. 4,
  5775. 2
  5776. ],
  5777. [
  5778. 4,
  5779. 2
  5780. ],
  5781. [
  5782. 4,
  5783. 2
  5784. ],
  5785. [
  5786. 4,
  5787. 2
  5788. ],
  5789. [
  5790. 4,
  5791. 2
  5792. ],
  5793. [
  5794. 4,
  5795. 2
  5796. ],
  5797. [
  5798. 4,
  5799. 2
  5800. ],
  5801. [
  5802. 4,
  5803. 2
  5804. ],
  5805. [
  5806. 4,
  5807. 2
  5808. ],
  5809. [
  5810. 4,
  5811. 2
  5812. ],
  5813. [
  5814. 4,
  5815. 2
  5816. ],
  5817. [
  5818. 4,
  5819. 2
  5820. ],
  5821. [
  5822. 4,
  5823. 2
  5824. ],
  5825. [
  5826. 4,
  5827. 2
  5828. ],
  5829. [
  5830. 4,
  5831. 2
  5832. ],
  5833. [
  5834. 4,
  5835. 2
  5836. ],
  5837. [
  5838. 4,
  5839. 2
  5840. ],
  5841. [
  5842. 4,
  5843. 2
  5844. ],
  5845. [
  5846. 4,
  5847. 2
  5848. ],
  5849. [
  5850. 4,
  5851. 2
  5852. ],
  5853. [
  5854. 4,
  5855. 2
  5856. ],
  5857. [
  5858. 4,
  5859. 2
  5860. ],
  5861. [
  5862. 4,
  5863. 2
  5864. ],
  5865. [
  5866. 4,
  5867. 2
  5868. ],
  5869. [
  5870. 4,
  5871. 3
  5872. ],
  5873. [
  5874. 4,
  5875. 3
  5876. ],
  5877. [
  5878. 4,
  5879. 3
  5880. ],
  5881. [
  5882. 4,
  5883. 3
  5884. ],
  5885. [
  5886. 4,
  5887. 3
  5888. ],
  5889. [
  5890. 4,
  5891. 3
  5892. ],
  5893. [
  5894. 4,
  5895. 3
  5896. ],
  5897. [
  5898. 4,
  5899. 3
  5900. ],
  5901. [
  5902. 4,
  5903. 3
  5904. ],
  5905. [
  5906. 4,
  5907. 3
  5908. ],
  5909. [
  5910. 4,
  5911. 3
  5912. ],
  5913. [
  5914. 4,
  5915. 3
  5916. ],
  5917. [
  5918. 4,
  5919. 3
  5920. ],
  5921. [
  5922. 4,
  5923. 3
  5924. ],
  5925. [
  5926. 4,
  5927. 3
  5928. ],
  5929. [
  5930. 4,
  5931. 3
  5932. ],
  5933. [
  5934. 4,
  5935. 3
  5936. ],
  5937. [
  5938. 4,
  5939. 3
  5940. ],
  5941. [
  5942. 4,
  5943. 3
  5944. ],
  5945. [
  5946. 4,
  5947. 3
  5948. ],
  5949. [
  5950. 4,
  5951. 3
  5952. ],
  5953. [
  5954. 4,
  5955. 3
  5956. ],
  5957. [
  5958. 4,
  5959. 3
  5960. ],
  5961. [
  5962. 4,
  5963. 3
  5964. ],
  5965. [
  5966. 4,
  5967. 3
  5968. ],
  5969. [
  5970. 4,
  5971. 3
  5972. ],
  5973. [
  5974. 4,
  5975. 3
  5976. ],
  5977. [
  5978. 4,
  5979. 3
  5980. ],
  5981. [
  5982. 4,
  5983. 3
  5984. ],
  5985. [
  5986. 4,
  5987. 3
  5988. ],
  5989. [
  5990. 4,
  5991. 3
  5992. ],
  5993. [
  5994. 4,
  5995. 3
  5996. ],
  5997. [
  5998. 5,
  5999. 128
  6000. ],
  6001. [
  6002. 5,
  6003. 128
  6004. ],
  6005. [
  6006. 5,
  6007. 128
  6008. ],
  6009. [
  6010. 5,
  6011. 128
  6012. ],
  6013. [
  6014. 5,
  6015. 128
  6016. ],
  6017. [
  6018. 5,
  6019. 128
  6020. ],
  6021. [
  6022. 5,
  6023. 128
  6024. ],
  6025. [
  6026. 5,
  6027. 128
  6028. ],
  6029. [
  6030. 5,
  6031. 128
  6032. ],
  6033. [
  6034. 5,
  6035. 128
  6036. ],
  6037. [
  6038. 5,
  6039. 128
  6040. ],
  6041. [
  6042. 5,
  6043. 128
  6044. ],
  6045. [
  6046. 5,
  6047. 128
  6048. ],
  6049. [
  6050. 5,
  6051. 128
  6052. ],
  6053. [
  6054. 5,
  6055. 128
  6056. ],
  6057. [
  6058. 5,
  6059. 128
  6060. ],
  6061. [
  6062. 5,
  6063. 8
  6064. ],
  6065. [
  6066. 5,
  6067. 8
  6068. ],
  6069. [
  6070. 5,
  6071. 8
  6072. ],
  6073. [
  6074. 5,
  6075. 8
  6076. ],
  6077. [
  6078. 5,
  6079. 8
  6080. ],
  6081. [
  6082. 5,
  6083. 8
  6084. ],
  6085. [
  6086. 5,
  6087. 8
  6088. ],
  6089. [
  6090. 5,
  6091. 8
  6092. ],
  6093. [
  6094. 5,
  6095. 8
  6096. ],
  6097. [
  6098. 5,
  6099. 8
  6100. ],
  6101. [
  6102. 5,
  6103. 8
  6104. ],
  6105. [
  6106. 5,
  6107. 8
  6108. ],
  6109. [
  6110. 5,
  6111. 8
  6112. ],
  6113. [
  6114. 5,
  6115. 8
  6116. ],
  6117. [
  6118. 5,
  6119. 8
  6120. ],
  6121. [
  6122. 5,
  6123. 8
  6124. ],
  6125. [
  6126. 5,
  6127. 9
  6128. ],
  6129. [
  6130. 5,
  6131. 9
  6132. ],
  6133. [
  6134. 5,
  6135. 9
  6136. ],
  6137. [
  6138. 5,
  6139. 9
  6140. ],
  6141. [
  6142. 5,
  6143. 9
  6144. ],
  6145. [
  6146. 5,
  6147. 9
  6148. ],
  6149. [
  6150. 5,
  6151. 9
  6152. ],
  6153. [
  6154. 5,
  6155. 9
  6156. ],
  6157. [
  6158. 5,
  6159. 9
  6160. ],
  6161. [
  6162. 5,
  6163. 9
  6164. ],
  6165. [
  6166. 5,
  6167. 9
  6168. ],
  6169. [
  6170. 5,
  6171. 9
  6172. ],
  6173. [
  6174. 5,
  6175. 9
  6176. ],
  6177. [
  6178. 5,
  6179. 9
  6180. ],
  6181. [
  6182. 5,
  6183. 9
  6184. ],
  6185. [
  6186. 5,
  6187. 9
  6188. ],
  6189. [
  6190. 6,
  6191. 16
  6192. ],
  6193. [
  6194. 6,
  6195. 16
  6196. ],
  6197. [
  6198. 6,
  6199. 16
  6200. ],
  6201. [
  6202. 6,
  6203. 16
  6204. ],
  6205. [
  6206. 6,
  6207. 16
  6208. ],
  6209. [
  6210. 6,
  6211. 16
  6212. ],
  6213. [
  6214. 6,
  6215. 16
  6216. ],
  6217. [
  6218. 6,
  6219. 16
  6220. ],
  6221. [
  6222. 6,
  6223. 17
  6224. ],
  6225. [
  6226. 6,
  6227. 17
  6228. ],
  6229. [
  6230. 6,
  6231. 17
  6232. ],
  6233. [
  6234. 6,
  6235. 17
  6236. ],
  6237. [
  6238. 6,
  6239. 17
  6240. ],
  6241. [
  6242. 6,
  6243. 17
  6244. ],
  6245. [
  6246. 6,
  6247. 17
  6248. ],
  6249. [
  6250. 6,
  6251. 17
  6252. ],
  6253. [
  6254. 4,
  6255. 4
  6256. ],
  6257. [
  6258. 4,
  6259. 4
  6260. ],
  6261. [
  6262. 4,
  6263. 4
  6264. ],
  6265. [
  6266. 4,
  6267. 4
  6268. ],
  6269. [
  6270. 4,
  6271. 4
  6272. ],
  6273. [
  6274. 4,
  6275. 4
  6276. ],
  6277. [
  6278. 4,
  6279. 4
  6280. ],
  6281. [
  6282. 4,
  6283. 4
  6284. ],
  6285. [
  6286. 4,
  6287. 4
  6288. ],
  6289. [
  6290. 4,
  6291. 4
  6292. ],
  6293. [
  6294. 4,
  6295. 4
  6296. ],
  6297. [
  6298. 4,
  6299. 4
  6300. ],
  6301. [
  6302. 4,
  6303. 4
  6304. ],
  6305. [
  6306. 4,
  6307. 4
  6308. ],
  6309. [
  6310. 4,
  6311. 4
  6312. ],
  6313. [
  6314. 4,
  6315. 4
  6316. ],
  6317. [
  6318. 4,
  6319. 4
  6320. ],
  6321. [
  6322. 4,
  6323. 4
  6324. ],
  6325. [
  6326. 4,
  6327. 4
  6328. ],
  6329. [
  6330. 4,
  6331. 4
  6332. ],
  6333. [
  6334. 4,
  6335. 4
  6336. ],
  6337. [
  6338. 4,
  6339. 4
  6340. ],
  6341. [
  6342. 4,
  6343. 4
  6344. ],
  6345. [
  6346. 4,
  6347. 4
  6348. ],
  6349. [
  6350. 4,
  6351. 4
  6352. ],
  6353. [
  6354. 4,
  6355. 4
  6356. ],
  6357. [
  6358. 4,
  6359. 4
  6360. ],
  6361. [
  6362. 4,
  6363. 4
  6364. ],
  6365. [
  6366. 4,
  6367. 4
  6368. ],
  6369. [
  6370. 4,
  6371. 4
  6372. ],
  6373. [
  6374. 4,
  6375. 4
  6376. ],
  6377. [
  6378. 4,
  6379. 4
  6380. ],
  6381. [
  6382. 4,
  6383. 5
  6384. ],
  6385. [
  6386. 4,
  6387. 5
  6388. ],
  6389. [
  6390. 4,
  6391. 5
  6392. ],
  6393. [
  6394. 4,
  6395. 5
  6396. ],
  6397. [
  6398. 4,
  6399. 5
  6400. ],
  6401. [
  6402. 4,
  6403. 5
  6404. ],
  6405. [
  6406. 4,
  6407. 5
  6408. ],
  6409. [
  6410. 4,
  6411. 5
  6412. ],
  6413. [
  6414. 4,
  6415. 5
  6416. ],
  6417. [
  6418. 4,
  6419. 5
  6420. ],
  6421. [
  6422. 4,
  6423. 5
  6424. ],
  6425. [
  6426. 4,
  6427. 5
  6428. ],
  6429. [
  6430. 4,
  6431. 5
  6432. ],
  6433. [
  6434. 4,
  6435. 5
  6436. ],
  6437. [
  6438. 4,
  6439. 5
  6440. ],
  6441. [
  6442. 4,
  6443. 5
  6444. ],
  6445. [
  6446. 4,
  6447. 5
  6448. ],
  6449. [
  6450. 4,
  6451. 5
  6452. ],
  6453. [
  6454. 4,
  6455. 5
  6456. ],
  6457. [
  6458. 4,
  6459. 5
  6460. ],
  6461. [
  6462. 4,
  6463. 5
  6464. ],
  6465. [
  6466. 4,
  6467. 5
  6468. ],
  6469. [
  6470. 4,
  6471. 5
  6472. ],
  6473. [
  6474. 4,
  6475. 5
  6476. ],
  6477. [
  6478. 4,
  6479. 5
  6480. ],
  6481. [
  6482. 4,
  6483. 5
  6484. ],
  6485. [
  6486. 4,
  6487. 5
  6488. ],
  6489. [
  6490. 4,
  6491. 5
  6492. ],
  6493. [
  6494. 4,
  6495. 5
  6496. ],
  6497. [
  6498. 4,
  6499. 5
  6500. ],
  6501. [
  6502. 4,
  6503. 5
  6504. ],
  6505. [
  6506. 4,
  6507. 5
  6508. ],
  6509. [
  6510. 6,
  6511. 14
  6512. ],
  6513. [
  6514. 6,
  6515. 14
  6516. ],
  6517. [
  6518. 6,
  6519. 14
  6520. ],
  6521. [
  6522. 6,
  6523. 14
  6524. ],
  6525. [
  6526. 6,
  6527. 14
  6528. ],
  6529. [
  6530. 6,
  6531. 14
  6532. ],
  6533. [
  6534. 6,
  6535. 14
  6536. ],
  6537. [
  6538. 6,
  6539. 14
  6540. ],
  6541. [
  6542. 6,
  6543. 15
  6544. ],
  6545. [
  6546. 6,
  6547. 15
  6548. ],
  6549. [
  6550. 6,
  6551. 15
  6552. ],
  6553. [
  6554. 6,
  6555. 15
  6556. ],
  6557. [
  6558. 6,
  6559. 15
  6560. ],
  6561. [
  6562. 6,
  6563. 15
  6564. ],
  6565. [
  6566. 6,
  6567. 15
  6568. ],
  6569. [
  6570. 6,
  6571. 15
  6572. ],
  6573. [
  6574. 5,
  6575. 64
  6576. ],
  6577. [
  6578. 5,
  6579. 64
  6580. ],
  6581. [
  6582. 5,
  6583. 64
  6584. ],
  6585. [
  6586. 5,
  6587. 64
  6588. ],
  6589. [
  6590. 5,
  6591. 64
  6592. ],
  6593. [
  6594. 5,
  6595. 64
  6596. ],
  6597. [
  6598. 5,
  6599. 64
  6600. ],
  6601. [
  6602. 5,
  6603. 64
  6604. ],
  6605. [
  6606. 5,
  6607. 64
  6608. ],
  6609. [
  6610. 5,
  6611. 64
  6612. ],
  6613. [
  6614. 5,
  6615. 64
  6616. ],
  6617. [
  6618. 5,
  6619. 64
  6620. ],
  6621. [
  6622. 5,
  6623. 64
  6624. ],
  6625. [
  6626. 5,
  6627. 64
  6628. ],
  6629. [
  6630. 5,
  6631. 64
  6632. ],
  6633. [
  6634. 5,
  6635. 64
  6636. ],
  6637. [
  6638. 4,
  6639. 6
  6640. ],
  6641. [
  6642. 4,
  6643. 6
  6644. ],
  6645. [
  6646. 4,
  6647. 6
  6648. ],
  6649. [
  6650. 4,
  6651. 6
  6652. ],
  6653. [
  6654. 4,
  6655. 6
  6656. ],
  6657. [
  6658. 4,
  6659. 6
  6660. ],
  6661. [
  6662. 4,
  6663. 6
  6664. ],
  6665. [
  6666. 4,
  6667. 6
  6668. ],
  6669. [
  6670. 4,
  6671. 6
  6672. ],
  6673. [
  6674. 4,
  6675. 6
  6676. ],
  6677. [
  6678. 4,
  6679. 6
  6680. ],
  6681. [
  6682. 4,
  6683. 6
  6684. ],
  6685. [
  6686. 4,
  6687. 6
  6688. ],
  6689. [
  6690. 4,
  6691. 6
  6692. ],
  6693. [
  6694. 4,
  6695. 6
  6696. ],
  6697. [
  6698. 4,
  6699. 6
  6700. ],
  6701. [
  6702. 4,
  6703. 6
  6704. ],
  6705. [
  6706. 4,
  6707. 6
  6708. ],
  6709. [
  6710. 4,
  6711. 6
  6712. ],
  6713. [
  6714. 4,
  6715. 6
  6716. ],
  6717. [
  6718. 4,
  6719. 6
  6720. ],
  6721. [
  6722. 4,
  6723. 6
  6724. ],
  6725. [
  6726. 4,
  6727. 6
  6728. ],
  6729. [
  6730. 4,
  6731. 6
  6732. ],
  6733. [
  6734. 4,
  6735. 6
  6736. ],
  6737. [
  6738. 4,
  6739. 6
  6740. ],
  6741. [
  6742. 4,
  6743. 6
  6744. ],
  6745. [
  6746. 4,
  6747. 6
  6748. ],
  6749. [
  6750. 4,
  6751. 6
  6752. ],
  6753. [
  6754. 4,
  6755. 6
  6756. ],
  6757. [
  6758. 4,
  6759. 6
  6760. ],
  6761. [
  6762. 4,
  6763. 6
  6764. ],
  6765. [
  6766. 4,
  6767. 7
  6768. ],
  6769. [
  6770. 4,
  6771. 7
  6772. ],
  6773. [
  6774. 4,
  6775. 7
  6776. ],
  6777. [
  6778. 4,
  6779. 7
  6780. ],
  6781. [
  6782. 4,
  6783. 7
  6784. ],
  6785. [
  6786. 4,
  6787. 7
  6788. ],
  6789. [
  6790. 4,
  6791. 7
  6792. ],
  6793. [
  6794. 4,
  6795. 7
  6796. ],
  6797. [
  6798. 4,
  6799. 7
  6800. ],
  6801. [
  6802. 4,
  6803. 7
  6804. ],
  6805. [
  6806. 4,
  6807. 7
  6808. ],
  6809. [
  6810. 4,
  6811. 7
  6812. ],
  6813. [
  6814. 4,
  6815. 7
  6816. ],
  6817. [
  6818. 4,
  6819. 7
  6820. ],
  6821. [
  6822. 4,
  6823. 7
  6824. ],
  6825. [
  6826. 4,
  6827. 7
  6828. ],
  6829. [
  6830. 4,
  6831. 7
  6832. ],
  6833. [
  6834. 4,
  6835. 7
  6836. ],
  6837. [
  6838. 4,
  6839. 7
  6840. ],
  6841. [
  6842. 4,
  6843. 7
  6844. ],
  6845. [
  6846. 4,
  6847. 7
  6848. ],
  6849. [
  6850. 4,
  6851. 7
  6852. ],
  6853. [
  6854. 4,
  6855. 7
  6856. ],
  6857. [
  6858. 4,
  6859. 7
  6860. ],
  6861. [
  6862. 4,
  6863. 7
  6864. ],
  6865. [
  6866. 4,
  6867. 7
  6868. ],
  6869. [
  6870. 4,
  6871. 7
  6872. ],
  6873. [
  6874. 4,
  6875. 7
  6876. ],
  6877. [
  6878. 4,
  6879. 7
  6880. ],
  6881. [
  6882. 4,
  6883. 7
  6884. ],
  6885. [
  6886. 4,
  6887. 7
  6888. ],
  6889. [
  6890. 4,
  6891. 7
  6892. ]
  6893. ];
  6894. var blackTable1 = [
  6895. [
  6896. -1,
  6897. -1
  6898. ],
  6899. [
  6900. -1,
  6901. -1
  6902. ],
  6903. [
  6904. 12,
  6905. ccittEOL
  6906. ],
  6907. [
  6908. 12,
  6909. ccittEOL
  6910. ],
  6911. [
  6912. -1,
  6913. -1
  6914. ],
  6915. [
  6916. -1,
  6917. -1
  6918. ],
  6919. [
  6920. -1,
  6921. -1
  6922. ],
  6923. [
  6924. -1,
  6925. -1
  6926. ],
  6927. [
  6928. -1,
  6929. -1
  6930. ],
  6931. [
  6932. -1,
  6933. -1
  6934. ],
  6935. [
  6936. -1,
  6937. -1
  6938. ],
  6939. [
  6940. -1,
  6941. -1
  6942. ],
  6943. [
  6944. -1,
  6945. -1
  6946. ],
  6947. [
  6948. -1,
  6949. -1
  6950. ],
  6951. [
  6952. -1,
  6953. -1
  6954. ],
  6955. [
  6956. -1,
  6957. -1
  6958. ],
  6959. [
  6960. -1,
  6961. -1
  6962. ],
  6963. [
  6964. -1,
  6965. -1
  6966. ],
  6967. [
  6968. -1,
  6969. -1
  6970. ],
  6971. [
  6972. -1,
  6973. -1
  6974. ],
  6975. [
  6976. -1,
  6977. -1
  6978. ],
  6979. [
  6980. -1,
  6981. -1
  6982. ],
  6983. [
  6984. -1,
  6985. -1
  6986. ],
  6987. [
  6988. -1,
  6989. -1
  6990. ],
  6991. [
  6992. -1,
  6993. -1
  6994. ],
  6995. [
  6996. -1,
  6997. -1
  6998. ],
  6999. [
  7000. -1,
  7001. -1
  7002. ],
  7003. [
  7004. -1,
  7005. -1
  7006. ],
  7007. [
  7008. -1,
  7009. -1
  7010. ],
  7011. [
  7012. -1,
  7013. -1
  7014. ],
  7015. [
  7016. -1,
  7017. -1
  7018. ],
  7019. [
  7020. -1,
  7021. -1
  7022. ],
  7023. [
  7024. 11,
  7025. 1792
  7026. ],
  7027. [
  7028. 11,
  7029. 1792
  7030. ],
  7031. [
  7032. 11,
  7033. 1792
  7034. ],
  7035. [
  7036. 11,
  7037. 1792
  7038. ],
  7039. [
  7040. 12,
  7041. 1984
  7042. ],
  7043. [
  7044. 12,
  7045. 1984
  7046. ],
  7047. [
  7048. 12,
  7049. 2048
  7050. ],
  7051. [
  7052. 12,
  7053. 2048
  7054. ],
  7055. [
  7056. 12,
  7057. 2112
  7058. ],
  7059. [
  7060. 12,
  7061. 2112
  7062. ],
  7063. [
  7064. 12,
  7065. 2176
  7066. ],
  7067. [
  7068. 12,
  7069. 2176
  7070. ],
  7071. [
  7072. 12,
  7073. 2240
  7074. ],
  7075. [
  7076. 12,
  7077. 2240
  7078. ],
  7079. [
  7080. 12,
  7081. 2304
  7082. ],
  7083. [
  7084. 12,
  7085. 2304
  7086. ],
  7087. [
  7088. 11,
  7089. 1856
  7090. ],
  7091. [
  7092. 11,
  7093. 1856
  7094. ],
  7095. [
  7096. 11,
  7097. 1856
  7098. ],
  7099. [
  7100. 11,
  7101. 1856
  7102. ],
  7103. [
  7104. 11,
  7105. 1920
  7106. ],
  7107. [
  7108. 11,
  7109. 1920
  7110. ],
  7111. [
  7112. 11,
  7113. 1920
  7114. ],
  7115. [
  7116. 11,
  7117. 1920
  7118. ],
  7119. [
  7120. 12,
  7121. 2368
  7122. ],
  7123. [
  7124. 12,
  7125. 2368
  7126. ],
  7127. [
  7128. 12,
  7129. 2432
  7130. ],
  7131. [
  7132. 12,
  7133. 2432
  7134. ],
  7135. [
  7136. 12,
  7137. 2496
  7138. ],
  7139. [
  7140. 12,
  7141. 2496
  7142. ],
  7143. [
  7144. 12,
  7145. 2560
  7146. ],
  7147. [
  7148. 12,
  7149. 2560
  7150. ],
  7151. [
  7152. 10,
  7153. 18
  7154. ],
  7155. [
  7156. 10,
  7157. 18
  7158. ],
  7159. [
  7160. 10,
  7161. 18
  7162. ],
  7163. [
  7164. 10,
  7165. 18
  7166. ],
  7167. [
  7168. 10,
  7169. 18
  7170. ],
  7171. [
  7172. 10,
  7173. 18
  7174. ],
  7175. [
  7176. 10,
  7177. 18
  7178. ],
  7179. [
  7180. 10,
  7181. 18
  7182. ],
  7183. [
  7184. 12,
  7185. 52
  7186. ],
  7187. [
  7188. 12,
  7189. 52
  7190. ],
  7191. [
  7192. 13,
  7193. 640
  7194. ],
  7195. [
  7196. 13,
  7197. 704
  7198. ],
  7199. [
  7200. 13,
  7201. 768
  7202. ],
  7203. [
  7204. 13,
  7205. 832
  7206. ],
  7207. [
  7208. 12,
  7209. 55
  7210. ],
  7211. [
  7212. 12,
  7213. 55
  7214. ],
  7215. [
  7216. 12,
  7217. 56
  7218. ],
  7219. [
  7220. 12,
  7221. 56
  7222. ],
  7223. [
  7224. 13,
  7225. 1280
  7226. ],
  7227. [
  7228. 13,
  7229. 1344
  7230. ],
  7231. [
  7232. 13,
  7233. 1408
  7234. ],
  7235. [
  7236. 13,
  7237. 1472
  7238. ],
  7239. [
  7240. 12,
  7241. 59
  7242. ],
  7243. [
  7244. 12,
  7245. 59
  7246. ],
  7247. [
  7248. 12,
  7249. 60
  7250. ],
  7251. [
  7252. 12,
  7253. 60
  7254. ],
  7255. [
  7256. 13,
  7257. 1536
  7258. ],
  7259. [
  7260. 13,
  7261. 1600
  7262. ],
  7263. [
  7264. 11,
  7265. 24
  7266. ],
  7267. [
  7268. 11,
  7269. 24
  7270. ],
  7271. [
  7272. 11,
  7273. 24
  7274. ],
  7275. [
  7276. 11,
  7277. 24
  7278. ],
  7279. [
  7280. 11,
  7281. 25
  7282. ],
  7283. [
  7284. 11,
  7285. 25
  7286. ],
  7287. [
  7288. 11,
  7289. 25
  7290. ],
  7291. [
  7292. 11,
  7293. 25
  7294. ],
  7295. [
  7296. 13,
  7297. 1664
  7298. ],
  7299. [
  7300. 13,
  7301. 1728
  7302. ],
  7303. [
  7304. 12,
  7305. 320
  7306. ],
  7307. [
  7308. 12,
  7309. 320
  7310. ],
  7311. [
  7312. 12,
  7313. 384
  7314. ],
  7315. [
  7316. 12,
  7317. 384
  7318. ],
  7319. [
  7320. 12,
  7321. 448
  7322. ],
  7323. [
  7324. 12,
  7325. 448
  7326. ],
  7327. [
  7328. 13,
  7329. 512
  7330. ],
  7331. [
  7332. 13,
  7333. 576
  7334. ],
  7335. [
  7336. 12,
  7337. 53
  7338. ],
  7339. [
  7340. 12,
  7341. 53
  7342. ],
  7343. [
  7344. 12,
  7345. 54
  7346. ],
  7347. [
  7348. 12,
  7349. 54
  7350. ],
  7351. [
  7352. 13,
  7353. 896
  7354. ],
  7355. [
  7356. 13,
  7357. 960
  7358. ],
  7359. [
  7360. 13,
  7361. 1024
  7362. ],
  7363. [
  7364. 13,
  7365. 1088
  7366. ],
  7367. [
  7368. 13,
  7369. 1152
  7370. ],
  7371. [
  7372. 13,
  7373. 1216
  7374. ],
  7375. [
  7376. 10,
  7377. 64
  7378. ],
  7379. [
  7380. 10,
  7381. 64
  7382. ],
  7383. [
  7384. 10,
  7385. 64
  7386. ],
  7387. [
  7388. 10,
  7389. 64
  7390. ],
  7391. [
  7392. 10,
  7393. 64
  7394. ],
  7395. [
  7396. 10,
  7397. 64
  7398. ],
  7399. [
  7400. 10,
  7401. 64
  7402. ],
  7403. [
  7404. 10,
  7405. 64
  7406. ]
  7407. ];
  7408. var blackTable2 = [
  7409. [
  7410. 8,
  7411. 13
  7412. ],
  7413. [
  7414. 8,
  7415. 13
  7416. ],
  7417. [
  7418. 8,
  7419. 13
  7420. ],
  7421. [
  7422. 8,
  7423. 13
  7424. ],
  7425. [
  7426. 8,
  7427. 13
  7428. ],
  7429. [
  7430. 8,
  7431. 13
  7432. ],
  7433. [
  7434. 8,
  7435. 13
  7436. ],
  7437. [
  7438. 8,
  7439. 13
  7440. ],
  7441. [
  7442. 8,
  7443. 13
  7444. ],
  7445. [
  7446. 8,
  7447. 13
  7448. ],
  7449. [
  7450. 8,
  7451. 13
  7452. ],
  7453. [
  7454. 8,
  7455. 13
  7456. ],
  7457. [
  7458. 8,
  7459. 13
  7460. ],
  7461. [
  7462. 8,
  7463. 13
  7464. ],
  7465. [
  7466. 8,
  7467. 13
  7468. ],
  7469. [
  7470. 8,
  7471. 13
  7472. ],
  7473. [
  7474. 11,
  7475. 23
  7476. ],
  7477. [
  7478. 11,
  7479. 23
  7480. ],
  7481. [
  7482. 12,
  7483. 50
  7484. ],
  7485. [
  7486. 12,
  7487. 51
  7488. ],
  7489. [
  7490. 12,
  7491. 44
  7492. ],
  7493. [
  7494. 12,
  7495. 45
  7496. ],
  7497. [
  7498. 12,
  7499. 46
  7500. ],
  7501. [
  7502. 12,
  7503. 47
  7504. ],
  7505. [
  7506. 12,
  7507. 57
  7508. ],
  7509. [
  7510. 12,
  7511. 58
  7512. ],
  7513. [
  7514. 12,
  7515. 61
  7516. ],
  7517. [
  7518. 12,
  7519. 256
  7520. ],
  7521. [
  7522. 10,
  7523. 16
  7524. ],
  7525. [
  7526. 10,
  7527. 16
  7528. ],
  7529. [
  7530. 10,
  7531. 16
  7532. ],
  7533. [
  7534. 10,
  7535. 16
  7536. ],
  7537. [
  7538. 10,
  7539. 17
  7540. ],
  7541. [
  7542. 10,
  7543. 17
  7544. ],
  7545. [
  7546. 10,
  7547. 17
  7548. ],
  7549. [
  7550. 10,
  7551. 17
  7552. ],
  7553. [
  7554. 12,
  7555. 48
  7556. ],
  7557. [
  7558. 12,
  7559. 49
  7560. ],
  7561. [
  7562. 12,
  7563. 62
  7564. ],
  7565. [
  7566. 12,
  7567. 63
  7568. ],
  7569. [
  7570. 12,
  7571. 30
  7572. ],
  7573. [
  7574. 12,
  7575. 31
  7576. ],
  7577. [
  7578. 12,
  7579. 32
  7580. ],
  7581. [
  7582. 12,
  7583. 33
  7584. ],
  7585. [
  7586. 12,
  7587. 40
  7588. ],
  7589. [
  7590. 12,
  7591. 41
  7592. ],
  7593. [
  7594. 11,
  7595. 22
  7596. ],
  7597. [
  7598. 11,
  7599. 22
  7600. ],
  7601. [
  7602. 8,
  7603. 14
  7604. ],
  7605. [
  7606. 8,
  7607. 14
  7608. ],
  7609. [
  7610. 8,
  7611. 14
  7612. ],
  7613. [
  7614. 8,
  7615. 14
  7616. ],
  7617. [
  7618. 8,
  7619. 14
  7620. ],
  7621. [
  7622. 8,
  7623. 14
  7624. ],
  7625. [
  7626. 8,
  7627. 14
  7628. ],
  7629. [
  7630. 8,
  7631. 14
  7632. ],
  7633. [
  7634. 8,
  7635. 14
  7636. ],
  7637. [
  7638. 8,
  7639. 14
  7640. ],
  7641. [
  7642. 8,
  7643. 14
  7644. ],
  7645. [
  7646. 8,
  7647. 14
  7648. ],
  7649. [
  7650. 8,
  7651. 14
  7652. ],
  7653. [
  7654. 8,
  7655. 14
  7656. ],
  7657. [
  7658. 8,
  7659. 14
  7660. ],
  7661. [
  7662. 8,
  7663. 14
  7664. ],
  7665. [
  7666. 7,
  7667. 10
  7668. ],
  7669. [
  7670. 7,
  7671. 10
  7672. ],
  7673. [
  7674. 7,
  7675. 10
  7676. ],
  7677. [
  7678. 7,
  7679. 10
  7680. ],
  7681. [
  7682. 7,
  7683. 10
  7684. ],
  7685. [
  7686. 7,
  7687. 10
  7688. ],
  7689. [
  7690. 7,
  7691. 10
  7692. ],
  7693. [
  7694. 7,
  7695. 10
  7696. ],
  7697. [
  7698. 7,
  7699. 10
  7700. ],
  7701. [
  7702. 7,
  7703. 10
  7704. ],
  7705. [
  7706. 7,
  7707. 10
  7708. ],
  7709. [
  7710. 7,
  7711. 10
  7712. ],
  7713. [
  7714. 7,
  7715. 10
  7716. ],
  7717. [
  7718. 7,
  7719. 10
  7720. ],
  7721. [
  7722. 7,
  7723. 10
  7724. ],
  7725. [
  7726. 7,
  7727. 10
  7728. ],
  7729. [
  7730. 7,
  7731. 10
  7732. ],
  7733. [
  7734. 7,
  7735. 10
  7736. ],
  7737. [
  7738. 7,
  7739. 10
  7740. ],
  7741. [
  7742. 7,
  7743. 10
  7744. ],
  7745. [
  7746. 7,
  7747. 10
  7748. ],
  7749. [
  7750. 7,
  7751. 10
  7752. ],
  7753. [
  7754. 7,
  7755. 10
  7756. ],
  7757. [
  7758. 7,
  7759. 10
  7760. ],
  7761. [
  7762. 7,
  7763. 10
  7764. ],
  7765. [
  7766. 7,
  7767. 10
  7768. ],
  7769. [
  7770. 7,
  7771. 10
  7772. ],
  7773. [
  7774. 7,
  7775. 10
  7776. ],
  7777. [
  7778. 7,
  7779. 10
  7780. ],
  7781. [
  7782. 7,
  7783. 10
  7784. ],
  7785. [
  7786. 7,
  7787. 10
  7788. ],
  7789. [
  7790. 7,
  7791. 10
  7792. ],
  7793. [
  7794. 7,
  7795. 11
  7796. ],
  7797. [
  7798. 7,
  7799. 11
  7800. ],
  7801. [
  7802. 7,
  7803. 11
  7804. ],
  7805. [
  7806. 7,
  7807. 11
  7808. ],
  7809. [
  7810. 7,
  7811. 11
  7812. ],
  7813. [
  7814. 7,
  7815. 11
  7816. ],
  7817. [
  7818. 7,
  7819. 11
  7820. ],
  7821. [
  7822. 7,
  7823. 11
  7824. ],
  7825. [
  7826. 7,
  7827. 11
  7828. ],
  7829. [
  7830. 7,
  7831. 11
  7832. ],
  7833. [
  7834. 7,
  7835. 11
  7836. ],
  7837. [
  7838. 7,
  7839. 11
  7840. ],
  7841. [
  7842. 7,
  7843. 11
  7844. ],
  7845. [
  7846. 7,
  7847. 11
  7848. ],
  7849. [
  7850. 7,
  7851. 11
  7852. ],
  7853. [
  7854. 7,
  7855. 11
  7856. ],
  7857. [
  7858. 7,
  7859. 11
  7860. ],
  7861. [
  7862. 7,
  7863. 11
  7864. ],
  7865. [
  7866. 7,
  7867. 11
  7868. ],
  7869. [
  7870. 7,
  7871. 11
  7872. ],
  7873. [
  7874. 7,
  7875. 11
  7876. ],
  7877. [
  7878. 7,
  7879. 11
  7880. ],
  7881. [
  7882. 7,
  7883. 11
  7884. ],
  7885. [
  7886. 7,
  7887. 11
  7888. ],
  7889. [
  7890. 7,
  7891. 11
  7892. ],
  7893. [
  7894. 7,
  7895. 11
  7896. ],
  7897. [
  7898. 7,
  7899. 11
  7900. ],
  7901. [
  7902. 7,
  7903. 11
  7904. ],
  7905. [
  7906. 7,
  7907. 11
  7908. ],
  7909. [
  7910. 7,
  7911. 11
  7912. ],
  7913. [
  7914. 7,
  7915. 11
  7916. ],
  7917. [
  7918. 7,
  7919. 11
  7920. ],
  7921. [
  7922. 9,
  7923. 15
  7924. ],
  7925. [
  7926. 9,
  7927. 15
  7928. ],
  7929. [
  7930. 9,
  7931. 15
  7932. ],
  7933. [
  7934. 9,
  7935. 15
  7936. ],
  7937. [
  7938. 9,
  7939. 15
  7940. ],
  7941. [
  7942. 9,
  7943. 15
  7944. ],
  7945. [
  7946. 9,
  7947. 15
  7948. ],
  7949. [
  7950. 9,
  7951. 15
  7952. ],
  7953. [
  7954. 12,
  7955. 128
  7956. ],
  7957. [
  7958. 12,
  7959. 192
  7960. ],
  7961. [
  7962. 12,
  7963. 26
  7964. ],
  7965. [
  7966. 12,
  7967. 27
  7968. ],
  7969. [
  7970. 12,
  7971. 28
  7972. ],
  7973. [
  7974. 12,
  7975. 29
  7976. ],
  7977. [
  7978. 11,
  7979. 19
  7980. ],
  7981. [
  7982. 11,
  7983. 19
  7984. ],
  7985. [
  7986. 11,
  7987. 20
  7988. ],
  7989. [
  7990. 11,
  7991. 20
  7992. ],
  7993. [
  7994. 12,
  7995. 34
  7996. ],
  7997. [
  7998. 12,
  7999. 35
  8000. ],
  8001. [
  8002. 12,
  8003. 36
  8004. ],
  8005. [
  8006. 12,
  8007. 37
  8008. ],
  8009. [
  8010. 12,
  8011. 38
  8012. ],
  8013. [
  8014. 12,
  8015. 39
  8016. ],
  8017. [
  8018. 11,
  8019. 21
  8020. ],
  8021. [
  8022. 11,
  8023. 21
  8024. ],
  8025. [
  8026. 12,
  8027. 42
  8028. ],
  8029. [
  8030. 12,
  8031. 43
  8032. ],
  8033. [
  8034. 10,
  8035. 0
  8036. ],
  8037. [
  8038. 10,
  8039. 0
  8040. ],
  8041. [
  8042. 10,
  8043. 0
  8044. ],
  8045. [
  8046. 10,
  8047. 0
  8048. ],
  8049. [
  8050. 7,
  8051. 12
  8052. ],
  8053. [
  8054. 7,
  8055. 12
  8056. ],
  8057. [
  8058. 7,
  8059. 12
  8060. ],
  8061. [
  8062. 7,
  8063. 12
  8064. ],
  8065. [
  8066. 7,
  8067. 12
  8068. ],
  8069. [
  8070. 7,
  8071. 12
  8072. ],
  8073. [
  8074. 7,
  8075. 12
  8076. ],
  8077. [
  8078. 7,
  8079. 12
  8080. ],
  8081. [
  8082. 7,
  8083. 12
  8084. ],
  8085. [
  8086. 7,
  8087. 12
  8088. ],
  8089. [
  8090. 7,
  8091. 12
  8092. ],
  8093. [
  8094. 7,
  8095. 12
  8096. ],
  8097. [
  8098. 7,
  8099. 12
  8100. ],
  8101. [
  8102. 7,
  8103. 12
  8104. ],
  8105. [
  8106. 7,
  8107. 12
  8108. ],
  8109. [
  8110. 7,
  8111. 12
  8112. ],
  8113. [
  8114. 7,
  8115. 12
  8116. ],
  8117. [
  8118. 7,
  8119. 12
  8120. ],
  8121. [
  8122. 7,
  8123. 12
  8124. ],
  8125. [
  8126. 7,
  8127. 12
  8128. ],
  8129. [
  8130. 7,
  8131. 12
  8132. ],
  8133. [
  8134. 7,
  8135. 12
  8136. ],
  8137. [
  8138. 7,
  8139. 12
  8140. ],
  8141. [
  8142. 7,
  8143. 12
  8144. ],
  8145. [
  8146. 7,
  8147. 12
  8148. ],
  8149. [
  8150. 7,
  8151. 12
  8152. ],
  8153. [
  8154. 7,
  8155. 12
  8156. ],
  8157. [
  8158. 7,
  8159. 12
  8160. ],
  8161. [
  8162. 7,
  8163. 12
  8164. ],
  8165. [
  8166. 7,
  8167. 12
  8168. ],
  8169. [
  8170. 7,
  8171. 12
  8172. ],
  8173. [
  8174. 7,
  8175. 12
  8176. ]
  8177. ];
  8178. var blackTable3 = [
  8179. [
  8180. -1,
  8181. -1
  8182. ],
  8183. [
  8184. -1,
  8185. -1
  8186. ],
  8187. [
  8188. -1,
  8189. -1
  8190. ],
  8191. [
  8192. -1,
  8193. -1
  8194. ],
  8195. [
  8196. 6,
  8197. 9
  8198. ],
  8199. [
  8200. 6,
  8201. 8
  8202. ],
  8203. [
  8204. 5,
  8205. 7
  8206. ],
  8207. [
  8208. 5,
  8209. 7
  8210. ],
  8211. [
  8212. 4,
  8213. 6
  8214. ],
  8215. [
  8216. 4,
  8217. 6
  8218. ],
  8219. [
  8220. 4,
  8221. 6
  8222. ],
  8223. [
  8224. 4,
  8225. 6
  8226. ],
  8227. [
  8228. 4,
  8229. 5
  8230. ],
  8231. [
  8232. 4,
  8233. 5
  8234. ],
  8235. [
  8236. 4,
  8237. 5
  8238. ],
  8239. [
  8240. 4,
  8241. 5
  8242. ],
  8243. [
  8244. 3,
  8245. 1
  8246. ],
  8247. [
  8248. 3,
  8249. 1
  8250. ],
  8251. [
  8252. 3,
  8253. 1
  8254. ],
  8255. [
  8256. 3,
  8257. 1
  8258. ],
  8259. [
  8260. 3,
  8261. 1
  8262. ],
  8263. [
  8264. 3,
  8265. 1
  8266. ],
  8267. [
  8268. 3,
  8269. 1
  8270. ],
  8271. [
  8272. 3,
  8273. 1
  8274. ],
  8275. [
  8276. 3,
  8277. 4
  8278. ],
  8279. [
  8280. 3,
  8281. 4
  8282. ],
  8283. [
  8284. 3,
  8285. 4
  8286. ],
  8287. [
  8288. 3,
  8289. 4
  8290. ],
  8291. [
  8292. 3,
  8293. 4
  8294. ],
  8295. [
  8296. 3,
  8297. 4
  8298. ],
  8299. [
  8300. 3,
  8301. 4
  8302. ],
  8303. [
  8304. 3,
  8305. 4
  8306. ],
  8307. [
  8308. 2,
  8309. 3
  8310. ],
  8311. [
  8312. 2,
  8313. 3
  8314. ],
  8315. [
  8316. 2,
  8317. 3
  8318. ],
  8319. [
  8320. 2,
  8321. 3
  8322. ],
  8323. [
  8324. 2,
  8325. 3
  8326. ],
  8327. [
  8328. 2,
  8329. 3
  8330. ],
  8331. [
  8332. 2,
  8333. 3
  8334. ],
  8335. [
  8336. 2,
  8337. 3
  8338. ],
  8339. [
  8340. 2,
  8341. 3
  8342. ],
  8343. [
  8344. 2,
  8345. 3
  8346. ],
  8347. [
  8348. 2,
  8349. 3
  8350. ],
  8351. [
  8352. 2,
  8353. 3
  8354. ],
  8355. [
  8356. 2,
  8357. 3
  8358. ],
  8359. [
  8360. 2,
  8361. 3
  8362. ],
  8363. [
  8364. 2,
  8365. 3
  8366. ],
  8367. [
  8368. 2,
  8369. 3
  8370. ],
  8371. [
  8372. 2,
  8373. 2
  8374. ],
  8375. [
  8376. 2,
  8377. 2
  8378. ],
  8379. [
  8380. 2,
  8381. 2
  8382. ],
  8383. [
  8384. 2,
  8385. 2
  8386. ],
  8387. [
  8388. 2,
  8389. 2
  8390. ],
  8391. [
  8392. 2,
  8393. 2
  8394. ],
  8395. [
  8396. 2,
  8397. 2
  8398. ],
  8399. [
  8400. 2,
  8401. 2
  8402. ],
  8403. [
  8404. 2,
  8405. 2
  8406. ],
  8407. [
  8408. 2,
  8409. 2
  8410. ],
  8411. [
  8412. 2,
  8413. 2
  8414. ],
  8415. [
  8416. 2,
  8417. 2
  8418. ],
  8419. [
  8420. 2,
  8421. 2
  8422. ],
  8423. [
  8424. 2,
  8425. 2
  8426. ],
  8427. [
  8428. 2,
  8429. 2
  8430. ],
  8431. [
  8432. 2,
  8433. 2
  8434. ]
  8435. ];
  8436. function CCITTFaxStream(str, maybeLength, params) {
  8437. this.str = str;
  8438. this.dict = str.dict;
  8439. params = params || Dict.empty;
  8440. this.encoding = params.get('K') || 0;
  8441. this.eoline = params.get('EndOfLine') || false;
  8442. this.byteAlign = params.get('EncodedByteAlign') || false;
  8443. this.columns = params.get('Columns') || 1728;
  8444. this.rows = params.get('Rows') || 0;
  8445. var eoblock = params.get('EndOfBlock');
  8446. if (eoblock === null || eoblock === undefined) {
  8447. eoblock = true;
  8448. }
  8449. this.eoblock = eoblock;
  8450. this.black = params.get('BlackIs1') || false;
  8451. this.codingLine = new Uint32Array(this.columns + 1);
  8452. this.refLine = new Uint32Array(this.columns + 2);
  8453. this.codingLine[0] = this.columns;
  8454. this.codingPos = 0;
  8455. this.row = 0;
  8456. this.nextLine2D = this.encoding < 0;
  8457. this.inputBits = 0;
  8458. this.inputBuf = 0;
  8459. this.outputBits = 0;
  8460. var code1;
  8461. while ((code1 = this.lookBits(12)) === 0) {
  8462. this.eatBits(1);
  8463. }
  8464. if (code1 === 1) {
  8465. this.eatBits(12);
  8466. }
  8467. if (this.encoding > 0) {
  8468. this.nextLine2D = !this.lookBits(1);
  8469. this.eatBits(1);
  8470. }
  8471. DecodeStream.call(this, maybeLength);
  8472. }
  8473. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  8474. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  8475. while (!this.eof) {
  8476. var c = this.lookChar();
  8477. this.ensureBuffer(this.bufferLength + 1);
  8478. this.buffer[this.bufferLength++] = c;
  8479. }
  8480. };
  8481. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  8482. var codingLine = this.codingLine;
  8483. var codingPos = this.codingPos;
  8484. if (a1 > codingLine[codingPos]) {
  8485. if (a1 > this.columns) {
  8486. info('row is wrong length');
  8487. this.err = true;
  8488. a1 = this.columns;
  8489. }
  8490. if (codingPos & 1 ^ blackPixels) {
  8491. ++codingPos;
  8492. }
  8493. codingLine[codingPos] = a1;
  8494. }
  8495. this.codingPos = codingPos;
  8496. };
  8497. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  8498. var codingLine = this.codingLine;
  8499. var codingPos = this.codingPos;
  8500. if (a1 > codingLine[codingPos]) {
  8501. if (a1 > this.columns) {
  8502. info('row is wrong length');
  8503. this.err = true;
  8504. a1 = this.columns;
  8505. }
  8506. if (codingPos & 1 ^ blackPixels) {
  8507. ++codingPos;
  8508. }
  8509. codingLine[codingPos] = a1;
  8510. } else if (a1 < codingLine[codingPos]) {
  8511. if (a1 < 0) {
  8512. info('invalid code');
  8513. this.err = true;
  8514. a1 = 0;
  8515. }
  8516. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  8517. --codingPos;
  8518. }
  8519. codingLine[codingPos] = a1;
  8520. }
  8521. this.codingPos = codingPos;
  8522. };
  8523. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  8524. var refLine = this.refLine;
  8525. var codingLine = this.codingLine;
  8526. var columns = this.columns;
  8527. var refPos, blackPixels, bits, i;
  8528. if (this.outputBits === 0) {
  8529. if (this.eof) {
  8530. return null;
  8531. }
  8532. this.err = false;
  8533. var code1, code2, code3;
  8534. if (this.nextLine2D) {
  8535. for (i = 0; codingLine[i] < columns; ++i) {
  8536. refLine[i] = codingLine[i];
  8537. }
  8538. refLine[i++] = columns;
  8539. refLine[i] = columns;
  8540. codingLine[0] = 0;
  8541. this.codingPos = 0;
  8542. refPos = 0;
  8543. blackPixels = 0;
  8544. while (codingLine[this.codingPos] < columns) {
  8545. code1 = this.getTwoDimCode();
  8546. switch (code1) {
  8547. case twoDimPass:
  8548. this.addPixels(refLine[refPos + 1], blackPixels);
  8549. if (refLine[refPos + 1] < columns) {
  8550. refPos += 2;
  8551. }
  8552. break;
  8553. case twoDimHoriz:
  8554. code1 = code2 = 0;
  8555. if (blackPixels) {
  8556. do {
  8557. code1 += code3 = this.getBlackCode();
  8558. } while (code3 >= 64);
  8559. do {
  8560. code2 += code3 = this.getWhiteCode();
  8561. } while (code3 >= 64);
  8562. } else {
  8563. do {
  8564. code1 += code3 = this.getWhiteCode();
  8565. } while (code3 >= 64);
  8566. do {
  8567. code2 += code3 = this.getBlackCode();
  8568. } while (code3 >= 64);
  8569. }
  8570. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8571. if (codingLine[this.codingPos] < columns) {
  8572. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  8573. }
  8574. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8575. refPos += 2;
  8576. }
  8577. break;
  8578. case twoDimVertR3:
  8579. this.addPixels(refLine[refPos] + 3, blackPixels);
  8580. blackPixels ^= 1;
  8581. if (codingLine[this.codingPos] < columns) {
  8582. ++refPos;
  8583. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8584. refPos += 2;
  8585. }
  8586. }
  8587. break;
  8588. case twoDimVertR2:
  8589. this.addPixels(refLine[refPos] + 2, blackPixels);
  8590. blackPixels ^= 1;
  8591. if (codingLine[this.codingPos] < columns) {
  8592. ++refPos;
  8593. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8594. refPos += 2;
  8595. }
  8596. }
  8597. break;
  8598. case twoDimVertR1:
  8599. this.addPixels(refLine[refPos] + 1, blackPixels);
  8600. blackPixels ^= 1;
  8601. if (codingLine[this.codingPos] < columns) {
  8602. ++refPos;
  8603. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8604. refPos += 2;
  8605. }
  8606. }
  8607. break;
  8608. case twoDimVert0:
  8609. this.addPixels(refLine[refPos], blackPixels);
  8610. blackPixels ^= 1;
  8611. if (codingLine[this.codingPos] < columns) {
  8612. ++refPos;
  8613. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8614. refPos += 2;
  8615. }
  8616. }
  8617. break;
  8618. case twoDimVertL3:
  8619. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  8620. blackPixels ^= 1;
  8621. if (codingLine[this.codingPos] < columns) {
  8622. if (refPos > 0) {
  8623. --refPos;
  8624. } else {
  8625. ++refPos;
  8626. }
  8627. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8628. refPos += 2;
  8629. }
  8630. }
  8631. break;
  8632. case twoDimVertL2:
  8633. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  8634. blackPixels ^= 1;
  8635. if (codingLine[this.codingPos] < columns) {
  8636. if (refPos > 0) {
  8637. --refPos;
  8638. } else {
  8639. ++refPos;
  8640. }
  8641. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8642. refPos += 2;
  8643. }
  8644. }
  8645. break;
  8646. case twoDimVertL1:
  8647. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  8648. blackPixels ^= 1;
  8649. if (codingLine[this.codingPos] < columns) {
  8650. if (refPos > 0) {
  8651. --refPos;
  8652. } else {
  8653. ++refPos;
  8654. }
  8655. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8656. refPos += 2;
  8657. }
  8658. }
  8659. break;
  8660. case ccittEOF:
  8661. this.addPixels(columns, 0);
  8662. this.eof = true;
  8663. break;
  8664. default:
  8665. info('bad 2d code');
  8666. this.addPixels(columns, 0);
  8667. this.err = true;
  8668. }
  8669. }
  8670. } else {
  8671. codingLine[0] = 0;
  8672. this.codingPos = 0;
  8673. blackPixels = 0;
  8674. while (codingLine[this.codingPos] < columns) {
  8675. code1 = 0;
  8676. if (blackPixels) {
  8677. do {
  8678. code1 += code3 = this.getBlackCode();
  8679. } while (code3 >= 64);
  8680. } else {
  8681. do {
  8682. code1 += code3 = this.getWhiteCode();
  8683. } while (code3 >= 64);
  8684. }
  8685. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8686. blackPixels ^= 1;
  8687. }
  8688. }
  8689. var gotEOL = false;
  8690. if (this.byteAlign) {
  8691. this.inputBits &= ~7;
  8692. }
  8693. if (!this.eoblock && this.row === this.rows - 1) {
  8694. this.eof = true;
  8695. } else {
  8696. code1 = this.lookBits(12);
  8697. if (this.eoline) {
  8698. while (code1 !== ccittEOF && code1 !== 1) {
  8699. this.eatBits(1);
  8700. code1 = this.lookBits(12);
  8701. }
  8702. } else {
  8703. while (code1 === 0) {
  8704. this.eatBits(1);
  8705. code1 = this.lookBits(12);
  8706. }
  8707. }
  8708. if (code1 === 1) {
  8709. this.eatBits(12);
  8710. gotEOL = true;
  8711. } else if (code1 === ccittEOF) {
  8712. this.eof = true;
  8713. }
  8714. }
  8715. if (!this.eof && this.encoding > 0) {
  8716. this.nextLine2D = !this.lookBits(1);
  8717. this.eatBits(1);
  8718. }
  8719. if (this.eoblock && gotEOL && this.byteAlign) {
  8720. code1 = this.lookBits(12);
  8721. if (code1 === 1) {
  8722. this.eatBits(12);
  8723. if (this.encoding > 0) {
  8724. this.lookBits(1);
  8725. this.eatBits(1);
  8726. }
  8727. if (this.encoding >= 0) {
  8728. for (i = 0; i < 4; ++i) {
  8729. code1 = this.lookBits(12);
  8730. if (code1 !== 1) {
  8731. info('bad rtc code: ' + code1);
  8732. }
  8733. this.eatBits(12);
  8734. if (this.encoding > 0) {
  8735. this.lookBits(1);
  8736. this.eatBits(1);
  8737. }
  8738. }
  8739. }
  8740. this.eof = true;
  8741. }
  8742. } else if (this.err && this.eoline) {
  8743. while (true) {
  8744. code1 = this.lookBits(13);
  8745. if (code1 === ccittEOF) {
  8746. this.eof = true;
  8747. return null;
  8748. }
  8749. if (code1 >> 1 === 1) {
  8750. break;
  8751. }
  8752. this.eatBits(1);
  8753. }
  8754. this.eatBits(12);
  8755. if (this.encoding > 0) {
  8756. this.eatBits(1);
  8757. this.nextLine2D = !(code1 & 1);
  8758. }
  8759. }
  8760. if (codingLine[0] > 0) {
  8761. this.outputBits = codingLine[this.codingPos = 0];
  8762. } else {
  8763. this.outputBits = codingLine[this.codingPos = 1];
  8764. }
  8765. this.row++;
  8766. }
  8767. var c;
  8768. if (this.outputBits >= 8) {
  8769. c = this.codingPos & 1 ? 0 : 0xFF;
  8770. this.outputBits -= 8;
  8771. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  8772. this.codingPos++;
  8773. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8774. }
  8775. } else {
  8776. bits = 8;
  8777. c = 0;
  8778. do {
  8779. if (this.outputBits > bits) {
  8780. c <<= bits;
  8781. if (!(this.codingPos & 1)) {
  8782. c |= 0xFF >> 8 - bits;
  8783. }
  8784. this.outputBits -= bits;
  8785. bits = 0;
  8786. } else {
  8787. c <<= this.outputBits;
  8788. if (!(this.codingPos & 1)) {
  8789. c |= 0xFF >> 8 - this.outputBits;
  8790. }
  8791. bits -= this.outputBits;
  8792. this.outputBits = 0;
  8793. if (codingLine[this.codingPos] < columns) {
  8794. this.codingPos++;
  8795. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8796. } else if (bits > 0) {
  8797. c <<= bits;
  8798. bits = 0;
  8799. }
  8800. }
  8801. } while (bits);
  8802. }
  8803. if (this.black) {
  8804. c ^= 0xFF;
  8805. }
  8806. return c;
  8807. };
  8808. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8809. var limitValue = limit || 0;
  8810. for (var i = start; i <= end; ++i) {
  8811. var code = this.lookBits(i);
  8812. if (code === ccittEOF) {
  8813. return [
  8814. true,
  8815. 1,
  8816. false
  8817. ];
  8818. }
  8819. if (i < end) {
  8820. code <<= end - i;
  8821. }
  8822. if (!limitValue || code >= limitValue) {
  8823. var p = table[code - limitValue];
  8824. if (p[0] === i) {
  8825. this.eatBits(i);
  8826. return [
  8827. true,
  8828. p[1],
  8829. true
  8830. ];
  8831. }
  8832. }
  8833. }
  8834. return [
  8835. false,
  8836. 0,
  8837. false
  8838. ];
  8839. };
  8840. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8841. var code = 0;
  8842. var p;
  8843. if (this.eoblock) {
  8844. code = this.lookBits(7);
  8845. p = twoDimTable[code];
  8846. if (p && p[0] > 0) {
  8847. this.eatBits(p[0]);
  8848. return p[1];
  8849. }
  8850. } else {
  8851. var result = this.findTableCode(1, 7, twoDimTable);
  8852. if (result[0] && result[2]) {
  8853. return result[1];
  8854. }
  8855. }
  8856. info('Bad two dim code');
  8857. return ccittEOF;
  8858. };
  8859. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8860. var code = 0;
  8861. var p;
  8862. if (this.eoblock) {
  8863. code = this.lookBits(12);
  8864. if (code === ccittEOF) {
  8865. return 1;
  8866. }
  8867. if (code >> 5 === 0) {
  8868. p = whiteTable1[code];
  8869. } else {
  8870. p = whiteTable2[code >> 3];
  8871. }
  8872. if (p[0] > 0) {
  8873. this.eatBits(p[0]);
  8874. return p[1];
  8875. }
  8876. } else {
  8877. var result = this.findTableCode(1, 9, whiteTable2);
  8878. if (result[0]) {
  8879. return result[1];
  8880. }
  8881. result = this.findTableCode(11, 12, whiteTable1);
  8882. if (result[0]) {
  8883. return result[1];
  8884. }
  8885. }
  8886. info('bad white code');
  8887. this.eatBits(1);
  8888. return 1;
  8889. };
  8890. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8891. var code, p;
  8892. if (this.eoblock) {
  8893. code = this.lookBits(13);
  8894. if (code === ccittEOF) {
  8895. return 1;
  8896. }
  8897. if (code >> 7 === 0) {
  8898. p = blackTable1[code];
  8899. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8900. p = blackTable2[(code >> 1) - 64];
  8901. } else {
  8902. p = blackTable3[code >> 7];
  8903. }
  8904. if (p[0] > 0) {
  8905. this.eatBits(p[0]);
  8906. return p[1];
  8907. }
  8908. } else {
  8909. var result = this.findTableCode(2, 6, blackTable3);
  8910. if (result[0]) {
  8911. return result[1];
  8912. }
  8913. result = this.findTableCode(7, 12, blackTable2, 64);
  8914. if (result[0]) {
  8915. return result[1];
  8916. }
  8917. result = this.findTableCode(10, 13, blackTable1);
  8918. if (result[0]) {
  8919. return result[1];
  8920. }
  8921. }
  8922. info('bad black code');
  8923. this.eatBits(1);
  8924. return 1;
  8925. };
  8926. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8927. var c;
  8928. while (this.inputBits < n) {
  8929. if ((c = this.str.getByte()) === -1) {
  8930. if (this.inputBits === 0) {
  8931. return ccittEOF;
  8932. }
  8933. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8934. }
  8935. this.inputBuf = this.inputBuf << 8 | c;
  8936. this.inputBits += 8;
  8937. }
  8938. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8939. };
  8940. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8941. if ((this.inputBits -= n) < 0) {
  8942. this.inputBits = 0;
  8943. }
  8944. };
  8945. return CCITTFaxStream;
  8946. }();
  8947. var LZWStream = function LZWStreamClosure() {
  8948. function LZWStream(str, maybeLength, earlyChange) {
  8949. this.str = str;
  8950. this.dict = str.dict;
  8951. this.cachedData = 0;
  8952. this.bitsCached = 0;
  8953. var maxLzwDictionarySize = 4096;
  8954. var lzwState = {
  8955. earlyChange: earlyChange,
  8956. codeLength: 9,
  8957. nextCode: 258,
  8958. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8959. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8960. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8961. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8962. currentSequenceLength: 0
  8963. };
  8964. for (var i = 0; i < 256; ++i) {
  8965. lzwState.dictionaryValues[i] = i;
  8966. lzwState.dictionaryLengths[i] = 1;
  8967. }
  8968. this.lzwState = lzwState;
  8969. DecodeStream.call(this, maybeLength);
  8970. }
  8971. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8972. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8973. var bitsCached = this.bitsCached;
  8974. var cachedData = this.cachedData;
  8975. while (bitsCached < n) {
  8976. var c = this.str.getByte();
  8977. if (c === -1) {
  8978. this.eof = true;
  8979. return null;
  8980. }
  8981. cachedData = cachedData << 8 | c;
  8982. bitsCached += 8;
  8983. }
  8984. this.bitsCached = bitsCached -= n;
  8985. this.cachedData = cachedData;
  8986. this.lastCode = null;
  8987. return cachedData >>> bitsCached & (1 << n) - 1;
  8988. };
  8989. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8990. var blockSize = 512;
  8991. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8992. var i, j, q;
  8993. var lzwState = this.lzwState;
  8994. if (!lzwState) {
  8995. return;
  8996. }
  8997. var earlyChange = lzwState.earlyChange;
  8998. var nextCode = lzwState.nextCode;
  8999. var dictionaryValues = lzwState.dictionaryValues;
  9000. var dictionaryLengths = lzwState.dictionaryLengths;
  9001. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  9002. var codeLength = lzwState.codeLength;
  9003. var prevCode = lzwState.prevCode;
  9004. var currentSequence = lzwState.currentSequence;
  9005. var currentSequenceLength = lzwState.currentSequenceLength;
  9006. var decodedLength = 0;
  9007. var currentBufferLength = this.bufferLength;
  9008. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9009. for (i = 0; i < blockSize; i++) {
  9010. var code = this.readBits(codeLength);
  9011. var hasPrev = currentSequenceLength > 0;
  9012. if (code < 256) {
  9013. currentSequence[0] = code;
  9014. currentSequenceLength = 1;
  9015. } else if (code >= 258) {
  9016. if (code < nextCode) {
  9017. currentSequenceLength = dictionaryLengths[code];
  9018. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  9019. currentSequence[j] = dictionaryValues[q];
  9020. q = dictionaryPrevCodes[q];
  9021. }
  9022. } else {
  9023. currentSequence[currentSequenceLength++] = currentSequence[0];
  9024. }
  9025. } else if (code === 256) {
  9026. codeLength = 9;
  9027. nextCode = 258;
  9028. currentSequenceLength = 0;
  9029. continue;
  9030. } else {
  9031. this.eof = true;
  9032. delete this.lzwState;
  9033. break;
  9034. }
  9035. if (hasPrev) {
  9036. dictionaryPrevCodes[nextCode] = prevCode;
  9037. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  9038. dictionaryValues[nextCode] = currentSequence[0];
  9039. nextCode++;
  9040. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  9041. }
  9042. prevCode = code;
  9043. decodedLength += currentSequenceLength;
  9044. if (estimatedDecodedSize < decodedLength) {
  9045. do {
  9046. estimatedDecodedSize += decodedSizeDelta;
  9047. } while (estimatedDecodedSize < decodedLength);
  9048. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9049. }
  9050. for (j = 0; j < currentSequenceLength; j++) {
  9051. buffer[currentBufferLength++] = currentSequence[j];
  9052. }
  9053. }
  9054. lzwState.nextCode = nextCode;
  9055. lzwState.codeLength = codeLength;
  9056. lzwState.prevCode = prevCode;
  9057. lzwState.currentSequenceLength = currentSequenceLength;
  9058. this.bufferLength = currentBufferLength;
  9059. };
  9060. return LZWStream;
  9061. }();
  9062. var NullStream = function NullStreamClosure() {
  9063. function NullStream() {
  9064. Stream.call(this, new Uint8Array(0));
  9065. }
  9066. NullStream.prototype = Stream.prototype;
  9067. return NullStream;
  9068. }();
  9069. exports.Ascii85Stream = Ascii85Stream;
  9070. exports.AsciiHexStream = AsciiHexStream;
  9071. exports.CCITTFaxStream = CCITTFaxStream;
  9072. exports.DecryptStream = DecryptStream;
  9073. exports.DecodeStream = DecodeStream;
  9074. exports.FlateStream = FlateStream;
  9075. exports.Jbig2Stream = Jbig2Stream;
  9076. exports.JpegStream = JpegStream;
  9077. exports.JpxStream = JpxStream;
  9078. exports.NullStream = NullStream;
  9079. exports.PredictorStream = PredictorStream;
  9080. exports.RunLengthStream = RunLengthStream;
  9081. exports.Stream = Stream;
  9082. exports.StreamsSequenceStream = StreamsSequenceStream;
  9083. exports.StringStream = StringStream;
  9084. exports.LZWStream = LZWStream;
  9085. /***/ }),
  9086. /* 3 */
  9087. /***/ (function(module, exports, __w_pdfjs_require__) {
  9088. "use strict";
  9089. var sharedUtil = __w_pdfjs_require__(0);
  9090. var assert = sharedUtil.assert;
  9091. var removeNullCharacters = sharedUtil.removeNullCharacters;
  9092. var warn = sharedUtil.warn;
  9093. var deprecated = sharedUtil.deprecated;
  9094. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  9095. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9096. function DOMCanvasFactory() {
  9097. }
  9098. DOMCanvasFactory.prototype = {
  9099. create: function DOMCanvasFactory_create(width, height) {
  9100. assert(width > 0 && height > 0, 'invalid canvas size');
  9101. var canvas = document.createElement('canvas');
  9102. var context = canvas.getContext('2d');
  9103. canvas.width = width;
  9104. canvas.height = height;
  9105. return {
  9106. canvas: canvas,
  9107. context: context
  9108. };
  9109. },
  9110. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  9111. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9112. assert(width > 0 && height > 0, 'invalid canvas size');
  9113. canvasAndContextPair.canvas.width = width;
  9114. canvasAndContextPair.canvas.height = height;
  9115. },
  9116. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  9117. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9118. canvasAndContextPair.canvas.width = 0;
  9119. canvasAndContextPair.canvas.height = 0;
  9120. canvasAndContextPair.canvas = null;
  9121. canvasAndContextPair.context = null;
  9122. }
  9123. };
  9124. var CustomStyle = function CustomStyleClosure() {
  9125. var prefixes = [
  9126. 'ms',
  9127. 'Moz',
  9128. 'Webkit',
  9129. 'O'
  9130. ];
  9131. var _cache = Object.create(null);
  9132. function CustomStyle() {
  9133. }
  9134. CustomStyle.getProp = function get(propName, element) {
  9135. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  9136. return _cache[propName];
  9137. }
  9138. element = element || document.documentElement;
  9139. var style = element.style, prefixed, uPropName;
  9140. if (typeof style[propName] === 'string') {
  9141. return _cache[propName] = propName;
  9142. }
  9143. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  9144. for (var i = 0, l = prefixes.length; i < l; i++) {
  9145. prefixed = prefixes[i] + uPropName;
  9146. if (typeof style[prefixed] === 'string') {
  9147. return _cache[propName] = prefixed;
  9148. }
  9149. }
  9150. return _cache[propName] = 'undefined';
  9151. };
  9152. CustomStyle.setProp = function set(propName, element, str) {
  9153. var prop = this.getProp(propName);
  9154. if (prop !== 'undefined') {
  9155. element.style[prop] = str;
  9156. }
  9157. };
  9158. return CustomStyle;
  9159. }();
  9160. var hasCanvasTypedArrays;
  9161. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  9162. var canvas = document.createElement('canvas');
  9163. canvas.width = canvas.height = 1;
  9164. var ctx = canvas.getContext('2d');
  9165. var imageData = ctx.createImageData(1, 1);
  9166. return typeof imageData.data.buffer !== 'undefined';
  9167. };
  9168. var LinkTarget = {
  9169. NONE: 0,
  9170. SELF: 1,
  9171. BLANK: 2,
  9172. PARENT: 3,
  9173. TOP: 4
  9174. };
  9175. var LinkTargetStringMap = [
  9176. '',
  9177. '_self',
  9178. '_blank',
  9179. '_parent',
  9180. '_top'
  9181. ];
  9182. function addLinkAttributes(link, params) {
  9183. var url = params && params.url;
  9184. link.href = link.title = url ? removeNullCharacters(url) : '';
  9185. if (url) {
  9186. var target = params.target;
  9187. if (typeof target === 'undefined') {
  9188. target = getDefaultSetting('externalLinkTarget');
  9189. }
  9190. link.target = LinkTargetStringMap[target];
  9191. var rel = params.rel;
  9192. if (typeof rel === 'undefined') {
  9193. rel = getDefaultSetting('externalLinkRel');
  9194. }
  9195. link.rel = rel;
  9196. }
  9197. }
  9198. function getFilenameFromUrl(url) {
  9199. var anchor = url.indexOf('#');
  9200. var query = url.indexOf('?');
  9201. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9202. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9203. }
  9204. function getDefaultSetting(id) {
  9205. var globalSettings = sharedUtil.globalScope.PDFJS;
  9206. switch (id) {
  9207. case 'pdfBug':
  9208. return globalSettings ? globalSettings.pdfBug : false;
  9209. case 'disableAutoFetch':
  9210. return globalSettings ? globalSettings.disableAutoFetch : false;
  9211. case 'disableStream':
  9212. return globalSettings ? globalSettings.disableStream : false;
  9213. case 'disableRange':
  9214. return globalSettings ? globalSettings.disableRange : false;
  9215. case 'disableFontFace':
  9216. return globalSettings ? globalSettings.disableFontFace : false;
  9217. case 'disableCreateObjectURL':
  9218. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  9219. case 'disableWebGL':
  9220. return globalSettings ? globalSettings.disableWebGL : true;
  9221. case 'cMapUrl':
  9222. return globalSettings ? globalSettings.cMapUrl : null;
  9223. case 'cMapPacked':
  9224. return globalSettings ? globalSettings.cMapPacked : false;
  9225. case 'postMessageTransfers':
  9226. return globalSettings ? globalSettings.postMessageTransfers : true;
  9227. case 'workerSrc':
  9228. return globalSettings ? globalSettings.workerSrc : null;
  9229. case 'disableWorker':
  9230. return globalSettings ? globalSettings.disableWorker : false;
  9231. case 'maxImageSize':
  9232. return globalSettings ? globalSettings.maxImageSize : -1;
  9233. case 'imageResourcesPath':
  9234. return globalSettings ? globalSettings.imageResourcesPath : '';
  9235. case 'isEvalSupported':
  9236. return globalSettings ? globalSettings.isEvalSupported : true;
  9237. case 'externalLinkTarget':
  9238. if (!globalSettings) {
  9239. return LinkTarget.NONE;
  9240. }
  9241. switch (globalSettings.externalLinkTarget) {
  9242. case LinkTarget.NONE:
  9243. case LinkTarget.SELF:
  9244. case LinkTarget.BLANK:
  9245. case LinkTarget.PARENT:
  9246. case LinkTarget.TOP:
  9247. return globalSettings.externalLinkTarget;
  9248. }
  9249. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  9250. globalSettings.externalLinkTarget = LinkTarget.NONE;
  9251. return LinkTarget.NONE;
  9252. case 'externalLinkRel':
  9253. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  9254. case 'enableStats':
  9255. return !!(globalSettings && globalSettings.enableStats);
  9256. default:
  9257. throw new Error('Unknown default setting: ' + id);
  9258. }
  9259. }
  9260. function isExternalLinkTargetSet() {
  9261. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  9262. switch (externalLinkTarget) {
  9263. case LinkTarget.NONE:
  9264. return false;
  9265. case LinkTarget.SELF:
  9266. case LinkTarget.BLANK:
  9267. case LinkTarget.PARENT:
  9268. case LinkTarget.TOP:
  9269. return true;
  9270. }
  9271. }
  9272. function isValidUrl(url, allowRelative) {
  9273. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  9274. var baseUrl = allowRelative ? 'http://example.com' : null;
  9275. return createValidAbsoluteUrl(url, baseUrl) !== null;
  9276. }
  9277. exports.CustomStyle = CustomStyle;
  9278. exports.addLinkAttributes = addLinkAttributes;
  9279. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  9280. exports.isValidUrl = isValidUrl;
  9281. exports.getFilenameFromUrl = getFilenameFromUrl;
  9282. exports.LinkTarget = LinkTarget;
  9283. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  9284. exports.getDefaultSetting = getDefaultSetting;
  9285. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9286. exports.DOMCanvasFactory = DOMCanvasFactory;
  9287. /***/ }),
  9288. /* 4 */
  9289. /***/ (function(module, exports, __w_pdfjs_require__) {
  9290. "use strict";
  9291. var sharedUtil = __w_pdfjs_require__(0);
  9292. var corePrimitives = __w_pdfjs_require__(1);
  9293. var coreFunction = __w_pdfjs_require__(7);
  9294. var error = sharedUtil.error;
  9295. var info = sharedUtil.info;
  9296. var isArray = sharedUtil.isArray;
  9297. var isString = sharedUtil.isString;
  9298. var shadow = sharedUtil.shadow;
  9299. var warn = sharedUtil.warn;
  9300. var isDict = corePrimitives.isDict;
  9301. var isName = corePrimitives.isName;
  9302. var isStream = corePrimitives.isStream;
  9303. var PDFFunction = coreFunction.PDFFunction;
  9304. var ColorSpace = function ColorSpaceClosure() {
  9305. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  9306. var COMPONENTS = 3;
  9307. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  9308. var xRatio = w1 / w2;
  9309. var yRatio = h1 / h2;
  9310. var i, j, py, newIndex = 0, oldIndex;
  9311. var xScaled = new Uint16Array(w2);
  9312. var w1Scanline = w1 * COMPONENTS;
  9313. for (i = 0; i < w2; i++) {
  9314. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  9315. }
  9316. for (i = 0; i < h2; i++) {
  9317. py = Math.floor(i * yRatio) * w1Scanline;
  9318. for (j = 0; j < w2; j++) {
  9319. oldIndex = py + xScaled[j];
  9320. dest[newIndex++] = src[oldIndex++];
  9321. dest[newIndex++] = src[oldIndex++];
  9322. dest[newIndex++] = src[oldIndex++];
  9323. newIndex += alpha01;
  9324. }
  9325. }
  9326. }
  9327. function ColorSpace() {
  9328. error('should not call ColorSpace constructor');
  9329. }
  9330. ColorSpace.prototype = {
  9331. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  9332. var rgb = new Uint8Array(3);
  9333. this.getRgbItem(src, srcOffset, rgb, 0);
  9334. return rgb;
  9335. },
  9336. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  9337. error('Should not call ColorSpace.getRgbItem');
  9338. },
  9339. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9340. error('Should not call ColorSpace.getRgbBuffer');
  9341. },
  9342. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  9343. error('Should not call ColorSpace.getOutputLength');
  9344. },
  9345. isPassthrough: function ColorSpace_isPassthrough(bits) {
  9346. return false;
  9347. },
  9348. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  9349. var count = originalWidth * originalHeight;
  9350. var rgbBuf = null;
  9351. var numComponentColors = 1 << bpc;
  9352. var needsResizing = originalHeight !== height || originalWidth !== width;
  9353. var i, ii;
  9354. if (this.isPassthrough(bpc)) {
  9355. rgbBuf = comps;
  9356. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  9357. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  9358. var key;
  9359. for (i = 0; i < numComponentColors; i++) {
  9360. allColors[i] = i;
  9361. }
  9362. var colorMap = new Uint8Array(numComponentColors * 3);
  9363. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  9364. var destPos, rgbPos;
  9365. if (!needsResizing) {
  9366. destPos = 0;
  9367. for (i = 0; i < count; ++i) {
  9368. key = comps[i] * 3;
  9369. dest[destPos++] = colorMap[key];
  9370. dest[destPos++] = colorMap[key + 1];
  9371. dest[destPos++] = colorMap[key + 2];
  9372. destPos += alpha01;
  9373. }
  9374. } else {
  9375. rgbBuf = new Uint8Array(count * 3);
  9376. rgbPos = 0;
  9377. for (i = 0; i < count; ++i) {
  9378. key = comps[i] * 3;
  9379. rgbBuf[rgbPos++] = colorMap[key];
  9380. rgbBuf[rgbPos++] = colorMap[key + 1];
  9381. rgbBuf[rgbPos++] = colorMap[key + 2];
  9382. }
  9383. }
  9384. } else {
  9385. if (!needsResizing) {
  9386. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  9387. } else {
  9388. rgbBuf = new Uint8Array(count * 3);
  9389. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  9390. }
  9391. }
  9392. if (rgbBuf) {
  9393. if (needsResizing) {
  9394. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  9395. } else {
  9396. rgbPos = 0;
  9397. destPos = 0;
  9398. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  9399. dest[destPos++] = rgbBuf[rgbPos++];
  9400. dest[destPos++] = rgbBuf[rgbPos++];
  9401. dest[destPos++] = rgbBuf[rgbPos++];
  9402. destPos += alpha01;
  9403. }
  9404. }
  9405. }
  9406. },
  9407. usesZeroToOneRange: true
  9408. };
  9409. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  9410. var IR = ColorSpace.parseToIR(cs, xref, res);
  9411. if (IR instanceof AlternateCS) {
  9412. return IR;
  9413. }
  9414. return ColorSpace.fromIR(IR);
  9415. };
  9416. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  9417. var name = isArray(IR) ? IR[0] : IR;
  9418. var whitePoint, blackPoint, gamma;
  9419. switch (name) {
  9420. case 'DeviceGrayCS':
  9421. return this.singletons.gray;
  9422. case 'DeviceRgbCS':
  9423. return this.singletons.rgb;
  9424. case 'DeviceCmykCS':
  9425. return this.singletons.cmyk;
  9426. case 'CalGrayCS':
  9427. whitePoint = IR[1];
  9428. blackPoint = IR[2];
  9429. gamma = IR[3];
  9430. return new CalGrayCS(whitePoint, blackPoint, gamma);
  9431. case 'CalRGBCS':
  9432. whitePoint = IR[1];
  9433. blackPoint = IR[2];
  9434. gamma = IR[3];
  9435. var matrix = IR[4];
  9436. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  9437. case 'PatternCS':
  9438. var basePatternCS = IR[1];
  9439. if (basePatternCS) {
  9440. basePatternCS = ColorSpace.fromIR(basePatternCS);
  9441. }
  9442. return new PatternCS(basePatternCS);
  9443. case 'IndexedCS':
  9444. var baseIndexedCS = IR[1];
  9445. var hiVal = IR[2];
  9446. var lookup = IR[3];
  9447. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  9448. case 'AlternateCS':
  9449. var numComps = IR[1];
  9450. var alt = IR[2];
  9451. var tintFnIR = IR[3];
  9452. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  9453. case 'LabCS':
  9454. whitePoint = IR[1];
  9455. blackPoint = IR[2];
  9456. var range = IR[3];
  9457. return new LabCS(whitePoint, blackPoint, range);
  9458. default:
  9459. error('Unknown name ' + name);
  9460. }
  9461. return null;
  9462. };
  9463. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  9464. if (isName(cs)) {
  9465. var colorSpaces = res.get('ColorSpace');
  9466. if (isDict(colorSpaces)) {
  9467. var refcs = colorSpaces.get(cs.name);
  9468. if (refcs) {
  9469. cs = refcs;
  9470. }
  9471. }
  9472. }
  9473. cs = xref.fetchIfRef(cs);
  9474. if (isName(cs)) {
  9475. switch (cs.name) {
  9476. case 'DeviceGray':
  9477. case 'G':
  9478. return 'DeviceGrayCS';
  9479. case 'DeviceRGB':
  9480. case 'RGB':
  9481. return 'DeviceRgbCS';
  9482. case 'DeviceCMYK':
  9483. case 'CMYK':
  9484. return 'DeviceCmykCS';
  9485. case 'Pattern':
  9486. return [
  9487. 'PatternCS',
  9488. null
  9489. ];
  9490. default:
  9491. error('unrecognized colorspace ' + cs.name);
  9492. }
  9493. } else if (isArray(cs)) {
  9494. var mode = xref.fetchIfRef(cs[0]).name;
  9495. var numComps, params, alt, whitePoint, blackPoint, gamma;
  9496. switch (mode) {
  9497. case 'DeviceGray':
  9498. case 'G':
  9499. return 'DeviceGrayCS';
  9500. case 'DeviceRGB':
  9501. case 'RGB':
  9502. return 'DeviceRgbCS';
  9503. case 'DeviceCMYK':
  9504. case 'CMYK':
  9505. return 'DeviceCmykCS';
  9506. case 'CalGray':
  9507. params = xref.fetchIfRef(cs[1]);
  9508. whitePoint = params.getArray('WhitePoint');
  9509. blackPoint = params.getArray('BlackPoint');
  9510. gamma = params.get('Gamma');
  9511. return [
  9512. 'CalGrayCS',
  9513. whitePoint,
  9514. blackPoint,
  9515. gamma
  9516. ];
  9517. case 'CalRGB':
  9518. params = xref.fetchIfRef(cs[1]);
  9519. whitePoint = params.getArray('WhitePoint');
  9520. blackPoint = params.getArray('BlackPoint');
  9521. gamma = params.getArray('Gamma');
  9522. var matrix = params.getArray('Matrix');
  9523. return [
  9524. 'CalRGBCS',
  9525. whitePoint,
  9526. blackPoint,
  9527. gamma,
  9528. matrix
  9529. ];
  9530. case 'ICCBased':
  9531. var stream = xref.fetchIfRef(cs[1]);
  9532. var dict = stream.dict;
  9533. numComps = dict.get('N');
  9534. alt = dict.get('Alternate');
  9535. if (alt) {
  9536. var altIR = ColorSpace.parseToIR(alt, xref, res);
  9537. var altCS = ColorSpace.fromIR(altIR);
  9538. if (altCS.numComps === numComps) {
  9539. return altIR;
  9540. }
  9541. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  9542. }
  9543. if (numComps === 1) {
  9544. return 'DeviceGrayCS';
  9545. } else if (numComps === 3) {
  9546. return 'DeviceRgbCS';
  9547. } else if (numComps === 4) {
  9548. return 'DeviceCmykCS';
  9549. }
  9550. break;
  9551. case 'Pattern':
  9552. var basePatternCS = cs[1] || null;
  9553. if (basePatternCS) {
  9554. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  9555. }
  9556. return [
  9557. 'PatternCS',
  9558. basePatternCS
  9559. ];
  9560. case 'Indexed':
  9561. case 'I':
  9562. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  9563. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  9564. var lookup = xref.fetchIfRef(cs[3]);
  9565. if (isStream(lookup)) {
  9566. lookup = lookup.getBytes();
  9567. }
  9568. return [
  9569. 'IndexedCS',
  9570. baseIndexedCS,
  9571. hiVal,
  9572. lookup
  9573. ];
  9574. case 'Separation':
  9575. case 'DeviceN':
  9576. var name = xref.fetchIfRef(cs[1]);
  9577. numComps = isArray(name) ? name.length : 1;
  9578. alt = ColorSpace.parseToIR(cs[2], xref, res);
  9579. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  9580. return [
  9581. 'AlternateCS',
  9582. numComps,
  9583. alt,
  9584. tintFnIR
  9585. ];
  9586. case 'Lab':
  9587. params = xref.fetchIfRef(cs[1]);
  9588. whitePoint = params.getArray('WhitePoint');
  9589. blackPoint = params.getArray('BlackPoint');
  9590. var range = params.getArray('Range');
  9591. return [
  9592. 'LabCS',
  9593. whitePoint,
  9594. blackPoint,
  9595. range
  9596. ];
  9597. default:
  9598. error('unimplemented color space object "' + mode + '"');
  9599. }
  9600. } else {
  9601. error('unrecognized color space object: "' + cs + '"');
  9602. }
  9603. return null;
  9604. };
  9605. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  9606. if (!isArray(decode)) {
  9607. return true;
  9608. }
  9609. if (n * 2 !== decode.length) {
  9610. warn('The decode map is not the correct length');
  9611. return true;
  9612. }
  9613. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  9614. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  9615. return false;
  9616. }
  9617. }
  9618. return true;
  9619. };
  9620. ColorSpace.singletons = {
  9621. get gray() {
  9622. return shadow(this, 'gray', new DeviceGrayCS());
  9623. },
  9624. get rgb() {
  9625. return shadow(this, 'rgb', new DeviceRgbCS());
  9626. },
  9627. get cmyk() {
  9628. return shadow(this, 'cmyk', new DeviceCmykCS());
  9629. }
  9630. };
  9631. return ColorSpace;
  9632. }();
  9633. var AlternateCS = function AlternateCSClosure() {
  9634. function AlternateCS(numComps, base, tintFn) {
  9635. this.name = 'Alternate';
  9636. this.numComps = numComps;
  9637. this.defaultColor = new Float32Array(numComps);
  9638. for (var i = 0; i < numComps; ++i) {
  9639. this.defaultColor[i] = 1;
  9640. }
  9641. this.base = base;
  9642. this.tintFn = tintFn;
  9643. this.tmpBuf = new Float32Array(base.numComps);
  9644. }
  9645. AlternateCS.prototype = {
  9646. getRgb: ColorSpace.prototype.getRgb,
  9647. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9648. var tmpBuf = this.tmpBuf;
  9649. this.tintFn(src, srcOffset, tmpBuf, 0);
  9650. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  9651. },
  9652. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9653. var tintFn = this.tintFn;
  9654. var base = this.base;
  9655. var scale = 1 / ((1 << bits) - 1);
  9656. var baseNumComps = base.numComps;
  9657. var usesZeroToOneRange = base.usesZeroToOneRange;
  9658. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  9659. var pos = isPassthrough ? destOffset : 0;
  9660. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  9661. var numComps = this.numComps;
  9662. var scaled = new Float32Array(numComps);
  9663. var tinted = new Float32Array(baseNumComps);
  9664. var i, j;
  9665. for (i = 0; i < count; i++) {
  9666. for (j = 0; j < numComps; j++) {
  9667. scaled[j] = src[srcOffset++] * scale;
  9668. }
  9669. tintFn(scaled, 0, tinted, 0);
  9670. if (usesZeroToOneRange) {
  9671. for (j = 0; j < baseNumComps; j++) {
  9672. baseBuf[pos++] = tinted[j] * 255;
  9673. }
  9674. } else {
  9675. base.getRgbItem(tinted, 0, baseBuf, pos);
  9676. pos += baseNumComps;
  9677. }
  9678. }
  9679. if (!isPassthrough) {
  9680. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  9681. }
  9682. },
  9683. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  9684. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  9685. },
  9686. isPassthrough: ColorSpace.prototype.isPassthrough,
  9687. fillRgb: ColorSpace.prototype.fillRgb,
  9688. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  9689. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9690. },
  9691. usesZeroToOneRange: true
  9692. };
  9693. return AlternateCS;
  9694. }();
  9695. var PatternCS = function PatternCSClosure() {
  9696. function PatternCS(baseCS) {
  9697. this.name = 'Pattern';
  9698. this.base = baseCS;
  9699. }
  9700. PatternCS.prototype = {};
  9701. return PatternCS;
  9702. }();
  9703. var IndexedCS = function IndexedCSClosure() {
  9704. function IndexedCS(base, highVal, lookup) {
  9705. this.name = 'Indexed';
  9706. this.numComps = 1;
  9707. this.defaultColor = new Uint8Array(this.numComps);
  9708. this.base = base;
  9709. this.highVal = highVal;
  9710. var baseNumComps = base.numComps;
  9711. var length = baseNumComps * highVal;
  9712. if (isStream(lookup)) {
  9713. this.lookup = new Uint8Array(length);
  9714. var bytes = lookup.getBytes(length);
  9715. this.lookup.set(bytes);
  9716. } else if (isString(lookup)) {
  9717. this.lookup = new Uint8Array(length);
  9718. for (var i = 0; i < length; ++i) {
  9719. this.lookup[i] = lookup.charCodeAt(i);
  9720. }
  9721. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  9722. this.lookup = lookup;
  9723. } else {
  9724. error('Unrecognized lookup table: ' + lookup);
  9725. }
  9726. }
  9727. IndexedCS.prototype = {
  9728. getRgb: ColorSpace.prototype.getRgb,
  9729. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9730. var numComps = this.base.numComps;
  9731. var start = src[srcOffset] * numComps;
  9732. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  9733. },
  9734. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9735. var base = this.base;
  9736. var numComps = base.numComps;
  9737. var outputDelta = base.getOutputLength(numComps, alpha01);
  9738. var lookup = this.lookup;
  9739. for (var i = 0; i < count; ++i) {
  9740. var lookupPos = src[srcOffset++] * numComps;
  9741. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  9742. destOffset += outputDelta;
  9743. }
  9744. },
  9745. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  9746. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  9747. },
  9748. isPassthrough: ColorSpace.prototype.isPassthrough,
  9749. fillRgb: ColorSpace.prototype.fillRgb,
  9750. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  9751. return true;
  9752. },
  9753. usesZeroToOneRange: true
  9754. };
  9755. return IndexedCS;
  9756. }();
  9757. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9758. function DeviceGrayCS() {
  9759. this.name = 'DeviceGray';
  9760. this.numComps = 1;
  9761. this.defaultColor = new Float32Array(this.numComps);
  9762. }
  9763. DeviceGrayCS.prototype = {
  9764. getRgb: ColorSpace.prototype.getRgb,
  9765. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9766. var c = src[srcOffset] * 255 | 0;
  9767. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9768. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9769. },
  9770. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9771. var scale = 255 / ((1 << bits) - 1);
  9772. var j = srcOffset, q = destOffset;
  9773. for (var i = 0; i < count; ++i) {
  9774. var c = scale * src[j++] | 0;
  9775. dest[q++] = c;
  9776. dest[q++] = c;
  9777. dest[q++] = c;
  9778. q += alpha01;
  9779. }
  9780. },
  9781. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9782. return inputLength * (3 + alpha01);
  9783. },
  9784. isPassthrough: ColorSpace.prototype.isPassthrough,
  9785. fillRgb: ColorSpace.prototype.fillRgb,
  9786. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9787. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9788. },
  9789. usesZeroToOneRange: true
  9790. };
  9791. return DeviceGrayCS;
  9792. }();
  9793. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9794. function DeviceRgbCS() {
  9795. this.name = 'DeviceRGB';
  9796. this.numComps = 3;
  9797. this.defaultColor = new Float32Array(this.numComps);
  9798. }
  9799. DeviceRgbCS.prototype = {
  9800. getRgb: ColorSpace.prototype.getRgb,
  9801. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9802. var r = src[srcOffset] * 255 | 0;
  9803. var g = src[srcOffset + 1] * 255 | 0;
  9804. var b = src[srcOffset + 2] * 255 | 0;
  9805. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9806. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9807. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9808. },
  9809. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9810. if (bits === 8 && alpha01 === 0) {
  9811. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9812. return;
  9813. }
  9814. var scale = 255 / ((1 << bits) - 1);
  9815. var j = srcOffset, q = destOffset;
  9816. for (var i = 0; i < count; ++i) {
  9817. dest[q++] = scale * src[j++] | 0;
  9818. dest[q++] = scale * src[j++] | 0;
  9819. dest[q++] = scale * src[j++] | 0;
  9820. q += alpha01;
  9821. }
  9822. },
  9823. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9824. return inputLength * (3 + alpha01) / 3 | 0;
  9825. },
  9826. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9827. return bits === 8;
  9828. },
  9829. fillRgb: ColorSpace.prototype.fillRgb,
  9830. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9831. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9832. },
  9833. usesZeroToOneRange: true
  9834. };
  9835. return DeviceRgbCS;
  9836. }();
  9837. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9838. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9839. var c = src[srcOffset + 0] * srcScale;
  9840. var m = src[srcOffset + 1] * srcScale;
  9841. var y = src[srcOffset + 2] * srcScale;
  9842. var k = src[srcOffset + 3] * srcScale;
  9843. 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;
  9844. 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;
  9845. 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;
  9846. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9847. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9848. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9849. }
  9850. function DeviceCmykCS() {
  9851. this.name = 'DeviceCMYK';
  9852. this.numComps = 4;
  9853. this.defaultColor = new Float32Array(this.numComps);
  9854. this.defaultColor[3] = 1;
  9855. }
  9856. DeviceCmykCS.prototype = {
  9857. getRgb: ColorSpace.prototype.getRgb,
  9858. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9859. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9860. },
  9861. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9862. var scale = 1 / ((1 << bits) - 1);
  9863. for (var i = 0; i < count; i++) {
  9864. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9865. srcOffset += 4;
  9866. destOffset += 3 + alpha01;
  9867. }
  9868. },
  9869. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9870. return inputLength / 4 * (3 + alpha01) | 0;
  9871. },
  9872. isPassthrough: ColorSpace.prototype.isPassthrough,
  9873. fillRgb: ColorSpace.prototype.fillRgb,
  9874. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9875. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9876. },
  9877. usesZeroToOneRange: true
  9878. };
  9879. return DeviceCmykCS;
  9880. }();
  9881. var CalGrayCS = function CalGrayCSClosure() {
  9882. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9883. this.name = 'CalGray';
  9884. this.numComps = 1;
  9885. this.defaultColor = new Float32Array(this.numComps);
  9886. if (!whitePoint) {
  9887. error('WhitePoint missing - required for color space CalGray');
  9888. }
  9889. blackPoint = blackPoint || [
  9890. 0,
  9891. 0,
  9892. 0
  9893. ];
  9894. gamma = gamma || 1;
  9895. this.XW = whitePoint[0];
  9896. this.YW = whitePoint[1];
  9897. this.ZW = whitePoint[2];
  9898. this.XB = blackPoint[0];
  9899. this.YB = blackPoint[1];
  9900. this.ZB = blackPoint[2];
  9901. this.G = gamma;
  9902. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9903. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9904. }
  9905. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9906. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9907. this.XB = this.YB = this.ZB = 0;
  9908. }
  9909. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9910. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9911. }
  9912. if (this.G < 1) {
  9913. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9914. this.G = 1;
  9915. }
  9916. }
  9917. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9918. var A = src[srcOffset] * scale;
  9919. var AG = Math.pow(A, cs.G);
  9920. var L = cs.YW * AG;
  9921. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9922. dest[destOffset] = val;
  9923. dest[destOffset + 1] = val;
  9924. dest[destOffset + 2] = val;
  9925. }
  9926. CalGrayCS.prototype = {
  9927. getRgb: ColorSpace.prototype.getRgb,
  9928. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9929. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9930. },
  9931. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9932. var scale = 1 / ((1 << bits) - 1);
  9933. for (var i = 0; i < count; ++i) {
  9934. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9935. srcOffset += 1;
  9936. destOffset += 3 + alpha01;
  9937. }
  9938. },
  9939. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9940. return inputLength * (3 + alpha01);
  9941. },
  9942. isPassthrough: ColorSpace.prototype.isPassthrough,
  9943. fillRgb: ColorSpace.prototype.fillRgb,
  9944. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9945. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9946. },
  9947. usesZeroToOneRange: true
  9948. };
  9949. return CalGrayCS;
  9950. }();
  9951. var CalRGBCS = function CalRGBCSClosure() {
  9952. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9953. 0.8951,
  9954. 0.2664,
  9955. -0.1614,
  9956. -0.7502,
  9957. 1.7135,
  9958. 0.0367,
  9959. 0.0389,
  9960. -0.0685,
  9961. 1.0296
  9962. ]);
  9963. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9964. 0.9869929,
  9965. -0.1470543,
  9966. 0.1599627,
  9967. 0.4323053,
  9968. 0.5183603,
  9969. 0.0492912,
  9970. -0.0085287,
  9971. 0.0400428,
  9972. 0.9684867
  9973. ]);
  9974. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9975. 3.2404542,
  9976. -1.5371385,
  9977. -0.4985314,
  9978. -0.9692660,
  9979. 1.8760108,
  9980. 0.0415560,
  9981. 0.0556434,
  9982. -0.2040259,
  9983. 1.0572252
  9984. ]);
  9985. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9986. 1,
  9987. 1,
  9988. 1
  9989. ]);
  9990. var tempNormalizeMatrix = new Float32Array(3);
  9991. var tempConvertMatrix1 = new Float32Array(3);
  9992. var tempConvertMatrix2 = new Float32Array(3);
  9993. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9994. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9995. this.name = 'CalRGB';
  9996. this.numComps = 3;
  9997. this.defaultColor = new Float32Array(this.numComps);
  9998. if (!whitePoint) {
  9999. error('WhitePoint missing - required for color space CalRGB');
  10000. }
  10001. blackPoint = blackPoint || new Float32Array(3);
  10002. gamma = gamma || new Float32Array([
  10003. 1,
  10004. 1,
  10005. 1
  10006. ]);
  10007. matrix = matrix || new Float32Array([
  10008. 1,
  10009. 0,
  10010. 0,
  10011. 0,
  10012. 1,
  10013. 0,
  10014. 0,
  10015. 0,
  10016. 1
  10017. ]);
  10018. var XW = whitePoint[0];
  10019. var YW = whitePoint[1];
  10020. var ZW = whitePoint[2];
  10021. this.whitePoint = whitePoint;
  10022. var XB = blackPoint[0];
  10023. var YB = blackPoint[1];
  10024. var ZB = blackPoint[2];
  10025. this.blackPoint = blackPoint;
  10026. this.GR = gamma[0];
  10027. this.GG = gamma[1];
  10028. this.GB = gamma[2];
  10029. this.MXA = matrix[0];
  10030. this.MYA = matrix[1];
  10031. this.MZA = matrix[2];
  10032. this.MXB = matrix[3];
  10033. this.MYB = matrix[4];
  10034. this.MZB = matrix[5];
  10035. this.MXC = matrix[6];
  10036. this.MYC = matrix[7];
  10037. this.MZC = matrix[8];
  10038. if (XW < 0 || ZW < 0 || YW !== 1) {
  10039. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  10040. }
  10041. if (XB < 0 || YB < 0 || ZB < 0) {
  10042. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  10043. this.blackPoint = new Float32Array(3);
  10044. }
  10045. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  10046. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  10047. this.GR = this.GG = this.GB = 1;
  10048. }
  10049. 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) {
  10050. 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');
  10051. this.MXA = this.MYB = this.MZC = 1;
  10052. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  10053. }
  10054. }
  10055. function matrixProduct(a, b, result) {
  10056. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  10057. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  10058. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  10059. }
  10060. function convertToFlat(sourceWhitePoint, LMS, result) {
  10061. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  10062. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  10063. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  10064. }
  10065. function convertToD65(sourceWhitePoint, LMS, result) {
  10066. var D65X = 0.95047;
  10067. var D65Y = 1;
  10068. var D65Z = 1.08883;
  10069. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  10070. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  10071. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  10072. }
  10073. function sRGBTransferFunction(color) {
  10074. if (color <= 0.0031308) {
  10075. return adjustToRange(0, 1, 12.92 * color);
  10076. }
  10077. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  10078. }
  10079. function adjustToRange(min, max, value) {
  10080. return Math.max(min, Math.min(max, value));
  10081. }
  10082. function decodeL(L) {
  10083. if (L < 0) {
  10084. return -decodeL(-L);
  10085. }
  10086. if (L > 8.0) {
  10087. return Math.pow((L + 16) / 116, 3);
  10088. }
  10089. return L * DECODE_L_CONSTANT;
  10090. }
  10091. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  10092. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  10093. result[0] = XYZ_Flat[0];
  10094. result[1] = XYZ_Flat[1];
  10095. result[2] = XYZ_Flat[2];
  10096. return;
  10097. }
  10098. var zeroDecodeL = decodeL(0);
  10099. var X_DST = zeroDecodeL;
  10100. var X_SRC = decodeL(sourceBlackPoint[0]);
  10101. var Y_DST = zeroDecodeL;
  10102. var Y_SRC = decodeL(sourceBlackPoint[1]);
  10103. var Z_DST = zeroDecodeL;
  10104. var Z_SRC = decodeL(sourceBlackPoint[2]);
  10105. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  10106. var X_Offset = 1 - X_Scale;
  10107. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  10108. var Y_Offset = 1 - Y_Scale;
  10109. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  10110. var Z_Offset = 1 - Z_Scale;
  10111. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  10112. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  10113. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  10114. }
  10115. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  10116. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  10117. result[0] = XYZ_In[0];
  10118. result[1] = XYZ_In[1];
  10119. result[2] = XYZ_In[2];
  10120. return;
  10121. }
  10122. var LMS = result;
  10123. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10124. var LMS_Flat = tempNormalizeMatrix;
  10125. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  10126. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  10127. }
  10128. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  10129. var LMS = result;
  10130. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10131. var LMS_D65 = tempNormalizeMatrix;
  10132. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  10133. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  10134. }
  10135. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  10136. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  10137. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  10138. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  10139. var AGR = Math.pow(A, cs.GR);
  10140. var BGG = Math.pow(B, cs.GG);
  10141. var CGB = Math.pow(C, cs.GB);
  10142. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  10143. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  10144. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  10145. var XYZ = tempConvertMatrix1;
  10146. XYZ[0] = X;
  10147. XYZ[1] = Y;
  10148. XYZ[2] = Z;
  10149. var XYZ_Flat = tempConvertMatrix2;
  10150. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  10151. var XYZ_Black = tempConvertMatrix1;
  10152. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  10153. var XYZ_D65 = tempConvertMatrix2;
  10154. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  10155. var SRGB = tempConvertMatrix1;
  10156. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  10157. var sR = sRGBTransferFunction(SRGB[0]);
  10158. var sG = sRGBTransferFunction(SRGB[1]);
  10159. var sB = sRGBTransferFunction(SRGB[2]);
  10160. dest[destOffset] = Math.round(sR * 255);
  10161. dest[destOffset + 1] = Math.round(sG * 255);
  10162. dest[destOffset + 2] = Math.round(sB * 255);
  10163. }
  10164. CalRGBCS.prototype = {
  10165. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  10166. var rgb = new Uint8Array(3);
  10167. this.getRgbItem(src, srcOffset, rgb, 0);
  10168. return rgb;
  10169. },
  10170. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10171. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  10172. },
  10173. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10174. var scale = 1 / ((1 << bits) - 1);
  10175. for (var i = 0; i < count; ++i) {
  10176. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  10177. srcOffset += 3;
  10178. destOffset += 3 + alpha01;
  10179. }
  10180. },
  10181. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  10182. return inputLength * (3 + alpha01) / 3 | 0;
  10183. },
  10184. isPassthrough: ColorSpace.prototype.isPassthrough,
  10185. fillRgb: ColorSpace.prototype.fillRgb,
  10186. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  10187. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10188. },
  10189. usesZeroToOneRange: true
  10190. };
  10191. return CalRGBCS;
  10192. }();
  10193. var LabCS = function LabCSClosure() {
  10194. function LabCS(whitePoint, blackPoint, range) {
  10195. this.name = 'Lab';
  10196. this.numComps = 3;
  10197. this.defaultColor = new Float32Array(this.numComps);
  10198. if (!whitePoint) {
  10199. error('WhitePoint missing - required for color space Lab');
  10200. }
  10201. blackPoint = blackPoint || [
  10202. 0,
  10203. 0,
  10204. 0
  10205. ];
  10206. range = range || [
  10207. -100,
  10208. 100,
  10209. -100,
  10210. 100
  10211. ];
  10212. this.XW = whitePoint[0];
  10213. this.YW = whitePoint[1];
  10214. this.ZW = whitePoint[2];
  10215. this.amin = range[0];
  10216. this.amax = range[1];
  10217. this.bmin = range[2];
  10218. this.bmax = range[3];
  10219. this.XB = blackPoint[0];
  10220. this.YB = blackPoint[1];
  10221. this.ZB = blackPoint[2];
  10222. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  10223. error('Invalid WhitePoint components, no fallback available');
  10224. }
  10225. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  10226. info('Invalid BlackPoint, falling back to default');
  10227. this.XB = this.YB = this.ZB = 0;
  10228. }
  10229. if (this.amin > this.amax || this.bmin > this.bmax) {
  10230. info('Invalid Range, falling back to defaults');
  10231. this.amin = -100;
  10232. this.amax = 100;
  10233. this.bmin = -100;
  10234. this.bmax = 100;
  10235. }
  10236. }
  10237. function fn_g(x) {
  10238. var result;
  10239. if (x >= 6 / 29) {
  10240. result = x * x * x;
  10241. } else {
  10242. result = 108 / 841 * (x - 4 / 29);
  10243. }
  10244. return result;
  10245. }
  10246. function decode(value, high1, low2, high2) {
  10247. return low2 + value * (high2 - low2) / high1;
  10248. }
  10249. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  10250. var Ls = src[srcOffset];
  10251. var as = src[srcOffset + 1];
  10252. var bs = src[srcOffset + 2];
  10253. if (maxVal !== false) {
  10254. Ls = decode(Ls, maxVal, 0, 100);
  10255. as = decode(as, maxVal, cs.amin, cs.amax);
  10256. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  10257. }
  10258. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  10259. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  10260. var M = (Ls + 16) / 116;
  10261. var L = M + as / 500;
  10262. var N = M - bs / 200;
  10263. var X = cs.XW * fn_g(L);
  10264. var Y = cs.YW * fn_g(M);
  10265. var Z = cs.ZW * fn_g(N);
  10266. var r, g, b;
  10267. if (cs.ZW < 1) {
  10268. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  10269. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  10270. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  10271. } else {
  10272. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  10273. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  10274. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  10275. }
  10276. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  10277. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  10278. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  10279. }
  10280. LabCS.prototype = {
  10281. getRgb: ColorSpace.prototype.getRgb,
  10282. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10283. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  10284. },
  10285. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10286. var maxVal = (1 << bits) - 1;
  10287. for (var i = 0; i < count; i++) {
  10288. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  10289. srcOffset += 3;
  10290. destOffset += 3 + alpha01;
  10291. }
  10292. },
  10293. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  10294. return inputLength * (3 + alpha01) / 3 | 0;
  10295. },
  10296. isPassthrough: ColorSpace.prototype.isPassthrough,
  10297. fillRgb: ColorSpace.prototype.fillRgb,
  10298. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  10299. return true;
  10300. },
  10301. usesZeroToOneRange: false
  10302. };
  10303. return LabCS;
  10304. }();
  10305. exports.ColorSpace = ColorSpace;
  10306. /***/ }),
  10307. /* 5 */
  10308. /***/ (function(module, exports, __w_pdfjs_require__) {
  10309. "use strict";
  10310. var ExpertEncoding = [
  10311. '',
  10312. '',
  10313. '',
  10314. '',
  10315. '',
  10316. '',
  10317. '',
  10318. '',
  10319. '',
  10320. '',
  10321. '',
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. 'space',
  10344. 'exclamsmall',
  10345. 'Hungarumlautsmall',
  10346. '',
  10347. 'dollaroldstyle',
  10348. 'dollarsuperior',
  10349. 'ampersandsmall',
  10350. 'Acutesmall',
  10351. 'parenleftsuperior',
  10352. 'parenrightsuperior',
  10353. 'twodotenleader',
  10354. 'onedotenleader',
  10355. 'comma',
  10356. 'hyphen',
  10357. 'period',
  10358. 'fraction',
  10359. 'zerooldstyle',
  10360. 'oneoldstyle',
  10361. 'twooldstyle',
  10362. 'threeoldstyle',
  10363. 'fouroldstyle',
  10364. 'fiveoldstyle',
  10365. 'sixoldstyle',
  10366. 'sevenoldstyle',
  10367. 'eightoldstyle',
  10368. 'nineoldstyle',
  10369. 'colon',
  10370. 'semicolon',
  10371. 'commasuperior',
  10372. 'threequartersemdash',
  10373. 'periodsuperior',
  10374. 'questionsmall',
  10375. '',
  10376. 'asuperior',
  10377. 'bsuperior',
  10378. 'centsuperior',
  10379. 'dsuperior',
  10380. 'esuperior',
  10381. '',
  10382. '',
  10383. 'isuperior',
  10384. '',
  10385. '',
  10386. 'lsuperior',
  10387. 'msuperior',
  10388. 'nsuperior',
  10389. 'osuperior',
  10390. '',
  10391. '',
  10392. 'rsuperior',
  10393. 'ssuperior',
  10394. 'tsuperior',
  10395. '',
  10396. 'ff',
  10397. 'fi',
  10398. 'fl',
  10399. 'ffi',
  10400. 'ffl',
  10401. 'parenleftinferior',
  10402. '',
  10403. 'parenrightinferior',
  10404. 'Circumflexsmall',
  10405. 'hyphensuperior',
  10406. 'Gravesmall',
  10407. 'Asmall',
  10408. 'Bsmall',
  10409. 'Csmall',
  10410. 'Dsmall',
  10411. 'Esmall',
  10412. 'Fsmall',
  10413. 'Gsmall',
  10414. 'Hsmall',
  10415. 'Ismall',
  10416. 'Jsmall',
  10417. 'Ksmall',
  10418. 'Lsmall',
  10419. 'Msmall',
  10420. 'Nsmall',
  10421. 'Osmall',
  10422. 'Psmall',
  10423. 'Qsmall',
  10424. 'Rsmall',
  10425. 'Ssmall',
  10426. 'Tsmall',
  10427. 'Usmall',
  10428. 'Vsmall',
  10429. 'Wsmall',
  10430. 'Xsmall',
  10431. 'Ysmall',
  10432. 'Zsmall',
  10433. 'colonmonetary',
  10434. 'onefitted',
  10435. 'rupiah',
  10436. 'Tildesmall',
  10437. '',
  10438. '',
  10439. '',
  10440. '',
  10441. '',
  10442. '',
  10443. '',
  10444. '',
  10445. '',
  10446. '',
  10447. '',
  10448. '',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. '',
  10467. '',
  10468. '',
  10469. '',
  10470. '',
  10471. 'exclamdownsmall',
  10472. 'centoldstyle',
  10473. 'Lslashsmall',
  10474. '',
  10475. '',
  10476. 'Scaronsmall',
  10477. 'Zcaronsmall',
  10478. 'Dieresissmall',
  10479. 'Brevesmall',
  10480. 'Caronsmall',
  10481. '',
  10482. 'Dotaccentsmall',
  10483. '',
  10484. '',
  10485. 'Macronsmall',
  10486. '',
  10487. '',
  10488. 'figuredash',
  10489. 'hypheninferior',
  10490. '',
  10491. '',
  10492. 'Ogoneksmall',
  10493. 'Ringsmall',
  10494. 'Cedillasmall',
  10495. '',
  10496. '',
  10497. '',
  10498. 'onequarter',
  10499. 'onehalf',
  10500. 'threequarters',
  10501. 'questiondownsmall',
  10502. 'oneeighth',
  10503. 'threeeighths',
  10504. 'fiveeighths',
  10505. 'seveneighths',
  10506. 'onethird',
  10507. 'twothirds',
  10508. '',
  10509. '',
  10510. 'zerosuperior',
  10511. 'onesuperior',
  10512. 'twosuperior',
  10513. 'threesuperior',
  10514. 'foursuperior',
  10515. 'fivesuperior',
  10516. 'sixsuperior',
  10517. 'sevensuperior',
  10518. 'eightsuperior',
  10519. 'ninesuperior',
  10520. 'zeroinferior',
  10521. 'oneinferior',
  10522. 'twoinferior',
  10523. 'threeinferior',
  10524. 'fourinferior',
  10525. 'fiveinferior',
  10526. 'sixinferior',
  10527. 'seveninferior',
  10528. 'eightinferior',
  10529. 'nineinferior',
  10530. 'centinferior',
  10531. 'dollarinferior',
  10532. 'periodinferior',
  10533. 'commainferior',
  10534. 'Agravesmall',
  10535. 'Aacutesmall',
  10536. 'Acircumflexsmall',
  10537. 'Atildesmall',
  10538. 'Adieresissmall',
  10539. 'Aringsmall',
  10540. 'AEsmall',
  10541. 'Ccedillasmall',
  10542. 'Egravesmall',
  10543. 'Eacutesmall',
  10544. 'Ecircumflexsmall',
  10545. 'Edieresissmall',
  10546. 'Igravesmall',
  10547. 'Iacutesmall',
  10548. 'Icircumflexsmall',
  10549. 'Idieresissmall',
  10550. 'Ethsmall',
  10551. 'Ntildesmall',
  10552. 'Ogravesmall',
  10553. 'Oacutesmall',
  10554. 'Ocircumflexsmall',
  10555. 'Otildesmall',
  10556. 'Odieresissmall',
  10557. 'OEsmall',
  10558. 'Oslashsmall',
  10559. 'Ugravesmall',
  10560. 'Uacutesmall',
  10561. 'Ucircumflexsmall',
  10562. 'Udieresissmall',
  10563. 'Yacutesmall',
  10564. 'Thornsmall',
  10565. 'Ydieresissmall'
  10566. ];
  10567. var MacExpertEncoding = [
  10568. '',
  10569. '',
  10570. '',
  10571. '',
  10572. '',
  10573. '',
  10574. '',
  10575. '',
  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. 'space',
  10601. 'exclamsmall',
  10602. 'Hungarumlautsmall',
  10603. 'centoldstyle',
  10604. 'dollaroldstyle',
  10605. 'dollarsuperior',
  10606. 'ampersandsmall',
  10607. 'Acutesmall',
  10608. 'parenleftsuperior',
  10609. 'parenrightsuperior',
  10610. 'twodotenleader',
  10611. 'onedotenleader',
  10612. 'comma',
  10613. 'hyphen',
  10614. 'period',
  10615. 'fraction',
  10616. 'zerooldstyle',
  10617. 'oneoldstyle',
  10618. 'twooldstyle',
  10619. 'threeoldstyle',
  10620. 'fouroldstyle',
  10621. 'fiveoldstyle',
  10622. 'sixoldstyle',
  10623. 'sevenoldstyle',
  10624. 'eightoldstyle',
  10625. 'nineoldstyle',
  10626. 'colon',
  10627. 'semicolon',
  10628. '',
  10629. 'threequartersemdash',
  10630. '',
  10631. 'questionsmall',
  10632. '',
  10633. '',
  10634. '',
  10635. '',
  10636. 'Ethsmall',
  10637. '',
  10638. '',
  10639. 'onequarter',
  10640. 'onehalf',
  10641. 'threequarters',
  10642. 'oneeighth',
  10643. 'threeeighths',
  10644. 'fiveeighths',
  10645. 'seveneighths',
  10646. 'onethird',
  10647. 'twothirds',
  10648. '',
  10649. '',
  10650. '',
  10651. '',
  10652. '',
  10653. '',
  10654. 'ff',
  10655. 'fi',
  10656. 'fl',
  10657. 'ffi',
  10658. 'ffl',
  10659. 'parenleftinferior',
  10660. '',
  10661. 'parenrightinferior',
  10662. 'Circumflexsmall',
  10663. 'hypheninferior',
  10664. 'Gravesmall',
  10665. 'Asmall',
  10666. 'Bsmall',
  10667. 'Csmall',
  10668. 'Dsmall',
  10669. 'Esmall',
  10670. 'Fsmall',
  10671. 'Gsmall',
  10672. 'Hsmall',
  10673. 'Ismall',
  10674. 'Jsmall',
  10675. 'Ksmall',
  10676. 'Lsmall',
  10677. 'Msmall',
  10678. 'Nsmall',
  10679. 'Osmall',
  10680. 'Psmall',
  10681. 'Qsmall',
  10682. 'Rsmall',
  10683. 'Ssmall',
  10684. 'Tsmall',
  10685. 'Usmall',
  10686. 'Vsmall',
  10687. 'Wsmall',
  10688. 'Xsmall',
  10689. 'Ysmall',
  10690. 'Zsmall',
  10691. 'colonmonetary',
  10692. 'onefitted',
  10693. 'rupiah',
  10694. 'Tildesmall',
  10695. '',
  10696. '',
  10697. 'asuperior',
  10698. 'centsuperior',
  10699. '',
  10700. '',
  10701. '',
  10702. '',
  10703. 'Aacutesmall',
  10704. 'Agravesmall',
  10705. 'Acircumflexsmall',
  10706. 'Adieresissmall',
  10707. 'Atildesmall',
  10708. 'Aringsmall',
  10709. 'Ccedillasmall',
  10710. 'Eacutesmall',
  10711. 'Egravesmall',
  10712. 'Ecircumflexsmall',
  10713. 'Edieresissmall',
  10714. 'Iacutesmall',
  10715. 'Igravesmall',
  10716. 'Icircumflexsmall',
  10717. 'Idieresissmall',
  10718. 'Ntildesmall',
  10719. 'Oacutesmall',
  10720. 'Ogravesmall',
  10721. 'Ocircumflexsmall',
  10722. 'Odieresissmall',
  10723. 'Otildesmall',
  10724. 'Uacutesmall',
  10725. 'Ugravesmall',
  10726. 'Ucircumflexsmall',
  10727. 'Udieresissmall',
  10728. '',
  10729. 'eightsuperior',
  10730. 'fourinferior',
  10731. 'threeinferior',
  10732. 'sixinferior',
  10733. 'eightinferior',
  10734. 'seveninferior',
  10735. 'Scaronsmall',
  10736. '',
  10737. 'centinferior',
  10738. 'twoinferior',
  10739. '',
  10740. 'Dieresissmall',
  10741. '',
  10742. 'Caronsmall',
  10743. 'osuperior',
  10744. 'fiveinferior',
  10745. '',
  10746. 'commainferior',
  10747. 'periodinferior',
  10748. 'Yacutesmall',
  10749. '',
  10750. 'dollarinferior',
  10751. '',
  10752. 'Thornsmall',
  10753. '',
  10754. 'nineinferior',
  10755. 'zeroinferior',
  10756. 'Zcaronsmall',
  10757. 'AEsmall',
  10758. 'Oslashsmall',
  10759. 'questiondownsmall',
  10760. 'oneinferior',
  10761. 'Lslashsmall',
  10762. '',
  10763. '',
  10764. '',
  10765. '',
  10766. '',
  10767. '',
  10768. 'Cedillasmall',
  10769. '',
  10770. '',
  10771. '',
  10772. '',
  10773. '',
  10774. 'OEsmall',
  10775. 'figuredash',
  10776. 'hyphensuperior',
  10777. '',
  10778. '',
  10779. '',
  10780. '',
  10781. 'exclamdownsmall',
  10782. '',
  10783. 'Ydieresissmall',
  10784. '',
  10785. 'onesuperior',
  10786. 'twosuperior',
  10787. 'threesuperior',
  10788. 'foursuperior',
  10789. 'fivesuperior',
  10790. 'sixsuperior',
  10791. 'sevensuperior',
  10792. 'ninesuperior',
  10793. 'zerosuperior',
  10794. '',
  10795. 'esuperior',
  10796. 'rsuperior',
  10797. 'tsuperior',
  10798. '',
  10799. '',
  10800. 'isuperior',
  10801. 'ssuperior',
  10802. 'dsuperior',
  10803. '',
  10804. '',
  10805. '',
  10806. '',
  10807. '',
  10808. 'lsuperior',
  10809. 'Ogoneksmall',
  10810. 'Brevesmall',
  10811. 'Macronsmall',
  10812. 'bsuperior',
  10813. 'nsuperior',
  10814. 'msuperior',
  10815. 'commasuperior',
  10816. 'periodsuperior',
  10817. 'Dotaccentsmall',
  10818. 'Ringsmall'
  10819. ];
  10820. var MacRomanEncoding = [
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. '',
  10826. '',
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. '',
  10833. '',
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. 'space',
  10854. 'exclam',
  10855. 'quotedbl',
  10856. 'numbersign',
  10857. 'dollar',
  10858. 'percent',
  10859. 'ampersand',
  10860. 'quotesingle',
  10861. 'parenleft',
  10862. 'parenright',
  10863. 'asterisk',
  10864. 'plus',
  10865. 'comma',
  10866. 'hyphen',
  10867. 'period',
  10868. 'slash',
  10869. 'zero',
  10870. 'one',
  10871. 'two',
  10872. 'three',
  10873. 'four',
  10874. 'five',
  10875. 'six',
  10876. 'seven',
  10877. 'eight',
  10878. 'nine',
  10879. 'colon',
  10880. 'semicolon',
  10881. 'less',
  10882. 'equal',
  10883. 'greater',
  10884. 'question',
  10885. 'at',
  10886. 'A',
  10887. 'B',
  10888. 'C',
  10889. 'D',
  10890. 'E',
  10891. 'F',
  10892. 'G',
  10893. 'H',
  10894. 'I',
  10895. 'J',
  10896. 'K',
  10897. 'L',
  10898. 'M',
  10899. 'N',
  10900. 'O',
  10901. 'P',
  10902. 'Q',
  10903. 'R',
  10904. 'S',
  10905. 'T',
  10906. 'U',
  10907. 'V',
  10908. 'W',
  10909. 'X',
  10910. 'Y',
  10911. 'Z',
  10912. 'bracketleft',
  10913. 'backslash',
  10914. 'bracketright',
  10915. 'asciicircum',
  10916. 'underscore',
  10917. 'grave',
  10918. 'a',
  10919. 'b',
  10920. 'c',
  10921. 'd',
  10922. 'e',
  10923. 'f',
  10924. 'g',
  10925. 'h',
  10926. 'i',
  10927. 'j',
  10928. 'k',
  10929. 'l',
  10930. 'm',
  10931. 'n',
  10932. 'o',
  10933. 'p',
  10934. 'q',
  10935. 'r',
  10936. 's',
  10937. 't',
  10938. 'u',
  10939. 'v',
  10940. 'w',
  10941. 'x',
  10942. 'y',
  10943. 'z',
  10944. 'braceleft',
  10945. 'bar',
  10946. 'braceright',
  10947. 'asciitilde',
  10948. '',
  10949. 'Adieresis',
  10950. 'Aring',
  10951. 'Ccedilla',
  10952. 'Eacute',
  10953. 'Ntilde',
  10954. 'Odieresis',
  10955. 'Udieresis',
  10956. 'aacute',
  10957. 'agrave',
  10958. 'acircumflex',
  10959. 'adieresis',
  10960. 'atilde',
  10961. 'aring',
  10962. 'ccedilla',
  10963. 'eacute',
  10964. 'egrave',
  10965. 'ecircumflex',
  10966. 'edieresis',
  10967. 'iacute',
  10968. 'igrave',
  10969. 'icircumflex',
  10970. 'idieresis',
  10971. 'ntilde',
  10972. 'oacute',
  10973. 'ograve',
  10974. 'ocircumflex',
  10975. 'odieresis',
  10976. 'otilde',
  10977. 'uacute',
  10978. 'ugrave',
  10979. 'ucircumflex',
  10980. 'udieresis',
  10981. 'dagger',
  10982. 'degree',
  10983. 'cent',
  10984. 'sterling',
  10985. 'section',
  10986. 'bullet',
  10987. 'paragraph',
  10988. 'germandbls',
  10989. 'registered',
  10990. 'copyright',
  10991. 'trademark',
  10992. 'acute',
  10993. 'dieresis',
  10994. 'notequal',
  10995. 'AE',
  10996. 'Oslash',
  10997. 'infinity',
  10998. 'plusminus',
  10999. 'lessequal',
  11000. 'greaterequal',
  11001. 'yen',
  11002. 'mu',
  11003. 'partialdiff',
  11004. 'summation',
  11005. 'product',
  11006. 'pi',
  11007. 'integral',
  11008. 'ordfeminine',
  11009. 'ordmasculine',
  11010. 'Omega',
  11011. 'ae',
  11012. 'oslash',
  11013. 'questiondown',
  11014. 'exclamdown',
  11015. 'logicalnot',
  11016. 'radical',
  11017. 'florin',
  11018. 'approxequal',
  11019. 'Delta',
  11020. 'guillemotleft',
  11021. 'guillemotright',
  11022. 'ellipsis',
  11023. 'space',
  11024. 'Agrave',
  11025. 'Atilde',
  11026. 'Otilde',
  11027. 'OE',
  11028. 'oe',
  11029. 'endash',
  11030. 'emdash',
  11031. 'quotedblleft',
  11032. 'quotedblright',
  11033. 'quoteleft',
  11034. 'quoteright',
  11035. 'divide',
  11036. 'lozenge',
  11037. 'ydieresis',
  11038. 'Ydieresis',
  11039. 'fraction',
  11040. 'currency',
  11041. 'guilsinglleft',
  11042. 'guilsinglright',
  11043. 'fi',
  11044. 'fl',
  11045. 'daggerdbl',
  11046. 'periodcentered',
  11047. 'quotesinglbase',
  11048. 'quotedblbase',
  11049. 'perthousand',
  11050. 'Acircumflex',
  11051. 'Ecircumflex',
  11052. 'Aacute',
  11053. 'Edieresis',
  11054. 'Egrave',
  11055. 'Iacute',
  11056. 'Icircumflex',
  11057. 'Idieresis',
  11058. 'Igrave',
  11059. 'Oacute',
  11060. 'Ocircumflex',
  11061. 'apple',
  11062. 'Ograve',
  11063. 'Uacute',
  11064. 'Ucircumflex',
  11065. 'Ugrave',
  11066. 'dotlessi',
  11067. 'circumflex',
  11068. 'tilde',
  11069. 'macron',
  11070. 'breve',
  11071. 'dotaccent',
  11072. 'ring',
  11073. 'cedilla',
  11074. 'hungarumlaut',
  11075. 'ogonek',
  11076. 'caron'
  11077. ];
  11078. var StandardEncoding = [
  11079. '',
  11080. '',
  11081. '',
  11082. '',
  11083. '',
  11084. '',
  11085. '',
  11086. '',
  11087. '',
  11088. '',
  11089. '',
  11090. '',
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. '',
  11107. '',
  11108. '',
  11109. '',
  11110. '',
  11111. 'space',
  11112. 'exclam',
  11113. 'quotedbl',
  11114. 'numbersign',
  11115. 'dollar',
  11116. 'percent',
  11117. 'ampersand',
  11118. 'quoteright',
  11119. 'parenleft',
  11120. 'parenright',
  11121. 'asterisk',
  11122. 'plus',
  11123. 'comma',
  11124. 'hyphen',
  11125. 'period',
  11126. 'slash',
  11127. 'zero',
  11128. 'one',
  11129. 'two',
  11130. 'three',
  11131. 'four',
  11132. 'five',
  11133. 'six',
  11134. 'seven',
  11135. 'eight',
  11136. 'nine',
  11137. 'colon',
  11138. 'semicolon',
  11139. 'less',
  11140. 'equal',
  11141. 'greater',
  11142. 'question',
  11143. 'at',
  11144. 'A',
  11145. 'B',
  11146. 'C',
  11147. 'D',
  11148. 'E',
  11149. 'F',
  11150. 'G',
  11151. 'H',
  11152. 'I',
  11153. 'J',
  11154. 'K',
  11155. 'L',
  11156. 'M',
  11157. 'N',
  11158. 'O',
  11159. 'P',
  11160. 'Q',
  11161. 'R',
  11162. 'S',
  11163. 'T',
  11164. 'U',
  11165. 'V',
  11166. 'W',
  11167. 'X',
  11168. 'Y',
  11169. 'Z',
  11170. 'bracketleft',
  11171. 'backslash',
  11172. 'bracketright',
  11173. 'asciicircum',
  11174. 'underscore',
  11175. 'quoteleft',
  11176. 'a',
  11177. 'b',
  11178. 'c',
  11179. 'd',
  11180. 'e',
  11181. 'f',
  11182. 'g',
  11183. 'h',
  11184. 'i',
  11185. 'j',
  11186. 'k',
  11187. 'l',
  11188. 'm',
  11189. 'n',
  11190. 'o',
  11191. 'p',
  11192. 'q',
  11193. 'r',
  11194. 's',
  11195. 't',
  11196. 'u',
  11197. 'v',
  11198. 'w',
  11199. 'x',
  11200. 'y',
  11201. 'z',
  11202. 'braceleft',
  11203. 'bar',
  11204. 'braceright',
  11205. 'asciitilde',
  11206. '',
  11207. '',
  11208. '',
  11209. '',
  11210. '',
  11211. '',
  11212. '',
  11213. '',
  11214. '',
  11215. '',
  11216. '',
  11217. '',
  11218. '',
  11219. '',
  11220. '',
  11221. '',
  11222. '',
  11223. '',
  11224. '',
  11225. '',
  11226. '',
  11227. '',
  11228. '',
  11229. '',
  11230. '',
  11231. '',
  11232. '',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. '',
  11238. '',
  11239. '',
  11240. 'exclamdown',
  11241. 'cent',
  11242. 'sterling',
  11243. 'fraction',
  11244. 'yen',
  11245. 'florin',
  11246. 'section',
  11247. 'currency',
  11248. 'quotesingle',
  11249. 'quotedblleft',
  11250. 'guillemotleft',
  11251. 'guilsinglleft',
  11252. 'guilsinglright',
  11253. 'fi',
  11254. 'fl',
  11255. '',
  11256. 'endash',
  11257. 'dagger',
  11258. 'daggerdbl',
  11259. 'periodcentered',
  11260. '',
  11261. 'paragraph',
  11262. 'bullet',
  11263. 'quotesinglbase',
  11264. 'quotedblbase',
  11265. 'quotedblright',
  11266. 'guillemotright',
  11267. 'ellipsis',
  11268. 'perthousand',
  11269. '',
  11270. 'questiondown',
  11271. '',
  11272. 'grave',
  11273. 'acute',
  11274. 'circumflex',
  11275. 'tilde',
  11276. 'macron',
  11277. 'breve',
  11278. 'dotaccent',
  11279. 'dieresis',
  11280. '',
  11281. 'ring',
  11282. 'cedilla',
  11283. '',
  11284. 'hungarumlaut',
  11285. 'ogonek',
  11286. 'caron',
  11287. 'emdash',
  11288. '',
  11289. '',
  11290. '',
  11291. '',
  11292. '',
  11293. '',
  11294. '',
  11295. '',
  11296. '',
  11297. '',
  11298. '',
  11299. '',
  11300. '',
  11301. '',
  11302. '',
  11303. '',
  11304. 'AE',
  11305. '',
  11306. 'ordfeminine',
  11307. '',
  11308. '',
  11309. '',
  11310. '',
  11311. 'Lslash',
  11312. 'Oslash',
  11313. 'OE',
  11314. 'ordmasculine',
  11315. '',
  11316. '',
  11317. '',
  11318. '',
  11319. '',
  11320. 'ae',
  11321. '',
  11322. '',
  11323. '',
  11324. 'dotlessi',
  11325. '',
  11326. '',
  11327. 'lslash',
  11328. 'oslash',
  11329. 'oe',
  11330. 'germandbls'
  11331. ];
  11332. var WinAnsiEncoding = [
  11333. '',
  11334. '',
  11335. '',
  11336. '',
  11337. '',
  11338. '',
  11339. '',
  11340. '',
  11341. '',
  11342. '',
  11343. '',
  11344. '',
  11345. '',
  11346. '',
  11347. '',
  11348. '',
  11349. '',
  11350. '',
  11351. '',
  11352. '',
  11353. '',
  11354. '',
  11355. '',
  11356. '',
  11357. '',
  11358. '',
  11359. '',
  11360. '',
  11361. '',
  11362. '',
  11363. '',
  11364. '',
  11365. 'space',
  11366. 'exclam',
  11367. 'quotedbl',
  11368. 'numbersign',
  11369. 'dollar',
  11370. 'percent',
  11371. 'ampersand',
  11372. 'quotesingle',
  11373. 'parenleft',
  11374. 'parenright',
  11375. 'asterisk',
  11376. 'plus',
  11377. 'comma',
  11378. 'hyphen',
  11379. 'period',
  11380. 'slash',
  11381. 'zero',
  11382. 'one',
  11383. 'two',
  11384. 'three',
  11385. 'four',
  11386. 'five',
  11387. 'six',
  11388. 'seven',
  11389. 'eight',
  11390. 'nine',
  11391. 'colon',
  11392. 'semicolon',
  11393. 'less',
  11394. 'equal',
  11395. 'greater',
  11396. 'question',
  11397. 'at',
  11398. 'A',
  11399. 'B',
  11400. 'C',
  11401. 'D',
  11402. 'E',
  11403. 'F',
  11404. 'G',
  11405. 'H',
  11406. 'I',
  11407. 'J',
  11408. 'K',
  11409. 'L',
  11410. 'M',
  11411. 'N',
  11412. 'O',
  11413. 'P',
  11414. 'Q',
  11415. 'R',
  11416. 'S',
  11417. 'T',
  11418. 'U',
  11419. 'V',
  11420. 'W',
  11421. 'X',
  11422. 'Y',
  11423. 'Z',
  11424. 'bracketleft',
  11425. 'backslash',
  11426. 'bracketright',
  11427. 'asciicircum',
  11428. 'underscore',
  11429. 'grave',
  11430. 'a',
  11431. 'b',
  11432. 'c',
  11433. 'd',
  11434. 'e',
  11435. 'f',
  11436. 'g',
  11437. 'h',
  11438. 'i',
  11439. 'j',
  11440. 'k',
  11441. 'l',
  11442. 'm',
  11443. 'n',
  11444. 'o',
  11445. 'p',
  11446. 'q',
  11447. 'r',
  11448. 's',
  11449. 't',
  11450. 'u',
  11451. 'v',
  11452. 'w',
  11453. 'x',
  11454. 'y',
  11455. 'z',
  11456. 'braceleft',
  11457. 'bar',
  11458. 'braceright',
  11459. 'asciitilde',
  11460. 'bullet',
  11461. 'Euro',
  11462. 'bullet',
  11463. 'quotesinglbase',
  11464. 'florin',
  11465. 'quotedblbase',
  11466. 'ellipsis',
  11467. 'dagger',
  11468. 'daggerdbl',
  11469. 'circumflex',
  11470. 'perthousand',
  11471. 'Scaron',
  11472. 'guilsinglleft',
  11473. 'OE',
  11474. 'bullet',
  11475. 'Zcaron',
  11476. 'bullet',
  11477. 'bullet',
  11478. 'quoteleft',
  11479. 'quoteright',
  11480. 'quotedblleft',
  11481. 'quotedblright',
  11482. 'bullet',
  11483. 'endash',
  11484. 'emdash',
  11485. 'tilde',
  11486. 'trademark',
  11487. 'scaron',
  11488. 'guilsinglright',
  11489. 'oe',
  11490. 'bullet',
  11491. 'zcaron',
  11492. 'Ydieresis',
  11493. 'space',
  11494. 'exclamdown',
  11495. 'cent',
  11496. 'sterling',
  11497. 'currency',
  11498. 'yen',
  11499. 'brokenbar',
  11500. 'section',
  11501. 'dieresis',
  11502. 'copyright',
  11503. 'ordfeminine',
  11504. 'guillemotleft',
  11505. 'logicalnot',
  11506. 'hyphen',
  11507. 'registered',
  11508. 'macron',
  11509. 'degree',
  11510. 'plusminus',
  11511. 'twosuperior',
  11512. 'threesuperior',
  11513. 'acute',
  11514. 'mu',
  11515. 'paragraph',
  11516. 'periodcentered',
  11517. 'cedilla',
  11518. 'onesuperior',
  11519. 'ordmasculine',
  11520. 'guillemotright',
  11521. 'onequarter',
  11522. 'onehalf',
  11523. 'threequarters',
  11524. 'questiondown',
  11525. 'Agrave',
  11526. 'Aacute',
  11527. 'Acircumflex',
  11528. 'Atilde',
  11529. 'Adieresis',
  11530. 'Aring',
  11531. 'AE',
  11532. 'Ccedilla',
  11533. 'Egrave',
  11534. 'Eacute',
  11535. 'Ecircumflex',
  11536. 'Edieresis',
  11537. 'Igrave',
  11538. 'Iacute',
  11539. 'Icircumflex',
  11540. 'Idieresis',
  11541. 'Eth',
  11542. 'Ntilde',
  11543. 'Ograve',
  11544. 'Oacute',
  11545. 'Ocircumflex',
  11546. 'Otilde',
  11547. 'Odieresis',
  11548. 'multiply',
  11549. 'Oslash',
  11550. 'Ugrave',
  11551. 'Uacute',
  11552. 'Ucircumflex',
  11553. 'Udieresis',
  11554. 'Yacute',
  11555. 'Thorn',
  11556. 'germandbls',
  11557. 'agrave',
  11558. 'aacute',
  11559. 'acircumflex',
  11560. 'atilde',
  11561. 'adieresis',
  11562. 'aring',
  11563. 'ae',
  11564. 'ccedilla',
  11565. 'egrave',
  11566. 'eacute',
  11567. 'ecircumflex',
  11568. 'edieresis',
  11569. 'igrave',
  11570. 'iacute',
  11571. 'icircumflex',
  11572. 'idieresis',
  11573. 'eth',
  11574. 'ntilde',
  11575. 'ograve',
  11576. 'oacute',
  11577. 'ocircumflex',
  11578. 'otilde',
  11579. 'odieresis',
  11580. 'divide',
  11581. 'oslash',
  11582. 'ugrave',
  11583. 'uacute',
  11584. 'ucircumflex',
  11585. 'udieresis',
  11586. 'yacute',
  11587. 'thorn',
  11588. 'ydieresis'
  11589. ];
  11590. var SymbolSetEncoding = [
  11591. '',
  11592. '',
  11593. '',
  11594. '',
  11595. '',
  11596. '',
  11597. '',
  11598. '',
  11599. '',
  11600. '',
  11601. '',
  11602. '',
  11603. '',
  11604. '',
  11605. '',
  11606. '',
  11607. '',
  11608. '',
  11609. '',
  11610. '',
  11611. '',
  11612. '',
  11613. '',
  11614. '',
  11615. '',
  11616. '',
  11617. '',
  11618. '',
  11619. '',
  11620. '',
  11621. '',
  11622. '',
  11623. 'space',
  11624. 'exclam',
  11625. 'universal',
  11626. 'numbersign',
  11627. 'existential',
  11628. 'percent',
  11629. 'ampersand',
  11630. 'suchthat',
  11631. 'parenleft',
  11632. 'parenright',
  11633. 'asteriskmath',
  11634. 'plus',
  11635. 'comma',
  11636. 'minus',
  11637. 'period',
  11638. 'slash',
  11639. 'zero',
  11640. 'one',
  11641. 'two',
  11642. 'three',
  11643. 'four',
  11644. 'five',
  11645. 'six',
  11646. 'seven',
  11647. 'eight',
  11648. 'nine',
  11649. 'colon',
  11650. 'semicolon',
  11651. 'less',
  11652. 'equal',
  11653. 'greater',
  11654. 'question',
  11655. 'congruent',
  11656. 'Alpha',
  11657. 'Beta',
  11658. 'Chi',
  11659. 'Delta',
  11660. 'Epsilon',
  11661. 'Phi',
  11662. 'Gamma',
  11663. 'Eta',
  11664. 'Iota',
  11665. 'theta1',
  11666. 'Kappa',
  11667. 'Lambda',
  11668. 'Mu',
  11669. 'Nu',
  11670. 'Omicron',
  11671. 'Pi',
  11672. 'Theta',
  11673. 'Rho',
  11674. 'Sigma',
  11675. 'Tau',
  11676. 'Upsilon',
  11677. 'sigma1',
  11678. 'Omega',
  11679. 'Xi',
  11680. 'Psi',
  11681. 'Zeta',
  11682. 'bracketleft',
  11683. 'therefore',
  11684. 'bracketright',
  11685. 'perpendicular',
  11686. 'underscore',
  11687. 'radicalex',
  11688. 'alpha',
  11689. 'beta',
  11690. 'chi',
  11691. 'delta',
  11692. 'epsilon',
  11693. 'phi',
  11694. 'gamma',
  11695. 'eta',
  11696. 'iota',
  11697. 'phi1',
  11698. 'kappa',
  11699. 'lambda',
  11700. 'mu',
  11701. 'nu',
  11702. 'omicron',
  11703. 'pi',
  11704. 'theta',
  11705. 'rho',
  11706. 'sigma',
  11707. 'tau',
  11708. 'upsilon',
  11709. 'omega1',
  11710. 'omega',
  11711. 'xi',
  11712. 'psi',
  11713. 'zeta',
  11714. 'braceleft',
  11715. 'bar',
  11716. 'braceright',
  11717. 'similar',
  11718. '',
  11719. '',
  11720. '',
  11721. '',
  11722. '',
  11723. '',
  11724. '',
  11725. '',
  11726. '',
  11727. '',
  11728. '',
  11729. '',
  11730. '',
  11731. '',
  11732. '',
  11733. '',
  11734. '',
  11735. '',
  11736. '',
  11737. '',
  11738. '',
  11739. '',
  11740. '',
  11741. '',
  11742. '',
  11743. '',
  11744. '',
  11745. '',
  11746. '',
  11747. '',
  11748. '',
  11749. '',
  11750. '',
  11751. 'Euro',
  11752. 'Upsilon1',
  11753. 'minute',
  11754. 'lessequal',
  11755. 'fraction',
  11756. 'infinity',
  11757. 'florin',
  11758. 'club',
  11759. 'diamond',
  11760. 'heart',
  11761. 'spade',
  11762. 'arrowboth',
  11763. 'arrowleft',
  11764. 'arrowup',
  11765. 'arrowright',
  11766. 'arrowdown',
  11767. 'degree',
  11768. 'plusminus',
  11769. 'second',
  11770. 'greaterequal',
  11771. 'multiply',
  11772. 'proportional',
  11773. 'partialdiff',
  11774. 'bullet',
  11775. 'divide',
  11776. 'notequal',
  11777. 'equivalence',
  11778. 'approxequal',
  11779. 'ellipsis',
  11780. 'arrowvertex',
  11781. 'arrowhorizex',
  11782. 'carriagereturn',
  11783. 'aleph',
  11784. 'Ifraktur',
  11785. 'Rfraktur',
  11786. 'weierstrass',
  11787. 'circlemultiply',
  11788. 'circleplus',
  11789. 'emptyset',
  11790. 'intersection',
  11791. 'union',
  11792. 'propersuperset',
  11793. 'reflexsuperset',
  11794. 'notsubset',
  11795. 'propersubset',
  11796. 'reflexsubset',
  11797. 'element',
  11798. 'notelement',
  11799. 'angle',
  11800. 'gradient',
  11801. 'registerserif',
  11802. 'copyrightserif',
  11803. 'trademarkserif',
  11804. 'product',
  11805. 'radical',
  11806. 'dotmath',
  11807. 'logicalnot',
  11808. 'logicaland',
  11809. 'logicalor',
  11810. 'arrowdblboth',
  11811. 'arrowdblleft',
  11812. 'arrowdblup',
  11813. 'arrowdblright',
  11814. 'arrowdbldown',
  11815. 'lozenge',
  11816. 'angleleft',
  11817. 'registersans',
  11818. 'copyrightsans',
  11819. 'trademarksans',
  11820. 'summation',
  11821. 'parenlefttp',
  11822. 'parenleftex',
  11823. 'parenleftbt',
  11824. 'bracketlefttp',
  11825. 'bracketleftex',
  11826. 'bracketleftbt',
  11827. 'bracelefttp',
  11828. 'braceleftmid',
  11829. 'braceleftbt',
  11830. 'braceex',
  11831. '',
  11832. 'angleright',
  11833. 'integral',
  11834. 'integraltp',
  11835. 'integralex',
  11836. 'integralbt',
  11837. 'parenrighttp',
  11838. 'parenrightex',
  11839. 'parenrightbt',
  11840. 'bracketrighttp',
  11841. 'bracketrightex',
  11842. 'bracketrightbt',
  11843. 'bracerighttp',
  11844. 'bracerightmid',
  11845. 'bracerightbt'
  11846. ];
  11847. var ZapfDingbatsEncoding = [
  11848. '',
  11849. '',
  11850. '',
  11851. '',
  11852. '',
  11853. '',
  11854. '',
  11855. '',
  11856. '',
  11857. '',
  11858. '',
  11859. '',
  11860. '',
  11861. '',
  11862. '',
  11863. '',
  11864. '',
  11865. '',
  11866. '',
  11867. '',
  11868. '',
  11869. '',
  11870. '',
  11871. '',
  11872. '',
  11873. '',
  11874. '',
  11875. '',
  11876. '',
  11877. '',
  11878. '',
  11879. '',
  11880. 'space',
  11881. 'a1',
  11882. 'a2',
  11883. 'a202',
  11884. 'a3',
  11885. 'a4',
  11886. 'a5',
  11887. 'a119',
  11888. 'a118',
  11889. 'a117',
  11890. 'a11',
  11891. 'a12',
  11892. 'a13',
  11893. 'a14',
  11894. 'a15',
  11895. 'a16',
  11896. 'a105',
  11897. 'a17',
  11898. 'a18',
  11899. 'a19',
  11900. 'a20',
  11901. 'a21',
  11902. 'a22',
  11903. 'a23',
  11904. 'a24',
  11905. 'a25',
  11906. 'a26',
  11907. 'a27',
  11908. 'a28',
  11909. 'a6',
  11910. 'a7',
  11911. 'a8',
  11912. 'a9',
  11913. 'a10',
  11914. 'a29',
  11915. 'a30',
  11916. 'a31',
  11917. 'a32',
  11918. 'a33',
  11919. 'a34',
  11920. 'a35',
  11921. 'a36',
  11922. 'a37',
  11923. 'a38',
  11924. 'a39',
  11925. 'a40',
  11926. 'a41',
  11927. 'a42',
  11928. 'a43',
  11929. 'a44',
  11930. 'a45',
  11931. 'a46',
  11932. 'a47',
  11933. 'a48',
  11934. 'a49',
  11935. 'a50',
  11936. 'a51',
  11937. 'a52',
  11938. 'a53',
  11939. 'a54',
  11940. 'a55',
  11941. 'a56',
  11942. 'a57',
  11943. 'a58',
  11944. 'a59',
  11945. 'a60',
  11946. 'a61',
  11947. 'a62',
  11948. 'a63',
  11949. 'a64',
  11950. 'a65',
  11951. 'a66',
  11952. 'a67',
  11953. 'a68',
  11954. 'a69',
  11955. 'a70',
  11956. 'a71',
  11957. 'a72',
  11958. 'a73',
  11959. 'a74',
  11960. 'a203',
  11961. 'a75',
  11962. 'a204',
  11963. 'a76',
  11964. 'a77',
  11965. 'a78',
  11966. 'a79',
  11967. 'a81',
  11968. 'a82',
  11969. 'a83',
  11970. 'a84',
  11971. 'a97',
  11972. 'a98',
  11973. 'a99',
  11974. 'a100',
  11975. '',
  11976. 'a89',
  11977. 'a90',
  11978. 'a93',
  11979. 'a94',
  11980. 'a91',
  11981. 'a92',
  11982. 'a205',
  11983. 'a85',
  11984. 'a206',
  11985. 'a86',
  11986. 'a87',
  11987. 'a88',
  11988. 'a95',
  11989. 'a96',
  11990. '',
  11991. '',
  11992. '',
  11993. '',
  11994. '',
  11995. '',
  11996. '',
  11997. '',
  11998. '',
  11999. '',
  12000. '',
  12001. '',
  12002. '',
  12003. '',
  12004. '',
  12005. '',
  12006. '',
  12007. '',
  12008. '',
  12009. 'a101',
  12010. 'a102',
  12011. 'a103',
  12012. 'a104',
  12013. 'a106',
  12014. 'a107',
  12015. 'a108',
  12016. 'a112',
  12017. 'a111',
  12018. 'a110',
  12019. 'a109',
  12020. 'a120',
  12021. 'a121',
  12022. 'a122',
  12023. 'a123',
  12024. 'a124',
  12025. 'a125',
  12026. 'a126',
  12027. 'a127',
  12028. 'a128',
  12029. 'a129',
  12030. 'a130',
  12031. 'a131',
  12032. 'a132',
  12033. 'a133',
  12034. 'a134',
  12035. 'a135',
  12036. 'a136',
  12037. 'a137',
  12038. 'a138',
  12039. 'a139',
  12040. 'a140',
  12041. 'a141',
  12042. 'a142',
  12043. 'a143',
  12044. 'a144',
  12045. 'a145',
  12046. 'a146',
  12047. 'a147',
  12048. 'a148',
  12049. 'a149',
  12050. 'a150',
  12051. 'a151',
  12052. 'a152',
  12053. 'a153',
  12054. 'a154',
  12055. 'a155',
  12056. 'a156',
  12057. 'a157',
  12058. 'a158',
  12059. 'a159',
  12060. 'a160',
  12061. 'a161',
  12062. 'a163',
  12063. 'a164',
  12064. 'a196',
  12065. 'a165',
  12066. 'a192',
  12067. 'a166',
  12068. 'a167',
  12069. 'a168',
  12070. 'a169',
  12071. 'a170',
  12072. 'a171',
  12073. 'a172',
  12074. 'a173',
  12075. 'a162',
  12076. 'a174',
  12077. 'a175',
  12078. 'a176',
  12079. 'a177',
  12080. 'a178',
  12081. 'a179',
  12082. 'a193',
  12083. 'a180',
  12084. 'a199',
  12085. 'a181',
  12086. 'a200',
  12087. 'a182',
  12088. '',
  12089. 'a201',
  12090. 'a183',
  12091. 'a184',
  12092. 'a197',
  12093. 'a185',
  12094. 'a194',
  12095. 'a198',
  12096. 'a186',
  12097. 'a195',
  12098. 'a187',
  12099. 'a188',
  12100. 'a189',
  12101. 'a190',
  12102. 'a191'
  12103. ];
  12104. function getEncoding(encodingName) {
  12105. switch (encodingName) {
  12106. case 'WinAnsiEncoding':
  12107. return WinAnsiEncoding;
  12108. case 'StandardEncoding':
  12109. return StandardEncoding;
  12110. case 'MacRomanEncoding':
  12111. return MacRomanEncoding;
  12112. case 'SymbolSetEncoding':
  12113. return SymbolSetEncoding;
  12114. case 'ZapfDingbatsEncoding':
  12115. return ZapfDingbatsEncoding;
  12116. case 'ExpertEncoding':
  12117. return ExpertEncoding;
  12118. case 'MacExpertEncoding':
  12119. return MacExpertEncoding;
  12120. default:
  12121. return null;
  12122. }
  12123. }
  12124. exports.WinAnsiEncoding = WinAnsiEncoding;
  12125. exports.StandardEncoding = StandardEncoding;
  12126. exports.MacRomanEncoding = MacRomanEncoding;
  12127. exports.SymbolSetEncoding = SymbolSetEncoding;
  12128. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  12129. exports.ExpertEncoding = ExpertEncoding;
  12130. exports.getEncoding = getEncoding;
  12131. /***/ }),
  12132. /* 6 */
  12133. /***/ (function(module, exports, __w_pdfjs_require__) {
  12134. "use strict";
  12135. var sharedUtil = __w_pdfjs_require__(0);
  12136. var corePrimitives = __w_pdfjs_require__(1);
  12137. var coreStream = __w_pdfjs_require__(2);
  12138. var MissingDataException = sharedUtil.MissingDataException;
  12139. var StreamType = sharedUtil.StreamType;
  12140. var assert = sharedUtil.assert;
  12141. var error = sharedUtil.error;
  12142. var info = sharedUtil.info;
  12143. var isArray = sharedUtil.isArray;
  12144. var isInt = sharedUtil.isInt;
  12145. var isNum = sharedUtil.isNum;
  12146. var isString = sharedUtil.isString;
  12147. var warn = sharedUtil.warn;
  12148. var EOF = corePrimitives.EOF;
  12149. var Cmd = corePrimitives.Cmd;
  12150. var Dict = corePrimitives.Dict;
  12151. var Name = corePrimitives.Name;
  12152. var Ref = corePrimitives.Ref;
  12153. var isEOF = corePrimitives.isEOF;
  12154. var isCmd = corePrimitives.isCmd;
  12155. var isDict = corePrimitives.isDict;
  12156. var isName = corePrimitives.isName;
  12157. var Ascii85Stream = coreStream.Ascii85Stream;
  12158. var AsciiHexStream = coreStream.AsciiHexStream;
  12159. var CCITTFaxStream = coreStream.CCITTFaxStream;
  12160. var FlateStream = coreStream.FlateStream;
  12161. var Jbig2Stream = coreStream.Jbig2Stream;
  12162. var JpegStream = coreStream.JpegStream;
  12163. var JpxStream = coreStream.JpxStream;
  12164. var LZWStream = coreStream.LZWStream;
  12165. var NullStream = coreStream.NullStream;
  12166. var PredictorStream = coreStream.PredictorStream;
  12167. var RunLengthStream = coreStream.RunLengthStream;
  12168. var MAX_LENGTH_TO_CACHE = 1000;
  12169. var Parser = function ParserClosure() {
  12170. function Parser(lexer, allowStreams, xref, recoveryMode) {
  12171. this.lexer = lexer;
  12172. this.allowStreams = allowStreams;
  12173. this.xref = xref;
  12174. this.recoveryMode = recoveryMode || false;
  12175. this.imageCache = Object.create(null);
  12176. this.refill();
  12177. }
  12178. Parser.prototype = {
  12179. refill: function Parser_refill() {
  12180. this.buf1 = this.lexer.getObj();
  12181. this.buf2 = this.lexer.getObj();
  12182. },
  12183. shift: function Parser_shift() {
  12184. if (isCmd(this.buf2, 'ID')) {
  12185. this.buf1 = this.buf2;
  12186. this.buf2 = null;
  12187. } else {
  12188. this.buf1 = this.buf2;
  12189. this.buf2 = this.lexer.getObj();
  12190. }
  12191. },
  12192. tryShift: function Parser_tryShift() {
  12193. try {
  12194. this.shift();
  12195. return true;
  12196. } catch (e) {
  12197. if (e instanceof MissingDataException) {
  12198. throw e;
  12199. }
  12200. return false;
  12201. }
  12202. },
  12203. getObj: function Parser_getObj(cipherTransform) {
  12204. var buf1 = this.buf1;
  12205. this.shift();
  12206. if (buf1 instanceof Cmd) {
  12207. switch (buf1.cmd) {
  12208. case 'BI':
  12209. return this.makeInlineImage(cipherTransform);
  12210. case '[':
  12211. var array = [];
  12212. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  12213. array.push(this.getObj(cipherTransform));
  12214. }
  12215. if (isEOF(this.buf1)) {
  12216. if (!this.recoveryMode) {
  12217. error('End of file inside array');
  12218. }
  12219. return array;
  12220. }
  12221. this.shift();
  12222. return array;
  12223. case '<<':
  12224. var dict = new Dict(this.xref);
  12225. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  12226. if (!isName(this.buf1)) {
  12227. info('Malformed dictionary: key must be a name object');
  12228. this.shift();
  12229. continue;
  12230. }
  12231. var key = this.buf1.name;
  12232. this.shift();
  12233. if (isEOF(this.buf1)) {
  12234. break;
  12235. }
  12236. dict.set(key, this.getObj(cipherTransform));
  12237. }
  12238. if (isEOF(this.buf1)) {
  12239. if (!this.recoveryMode) {
  12240. error('End of file inside dictionary');
  12241. }
  12242. return dict;
  12243. }
  12244. if (isCmd(this.buf2, 'stream')) {
  12245. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  12246. }
  12247. this.shift();
  12248. return dict;
  12249. default:
  12250. return buf1;
  12251. }
  12252. }
  12253. if (isInt(buf1)) {
  12254. var num = buf1;
  12255. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  12256. var ref = new Ref(num, this.buf1);
  12257. this.shift();
  12258. this.shift();
  12259. return ref;
  12260. }
  12261. return num;
  12262. }
  12263. if (isString(buf1)) {
  12264. var str = buf1;
  12265. if (cipherTransform) {
  12266. str = cipherTransform.decryptString(str);
  12267. }
  12268. return str;
  12269. }
  12270. return buf1;
  12271. },
  12272. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  12273. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  12274. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  12275. while ((ch = stream.getByte()) !== -1) {
  12276. if (state === 0) {
  12277. state = ch === E ? 1 : 0;
  12278. } else if (state === 1) {
  12279. state = ch === I ? 2 : 0;
  12280. } else {
  12281. assert(state === 2);
  12282. if (ch === SPACE || ch === LF || ch === CR) {
  12283. n = 5;
  12284. followingBytes = stream.peekBytes(n);
  12285. for (i = 0; i < n; i++) {
  12286. ch = followingBytes[i];
  12287. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  12288. state = 0;
  12289. break;
  12290. }
  12291. }
  12292. if (state === 2) {
  12293. break;
  12294. }
  12295. } else {
  12296. state = 0;
  12297. }
  12298. }
  12299. }
  12300. return stream.pos - 4 - startPos;
  12301. },
  12302. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  12303. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  12304. while ((b = stream.getByte()) !== -1) {
  12305. if (b !== 0xFF) {
  12306. continue;
  12307. }
  12308. switch (stream.getByte()) {
  12309. case 0x00:
  12310. break;
  12311. case 0xFF:
  12312. stream.skip(-1);
  12313. break;
  12314. case 0xD9:
  12315. foundEOI = true;
  12316. break;
  12317. case 0xC0:
  12318. case 0xC1:
  12319. case 0xC2:
  12320. case 0xC3:
  12321. case 0xC5:
  12322. case 0xC6:
  12323. case 0xC7:
  12324. case 0xC9:
  12325. case 0xCA:
  12326. case 0xCB:
  12327. case 0xCD:
  12328. case 0xCE:
  12329. case 0xCF:
  12330. case 0xC4:
  12331. case 0xCC:
  12332. case 0xDA:
  12333. case 0xDB:
  12334. case 0xDC:
  12335. case 0xDD:
  12336. case 0xDE:
  12337. case 0xDF:
  12338. case 0xE0:
  12339. case 0xE1:
  12340. case 0xE2:
  12341. case 0xE3:
  12342. case 0xE4:
  12343. case 0xE5:
  12344. case 0xE6:
  12345. case 0xE7:
  12346. case 0xE8:
  12347. case 0xE9:
  12348. case 0xEA:
  12349. case 0xEB:
  12350. case 0xEC:
  12351. case 0xED:
  12352. case 0xEE:
  12353. case 0xEF:
  12354. case 0xFE:
  12355. markerLength = stream.getUint16();
  12356. if (markerLength > 2) {
  12357. stream.skip(markerLength - 2);
  12358. } else {
  12359. stream.skip(-2);
  12360. }
  12361. break;
  12362. }
  12363. if (foundEOI) {
  12364. break;
  12365. }
  12366. }
  12367. length = stream.pos - startPos;
  12368. if (b === -1) {
  12369. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  12370. stream.skip(-length);
  12371. return this.findDefaultInlineStreamEnd(stream);
  12372. }
  12373. this.inlineStreamSkipEI(stream);
  12374. return length;
  12375. },
  12376. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  12377. var TILDE = 0x7E, GT = 0x3E;
  12378. var startPos = stream.pos, ch, length;
  12379. while ((ch = stream.getByte()) !== -1) {
  12380. if (ch === TILDE && stream.peekByte() === GT) {
  12381. stream.skip();
  12382. break;
  12383. }
  12384. }
  12385. length = stream.pos - startPos;
  12386. if (ch === -1) {
  12387. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12388. stream.skip(-length);
  12389. return this.findDefaultInlineStreamEnd(stream);
  12390. }
  12391. this.inlineStreamSkipEI(stream);
  12392. return length;
  12393. },
  12394. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  12395. var GT = 0x3E;
  12396. var startPos = stream.pos, ch, length;
  12397. while ((ch = stream.getByte()) !== -1) {
  12398. if (ch === GT) {
  12399. break;
  12400. }
  12401. }
  12402. length = stream.pos - startPos;
  12403. if (ch === -1) {
  12404. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12405. stream.skip(-length);
  12406. return this.findDefaultInlineStreamEnd(stream);
  12407. }
  12408. this.inlineStreamSkipEI(stream);
  12409. return length;
  12410. },
  12411. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  12412. var E = 0x45, I = 0x49;
  12413. var state = 0, ch;
  12414. while ((ch = stream.getByte()) !== -1) {
  12415. if (state === 0) {
  12416. state = ch === E ? 1 : 0;
  12417. } else if (state === 1) {
  12418. state = ch === I ? 2 : 0;
  12419. } else if (state === 2) {
  12420. break;
  12421. }
  12422. }
  12423. },
  12424. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  12425. var lexer = this.lexer;
  12426. var stream = lexer.stream;
  12427. var dict = new Dict(this.xref);
  12428. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  12429. if (!isName(this.buf1)) {
  12430. error('Dictionary key must be a name object');
  12431. }
  12432. var key = this.buf1.name;
  12433. this.shift();
  12434. if (isEOF(this.buf1)) {
  12435. break;
  12436. }
  12437. dict.set(key, this.getObj(cipherTransform));
  12438. }
  12439. var filter = dict.get('Filter', 'F'), filterName;
  12440. if (isName(filter)) {
  12441. filterName = filter.name;
  12442. } else if (isArray(filter)) {
  12443. var filterZero = this.xref.fetchIfRef(filter[0]);
  12444. if (isName(filterZero)) {
  12445. filterName = filterZero.name;
  12446. }
  12447. }
  12448. var startPos = stream.pos, length, i, ii;
  12449. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  12450. length = this.findDCTDecodeInlineStreamEnd(stream);
  12451. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  12452. length = this.findASCII85DecodeInlineStreamEnd(stream);
  12453. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  12454. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  12455. } else {
  12456. length = this.findDefaultInlineStreamEnd(stream);
  12457. }
  12458. var imageStream = stream.makeSubStream(startPos, length, dict);
  12459. var adler32;
  12460. if (length < MAX_LENGTH_TO_CACHE) {
  12461. var imageBytes = imageStream.getBytes();
  12462. imageStream.reset();
  12463. var a = 1;
  12464. var b = 0;
  12465. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  12466. a += imageBytes[i] & 0xff;
  12467. b += a;
  12468. }
  12469. adler32 = b % 65521 << 16 | a % 65521;
  12470. if (this.imageCache.adler32 === adler32) {
  12471. this.buf2 = Cmd.get('EI');
  12472. this.shift();
  12473. this.imageCache[adler32].reset();
  12474. return this.imageCache[adler32];
  12475. }
  12476. }
  12477. if (cipherTransform) {
  12478. imageStream = cipherTransform.createStream(imageStream, length);
  12479. }
  12480. imageStream = this.filter(imageStream, dict, length);
  12481. imageStream.dict = dict;
  12482. if (adler32 !== undefined) {
  12483. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  12484. this.imageCache[adler32] = imageStream;
  12485. }
  12486. this.buf2 = Cmd.get('EI');
  12487. this.shift();
  12488. return imageStream;
  12489. },
  12490. makeStream: function Parser_makeStream(dict, cipherTransform) {
  12491. var lexer = this.lexer;
  12492. var stream = lexer.stream;
  12493. lexer.skipToNextLine();
  12494. var pos = stream.pos - 1;
  12495. var length = dict.get('Length');
  12496. if (!isInt(length)) {
  12497. info('Bad ' + length + ' attribute in stream');
  12498. length = 0;
  12499. }
  12500. stream.pos = pos + length;
  12501. lexer.nextChar();
  12502. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  12503. this.shift();
  12504. } else {
  12505. stream.pos = pos;
  12506. var SCAN_BLOCK_SIZE = 2048;
  12507. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  12508. var ENDSTREAM_SIGNATURE = [
  12509. 0x65,
  12510. 0x6E,
  12511. 0x64,
  12512. 0x73,
  12513. 0x74,
  12514. 0x72,
  12515. 0x65,
  12516. 0x61,
  12517. 0x6D
  12518. ];
  12519. var skipped = 0, found = false, i, j;
  12520. while (stream.pos < stream.end) {
  12521. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  12522. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  12523. if (scanLength <= 0) {
  12524. break;
  12525. }
  12526. found = false;
  12527. i = 0;
  12528. while (i < scanLength) {
  12529. j = 0;
  12530. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  12531. j++;
  12532. }
  12533. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  12534. found = true;
  12535. break;
  12536. }
  12537. i++;
  12538. }
  12539. if (found) {
  12540. skipped += i;
  12541. stream.pos += i;
  12542. break;
  12543. }
  12544. skipped += scanLength;
  12545. stream.pos += scanLength;
  12546. }
  12547. if (!found) {
  12548. error('Missing endstream');
  12549. }
  12550. length = skipped;
  12551. lexer.nextChar();
  12552. this.shift();
  12553. this.shift();
  12554. }
  12555. this.shift();
  12556. stream = stream.makeSubStream(pos, length, dict);
  12557. if (cipherTransform) {
  12558. stream = cipherTransform.createStream(stream, length);
  12559. }
  12560. stream = this.filter(stream, dict, length);
  12561. stream.dict = dict;
  12562. return stream;
  12563. },
  12564. filter: function Parser_filter(stream, dict, length) {
  12565. var filter = dict.get('Filter', 'F');
  12566. var params = dict.get('DecodeParms', 'DP');
  12567. if (isName(filter)) {
  12568. if (isArray(params)) {
  12569. params = this.xref.fetchIfRef(params[0]);
  12570. }
  12571. return this.makeFilter(stream, filter.name, length, params);
  12572. }
  12573. var maybeLength = length;
  12574. if (isArray(filter)) {
  12575. var filterArray = filter;
  12576. var paramsArray = params;
  12577. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  12578. filter = this.xref.fetchIfRef(filterArray[i]);
  12579. if (!isName(filter)) {
  12580. error('Bad filter name: ' + filter);
  12581. }
  12582. params = null;
  12583. if (isArray(paramsArray) && i in paramsArray) {
  12584. params = this.xref.fetchIfRef(paramsArray[i]);
  12585. }
  12586. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  12587. maybeLength = null;
  12588. }
  12589. }
  12590. return stream;
  12591. },
  12592. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  12593. if (maybeLength === 0) {
  12594. warn('Empty "' + name + '" stream.');
  12595. return new NullStream(stream);
  12596. }
  12597. try {
  12598. var xrefStreamStats = this.xref.stats.streamTypes;
  12599. if (name === 'FlateDecode' || name === 'Fl') {
  12600. xrefStreamStats[StreamType.FLATE] = true;
  12601. if (params) {
  12602. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  12603. }
  12604. return new FlateStream(stream, maybeLength);
  12605. }
  12606. if (name === 'LZWDecode' || name === 'LZW') {
  12607. xrefStreamStats[StreamType.LZW] = true;
  12608. var earlyChange = 1;
  12609. if (params) {
  12610. if (params.has('EarlyChange')) {
  12611. earlyChange = params.get('EarlyChange');
  12612. }
  12613. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  12614. }
  12615. return new LZWStream(stream, maybeLength, earlyChange);
  12616. }
  12617. if (name === 'DCTDecode' || name === 'DCT') {
  12618. xrefStreamStats[StreamType.DCT] = true;
  12619. return new JpegStream(stream, maybeLength, stream.dict, params);
  12620. }
  12621. if (name === 'JPXDecode' || name === 'JPX') {
  12622. xrefStreamStats[StreamType.JPX] = true;
  12623. return new JpxStream(stream, maybeLength, stream.dict, params);
  12624. }
  12625. if (name === 'ASCII85Decode' || name === 'A85') {
  12626. xrefStreamStats[StreamType.A85] = true;
  12627. return new Ascii85Stream(stream, maybeLength);
  12628. }
  12629. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  12630. xrefStreamStats[StreamType.AHX] = true;
  12631. return new AsciiHexStream(stream, maybeLength);
  12632. }
  12633. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  12634. xrefStreamStats[StreamType.CCF] = true;
  12635. return new CCITTFaxStream(stream, maybeLength, params);
  12636. }
  12637. if (name === 'RunLengthDecode' || name === 'RL') {
  12638. xrefStreamStats[StreamType.RL] = true;
  12639. return new RunLengthStream(stream, maybeLength);
  12640. }
  12641. if (name === 'JBIG2Decode') {
  12642. xrefStreamStats[StreamType.JBIG] = true;
  12643. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  12644. }
  12645. warn('filter "' + name + '" not supported yet');
  12646. return stream;
  12647. } catch (ex) {
  12648. if (ex instanceof MissingDataException) {
  12649. throw ex;
  12650. }
  12651. warn('Invalid stream: \"' + ex + '\"');
  12652. return new NullStream(stream);
  12653. }
  12654. }
  12655. };
  12656. return Parser;
  12657. }();
  12658. var Lexer = function LexerClosure() {
  12659. function Lexer(stream, knownCommands) {
  12660. this.stream = stream;
  12661. this.nextChar();
  12662. this.strBuf = [];
  12663. this.knownCommands = knownCommands;
  12664. }
  12665. var specialChars = [
  12666. 1,
  12667. 0,
  12668. 0,
  12669. 0,
  12670. 0,
  12671. 0,
  12672. 0,
  12673. 0,
  12674. 0,
  12675. 1,
  12676. 1,
  12677. 0,
  12678. 1,
  12679. 1,
  12680. 0,
  12681. 0,
  12682. 0,
  12683. 0,
  12684. 0,
  12685. 0,
  12686. 0,
  12687. 0,
  12688. 0,
  12689. 0,
  12690. 0,
  12691. 0,
  12692. 0,
  12693. 0,
  12694. 0,
  12695. 0,
  12696. 0,
  12697. 0,
  12698. 1,
  12699. 0,
  12700. 0,
  12701. 0,
  12702. 0,
  12703. 2,
  12704. 0,
  12705. 0,
  12706. 2,
  12707. 2,
  12708. 0,
  12709. 0,
  12710. 0,
  12711. 0,
  12712. 0,
  12713. 2,
  12714. 0,
  12715. 0,
  12716. 0,
  12717. 0,
  12718. 0,
  12719. 0,
  12720. 0,
  12721. 0,
  12722. 0,
  12723. 0,
  12724. 0,
  12725. 0,
  12726. 2,
  12727. 0,
  12728. 2,
  12729. 0,
  12730. 0,
  12731. 0,
  12732. 0,
  12733. 0,
  12734. 0,
  12735. 0,
  12736. 0,
  12737. 0,
  12738. 0,
  12739. 0,
  12740. 0,
  12741. 0,
  12742. 0,
  12743. 0,
  12744. 0,
  12745. 0,
  12746. 0,
  12747. 0,
  12748. 0,
  12749. 0,
  12750. 0,
  12751. 0,
  12752. 0,
  12753. 0,
  12754. 0,
  12755. 0,
  12756. 0,
  12757. 2,
  12758. 0,
  12759. 2,
  12760. 0,
  12761. 0,
  12762. 0,
  12763. 0,
  12764. 0,
  12765. 0,
  12766. 0,
  12767. 0,
  12768. 0,
  12769. 0,
  12770. 0,
  12771. 0,
  12772. 0,
  12773. 0,
  12774. 0,
  12775. 0,
  12776. 0,
  12777. 0,
  12778. 0,
  12779. 0,
  12780. 0,
  12781. 0,
  12782. 0,
  12783. 0,
  12784. 0,
  12785. 0,
  12786. 0,
  12787. 0,
  12788. 0,
  12789. 2,
  12790. 0,
  12791. 2,
  12792. 0,
  12793. 0,
  12794. 0,
  12795. 0,
  12796. 0,
  12797. 0,
  12798. 0,
  12799. 0,
  12800. 0,
  12801. 0,
  12802. 0,
  12803. 0,
  12804. 0,
  12805. 0,
  12806. 0,
  12807. 0,
  12808. 0,
  12809. 0,
  12810. 0,
  12811. 0,
  12812. 0,
  12813. 0,
  12814. 0,
  12815. 0,
  12816. 0,
  12817. 0,
  12818. 0,
  12819. 0,
  12820. 0,
  12821. 0,
  12822. 0,
  12823. 0,
  12824. 0,
  12825. 0,
  12826. 0,
  12827. 0,
  12828. 0,
  12829. 0,
  12830. 0,
  12831. 0,
  12832. 0,
  12833. 0,
  12834. 0,
  12835. 0,
  12836. 0,
  12837. 0,
  12838. 0,
  12839. 0,
  12840. 0,
  12841. 0,
  12842. 0,
  12843. 0,
  12844. 0,
  12845. 0,
  12846. 0,
  12847. 0,
  12848. 0,
  12849. 0,
  12850. 0,
  12851. 0,
  12852. 0,
  12853. 0,
  12854. 0,
  12855. 0,
  12856. 0,
  12857. 0,
  12858. 0,
  12859. 0,
  12860. 0,
  12861. 0,
  12862. 0,
  12863. 0,
  12864. 0,
  12865. 0,
  12866. 0,
  12867. 0,
  12868. 0,
  12869. 0,
  12870. 0,
  12871. 0,
  12872. 0,
  12873. 0,
  12874. 0,
  12875. 0,
  12876. 0,
  12877. 0,
  12878. 0,
  12879. 0,
  12880. 0,
  12881. 0,
  12882. 0,
  12883. 0,
  12884. 0,
  12885. 0,
  12886. 0,
  12887. 0,
  12888. 0,
  12889. 0,
  12890. 0,
  12891. 0,
  12892. 0,
  12893. 0,
  12894. 0,
  12895. 0,
  12896. 0,
  12897. 0,
  12898. 0,
  12899. 0,
  12900. 0,
  12901. 0,
  12902. 0,
  12903. 0,
  12904. 0,
  12905. 0,
  12906. 0,
  12907. 0,
  12908. 0,
  12909. 0,
  12910. 0,
  12911. 0,
  12912. 0,
  12913. 0,
  12914. 0,
  12915. 0,
  12916. 0,
  12917. 0,
  12918. 0,
  12919. 0,
  12920. 0,
  12921. 0
  12922. ];
  12923. function toHexDigit(ch) {
  12924. if (ch >= 0x30 && ch <= 0x39) {
  12925. return ch & 0x0F;
  12926. }
  12927. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12928. return (ch & 0x0F) + 9;
  12929. }
  12930. return -1;
  12931. }
  12932. Lexer.prototype = {
  12933. nextChar: function Lexer_nextChar() {
  12934. return this.currentChar = this.stream.getByte();
  12935. },
  12936. peekChar: function Lexer_peekChar() {
  12937. return this.stream.peekByte();
  12938. },
  12939. getNumber: function Lexer_getNumber() {
  12940. var ch = this.currentChar;
  12941. var eNotation = false;
  12942. var divideBy = 0;
  12943. var sign = 1;
  12944. if (ch === 0x2D) {
  12945. sign = -1;
  12946. ch = this.nextChar();
  12947. if (ch === 0x2D) {
  12948. ch = this.nextChar();
  12949. }
  12950. } else if (ch === 0x2B) {
  12951. ch = this.nextChar();
  12952. }
  12953. if (ch === 0x2E) {
  12954. divideBy = 10;
  12955. ch = this.nextChar();
  12956. }
  12957. if (ch < 0x30 || ch > 0x39) {
  12958. error('Invalid number: ' + String.fromCharCode(ch));
  12959. return 0;
  12960. }
  12961. var baseValue = ch - 0x30;
  12962. var powerValue = 0;
  12963. var powerValueSign = 1;
  12964. while ((ch = this.nextChar()) >= 0) {
  12965. if (0x30 <= ch && ch <= 0x39) {
  12966. var currentDigit = ch - 0x30;
  12967. if (eNotation) {
  12968. powerValue = powerValue * 10 + currentDigit;
  12969. } else {
  12970. if (divideBy !== 0) {
  12971. divideBy *= 10;
  12972. }
  12973. baseValue = baseValue * 10 + currentDigit;
  12974. }
  12975. } else if (ch === 0x2E) {
  12976. if (divideBy === 0) {
  12977. divideBy = 1;
  12978. } else {
  12979. break;
  12980. }
  12981. } else if (ch === 0x2D) {
  12982. warn('Badly formatted number');
  12983. } else if (ch === 0x45 || ch === 0x65) {
  12984. ch = this.peekChar();
  12985. if (ch === 0x2B || ch === 0x2D) {
  12986. powerValueSign = ch === 0x2D ? -1 : 1;
  12987. this.nextChar();
  12988. } else if (ch < 0x30 || ch > 0x39) {
  12989. break;
  12990. }
  12991. eNotation = true;
  12992. } else {
  12993. break;
  12994. }
  12995. }
  12996. if (divideBy !== 0) {
  12997. baseValue /= divideBy;
  12998. }
  12999. if (eNotation) {
  13000. baseValue *= Math.pow(10, powerValueSign * powerValue);
  13001. }
  13002. return sign * baseValue;
  13003. },
  13004. getString: function Lexer_getString() {
  13005. var numParen = 1;
  13006. var done = false;
  13007. var strBuf = this.strBuf;
  13008. strBuf.length = 0;
  13009. var ch = this.nextChar();
  13010. while (true) {
  13011. var charBuffered = false;
  13012. switch (ch | 0) {
  13013. case -1:
  13014. warn('Unterminated string');
  13015. done = true;
  13016. break;
  13017. case 0x28:
  13018. ++numParen;
  13019. strBuf.push('(');
  13020. break;
  13021. case 0x29:
  13022. if (--numParen === 0) {
  13023. this.nextChar();
  13024. done = true;
  13025. } else {
  13026. strBuf.push(')');
  13027. }
  13028. break;
  13029. case 0x5C:
  13030. ch = this.nextChar();
  13031. switch (ch) {
  13032. case -1:
  13033. warn('Unterminated string');
  13034. done = true;
  13035. break;
  13036. case 0x6E:
  13037. strBuf.push('\n');
  13038. break;
  13039. case 0x72:
  13040. strBuf.push('\r');
  13041. break;
  13042. case 0x74:
  13043. strBuf.push('\t');
  13044. break;
  13045. case 0x62:
  13046. strBuf.push('\b');
  13047. break;
  13048. case 0x66:
  13049. strBuf.push('\f');
  13050. break;
  13051. case 0x5C:
  13052. case 0x28:
  13053. case 0x29:
  13054. strBuf.push(String.fromCharCode(ch));
  13055. break;
  13056. case 0x30:
  13057. case 0x31:
  13058. case 0x32:
  13059. case 0x33:
  13060. case 0x34:
  13061. case 0x35:
  13062. case 0x36:
  13063. case 0x37:
  13064. var x = ch & 0x0F;
  13065. ch = this.nextChar();
  13066. charBuffered = true;
  13067. if (ch >= 0x30 && ch <= 0x37) {
  13068. x = (x << 3) + (ch & 0x0F);
  13069. ch = this.nextChar();
  13070. if (ch >= 0x30 && ch <= 0x37) {
  13071. charBuffered = false;
  13072. x = (x << 3) + (ch & 0x0F);
  13073. }
  13074. }
  13075. strBuf.push(String.fromCharCode(x));
  13076. break;
  13077. case 0x0D:
  13078. if (this.peekChar() === 0x0A) {
  13079. this.nextChar();
  13080. }
  13081. break;
  13082. case 0x0A:
  13083. break;
  13084. default:
  13085. strBuf.push(String.fromCharCode(ch));
  13086. break;
  13087. }
  13088. break;
  13089. default:
  13090. strBuf.push(String.fromCharCode(ch));
  13091. break;
  13092. }
  13093. if (done) {
  13094. break;
  13095. }
  13096. if (!charBuffered) {
  13097. ch = this.nextChar();
  13098. }
  13099. }
  13100. return strBuf.join('');
  13101. },
  13102. getName: function Lexer_getName() {
  13103. var ch, previousCh;
  13104. var strBuf = this.strBuf;
  13105. strBuf.length = 0;
  13106. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13107. if (ch === 0x23) {
  13108. ch = this.nextChar();
  13109. if (specialChars[ch]) {
  13110. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  13111. strBuf.push('#');
  13112. break;
  13113. }
  13114. var x = toHexDigit(ch);
  13115. if (x !== -1) {
  13116. previousCh = ch;
  13117. ch = this.nextChar();
  13118. var x2 = toHexDigit(ch);
  13119. if (x2 === -1) {
  13120. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  13121. strBuf.push('#', String.fromCharCode(previousCh));
  13122. if (specialChars[ch]) {
  13123. break;
  13124. }
  13125. strBuf.push(String.fromCharCode(ch));
  13126. continue;
  13127. }
  13128. strBuf.push(String.fromCharCode(x << 4 | x2));
  13129. } else {
  13130. strBuf.push('#', String.fromCharCode(ch));
  13131. }
  13132. } else {
  13133. strBuf.push(String.fromCharCode(ch));
  13134. }
  13135. }
  13136. if (strBuf.length > 127) {
  13137. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  13138. }
  13139. return Name.get(strBuf.join(''));
  13140. },
  13141. getHexString: function Lexer_getHexString() {
  13142. var strBuf = this.strBuf;
  13143. strBuf.length = 0;
  13144. var ch = this.currentChar;
  13145. var isFirstHex = true;
  13146. var firstDigit;
  13147. var secondDigit;
  13148. while (true) {
  13149. if (ch < 0) {
  13150. warn('Unterminated hex string');
  13151. break;
  13152. } else if (ch === 0x3E) {
  13153. this.nextChar();
  13154. break;
  13155. } else if (specialChars[ch] === 1) {
  13156. ch = this.nextChar();
  13157. continue;
  13158. } else {
  13159. if (isFirstHex) {
  13160. firstDigit = toHexDigit(ch);
  13161. if (firstDigit === -1) {
  13162. warn('Ignoring invalid character "' + ch + '" in hex string');
  13163. ch = this.nextChar();
  13164. continue;
  13165. }
  13166. } else {
  13167. secondDigit = toHexDigit(ch);
  13168. if (secondDigit === -1) {
  13169. warn('Ignoring invalid character "' + ch + '" in hex string');
  13170. ch = this.nextChar();
  13171. continue;
  13172. }
  13173. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  13174. }
  13175. isFirstHex = !isFirstHex;
  13176. ch = this.nextChar();
  13177. }
  13178. }
  13179. return strBuf.join('');
  13180. },
  13181. getObj: function Lexer_getObj() {
  13182. var comment = false;
  13183. var ch = this.currentChar;
  13184. while (true) {
  13185. if (ch < 0) {
  13186. return EOF;
  13187. }
  13188. if (comment) {
  13189. if (ch === 0x0A || ch === 0x0D) {
  13190. comment = false;
  13191. }
  13192. } else if (ch === 0x25) {
  13193. comment = true;
  13194. } else if (specialChars[ch] !== 1) {
  13195. break;
  13196. }
  13197. ch = this.nextChar();
  13198. }
  13199. switch (ch | 0) {
  13200. case 0x30:
  13201. case 0x31:
  13202. case 0x32:
  13203. case 0x33:
  13204. case 0x34:
  13205. case 0x35:
  13206. case 0x36:
  13207. case 0x37:
  13208. case 0x38:
  13209. case 0x39:
  13210. case 0x2B:
  13211. case 0x2D:
  13212. case 0x2E:
  13213. return this.getNumber();
  13214. case 0x28:
  13215. return this.getString();
  13216. case 0x2F:
  13217. return this.getName();
  13218. case 0x5B:
  13219. this.nextChar();
  13220. return Cmd.get('[');
  13221. case 0x5D:
  13222. this.nextChar();
  13223. return Cmd.get(']');
  13224. case 0x3C:
  13225. ch = this.nextChar();
  13226. if (ch === 0x3C) {
  13227. this.nextChar();
  13228. return Cmd.get('<<');
  13229. }
  13230. return this.getHexString();
  13231. case 0x3E:
  13232. ch = this.nextChar();
  13233. if (ch === 0x3E) {
  13234. this.nextChar();
  13235. return Cmd.get('>>');
  13236. }
  13237. return Cmd.get('>');
  13238. case 0x7B:
  13239. this.nextChar();
  13240. return Cmd.get('{');
  13241. case 0x7D:
  13242. this.nextChar();
  13243. return Cmd.get('}');
  13244. case 0x29:
  13245. this.nextChar();
  13246. error('Illegal character: ' + ch);
  13247. break;
  13248. }
  13249. var str = String.fromCharCode(ch);
  13250. var knownCommands = this.knownCommands;
  13251. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13252. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13253. var possibleCommand = str + String.fromCharCode(ch);
  13254. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13255. break;
  13256. }
  13257. if (str.length === 128) {
  13258. error('Command token too long: ' + str.length);
  13259. }
  13260. str = possibleCommand;
  13261. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13262. }
  13263. if (str === 'true') {
  13264. return true;
  13265. }
  13266. if (str === 'false') {
  13267. return false;
  13268. }
  13269. if (str === 'null') {
  13270. return null;
  13271. }
  13272. return Cmd.get(str);
  13273. },
  13274. skipToNextLine: function Lexer_skipToNextLine() {
  13275. var ch = this.currentChar;
  13276. while (ch >= 0) {
  13277. if (ch === 0x0D) {
  13278. ch = this.nextChar();
  13279. if (ch === 0x0A) {
  13280. this.nextChar();
  13281. }
  13282. break;
  13283. } else if (ch === 0x0A) {
  13284. this.nextChar();
  13285. break;
  13286. }
  13287. ch = this.nextChar();
  13288. }
  13289. }
  13290. };
  13291. return Lexer;
  13292. }();
  13293. var Linearization = {
  13294. create: function LinearizationCreate(stream) {
  13295. function getInt(name, allowZeroValue) {
  13296. var obj = linDict.get(name);
  13297. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13298. return obj;
  13299. }
  13300. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13301. }
  13302. function getHints() {
  13303. var hints = linDict.get('H'), hintsLength, item;
  13304. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13305. for (var index = 0; index < hintsLength; index++) {
  13306. if (!(isInt(item = hints[index]) && item > 0)) {
  13307. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13308. }
  13309. }
  13310. return hints;
  13311. }
  13312. throw new Error('Hint array in the linearization dictionary is invalid.');
  13313. }
  13314. var parser = new Parser(new Lexer(stream), false, null);
  13315. var obj1 = parser.getObj();
  13316. var obj2 = parser.getObj();
  13317. var obj3 = parser.getObj();
  13318. var linDict = parser.getObj();
  13319. var obj, length;
  13320. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13321. return null;
  13322. } else if ((length = getInt('L')) !== stream.length) {
  13323. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13324. }
  13325. return {
  13326. length: length,
  13327. hints: getHints(),
  13328. objectNumberFirst: getInt('O'),
  13329. endFirst: getInt('E'),
  13330. numPages: getInt('N'),
  13331. mainXRefEntriesOffset: getInt('T'),
  13332. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13333. };
  13334. }
  13335. };
  13336. exports.Lexer = Lexer;
  13337. exports.Linearization = Linearization;
  13338. exports.Parser = Parser;
  13339. /***/ }),
  13340. /* 7 */
  13341. /***/ (function(module, exports, __w_pdfjs_require__) {
  13342. "use strict";
  13343. var sharedUtil = __w_pdfjs_require__(0);
  13344. var corePrimitives = __w_pdfjs_require__(1);
  13345. var corePsParser = __w_pdfjs_require__(43);
  13346. var error = sharedUtil.error;
  13347. var info = sharedUtil.info;
  13348. var isArray = sharedUtil.isArray;
  13349. var isBool = sharedUtil.isBool;
  13350. var isDict = corePrimitives.isDict;
  13351. var isStream = corePrimitives.isStream;
  13352. var PostScriptLexer = corePsParser.PostScriptLexer;
  13353. var PostScriptParser = corePsParser.PostScriptParser;
  13354. var PDFFunction = function PDFFunctionClosure() {
  13355. var CONSTRUCT_SAMPLED = 0;
  13356. var CONSTRUCT_INTERPOLATED = 2;
  13357. var CONSTRUCT_STICHED = 3;
  13358. var CONSTRUCT_POSTSCRIPT = 4;
  13359. return {
  13360. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13361. var i, ii;
  13362. var length = 1;
  13363. for (i = 0, ii = size.length; i < ii; i++) {
  13364. length *= size[i];
  13365. }
  13366. length *= outputSize;
  13367. var array = new Array(length);
  13368. var codeSize = 0;
  13369. var codeBuf = 0;
  13370. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13371. var strBytes = str.getBytes((length * bps + 7) / 8);
  13372. var strIdx = 0;
  13373. for (i = 0; i < length; i++) {
  13374. while (codeSize < bps) {
  13375. codeBuf <<= 8;
  13376. codeBuf |= strBytes[strIdx++];
  13377. codeSize += 8;
  13378. }
  13379. codeSize -= bps;
  13380. array[i] = (codeBuf >> codeSize) * sampleMul;
  13381. codeBuf &= (1 << codeSize) - 1;
  13382. }
  13383. return array;
  13384. },
  13385. getIR: function PDFFunction_getIR(xref, fn) {
  13386. var dict = fn.dict;
  13387. if (!dict) {
  13388. dict = fn;
  13389. }
  13390. var types = [
  13391. this.constructSampled,
  13392. null,
  13393. this.constructInterpolated,
  13394. this.constructStiched,
  13395. this.constructPostScript
  13396. ];
  13397. var typeNum = dict.get('FunctionType');
  13398. var typeFn = types[typeNum];
  13399. if (!typeFn) {
  13400. error('Unknown type of function');
  13401. }
  13402. return typeFn.call(this, fn, dict, xref);
  13403. },
  13404. fromIR: function PDFFunction_fromIR(IR) {
  13405. var type = IR[0];
  13406. switch (type) {
  13407. case CONSTRUCT_SAMPLED:
  13408. return this.constructSampledFromIR(IR);
  13409. case CONSTRUCT_INTERPOLATED:
  13410. return this.constructInterpolatedFromIR(IR);
  13411. case CONSTRUCT_STICHED:
  13412. return this.constructStichedFromIR(IR);
  13413. default:
  13414. return this.constructPostScriptFromIR(IR);
  13415. }
  13416. },
  13417. parse: function PDFFunction_parse(xref, fn) {
  13418. var IR = this.getIR(xref, fn);
  13419. return this.fromIR(IR);
  13420. },
  13421. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13422. if (!isArray(fnObj)) {
  13423. return this.parse(xref, fnObj);
  13424. }
  13425. var fnArray = [];
  13426. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13427. var obj = xref.fetchIfRef(fnObj[j]);
  13428. fnArray.push(PDFFunction.parse(xref, obj));
  13429. }
  13430. return function (src, srcOffset, dest, destOffset) {
  13431. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13432. fnArray[i](src, srcOffset, dest, destOffset + i);
  13433. }
  13434. };
  13435. },
  13436. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13437. function toMultiArray(arr) {
  13438. var inputLength = arr.length;
  13439. var out = [];
  13440. var index = 0;
  13441. for (var i = 0; i < inputLength; i += 2) {
  13442. out[index] = [
  13443. arr[i],
  13444. arr[i + 1]
  13445. ];
  13446. ++index;
  13447. }
  13448. return out;
  13449. }
  13450. var domain = dict.getArray('Domain');
  13451. var range = dict.getArray('Range');
  13452. if (!domain || !range) {
  13453. error('No domain or range');
  13454. }
  13455. var inputSize = domain.length / 2;
  13456. var outputSize = range.length / 2;
  13457. domain = toMultiArray(domain);
  13458. range = toMultiArray(range);
  13459. var size = dict.get('Size');
  13460. var bps = dict.get('BitsPerSample');
  13461. var order = dict.get('Order') || 1;
  13462. if (order !== 1) {
  13463. info('No support for cubic spline interpolation: ' + order);
  13464. }
  13465. var encode = dict.getArray('Encode');
  13466. if (!encode) {
  13467. encode = [];
  13468. for (var i = 0; i < inputSize; ++i) {
  13469. encode.push(0);
  13470. encode.push(size[i] - 1);
  13471. }
  13472. }
  13473. encode = toMultiArray(encode);
  13474. var decode = dict.getArray('Decode');
  13475. if (!decode) {
  13476. decode = range;
  13477. } else {
  13478. decode = toMultiArray(decode);
  13479. }
  13480. var samples = this.getSampleArray(size, outputSize, bps, str);
  13481. return [
  13482. CONSTRUCT_SAMPLED,
  13483. inputSize,
  13484. domain,
  13485. encode,
  13486. decode,
  13487. samples,
  13488. size,
  13489. outputSize,
  13490. Math.pow(2, bps) - 1,
  13491. range
  13492. ];
  13493. },
  13494. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13495. function interpolate(x, xmin, xmax, ymin, ymax) {
  13496. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13497. }
  13498. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13499. var m = IR[1];
  13500. var domain = IR[2];
  13501. var encode = IR[3];
  13502. var decode = IR[4];
  13503. var samples = IR[5];
  13504. var size = IR[6];
  13505. var n = IR[7];
  13506. var range = IR[9];
  13507. var cubeVertices = 1 << m;
  13508. var cubeN = new Float64Array(cubeVertices);
  13509. var cubeVertex = new Uint32Array(cubeVertices);
  13510. var i, j;
  13511. for (j = 0; j < cubeVertices; j++) {
  13512. cubeN[j] = 1;
  13513. }
  13514. var k = n, pos = 1;
  13515. for (i = 0; i < m; ++i) {
  13516. var domain_2i = domain[i][0];
  13517. var domain_2i_1 = domain[i][1];
  13518. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13519. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13520. var size_i = size[i];
  13521. e = Math.min(Math.max(e, 0), size_i - 1);
  13522. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13523. var n0 = e0 + 1 - e;
  13524. var n1 = e - e0;
  13525. var offset0 = e0 * k;
  13526. var offset1 = offset0 + k;
  13527. for (j = 0; j < cubeVertices; j++) {
  13528. if (j & pos) {
  13529. cubeN[j] *= n1;
  13530. cubeVertex[j] += offset1;
  13531. } else {
  13532. cubeN[j] *= n0;
  13533. cubeVertex[j] += offset0;
  13534. }
  13535. }
  13536. k *= size_i;
  13537. pos <<= 1;
  13538. }
  13539. for (j = 0; j < n; ++j) {
  13540. var rj = 0;
  13541. for (i = 0; i < cubeVertices; i++) {
  13542. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13543. }
  13544. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13545. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13546. }
  13547. };
  13548. },
  13549. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13550. var c0 = dict.getArray('C0') || [0];
  13551. var c1 = dict.getArray('C1') || [1];
  13552. var n = dict.get('N');
  13553. if (!isArray(c0) || !isArray(c1)) {
  13554. error('Illegal dictionary for interpolated function');
  13555. }
  13556. var length = c0.length;
  13557. var diff = [];
  13558. for (var i = 0; i < length; ++i) {
  13559. diff.push(c1[i] - c0[i]);
  13560. }
  13561. return [
  13562. CONSTRUCT_INTERPOLATED,
  13563. c0,
  13564. diff,
  13565. n
  13566. ];
  13567. },
  13568. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13569. var c0 = IR[1];
  13570. var diff = IR[2];
  13571. var n = IR[3];
  13572. var length = diff.length;
  13573. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13574. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13575. for (var j = 0; j < length; ++j) {
  13576. dest[destOffset + j] = c0[j] + x * diff[j];
  13577. }
  13578. };
  13579. },
  13580. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13581. var domain = dict.getArray('Domain');
  13582. if (!domain) {
  13583. error('No domain');
  13584. }
  13585. var inputSize = domain.length / 2;
  13586. if (inputSize !== 1) {
  13587. error('Bad domain for stiched function');
  13588. }
  13589. var fnRefs = dict.get('Functions');
  13590. var fns = [];
  13591. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13592. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13593. }
  13594. var bounds = dict.getArray('Bounds');
  13595. var encode = dict.getArray('Encode');
  13596. return [
  13597. CONSTRUCT_STICHED,
  13598. domain,
  13599. bounds,
  13600. encode,
  13601. fns
  13602. ];
  13603. },
  13604. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13605. var domain = IR[1];
  13606. var bounds = IR[2];
  13607. var encode = IR[3];
  13608. var fnsIR = IR[4];
  13609. var fns = [];
  13610. var tmpBuf = new Float32Array(1);
  13611. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13612. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13613. }
  13614. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13615. var clip = function constructStichedFromIRClip(v, min, max) {
  13616. if (v > max) {
  13617. v = max;
  13618. } else if (v < min) {
  13619. v = min;
  13620. }
  13621. return v;
  13622. };
  13623. var v = clip(src[srcOffset], domain[0], domain[1]);
  13624. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13625. if (v < bounds[i]) {
  13626. break;
  13627. }
  13628. }
  13629. var dmin = domain[0];
  13630. if (i > 0) {
  13631. dmin = bounds[i - 1];
  13632. }
  13633. var dmax = domain[1];
  13634. if (i < bounds.length) {
  13635. dmax = bounds[i];
  13636. }
  13637. var rmin = encode[2 * i];
  13638. var rmax = encode[2 * i + 1];
  13639. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13640. fns[i](tmpBuf, 0, dest, destOffset);
  13641. };
  13642. },
  13643. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13644. var domain = dict.getArray('Domain');
  13645. var range = dict.getArray('Range');
  13646. if (!domain) {
  13647. error('No domain.');
  13648. }
  13649. if (!range) {
  13650. error('No range.');
  13651. }
  13652. var lexer = new PostScriptLexer(fn);
  13653. var parser = new PostScriptParser(lexer);
  13654. var code = parser.parse();
  13655. return [
  13656. CONSTRUCT_POSTSCRIPT,
  13657. domain,
  13658. range,
  13659. code
  13660. ];
  13661. },
  13662. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13663. var domain = IR[1];
  13664. var range = IR[2];
  13665. var code = IR[3];
  13666. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13667. if (compiled) {
  13668. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13669. }
  13670. info('Unable to compile PS function');
  13671. var numOutputs = range.length >> 1;
  13672. var numInputs = domain.length >> 1;
  13673. var evaluator = new PostScriptEvaluator(code);
  13674. var cache = Object.create(null);
  13675. var MAX_CACHE_SIZE = 2048 * 4;
  13676. var cache_available = MAX_CACHE_SIZE;
  13677. var tmpBuf = new Float32Array(numInputs);
  13678. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13679. var i, value;
  13680. var key = '';
  13681. var input = tmpBuf;
  13682. for (i = 0; i < numInputs; i++) {
  13683. value = src[srcOffset + i];
  13684. input[i] = value;
  13685. key += value + '_';
  13686. }
  13687. var cachedValue = cache[key];
  13688. if (cachedValue !== undefined) {
  13689. dest.set(cachedValue, destOffset);
  13690. return;
  13691. }
  13692. var output = new Float32Array(numOutputs);
  13693. var stack = evaluator.execute(input);
  13694. var stackIndex = stack.length - numOutputs;
  13695. for (i = 0; i < numOutputs; i++) {
  13696. value = stack[stackIndex + i];
  13697. var bound = range[i * 2];
  13698. if (value < bound) {
  13699. value = bound;
  13700. } else {
  13701. bound = range[i * 2 + 1];
  13702. if (value > bound) {
  13703. value = bound;
  13704. }
  13705. }
  13706. output[i] = value;
  13707. }
  13708. if (cache_available > 0) {
  13709. cache_available--;
  13710. cache[key] = output;
  13711. }
  13712. dest.set(output, destOffset);
  13713. };
  13714. }
  13715. };
  13716. }();
  13717. function isPDFFunction(v) {
  13718. var fnDict;
  13719. if (typeof v !== 'object') {
  13720. return false;
  13721. } else if (isDict(v)) {
  13722. fnDict = v;
  13723. } else if (isStream(v)) {
  13724. fnDict = v.dict;
  13725. } else {
  13726. return false;
  13727. }
  13728. return fnDict.has('FunctionType');
  13729. }
  13730. var PostScriptStack = function PostScriptStackClosure() {
  13731. var MAX_STACK_SIZE = 100;
  13732. function PostScriptStack(initialStack) {
  13733. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13734. }
  13735. PostScriptStack.prototype = {
  13736. push: function PostScriptStack_push(value) {
  13737. if (this.stack.length >= MAX_STACK_SIZE) {
  13738. error('PostScript function stack overflow.');
  13739. }
  13740. this.stack.push(value);
  13741. },
  13742. pop: function PostScriptStack_pop() {
  13743. if (this.stack.length <= 0) {
  13744. error('PostScript function stack underflow.');
  13745. }
  13746. return this.stack.pop();
  13747. },
  13748. copy: function PostScriptStack_copy(n) {
  13749. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13750. error('PostScript function stack overflow.');
  13751. }
  13752. var stack = this.stack;
  13753. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13754. stack.push(stack[i]);
  13755. }
  13756. },
  13757. index: function PostScriptStack_index(n) {
  13758. this.push(this.stack[this.stack.length - n - 1]);
  13759. },
  13760. roll: function PostScriptStack_roll(n, p) {
  13761. var stack = this.stack;
  13762. var l = stack.length - n;
  13763. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13764. for (i = l, j = r; i < j; i++, j--) {
  13765. t = stack[i];
  13766. stack[i] = stack[j];
  13767. stack[j] = t;
  13768. }
  13769. for (i = l, j = c - 1; i < j; i++, j--) {
  13770. t = stack[i];
  13771. stack[i] = stack[j];
  13772. stack[j] = t;
  13773. }
  13774. for (i = c, j = r; i < j; i++, j--) {
  13775. t = stack[i];
  13776. stack[i] = stack[j];
  13777. stack[j] = t;
  13778. }
  13779. }
  13780. };
  13781. return PostScriptStack;
  13782. }();
  13783. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13784. function PostScriptEvaluator(operators) {
  13785. this.operators = operators;
  13786. }
  13787. PostScriptEvaluator.prototype = {
  13788. execute: function PostScriptEvaluator_execute(initialStack) {
  13789. var stack = new PostScriptStack(initialStack);
  13790. var counter = 0;
  13791. var operators = this.operators;
  13792. var length = operators.length;
  13793. var operator, a, b;
  13794. while (counter < length) {
  13795. operator = operators[counter++];
  13796. if (typeof operator === 'number') {
  13797. stack.push(operator);
  13798. continue;
  13799. }
  13800. switch (operator) {
  13801. case 'jz':
  13802. b = stack.pop();
  13803. a = stack.pop();
  13804. if (!a) {
  13805. counter = b;
  13806. }
  13807. break;
  13808. case 'j':
  13809. a = stack.pop();
  13810. counter = a;
  13811. break;
  13812. case 'abs':
  13813. a = stack.pop();
  13814. stack.push(Math.abs(a));
  13815. break;
  13816. case 'add':
  13817. b = stack.pop();
  13818. a = stack.pop();
  13819. stack.push(a + b);
  13820. break;
  13821. case 'and':
  13822. b = stack.pop();
  13823. a = stack.pop();
  13824. if (isBool(a) && isBool(b)) {
  13825. stack.push(a && b);
  13826. } else {
  13827. stack.push(a & b);
  13828. }
  13829. break;
  13830. case 'atan':
  13831. a = stack.pop();
  13832. stack.push(Math.atan(a));
  13833. break;
  13834. case 'bitshift':
  13835. b = stack.pop();
  13836. a = stack.pop();
  13837. if (a > 0) {
  13838. stack.push(a << b);
  13839. } else {
  13840. stack.push(a >> b);
  13841. }
  13842. break;
  13843. case 'ceiling':
  13844. a = stack.pop();
  13845. stack.push(Math.ceil(a));
  13846. break;
  13847. case 'copy':
  13848. a = stack.pop();
  13849. stack.copy(a);
  13850. break;
  13851. case 'cos':
  13852. a = stack.pop();
  13853. stack.push(Math.cos(a));
  13854. break;
  13855. case 'cvi':
  13856. a = stack.pop() | 0;
  13857. stack.push(a);
  13858. break;
  13859. case 'cvr':
  13860. break;
  13861. case 'div':
  13862. b = stack.pop();
  13863. a = stack.pop();
  13864. stack.push(a / b);
  13865. break;
  13866. case 'dup':
  13867. stack.copy(1);
  13868. break;
  13869. case 'eq':
  13870. b = stack.pop();
  13871. a = stack.pop();
  13872. stack.push(a === b);
  13873. break;
  13874. case 'exch':
  13875. stack.roll(2, 1);
  13876. break;
  13877. case 'exp':
  13878. b = stack.pop();
  13879. a = stack.pop();
  13880. stack.push(Math.pow(a, b));
  13881. break;
  13882. case 'false':
  13883. stack.push(false);
  13884. break;
  13885. case 'floor':
  13886. a = stack.pop();
  13887. stack.push(Math.floor(a));
  13888. break;
  13889. case 'ge':
  13890. b = stack.pop();
  13891. a = stack.pop();
  13892. stack.push(a >= b);
  13893. break;
  13894. case 'gt':
  13895. b = stack.pop();
  13896. a = stack.pop();
  13897. stack.push(a > b);
  13898. break;
  13899. case 'idiv':
  13900. b = stack.pop();
  13901. a = stack.pop();
  13902. stack.push(a / b | 0);
  13903. break;
  13904. case 'index':
  13905. a = stack.pop();
  13906. stack.index(a);
  13907. break;
  13908. case 'le':
  13909. b = stack.pop();
  13910. a = stack.pop();
  13911. stack.push(a <= b);
  13912. break;
  13913. case 'ln':
  13914. a = stack.pop();
  13915. stack.push(Math.log(a));
  13916. break;
  13917. case 'log':
  13918. a = stack.pop();
  13919. stack.push(Math.log(a) / Math.LN10);
  13920. break;
  13921. case 'lt':
  13922. b = stack.pop();
  13923. a = stack.pop();
  13924. stack.push(a < b);
  13925. break;
  13926. case 'mod':
  13927. b = stack.pop();
  13928. a = stack.pop();
  13929. stack.push(a % b);
  13930. break;
  13931. case 'mul':
  13932. b = stack.pop();
  13933. a = stack.pop();
  13934. stack.push(a * b);
  13935. break;
  13936. case 'ne':
  13937. b = stack.pop();
  13938. a = stack.pop();
  13939. stack.push(a !== b);
  13940. break;
  13941. case 'neg':
  13942. a = stack.pop();
  13943. stack.push(-a);
  13944. break;
  13945. case 'not':
  13946. a = stack.pop();
  13947. if (isBool(a)) {
  13948. stack.push(!a);
  13949. } else {
  13950. stack.push(~a);
  13951. }
  13952. break;
  13953. case 'or':
  13954. b = stack.pop();
  13955. a = stack.pop();
  13956. if (isBool(a) && isBool(b)) {
  13957. stack.push(a || b);
  13958. } else {
  13959. stack.push(a | b);
  13960. }
  13961. break;
  13962. case 'pop':
  13963. stack.pop();
  13964. break;
  13965. case 'roll':
  13966. b = stack.pop();
  13967. a = stack.pop();
  13968. stack.roll(a, b);
  13969. break;
  13970. case 'round':
  13971. a = stack.pop();
  13972. stack.push(Math.round(a));
  13973. break;
  13974. case 'sin':
  13975. a = stack.pop();
  13976. stack.push(Math.sin(a));
  13977. break;
  13978. case 'sqrt':
  13979. a = stack.pop();
  13980. stack.push(Math.sqrt(a));
  13981. break;
  13982. case 'sub':
  13983. b = stack.pop();
  13984. a = stack.pop();
  13985. stack.push(a - b);
  13986. break;
  13987. case 'true':
  13988. stack.push(true);
  13989. break;
  13990. case 'truncate':
  13991. a = stack.pop();
  13992. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13993. stack.push(a);
  13994. break;
  13995. case 'xor':
  13996. b = stack.pop();
  13997. a = stack.pop();
  13998. if (isBool(a) && isBool(b)) {
  13999. stack.push(a !== b);
  14000. } else {
  14001. stack.push(a ^ b);
  14002. }
  14003. break;
  14004. default:
  14005. error('Unknown operator ' + operator);
  14006. break;
  14007. }
  14008. }
  14009. return stack.stack;
  14010. }
  14011. };
  14012. return PostScriptEvaluator;
  14013. }();
  14014. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14015. function AstNode(type) {
  14016. this.type = type;
  14017. }
  14018. AstNode.prototype.visit = function (visitor) {
  14019. throw new Error('abstract method');
  14020. };
  14021. function AstArgument(index, min, max) {
  14022. AstNode.call(this, 'args');
  14023. this.index = index;
  14024. this.min = min;
  14025. this.max = max;
  14026. }
  14027. AstArgument.prototype = Object.create(AstNode.prototype);
  14028. AstArgument.prototype.visit = function (visitor) {
  14029. visitor.visitArgument(this);
  14030. };
  14031. function AstLiteral(number) {
  14032. AstNode.call(this, 'literal');
  14033. this.number = number;
  14034. this.min = number;
  14035. this.max = number;
  14036. }
  14037. AstLiteral.prototype = Object.create(AstNode.prototype);
  14038. AstLiteral.prototype.visit = function (visitor) {
  14039. visitor.visitLiteral(this);
  14040. };
  14041. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14042. AstNode.call(this, 'binary');
  14043. this.op = op;
  14044. this.arg1 = arg1;
  14045. this.arg2 = arg2;
  14046. this.min = min;
  14047. this.max = max;
  14048. }
  14049. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14050. AstBinaryOperation.prototype.visit = function (visitor) {
  14051. visitor.visitBinaryOperation(this);
  14052. };
  14053. function AstMin(arg, max) {
  14054. AstNode.call(this, 'max');
  14055. this.arg = arg;
  14056. this.min = arg.min;
  14057. this.max = max;
  14058. }
  14059. AstMin.prototype = Object.create(AstNode.prototype);
  14060. AstMin.prototype.visit = function (visitor) {
  14061. visitor.visitMin(this);
  14062. };
  14063. function AstVariable(index, min, max) {
  14064. AstNode.call(this, 'var');
  14065. this.index = index;
  14066. this.min = min;
  14067. this.max = max;
  14068. }
  14069. AstVariable.prototype = Object.create(AstNode.prototype);
  14070. AstVariable.prototype.visit = function (visitor) {
  14071. visitor.visitVariable(this);
  14072. };
  14073. function AstVariableDefinition(variable, arg) {
  14074. AstNode.call(this, 'definition');
  14075. this.variable = variable;
  14076. this.arg = arg;
  14077. }
  14078. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14079. AstVariableDefinition.prototype.visit = function (visitor) {
  14080. visitor.visitVariableDefinition(this);
  14081. };
  14082. function ExpressionBuilderVisitor() {
  14083. this.parts = [];
  14084. }
  14085. ExpressionBuilderVisitor.prototype = {
  14086. visitArgument: function (arg) {
  14087. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14088. },
  14089. visitVariable: function (variable) {
  14090. this.parts.push('v', variable.index);
  14091. },
  14092. visitLiteral: function (literal) {
  14093. this.parts.push(literal.number);
  14094. },
  14095. visitBinaryOperation: function (operation) {
  14096. this.parts.push('(');
  14097. operation.arg1.visit(this);
  14098. this.parts.push(' ', operation.op, ' ');
  14099. operation.arg2.visit(this);
  14100. this.parts.push(')');
  14101. },
  14102. visitVariableDefinition: function (definition) {
  14103. this.parts.push('var ');
  14104. definition.variable.visit(this);
  14105. this.parts.push(' = ');
  14106. definition.arg.visit(this);
  14107. this.parts.push(';');
  14108. },
  14109. visitMin: function (max) {
  14110. this.parts.push('Math.min(');
  14111. max.arg.visit(this);
  14112. this.parts.push(', ', max.max, ')');
  14113. },
  14114. toString: function () {
  14115. return this.parts.join('');
  14116. }
  14117. };
  14118. function buildAddOperation(num1, num2) {
  14119. if (num2.type === 'literal' && num2.number === 0) {
  14120. return num1;
  14121. }
  14122. if (num1.type === 'literal' && num1.number === 0) {
  14123. return num2;
  14124. }
  14125. if (num2.type === 'literal' && num1.type === 'literal') {
  14126. return new AstLiteral(num1.number + num2.number);
  14127. }
  14128. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14129. }
  14130. function buildMulOperation(num1, num2) {
  14131. if (num2.type === 'literal') {
  14132. if (num2.number === 0) {
  14133. return new AstLiteral(0);
  14134. } else if (num2.number === 1) {
  14135. return num1;
  14136. } else if (num1.type === 'literal') {
  14137. return new AstLiteral(num1.number * num2.number);
  14138. }
  14139. }
  14140. if (num1.type === 'literal') {
  14141. if (num1.number === 0) {
  14142. return new AstLiteral(0);
  14143. } else if (num1.number === 1) {
  14144. return num2;
  14145. }
  14146. }
  14147. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14148. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14149. return new AstBinaryOperation('*', num1, num2, min, max);
  14150. }
  14151. function buildSubOperation(num1, num2) {
  14152. if (num2.type === 'literal') {
  14153. if (num2.number === 0) {
  14154. return num1;
  14155. } else if (num1.type === 'literal') {
  14156. return new AstLiteral(num1.number - num2.number);
  14157. }
  14158. }
  14159. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14160. return num2.arg2;
  14161. }
  14162. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14163. }
  14164. function buildMinOperation(num1, max) {
  14165. if (num1.min >= max) {
  14166. return new AstLiteral(max);
  14167. } else if (num1.max <= max) {
  14168. return num1;
  14169. }
  14170. return new AstMin(num1, max);
  14171. }
  14172. function PostScriptCompiler() {
  14173. }
  14174. PostScriptCompiler.prototype = {
  14175. compile: function PostScriptCompiler_compile(code, domain, range) {
  14176. var stack = [];
  14177. var i, ii;
  14178. var instructions = [];
  14179. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14180. var lastRegister = 0;
  14181. var n, j;
  14182. var num1, num2, ast1, ast2, tmpVar, item;
  14183. for (i = 0; i < inputSize; i++) {
  14184. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14185. }
  14186. for (i = 0, ii = code.length; i < ii; i++) {
  14187. item = code[i];
  14188. if (typeof item === 'number') {
  14189. stack.push(new AstLiteral(item));
  14190. continue;
  14191. }
  14192. switch (item) {
  14193. case 'add':
  14194. if (stack.length < 2) {
  14195. return null;
  14196. }
  14197. num2 = stack.pop();
  14198. num1 = stack.pop();
  14199. stack.push(buildAddOperation(num1, num2));
  14200. break;
  14201. case 'cvr':
  14202. if (stack.length < 1) {
  14203. return null;
  14204. }
  14205. break;
  14206. case 'mul':
  14207. if (stack.length < 2) {
  14208. return null;
  14209. }
  14210. num2 = stack.pop();
  14211. num1 = stack.pop();
  14212. stack.push(buildMulOperation(num1, num2));
  14213. break;
  14214. case 'sub':
  14215. if (stack.length < 2) {
  14216. return null;
  14217. }
  14218. num2 = stack.pop();
  14219. num1 = stack.pop();
  14220. stack.push(buildSubOperation(num1, num2));
  14221. break;
  14222. case 'exch':
  14223. if (stack.length < 2) {
  14224. return null;
  14225. }
  14226. ast1 = stack.pop();
  14227. ast2 = stack.pop();
  14228. stack.push(ast1, ast2);
  14229. break;
  14230. case 'pop':
  14231. if (stack.length < 1) {
  14232. return null;
  14233. }
  14234. stack.pop();
  14235. break;
  14236. case 'index':
  14237. if (stack.length < 1) {
  14238. return null;
  14239. }
  14240. num1 = stack.pop();
  14241. if (num1.type !== 'literal') {
  14242. return null;
  14243. }
  14244. n = num1.number;
  14245. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14246. return null;
  14247. }
  14248. ast1 = stack[stack.length - n - 1];
  14249. if (ast1.type === 'literal' || ast1.type === 'var') {
  14250. stack.push(ast1);
  14251. break;
  14252. }
  14253. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14254. stack[stack.length - n - 1] = tmpVar;
  14255. stack.push(tmpVar);
  14256. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14257. break;
  14258. case 'dup':
  14259. if (stack.length < 1) {
  14260. return null;
  14261. }
  14262. 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]) {
  14263. num1 = stack.pop();
  14264. stack.push(buildMinOperation(num1, code[i + 1]));
  14265. i += 6;
  14266. break;
  14267. }
  14268. ast1 = stack[stack.length - 1];
  14269. if (ast1.type === 'literal' || ast1.type === 'var') {
  14270. stack.push(ast1);
  14271. break;
  14272. }
  14273. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14274. stack[stack.length - 1] = tmpVar;
  14275. stack.push(tmpVar);
  14276. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14277. break;
  14278. case 'roll':
  14279. if (stack.length < 2) {
  14280. return null;
  14281. }
  14282. num2 = stack.pop();
  14283. num1 = stack.pop();
  14284. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14285. return null;
  14286. }
  14287. j = num2.number;
  14288. n = num1.number;
  14289. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14290. return null;
  14291. }
  14292. j = (j % n + n) % n;
  14293. if (j === 0) {
  14294. break;
  14295. }
  14296. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14297. break;
  14298. default:
  14299. return null;
  14300. }
  14301. }
  14302. if (stack.length !== outputSize) {
  14303. return null;
  14304. }
  14305. var result = [];
  14306. instructions.forEach(function (instruction) {
  14307. var statementBuilder = new ExpressionBuilderVisitor();
  14308. instruction.visit(statementBuilder);
  14309. result.push(statementBuilder.toString());
  14310. });
  14311. stack.forEach(function (expr, i) {
  14312. var statementBuilder = new ExpressionBuilderVisitor();
  14313. expr.visit(statementBuilder);
  14314. var min = range[i * 2], max = range[i * 2 + 1];
  14315. var out = [statementBuilder.toString()];
  14316. if (min > expr.min) {
  14317. out.unshift('Math.max(', min, ', ');
  14318. out.push(')');
  14319. }
  14320. if (max < expr.max) {
  14321. out.unshift('Math.min(', max, ', ');
  14322. out.push(')');
  14323. }
  14324. out.unshift('dest[destOffset + ', i, '] = ');
  14325. out.push(';');
  14326. result.push(out.join(''));
  14327. });
  14328. return result.join('\n');
  14329. }
  14330. };
  14331. return PostScriptCompiler;
  14332. }();
  14333. exports.isPDFFunction = isPDFFunction;
  14334. exports.PDFFunction = PDFFunction;
  14335. exports.PostScriptEvaluator = PostScriptEvaluator;
  14336. exports.PostScriptCompiler = PostScriptCompiler;
  14337. /***/ }),
  14338. /* 8 */
  14339. /***/ (function(module, exports, __w_pdfjs_require__) {
  14340. "use strict";
  14341. var sharedUtil = __w_pdfjs_require__(0);
  14342. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14343. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14344. t['A'] = 0x0041;
  14345. t['AE'] = 0x00C6;
  14346. t['AEacute'] = 0x01FC;
  14347. t['AEmacron'] = 0x01E2;
  14348. t['AEsmall'] = 0xF7E6;
  14349. t['Aacute'] = 0x00C1;
  14350. t['Aacutesmall'] = 0xF7E1;
  14351. t['Abreve'] = 0x0102;
  14352. t['Abreveacute'] = 0x1EAE;
  14353. t['Abrevecyrillic'] = 0x04D0;
  14354. t['Abrevedotbelow'] = 0x1EB6;
  14355. t['Abrevegrave'] = 0x1EB0;
  14356. t['Abrevehookabove'] = 0x1EB2;
  14357. t['Abrevetilde'] = 0x1EB4;
  14358. t['Acaron'] = 0x01CD;
  14359. t['Acircle'] = 0x24B6;
  14360. t['Acircumflex'] = 0x00C2;
  14361. t['Acircumflexacute'] = 0x1EA4;
  14362. t['Acircumflexdotbelow'] = 0x1EAC;
  14363. t['Acircumflexgrave'] = 0x1EA6;
  14364. t['Acircumflexhookabove'] = 0x1EA8;
  14365. t['Acircumflexsmall'] = 0xF7E2;
  14366. t['Acircumflextilde'] = 0x1EAA;
  14367. t['Acute'] = 0xF6C9;
  14368. t['Acutesmall'] = 0xF7B4;
  14369. t['Acyrillic'] = 0x0410;
  14370. t['Adblgrave'] = 0x0200;
  14371. t['Adieresis'] = 0x00C4;
  14372. t['Adieresiscyrillic'] = 0x04D2;
  14373. t['Adieresismacron'] = 0x01DE;
  14374. t['Adieresissmall'] = 0xF7E4;
  14375. t['Adotbelow'] = 0x1EA0;
  14376. t['Adotmacron'] = 0x01E0;
  14377. t['Agrave'] = 0x00C0;
  14378. t['Agravesmall'] = 0xF7E0;
  14379. t['Ahookabove'] = 0x1EA2;
  14380. t['Aiecyrillic'] = 0x04D4;
  14381. t['Ainvertedbreve'] = 0x0202;
  14382. t['Alpha'] = 0x0391;
  14383. t['Alphatonos'] = 0x0386;
  14384. t['Amacron'] = 0x0100;
  14385. t['Amonospace'] = 0xFF21;
  14386. t['Aogonek'] = 0x0104;
  14387. t['Aring'] = 0x00C5;
  14388. t['Aringacute'] = 0x01FA;
  14389. t['Aringbelow'] = 0x1E00;
  14390. t['Aringsmall'] = 0xF7E5;
  14391. t['Asmall'] = 0xF761;
  14392. t['Atilde'] = 0x00C3;
  14393. t['Atildesmall'] = 0xF7E3;
  14394. t['Aybarmenian'] = 0x0531;
  14395. t['B'] = 0x0042;
  14396. t['Bcircle'] = 0x24B7;
  14397. t['Bdotaccent'] = 0x1E02;
  14398. t['Bdotbelow'] = 0x1E04;
  14399. t['Becyrillic'] = 0x0411;
  14400. t['Benarmenian'] = 0x0532;
  14401. t['Beta'] = 0x0392;
  14402. t['Bhook'] = 0x0181;
  14403. t['Blinebelow'] = 0x1E06;
  14404. t['Bmonospace'] = 0xFF22;
  14405. t['Brevesmall'] = 0xF6F4;
  14406. t['Bsmall'] = 0xF762;
  14407. t['Btopbar'] = 0x0182;
  14408. t['C'] = 0x0043;
  14409. t['Caarmenian'] = 0x053E;
  14410. t['Cacute'] = 0x0106;
  14411. t['Caron'] = 0xF6CA;
  14412. t['Caronsmall'] = 0xF6F5;
  14413. t['Ccaron'] = 0x010C;
  14414. t['Ccedilla'] = 0x00C7;
  14415. t['Ccedillaacute'] = 0x1E08;
  14416. t['Ccedillasmall'] = 0xF7E7;
  14417. t['Ccircle'] = 0x24B8;
  14418. t['Ccircumflex'] = 0x0108;
  14419. t['Cdot'] = 0x010A;
  14420. t['Cdotaccent'] = 0x010A;
  14421. t['Cedillasmall'] = 0xF7B8;
  14422. t['Chaarmenian'] = 0x0549;
  14423. t['Cheabkhasiancyrillic'] = 0x04BC;
  14424. t['Checyrillic'] = 0x0427;
  14425. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14426. t['Chedescendercyrillic'] = 0x04B6;
  14427. t['Chedieresiscyrillic'] = 0x04F4;
  14428. t['Cheharmenian'] = 0x0543;
  14429. t['Chekhakassiancyrillic'] = 0x04CB;
  14430. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14431. t['Chi'] = 0x03A7;
  14432. t['Chook'] = 0x0187;
  14433. t['Circumflexsmall'] = 0xF6F6;
  14434. t['Cmonospace'] = 0xFF23;
  14435. t['Coarmenian'] = 0x0551;
  14436. t['Csmall'] = 0xF763;
  14437. t['D'] = 0x0044;
  14438. t['DZ'] = 0x01F1;
  14439. t['DZcaron'] = 0x01C4;
  14440. t['Daarmenian'] = 0x0534;
  14441. t['Dafrican'] = 0x0189;
  14442. t['Dcaron'] = 0x010E;
  14443. t['Dcedilla'] = 0x1E10;
  14444. t['Dcircle'] = 0x24B9;
  14445. t['Dcircumflexbelow'] = 0x1E12;
  14446. t['Dcroat'] = 0x0110;
  14447. t['Ddotaccent'] = 0x1E0A;
  14448. t['Ddotbelow'] = 0x1E0C;
  14449. t['Decyrillic'] = 0x0414;
  14450. t['Deicoptic'] = 0x03EE;
  14451. t['Delta'] = 0x2206;
  14452. t['Deltagreek'] = 0x0394;
  14453. t['Dhook'] = 0x018A;
  14454. t['Dieresis'] = 0xF6CB;
  14455. t['DieresisAcute'] = 0xF6CC;
  14456. t['DieresisGrave'] = 0xF6CD;
  14457. t['Dieresissmall'] = 0xF7A8;
  14458. t['Digammagreek'] = 0x03DC;
  14459. t['Djecyrillic'] = 0x0402;
  14460. t['Dlinebelow'] = 0x1E0E;
  14461. t['Dmonospace'] = 0xFF24;
  14462. t['Dotaccentsmall'] = 0xF6F7;
  14463. t['Dslash'] = 0x0110;
  14464. t['Dsmall'] = 0xF764;
  14465. t['Dtopbar'] = 0x018B;
  14466. t['Dz'] = 0x01F2;
  14467. t['Dzcaron'] = 0x01C5;
  14468. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14469. t['Dzecyrillic'] = 0x0405;
  14470. t['Dzhecyrillic'] = 0x040F;
  14471. t['E'] = 0x0045;
  14472. t['Eacute'] = 0x00C9;
  14473. t['Eacutesmall'] = 0xF7E9;
  14474. t['Ebreve'] = 0x0114;
  14475. t['Ecaron'] = 0x011A;
  14476. t['Ecedillabreve'] = 0x1E1C;
  14477. t['Echarmenian'] = 0x0535;
  14478. t['Ecircle'] = 0x24BA;
  14479. t['Ecircumflex'] = 0x00CA;
  14480. t['Ecircumflexacute'] = 0x1EBE;
  14481. t['Ecircumflexbelow'] = 0x1E18;
  14482. t['Ecircumflexdotbelow'] = 0x1EC6;
  14483. t['Ecircumflexgrave'] = 0x1EC0;
  14484. t['Ecircumflexhookabove'] = 0x1EC2;
  14485. t['Ecircumflexsmall'] = 0xF7EA;
  14486. t['Ecircumflextilde'] = 0x1EC4;
  14487. t['Ecyrillic'] = 0x0404;
  14488. t['Edblgrave'] = 0x0204;
  14489. t['Edieresis'] = 0x00CB;
  14490. t['Edieresissmall'] = 0xF7EB;
  14491. t['Edot'] = 0x0116;
  14492. t['Edotaccent'] = 0x0116;
  14493. t['Edotbelow'] = 0x1EB8;
  14494. t['Efcyrillic'] = 0x0424;
  14495. t['Egrave'] = 0x00C8;
  14496. t['Egravesmall'] = 0xF7E8;
  14497. t['Eharmenian'] = 0x0537;
  14498. t['Ehookabove'] = 0x1EBA;
  14499. t['Eightroman'] = 0x2167;
  14500. t['Einvertedbreve'] = 0x0206;
  14501. t['Eiotifiedcyrillic'] = 0x0464;
  14502. t['Elcyrillic'] = 0x041B;
  14503. t['Elevenroman'] = 0x216A;
  14504. t['Emacron'] = 0x0112;
  14505. t['Emacronacute'] = 0x1E16;
  14506. t['Emacrongrave'] = 0x1E14;
  14507. t['Emcyrillic'] = 0x041C;
  14508. t['Emonospace'] = 0xFF25;
  14509. t['Encyrillic'] = 0x041D;
  14510. t['Endescendercyrillic'] = 0x04A2;
  14511. t['Eng'] = 0x014A;
  14512. t['Enghecyrillic'] = 0x04A4;
  14513. t['Enhookcyrillic'] = 0x04C7;
  14514. t['Eogonek'] = 0x0118;
  14515. t['Eopen'] = 0x0190;
  14516. t['Epsilon'] = 0x0395;
  14517. t['Epsilontonos'] = 0x0388;
  14518. t['Ercyrillic'] = 0x0420;
  14519. t['Ereversed'] = 0x018E;
  14520. t['Ereversedcyrillic'] = 0x042D;
  14521. t['Escyrillic'] = 0x0421;
  14522. t['Esdescendercyrillic'] = 0x04AA;
  14523. t['Esh'] = 0x01A9;
  14524. t['Esmall'] = 0xF765;
  14525. t['Eta'] = 0x0397;
  14526. t['Etarmenian'] = 0x0538;
  14527. t['Etatonos'] = 0x0389;
  14528. t['Eth'] = 0x00D0;
  14529. t['Ethsmall'] = 0xF7F0;
  14530. t['Etilde'] = 0x1EBC;
  14531. t['Etildebelow'] = 0x1E1A;
  14532. t['Euro'] = 0x20AC;
  14533. t['Ezh'] = 0x01B7;
  14534. t['Ezhcaron'] = 0x01EE;
  14535. t['Ezhreversed'] = 0x01B8;
  14536. t['F'] = 0x0046;
  14537. t['Fcircle'] = 0x24BB;
  14538. t['Fdotaccent'] = 0x1E1E;
  14539. t['Feharmenian'] = 0x0556;
  14540. t['Feicoptic'] = 0x03E4;
  14541. t['Fhook'] = 0x0191;
  14542. t['Fitacyrillic'] = 0x0472;
  14543. t['Fiveroman'] = 0x2164;
  14544. t['Fmonospace'] = 0xFF26;
  14545. t['Fourroman'] = 0x2163;
  14546. t['Fsmall'] = 0xF766;
  14547. t['G'] = 0x0047;
  14548. t['GBsquare'] = 0x3387;
  14549. t['Gacute'] = 0x01F4;
  14550. t['Gamma'] = 0x0393;
  14551. t['Gammaafrican'] = 0x0194;
  14552. t['Gangiacoptic'] = 0x03EA;
  14553. t['Gbreve'] = 0x011E;
  14554. t['Gcaron'] = 0x01E6;
  14555. t['Gcedilla'] = 0x0122;
  14556. t['Gcircle'] = 0x24BC;
  14557. t['Gcircumflex'] = 0x011C;
  14558. t['Gcommaaccent'] = 0x0122;
  14559. t['Gdot'] = 0x0120;
  14560. t['Gdotaccent'] = 0x0120;
  14561. t['Gecyrillic'] = 0x0413;
  14562. t['Ghadarmenian'] = 0x0542;
  14563. t['Ghemiddlehookcyrillic'] = 0x0494;
  14564. t['Ghestrokecyrillic'] = 0x0492;
  14565. t['Gheupturncyrillic'] = 0x0490;
  14566. t['Ghook'] = 0x0193;
  14567. t['Gimarmenian'] = 0x0533;
  14568. t['Gjecyrillic'] = 0x0403;
  14569. t['Gmacron'] = 0x1E20;
  14570. t['Gmonospace'] = 0xFF27;
  14571. t['Grave'] = 0xF6CE;
  14572. t['Gravesmall'] = 0xF760;
  14573. t['Gsmall'] = 0xF767;
  14574. t['Gsmallhook'] = 0x029B;
  14575. t['Gstroke'] = 0x01E4;
  14576. t['H'] = 0x0048;
  14577. t['H18533'] = 0x25CF;
  14578. t['H18543'] = 0x25AA;
  14579. t['H18551'] = 0x25AB;
  14580. t['H22073'] = 0x25A1;
  14581. t['HPsquare'] = 0x33CB;
  14582. t['Haabkhasiancyrillic'] = 0x04A8;
  14583. t['Hadescendercyrillic'] = 0x04B2;
  14584. t['Hardsigncyrillic'] = 0x042A;
  14585. t['Hbar'] = 0x0126;
  14586. t['Hbrevebelow'] = 0x1E2A;
  14587. t['Hcedilla'] = 0x1E28;
  14588. t['Hcircle'] = 0x24BD;
  14589. t['Hcircumflex'] = 0x0124;
  14590. t['Hdieresis'] = 0x1E26;
  14591. t['Hdotaccent'] = 0x1E22;
  14592. t['Hdotbelow'] = 0x1E24;
  14593. t['Hmonospace'] = 0xFF28;
  14594. t['Hoarmenian'] = 0x0540;
  14595. t['Horicoptic'] = 0x03E8;
  14596. t['Hsmall'] = 0xF768;
  14597. t['Hungarumlaut'] = 0xF6CF;
  14598. t['Hungarumlautsmall'] = 0xF6F8;
  14599. t['Hzsquare'] = 0x3390;
  14600. t['I'] = 0x0049;
  14601. t['IAcyrillic'] = 0x042F;
  14602. t['IJ'] = 0x0132;
  14603. t['IUcyrillic'] = 0x042E;
  14604. t['Iacute'] = 0x00CD;
  14605. t['Iacutesmall'] = 0xF7ED;
  14606. t['Ibreve'] = 0x012C;
  14607. t['Icaron'] = 0x01CF;
  14608. t['Icircle'] = 0x24BE;
  14609. t['Icircumflex'] = 0x00CE;
  14610. t['Icircumflexsmall'] = 0xF7EE;
  14611. t['Icyrillic'] = 0x0406;
  14612. t['Idblgrave'] = 0x0208;
  14613. t['Idieresis'] = 0x00CF;
  14614. t['Idieresisacute'] = 0x1E2E;
  14615. t['Idieresiscyrillic'] = 0x04E4;
  14616. t['Idieresissmall'] = 0xF7EF;
  14617. t['Idot'] = 0x0130;
  14618. t['Idotaccent'] = 0x0130;
  14619. t['Idotbelow'] = 0x1ECA;
  14620. t['Iebrevecyrillic'] = 0x04D6;
  14621. t['Iecyrillic'] = 0x0415;
  14622. t['Ifraktur'] = 0x2111;
  14623. t['Igrave'] = 0x00CC;
  14624. t['Igravesmall'] = 0xF7EC;
  14625. t['Ihookabove'] = 0x1EC8;
  14626. t['Iicyrillic'] = 0x0418;
  14627. t['Iinvertedbreve'] = 0x020A;
  14628. t['Iishortcyrillic'] = 0x0419;
  14629. t['Imacron'] = 0x012A;
  14630. t['Imacroncyrillic'] = 0x04E2;
  14631. t['Imonospace'] = 0xFF29;
  14632. t['Iniarmenian'] = 0x053B;
  14633. t['Iocyrillic'] = 0x0401;
  14634. t['Iogonek'] = 0x012E;
  14635. t['Iota'] = 0x0399;
  14636. t['Iotaafrican'] = 0x0196;
  14637. t['Iotadieresis'] = 0x03AA;
  14638. t['Iotatonos'] = 0x038A;
  14639. t['Ismall'] = 0xF769;
  14640. t['Istroke'] = 0x0197;
  14641. t['Itilde'] = 0x0128;
  14642. t['Itildebelow'] = 0x1E2C;
  14643. t['Izhitsacyrillic'] = 0x0474;
  14644. t['Izhitsadblgravecyrillic'] = 0x0476;
  14645. t['J'] = 0x004A;
  14646. t['Jaarmenian'] = 0x0541;
  14647. t['Jcircle'] = 0x24BF;
  14648. t['Jcircumflex'] = 0x0134;
  14649. t['Jecyrillic'] = 0x0408;
  14650. t['Jheharmenian'] = 0x054B;
  14651. t['Jmonospace'] = 0xFF2A;
  14652. t['Jsmall'] = 0xF76A;
  14653. t['K'] = 0x004B;
  14654. t['KBsquare'] = 0x3385;
  14655. t['KKsquare'] = 0x33CD;
  14656. t['Kabashkircyrillic'] = 0x04A0;
  14657. t['Kacute'] = 0x1E30;
  14658. t['Kacyrillic'] = 0x041A;
  14659. t['Kadescendercyrillic'] = 0x049A;
  14660. t['Kahookcyrillic'] = 0x04C3;
  14661. t['Kappa'] = 0x039A;
  14662. t['Kastrokecyrillic'] = 0x049E;
  14663. t['Kaverticalstrokecyrillic'] = 0x049C;
  14664. t['Kcaron'] = 0x01E8;
  14665. t['Kcedilla'] = 0x0136;
  14666. t['Kcircle'] = 0x24C0;
  14667. t['Kcommaaccent'] = 0x0136;
  14668. t['Kdotbelow'] = 0x1E32;
  14669. t['Keharmenian'] = 0x0554;
  14670. t['Kenarmenian'] = 0x053F;
  14671. t['Khacyrillic'] = 0x0425;
  14672. t['Kheicoptic'] = 0x03E6;
  14673. t['Khook'] = 0x0198;
  14674. t['Kjecyrillic'] = 0x040C;
  14675. t['Klinebelow'] = 0x1E34;
  14676. t['Kmonospace'] = 0xFF2B;
  14677. t['Koppacyrillic'] = 0x0480;
  14678. t['Koppagreek'] = 0x03DE;
  14679. t['Ksicyrillic'] = 0x046E;
  14680. t['Ksmall'] = 0xF76B;
  14681. t['L'] = 0x004C;
  14682. t['LJ'] = 0x01C7;
  14683. t['LL'] = 0xF6BF;
  14684. t['Lacute'] = 0x0139;
  14685. t['Lambda'] = 0x039B;
  14686. t['Lcaron'] = 0x013D;
  14687. t['Lcedilla'] = 0x013B;
  14688. t['Lcircle'] = 0x24C1;
  14689. t['Lcircumflexbelow'] = 0x1E3C;
  14690. t['Lcommaaccent'] = 0x013B;
  14691. t['Ldot'] = 0x013F;
  14692. t['Ldotaccent'] = 0x013F;
  14693. t['Ldotbelow'] = 0x1E36;
  14694. t['Ldotbelowmacron'] = 0x1E38;
  14695. t['Liwnarmenian'] = 0x053C;
  14696. t['Lj'] = 0x01C8;
  14697. t['Ljecyrillic'] = 0x0409;
  14698. t['Llinebelow'] = 0x1E3A;
  14699. t['Lmonospace'] = 0xFF2C;
  14700. t['Lslash'] = 0x0141;
  14701. t['Lslashsmall'] = 0xF6F9;
  14702. t['Lsmall'] = 0xF76C;
  14703. t['M'] = 0x004D;
  14704. t['MBsquare'] = 0x3386;
  14705. t['Macron'] = 0xF6D0;
  14706. t['Macronsmall'] = 0xF7AF;
  14707. t['Macute'] = 0x1E3E;
  14708. t['Mcircle'] = 0x24C2;
  14709. t['Mdotaccent'] = 0x1E40;
  14710. t['Mdotbelow'] = 0x1E42;
  14711. t['Menarmenian'] = 0x0544;
  14712. t['Mmonospace'] = 0xFF2D;
  14713. t['Msmall'] = 0xF76D;
  14714. t['Mturned'] = 0x019C;
  14715. t['Mu'] = 0x039C;
  14716. t['N'] = 0x004E;
  14717. t['NJ'] = 0x01CA;
  14718. t['Nacute'] = 0x0143;
  14719. t['Ncaron'] = 0x0147;
  14720. t['Ncedilla'] = 0x0145;
  14721. t['Ncircle'] = 0x24C3;
  14722. t['Ncircumflexbelow'] = 0x1E4A;
  14723. t['Ncommaaccent'] = 0x0145;
  14724. t['Ndotaccent'] = 0x1E44;
  14725. t['Ndotbelow'] = 0x1E46;
  14726. t['Nhookleft'] = 0x019D;
  14727. t['Nineroman'] = 0x2168;
  14728. t['Nj'] = 0x01CB;
  14729. t['Njecyrillic'] = 0x040A;
  14730. t['Nlinebelow'] = 0x1E48;
  14731. t['Nmonospace'] = 0xFF2E;
  14732. t['Nowarmenian'] = 0x0546;
  14733. t['Nsmall'] = 0xF76E;
  14734. t['Ntilde'] = 0x00D1;
  14735. t['Ntildesmall'] = 0xF7F1;
  14736. t['Nu'] = 0x039D;
  14737. t['O'] = 0x004F;
  14738. t['OE'] = 0x0152;
  14739. t['OEsmall'] = 0xF6FA;
  14740. t['Oacute'] = 0x00D3;
  14741. t['Oacutesmall'] = 0xF7F3;
  14742. t['Obarredcyrillic'] = 0x04E8;
  14743. t['Obarreddieresiscyrillic'] = 0x04EA;
  14744. t['Obreve'] = 0x014E;
  14745. t['Ocaron'] = 0x01D1;
  14746. t['Ocenteredtilde'] = 0x019F;
  14747. t['Ocircle'] = 0x24C4;
  14748. t['Ocircumflex'] = 0x00D4;
  14749. t['Ocircumflexacute'] = 0x1ED0;
  14750. t['Ocircumflexdotbelow'] = 0x1ED8;
  14751. t['Ocircumflexgrave'] = 0x1ED2;
  14752. t['Ocircumflexhookabove'] = 0x1ED4;
  14753. t['Ocircumflexsmall'] = 0xF7F4;
  14754. t['Ocircumflextilde'] = 0x1ED6;
  14755. t['Ocyrillic'] = 0x041E;
  14756. t['Odblacute'] = 0x0150;
  14757. t['Odblgrave'] = 0x020C;
  14758. t['Odieresis'] = 0x00D6;
  14759. t['Odieresiscyrillic'] = 0x04E6;
  14760. t['Odieresissmall'] = 0xF7F6;
  14761. t['Odotbelow'] = 0x1ECC;
  14762. t['Ogoneksmall'] = 0xF6FB;
  14763. t['Ograve'] = 0x00D2;
  14764. t['Ogravesmall'] = 0xF7F2;
  14765. t['Oharmenian'] = 0x0555;
  14766. t['Ohm'] = 0x2126;
  14767. t['Ohookabove'] = 0x1ECE;
  14768. t['Ohorn'] = 0x01A0;
  14769. t['Ohornacute'] = 0x1EDA;
  14770. t['Ohorndotbelow'] = 0x1EE2;
  14771. t['Ohorngrave'] = 0x1EDC;
  14772. t['Ohornhookabove'] = 0x1EDE;
  14773. t['Ohorntilde'] = 0x1EE0;
  14774. t['Ohungarumlaut'] = 0x0150;
  14775. t['Oi'] = 0x01A2;
  14776. t['Oinvertedbreve'] = 0x020E;
  14777. t['Omacron'] = 0x014C;
  14778. t['Omacronacute'] = 0x1E52;
  14779. t['Omacrongrave'] = 0x1E50;
  14780. t['Omega'] = 0x2126;
  14781. t['Omegacyrillic'] = 0x0460;
  14782. t['Omegagreek'] = 0x03A9;
  14783. t['Omegaroundcyrillic'] = 0x047A;
  14784. t['Omegatitlocyrillic'] = 0x047C;
  14785. t['Omegatonos'] = 0x038F;
  14786. t['Omicron'] = 0x039F;
  14787. t['Omicrontonos'] = 0x038C;
  14788. t['Omonospace'] = 0xFF2F;
  14789. t['Oneroman'] = 0x2160;
  14790. t['Oogonek'] = 0x01EA;
  14791. t['Oogonekmacron'] = 0x01EC;
  14792. t['Oopen'] = 0x0186;
  14793. t['Oslash'] = 0x00D8;
  14794. t['Oslashacute'] = 0x01FE;
  14795. t['Oslashsmall'] = 0xF7F8;
  14796. t['Osmall'] = 0xF76F;
  14797. t['Ostrokeacute'] = 0x01FE;
  14798. t['Otcyrillic'] = 0x047E;
  14799. t['Otilde'] = 0x00D5;
  14800. t['Otildeacute'] = 0x1E4C;
  14801. t['Otildedieresis'] = 0x1E4E;
  14802. t['Otildesmall'] = 0xF7F5;
  14803. t['P'] = 0x0050;
  14804. t['Pacute'] = 0x1E54;
  14805. t['Pcircle'] = 0x24C5;
  14806. t['Pdotaccent'] = 0x1E56;
  14807. t['Pecyrillic'] = 0x041F;
  14808. t['Peharmenian'] = 0x054A;
  14809. t['Pemiddlehookcyrillic'] = 0x04A6;
  14810. t['Phi'] = 0x03A6;
  14811. t['Phook'] = 0x01A4;
  14812. t['Pi'] = 0x03A0;
  14813. t['Piwrarmenian'] = 0x0553;
  14814. t['Pmonospace'] = 0xFF30;
  14815. t['Psi'] = 0x03A8;
  14816. t['Psicyrillic'] = 0x0470;
  14817. t['Psmall'] = 0xF770;
  14818. t['Q'] = 0x0051;
  14819. t['Qcircle'] = 0x24C6;
  14820. t['Qmonospace'] = 0xFF31;
  14821. t['Qsmall'] = 0xF771;
  14822. t['R'] = 0x0052;
  14823. t['Raarmenian'] = 0x054C;
  14824. t['Racute'] = 0x0154;
  14825. t['Rcaron'] = 0x0158;
  14826. t['Rcedilla'] = 0x0156;
  14827. t['Rcircle'] = 0x24C7;
  14828. t['Rcommaaccent'] = 0x0156;
  14829. t['Rdblgrave'] = 0x0210;
  14830. t['Rdotaccent'] = 0x1E58;
  14831. t['Rdotbelow'] = 0x1E5A;
  14832. t['Rdotbelowmacron'] = 0x1E5C;
  14833. t['Reharmenian'] = 0x0550;
  14834. t['Rfraktur'] = 0x211C;
  14835. t['Rho'] = 0x03A1;
  14836. t['Ringsmall'] = 0xF6FC;
  14837. t['Rinvertedbreve'] = 0x0212;
  14838. t['Rlinebelow'] = 0x1E5E;
  14839. t['Rmonospace'] = 0xFF32;
  14840. t['Rsmall'] = 0xF772;
  14841. t['Rsmallinverted'] = 0x0281;
  14842. t['Rsmallinvertedsuperior'] = 0x02B6;
  14843. t['S'] = 0x0053;
  14844. t['SF010000'] = 0x250C;
  14845. t['SF020000'] = 0x2514;
  14846. t['SF030000'] = 0x2510;
  14847. t['SF040000'] = 0x2518;
  14848. t['SF050000'] = 0x253C;
  14849. t['SF060000'] = 0x252C;
  14850. t['SF070000'] = 0x2534;
  14851. t['SF080000'] = 0x251C;
  14852. t['SF090000'] = 0x2524;
  14853. t['SF100000'] = 0x2500;
  14854. t['SF110000'] = 0x2502;
  14855. t['SF190000'] = 0x2561;
  14856. t['SF200000'] = 0x2562;
  14857. t['SF210000'] = 0x2556;
  14858. t['SF220000'] = 0x2555;
  14859. t['SF230000'] = 0x2563;
  14860. t['SF240000'] = 0x2551;
  14861. t['SF250000'] = 0x2557;
  14862. t['SF260000'] = 0x255D;
  14863. t['SF270000'] = 0x255C;
  14864. t['SF280000'] = 0x255B;
  14865. t['SF360000'] = 0x255E;
  14866. t['SF370000'] = 0x255F;
  14867. t['SF380000'] = 0x255A;
  14868. t['SF390000'] = 0x2554;
  14869. t['SF400000'] = 0x2569;
  14870. t['SF410000'] = 0x2566;
  14871. t['SF420000'] = 0x2560;
  14872. t['SF430000'] = 0x2550;
  14873. t['SF440000'] = 0x256C;
  14874. t['SF450000'] = 0x2567;
  14875. t['SF460000'] = 0x2568;
  14876. t['SF470000'] = 0x2564;
  14877. t['SF480000'] = 0x2565;
  14878. t['SF490000'] = 0x2559;
  14879. t['SF500000'] = 0x2558;
  14880. t['SF510000'] = 0x2552;
  14881. t['SF520000'] = 0x2553;
  14882. t['SF530000'] = 0x256B;
  14883. t['SF540000'] = 0x256A;
  14884. t['Sacute'] = 0x015A;
  14885. t['Sacutedotaccent'] = 0x1E64;
  14886. t['Sampigreek'] = 0x03E0;
  14887. t['Scaron'] = 0x0160;
  14888. t['Scarondotaccent'] = 0x1E66;
  14889. t['Scaronsmall'] = 0xF6FD;
  14890. t['Scedilla'] = 0x015E;
  14891. t['Schwa'] = 0x018F;
  14892. t['Schwacyrillic'] = 0x04D8;
  14893. t['Schwadieresiscyrillic'] = 0x04DA;
  14894. t['Scircle'] = 0x24C8;
  14895. t['Scircumflex'] = 0x015C;
  14896. t['Scommaaccent'] = 0x0218;
  14897. t['Sdotaccent'] = 0x1E60;
  14898. t['Sdotbelow'] = 0x1E62;
  14899. t['Sdotbelowdotaccent'] = 0x1E68;
  14900. t['Seharmenian'] = 0x054D;
  14901. t['Sevenroman'] = 0x2166;
  14902. t['Shaarmenian'] = 0x0547;
  14903. t['Shacyrillic'] = 0x0428;
  14904. t['Shchacyrillic'] = 0x0429;
  14905. t['Sheicoptic'] = 0x03E2;
  14906. t['Shhacyrillic'] = 0x04BA;
  14907. t['Shimacoptic'] = 0x03EC;
  14908. t['Sigma'] = 0x03A3;
  14909. t['Sixroman'] = 0x2165;
  14910. t['Smonospace'] = 0xFF33;
  14911. t['Softsigncyrillic'] = 0x042C;
  14912. t['Ssmall'] = 0xF773;
  14913. t['Stigmagreek'] = 0x03DA;
  14914. t['T'] = 0x0054;
  14915. t['Tau'] = 0x03A4;
  14916. t['Tbar'] = 0x0166;
  14917. t['Tcaron'] = 0x0164;
  14918. t['Tcedilla'] = 0x0162;
  14919. t['Tcircle'] = 0x24C9;
  14920. t['Tcircumflexbelow'] = 0x1E70;
  14921. t['Tcommaaccent'] = 0x0162;
  14922. t['Tdotaccent'] = 0x1E6A;
  14923. t['Tdotbelow'] = 0x1E6C;
  14924. t['Tecyrillic'] = 0x0422;
  14925. t['Tedescendercyrillic'] = 0x04AC;
  14926. t['Tenroman'] = 0x2169;
  14927. t['Tetsecyrillic'] = 0x04B4;
  14928. t['Theta'] = 0x0398;
  14929. t['Thook'] = 0x01AC;
  14930. t['Thorn'] = 0x00DE;
  14931. t['Thornsmall'] = 0xF7FE;
  14932. t['Threeroman'] = 0x2162;
  14933. t['Tildesmall'] = 0xF6FE;
  14934. t['Tiwnarmenian'] = 0x054F;
  14935. t['Tlinebelow'] = 0x1E6E;
  14936. t['Tmonospace'] = 0xFF34;
  14937. t['Toarmenian'] = 0x0539;
  14938. t['Tonefive'] = 0x01BC;
  14939. t['Tonesix'] = 0x0184;
  14940. t['Tonetwo'] = 0x01A7;
  14941. t['Tretroflexhook'] = 0x01AE;
  14942. t['Tsecyrillic'] = 0x0426;
  14943. t['Tshecyrillic'] = 0x040B;
  14944. t['Tsmall'] = 0xF774;
  14945. t['Twelveroman'] = 0x216B;
  14946. t['Tworoman'] = 0x2161;
  14947. t['U'] = 0x0055;
  14948. t['Uacute'] = 0x00DA;
  14949. t['Uacutesmall'] = 0xF7FA;
  14950. t['Ubreve'] = 0x016C;
  14951. t['Ucaron'] = 0x01D3;
  14952. t['Ucircle'] = 0x24CA;
  14953. t['Ucircumflex'] = 0x00DB;
  14954. t['Ucircumflexbelow'] = 0x1E76;
  14955. t['Ucircumflexsmall'] = 0xF7FB;
  14956. t['Ucyrillic'] = 0x0423;
  14957. t['Udblacute'] = 0x0170;
  14958. t['Udblgrave'] = 0x0214;
  14959. t['Udieresis'] = 0x00DC;
  14960. t['Udieresisacute'] = 0x01D7;
  14961. t['Udieresisbelow'] = 0x1E72;
  14962. t['Udieresiscaron'] = 0x01D9;
  14963. t['Udieresiscyrillic'] = 0x04F0;
  14964. t['Udieresisgrave'] = 0x01DB;
  14965. t['Udieresismacron'] = 0x01D5;
  14966. t['Udieresissmall'] = 0xF7FC;
  14967. t['Udotbelow'] = 0x1EE4;
  14968. t['Ugrave'] = 0x00D9;
  14969. t['Ugravesmall'] = 0xF7F9;
  14970. t['Uhookabove'] = 0x1EE6;
  14971. t['Uhorn'] = 0x01AF;
  14972. t['Uhornacute'] = 0x1EE8;
  14973. t['Uhorndotbelow'] = 0x1EF0;
  14974. t['Uhorngrave'] = 0x1EEA;
  14975. t['Uhornhookabove'] = 0x1EEC;
  14976. t['Uhorntilde'] = 0x1EEE;
  14977. t['Uhungarumlaut'] = 0x0170;
  14978. t['Uhungarumlautcyrillic'] = 0x04F2;
  14979. t['Uinvertedbreve'] = 0x0216;
  14980. t['Ukcyrillic'] = 0x0478;
  14981. t['Umacron'] = 0x016A;
  14982. t['Umacroncyrillic'] = 0x04EE;
  14983. t['Umacrondieresis'] = 0x1E7A;
  14984. t['Umonospace'] = 0xFF35;
  14985. t['Uogonek'] = 0x0172;
  14986. t['Upsilon'] = 0x03A5;
  14987. t['Upsilon1'] = 0x03D2;
  14988. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14989. t['Upsilonafrican'] = 0x01B1;
  14990. t['Upsilondieresis'] = 0x03AB;
  14991. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14992. t['Upsilonhooksymbol'] = 0x03D2;
  14993. t['Upsilontonos'] = 0x038E;
  14994. t['Uring'] = 0x016E;
  14995. t['Ushortcyrillic'] = 0x040E;
  14996. t['Usmall'] = 0xF775;
  14997. t['Ustraightcyrillic'] = 0x04AE;
  14998. t['Ustraightstrokecyrillic'] = 0x04B0;
  14999. t['Utilde'] = 0x0168;
  15000. t['Utildeacute'] = 0x1E78;
  15001. t['Utildebelow'] = 0x1E74;
  15002. t['V'] = 0x0056;
  15003. t['Vcircle'] = 0x24CB;
  15004. t['Vdotbelow'] = 0x1E7E;
  15005. t['Vecyrillic'] = 0x0412;
  15006. t['Vewarmenian'] = 0x054E;
  15007. t['Vhook'] = 0x01B2;
  15008. t['Vmonospace'] = 0xFF36;
  15009. t['Voarmenian'] = 0x0548;
  15010. t['Vsmall'] = 0xF776;
  15011. t['Vtilde'] = 0x1E7C;
  15012. t['W'] = 0x0057;
  15013. t['Wacute'] = 0x1E82;
  15014. t['Wcircle'] = 0x24CC;
  15015. t['Wcircumflex'] = 0x0174;
  15016. t['Wdieresis'] = 0x1E84;
  15017. t['Wdotaccent'] = 0x1E86;
  15018. t['Wdotbelow'] = 0x1E88;
  15019. t['Wgrave'] = 0x1E80;
  15020. t['Wmonospace'] = 0xFF37;
  15021. t['Wsmall'] = 0xF777;
  15022. t['X'] = 0x0058;
  15023. t['Xcircle'] = 0x24CD;
  15024. t['Xdieresis'] = 0x1E8C;
  15025. t['Xdotaccent'] = 0x1E8A;
  15026. t['Xeharmenian'] = 0x053D;
  15027. t['Xi'] = 0x039E;
  15028. t['Xmonospace'] = 0xFF38;
  15029. t['Xsmall'] = 0xF778;
  15030. t['Y'] = 0x0059;
  15031. t['Yacute'] = 0x00DD;
  15032. t['Yacutesmall'] = 0xF7FD;
  15033. t['Yatcyrillic'] = 0x0462;
  15034. t['Ycircle'] = 0x24CE;
  15035. t['Ycircumflex'] = 0x0176;
  15036. t['Ydieresis'] = 0x0178;
  15037. t['Ydieresissmall'] = 0xF7FF;
  15038. t['Ydotaccent'] = 0x1E8E;
  15039. t['Ydotbelow'] = 0x1EF4;
  15040. t['Yericyrillic'] = 0x042B;
  15041. t['Yerudieresiscyrillic'] = 0x04F8;
  15042. t['Ygrave'] = 0x1EF2;
  15043. t['Yhook'] = 0x01B3;
  15044. t['Yhookabove'] = 0x1EF6;
  15045. t['Yiarmenian'] = 0x0545;
  15046. t['Yicyrillic'] = 0x0407;
  15047. t['Yiwnarmenian'] = 0x0552;
  15048. t['Ymonospace'] = 0xFF39;
  15049. t['Ysmall'] = 0xF779;
  15050. t['Ytilde'] = 0x1EF8;
  15051. t['Yusbigcyrillic'] = 0x046A;
  15052. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15053. t['Yuslittlecyrillic'] = 0x0466;
  15054. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15055. t['Z'] = 0x005A;
  15056. t['Zaarmenian'] = 0x0536;
  15057. t['Zacute'] = 0x0179;
  15058. t['Zcaron'] = 0x017D;
  15059. t['Zcaronsmall'] = 0xF6FF;
  15060. t['Zcircle'] = 0x24CF;
  15061. t['Zcircumflex'] = 0x1E90;
  15062. t['Zdot'] = 0x017B;
  15063. t['Zdotaccent'] = 0x017B;
  15064. t['Zdotbelow'] = 0x1E92;
  15065. t['Zecyrillic'] = 0x0417;
  15066. t['Zedescendercyrillic'] = 0x0498;
  15067. t['Zedieresiscyrillic'] = 0x04DE;
  15068. t['Zeta'] = 0x0396;
  15069. t['Zhearmenian'] = 0x053A;
  15070. t['Zhebrevecyrillic'] = 0x04C1;
  15071. t['Zhecyrillic'] = 0x0416;
  15072. t['Zhedescendercyrillic'] = 0x0496;
  15073. t['Zhedieresiscyrillic'] = 0x04DC;
  15074. t['Zlinebelow'] = 0x1E94;
  15075. t['Zmonospace'] = 0xFF3A;
  15076. t['Zsmall'] = 0xF77A;
  15077. t['Zstroke'] = 0x01B5;
  15078. t['a'] = 0x0061;
  15079. t['aabengali'] = 0x0986;
  15080. t['aacute'] = 0x00E1;
  15081. t['aadeva'] = 0x0906;
  15082. t['aagujarati'] = 0x0A86;
  15083. t['aagurmukhi'] = 0x0A06;
  15084. t['aamatragurmukhi'] = 0x0A3E;
  15085. t['aarusquare'] = 0x3303;
  15086. t['aavowelsignbengali'] = 0x09BE;
  15087. t['aavowelsigndeva'] = 0x093E;
  15088. t['aavowelsigngujarati'] = 0x0ABE;
  15089. t['abbreviationmarkarmenian'] = 0x055F;
  15090. t['abbreviationsigndeva'] = 0x0970;
  15091. t['abengali'] = 0x0985;
  15092. t['abopomofo'] = 0x311A;
  15093. t['abreve'] = 0x0103;
  15094. t['abreveacute'] = 0x1EAF;
  15095. t['abrevecyrillic'] = 0x04D1;
  15096. t['abrevedotbelow'] = 0x1EB7;
  15097. t['abrevegrave'] = 0x1EB1;
  15098. t['abrevehookabove'] = 0x1EB3;
  15099. t['abrevetilde'] = 0x1EB5;
  15100. t['acaron'] = 0x01CE;
  15101. t['acircle'] = 0x24D0;
  15102. t['acircumflex'] = 0x00E2;
  15103. t['acircumflexacute'] = 0x1EA5;
  15104. t['acircumflexdotbelow'] = 0x1EAD;
  15105. t['acircumflexgrave'] = 0x1EA7;
  15106. t['acircumflexhookabove'] = 0x1EA9;
  15107. t['acircumflextilde'] = 0x1EAB;
  15108. t['acute'] = 0x00B4;
  15109. t['acutebelowcmb'] = 0x0317;
  15110. t['acutecmb'] = 0x0301;
  15111. t['acutecomb'] = 0x0301;
  15112. t['acutedeva'] = 0x0954;
  15113. t['acutelowmod'] = 0x02CF;
  15114. t['acutetonecmb'] = 0x0341;
  15115. t['acyrillic'] = 0x0430;
  15116. t['adblgrave'] = 0x0201;
  15117. t['addakgurmukhi'] = 0x0A71;
  15118. t['adeva'] = 0x0905;
  15119. t['adieresis'] = 0x00E4;
  15120. t['adieresiscyrillic'] = 0x04D3;
  15121. t['adieresismacron'] = 0x01DF;
  15122. t['adotbelow'] = 0x1EA1;
  15123. t['adotmacron'] = 0x01E1;
  15124. t['ae'] = 0x00E6;
  15125. t['aeacute'] = 0x01FD;
  15126. t['aekorean'] = 0x3150;
  15127. t['aemacron'] = 0x01E3;
  15128. t['afii00208'] = 0x2015;
  15129. t['afii08941'] = 0x20A4;
  15130. t['afii10017'] = 0x0410;
  15131. t['afii10018'] = 0x0411;
  15132. t['afii10019'] = 0x0412;
  15133. t['afii10020'] = 0x0413;
  15134. t['afii10021'] = 0x0414;
  15135. t['afii10022'] = 0x0415;
  15136. t['afii10023'] = 0x0401;
  15137. t['afii10024'] = 0x0416;
  15138. t['afii10025'] = 0x0417;
  15139. t['afii10026'] = 0x0418;
  15140. t['afii10027'] = 0x0419;
  15141. t['afii10028'] = 0x041A;
  15142. t['afii10029'] = 0x041B;
  15143. t['afii10030'] = 0x041C;
  15144. t['afii10031'] = 0x041D;
  15145. t['afii10032'] = 0x041E;
  15146. t['afii10033'] = 0x041F;
  15147. t['afii10034'] = 0x0420;
  15148. t['afii10035'] = 0x0421;
  15149. t['afii10036'] = 0x0422;
  15150. t['afii10037'] = 0x0423;
  15151. t['afii10038'] = 0x0424;
  15152. t['afii10039'] = 0x0425;
  15153. t['afii10040'] = 0x0426;
  15154. t['afii10041'] = 0x0427;
  15155. t['afii10042'] = 0x0428;
  15156. t['afii10043'] = 0x0429;
  15157. t['afii10044'] = 0x042A;
  15158. t['afii10045'] = 0x042B;
  15159. t['afii10046'] = 0x042C;
  15160. t['afii10047'] = 0x042D;
  15161. t['afii10048'] = 0x042E;
  15162. t['afii10049'] = 0x042F;
  15163. t['afii10050'] = 0x0490;
  15164. t['afii10051'] = 0x0402;
  15165. t['afii10052'] = 0x0403;
  15166. t['afii10053'] = 0x0404;
  15167. t['afii10054'] = 0x0405;
  15168. t['afii10055'] = 0x0406;
  15169. t['afii10056'] = 0x0407;
  15170. t['afii10057'] = 0x0408;
  15171. t['afii10058'] = 0x0409;
  15172. t['afii10059'] = 0x040A;
  15173. t['afii10060'] = 0x040B;
  15174. t['afii10061'] = 0x040C;
  15175. t['afii10062'] = 0x040E;
  15176. t['afii10063'] = 0xF6C4;
  15177. t['afii10064'] = 0xF6C5;
  15178. t['afii10065'] = 0x0430;
  15179. t['afii10066'] = 0x0431;
  15180. t['afii10067'] = 0x0432;
  15181. t['afii10068'] = 0x0433;
  15182. t['afii10069'] = 0x0434;
  15183. t['afii10070'] = 0x0435;
  15184. t['afii10071'] = 0x0451;
  15185. t['afii10072'] = 0x0436;
  15186. t['afii10073'] = 0x0437;
  15187. t['afii10074'] = 0x0438;
  15188. t['afii10075'] = 0x0439;
  15189. t['afii10076'] = 0x043A;
  15190. t['afii10077'] = 0x043B;
  15191. t['afii10078'] = 0x043C;
  15192. t['afii10079'] = 0x043D;
  15193. t['afii10080'] = 0x043E;
  15194. t['afii10081'] = 0x043F;
  15195. t['afii10082'] = 0x0440;
  15196. t['afii10083'] = 0x0441;
  15197. t['afii10084'] = 0x0442;
  15198. t['afii10085'] = 0x0443;
  15199. t['afii10086'] = 0x0444;
  15200. t['afii10087'] = 0x0445;
  15201. t['afii10088'] = 0x0446;
  15202. t['afii10089'] = 0x0447;
  15203. t['afii10090'] = 0x0448;
  15204. t['afii10091'] = 0x0449;
  15205. t['afii10092'] = 0x044A;
  15206. t['afii10093'] = 0x044B;
  15207. t['afii10094'] = 0x044C;
  15208. t['afii10095'] = 0x044D;
  15209. t['afii10096'] = 0x044E;
  15210. t['afii10097'] = 0x044F;
  15211. t['afii10098'] = 0x0491;
  15212. t['afii10099'] = 0x0452;
  15213. t['afii10100'] = 0x0453;
  15214. t['afii10101'] = 0x0454;
  15215. t['afii10102'] = 0x0455;
  15216. t['afii10103'] = 0x0456;
  15217. t['afii10104'] = 0x0457;
  15218. t['afii10105'] = 0x0458;
  15219. t['afii10106'] = 0x0459;
  15220. t['afii10107'] = 0x045A;
  15221. t['afii10108'] = 0x045B;
  15222. t['afii10109'] = 0x045C;
  15223. t['afii10110'] = 0x045E;
  15224. t['afii10145'] = 0x040F;
  15225. t['afii10146'] = 0x0462;
  15226. t['afii10147'] = 0x0472;
  15227. t['afii10148'] = 0x0474;
  15228. t['afii10192'] = 0xF6C6;
  15229. t['afii10193'] = 0x045F;
  15230. t['afii10194'] = 0x0463;
  15231. t['afii10195'] = 0x0473;
  15232. t['afii10196'] = 0x0475;
  15233. t['afii10831'] = 0xF6C7;
  15234. t['afii10832'] = 0xF6C8;
  15235. t['afii10846'] = 0x04D9;
  15236. t['afii299'] = 0x200E;
  15237. t['afii300'] = 0x200F;
  15238. t['afii301'] = 0x200D;
  15239. t['afii57381'] = 0x066A;
  15240. t['afii57388'] = 0x060C;
  15241. t['afii57392'] = 0x0660;
  15242. t['afii57393'] = 0x0661;
  15243. t['afii57394'] = 0x0662;
  15244. t['afii57395'] = 0x0663;
  15245. t['afii57396'] = 0x0664;
  15246. t['afii57397'] = 0x0665;
  15247. t['afii57398'] = 0x0666;
  15248. t['afii57399'] = 0x0667;
  15249. t['afii57400'] = 0x0668;
  15250. t['afii57401'] = 0x0669;
  15251. t['afii57403'] = 0x061B;
  15252. t['afii57407'] = 0x061F;
  15253. t['afii57409'] = 0x0621;
  15254. t['afii57410'] = 0x0622;
  15255. t['afii57411'] = 0x0623;
  15256. t['afii57412'] = 0x0624;
  15257. t['afii57413'] = 0x0625;
  15258. t['afii57414'] = 0x0626;
  15259. t['afii57415'] = 0x0627;
  15260. t['afii57416'] = 0x0628;
  15261. t['afii57417'] = 0x0629;
  15262. t['afii57418'] = 0x062A;
  15263. t['afii57419'] = 0x062B;
  15264. t['afii57420'] = 0x062C;
  15265. t['afii57421'] = 0x062D;
  15266. t['afii57422'] = 0x062E;
  15267. t['afii57423'] = 0x062F;
  15268. t['afii57424'] = 0x0630;
  15269. t['afii57425'] = 0x0631;
  15270. t['afii57426'] = 0x0632;
  15271. t['afii57427'] = 0x0633;
  15272. t['afii57428'] = 0x0634;
  15273. t['afii57429'] = 0x0635;
  15274. t['afii57430'] = 0x0636;
  15275. t['afii57431'] = 0x0637;
  15276. t['afii57432'] = 0x0638;
  15277. t['afii57433'] = 0x0639;
  15278. t['afii57434'] = 0x063A;
  15279. t['afii57440'] = 0x0640;
  15280. t['afii57441'] = 0x0641;
  15281. t['afii57442'] = 0x0642;
  15282. t['afii57443'] = 0x0643;
  15283. t['afii57444'] = 0x0644;
  15284. t['afii57445'] = 0x0645;
  15285. t['afii57446'] = 0x0646;
  15286. t['afii57448'] = 0x0648;
  15287. t['afii57449'] = 0x0649;
  15288. t['afii57450'] = 0x064A;
  15289. t['afii57451'] = 0x064B;
  15290. t['afii57452'] = 0x064C;
  15291. t['afii57453'] = 0x064D;
  15292. t['afii57454'] = 0x064E;
  15293. t['afii57455'] = 0x064F;
  15294. t['afii57456'] = 0x0650;
  15295. t['afii57457'] = 0x0651;
  15296. t['afii57458'] = 0x0652;
  15297. t['afii57470'] = 0x0647;
  15298. t['afii57505'] = 0x06A4;
  15299. t['afii57506'] = 0x067E;
  15300. t['afii57507'] = 0x0686;
  15301. t['afii57508'] = 0x0698;
  15302. t['afii57509'] = 0x06AF;
  15303. t['afii57511'] = 0x0679;
  15304. t['afii57512'] = 0x0688;
  15305. t['afii57513'] = 0x0691;
  15306. t['afii57514'] = 0x06BA;
  15307. t['afii57519'] = 0x06D2;
  15308. t['afii57534'] = 0x06D5;
  15309. t['afii57636'] = 0x20AA;
  15310. t['afii57645'] = 0x05BE;
  15311. t['afii57658'] = 0x05C3;
  15312. t['afii57664'] = 0x05D0;
  15313. t['afii57665'] = 0x05D1;
  15314. t['afii57666'] = 0x05D2;
  15315. t['afii57667'] = 0x05D3;
  15316. t['afii57668'] = 0x05D4;
  15317. t['afii57669'] = 0x05D5;
  15318. t['afii57670'] = 0x05D6;
  15319. t['afii57671'] = 0x05D7;
  15320. t['afii57672'] = 0x05D8;
  15321. t['afii57673'] = 0x05D9;
  15322. t['afii57674'] = 0x05DA;
  15323. t['afii57675'] = 0x05DB;
  15324. t['afii57676'] = 0x05DC;
  15325. t['afii57677'] = 0x05DD;
  15326. t['afii57678'] = 0x05DE;
  15327. t['afii57679'] = 0x05DF;
  15328. t['afii57680'] = 0x05E0;
  15329. t['afii57681'] = 0x05E1;
  15330. t['afii57682'] = 0x05E2;
  15331. t['afii57683'] = 0x05E3;
  15332. t['afii57684'] = 0x05E4;
  15333. t['afii57685'] = 0x05E5;
  15334. t['afii57686'] = 0x05E6;
  15335. t['afii57687'] = 0x05E7;
  15336. t['afii57688'] = 0x05E8;
  15337. t['afii57689'] = 0x05E9;
  15338. t['afii57690'] = 0x05EA;
  15339. t['afii57694'] = 0xFB2A;
  15340. t['afii57695'] = 0xFB2B;
  15341. t['afii57700'] = 0xFB4B;
  15342. t['afii57705'] = 0xFB1F;
  15343. t['afii57716'] = 0x05F0;
  15344. t['afii57717'] = 0x05F1;
  15345. t['afii57718'] = 0x05F2;
  15346. t['afii57723'] = 0xFB35;
  15347. t['afii57793'] = 0x05B4;
  15348. t['afii57794'] = 0x05B5;
  15349. t['afii57795'] = 0x05B6;
  15350. t['afii57796'] = 0x05BB;
  15351. t['afii57797'] = 0x05B8;
  15352. t['afii57798'] = 0x05B7;
  15353. t['afii57799'] = 0x05B0;
  15354. t['afii57800'] = 0x05B2;
  15355. t['afii57801'] = 0x05B1;
  15356. t['afii57802'] = 0x05B3;
  15357. t['afii57803'] = 0x05C2;
  15358. t['afii57804'] = 0x05C1;
  15359. t['afii57806'] = 0x05B9;
  15360. t['afii57807'] = 0x05BC;
  15361. t['afii57839'] = 0x05BD;
  15362. t['afii57841'] = 0x05BF;
  15363. t['afii57842'] = 0x05C0;
  15364. t['afii57929'] = 0x02BC;
  15365. t['afii61248'] = 0x2105;
  15366. t['afii61289'] = 0x2113;
  15367. t['afii61352'] = 0x2116;
  15368. t['afii61573'] = 0x202C;
  15369. t['afii61574'] = 0x202D;
  15370. t['afii61575'] = 0x202E;
  15371. t['afii61664'] = 0x200C;
  15372. t['afii63167'] = 0x066D;
  15373. t['afii64937'] = 0x02BD;
  15374. t['agrave'] = 0x00E0;
  15375. t['agujarati'] = 0x0A85;
  15376. t['agurmukhi'] = 0x0A05;
  15377. t['ahiragana'] = 0x3042;
  15378. t['ahookabove'] = 0x1EA3;
  15379. t['aibengali'] = 0x0990;
  15380. t['aibopomofo'] = 0x311E;
  15381. t['aideva'] = 0x0910;
  15382. t['aiecyrillic'] = 0x04D5;
  15383. t['aigujarati'] = 0x0A90;
  15384. t['aigurmukhi'] = 0x0A10;
  15385. t['aimatragurmukhi'] = 0x0A48;
  15386. t['ainarabic'] = 0x0639;
  15387. t['ainfinalarabic'] = 0xFECA;
  15388. t['aininitialarabic'] = 0xFECB;
  15389. t['ainmedialarabic'] = 0xFECC;
  15390. t['ainvertedbreve'] = 0x0203;
  15391. t['aivowelsignbengali'] = 0x09C8;
  15392. t['aivowelsigndeva'] = 0x0948;
  15393. t['aivowelsigngujarati'] = 0x0AC8;
  15394. t['akatakana'] = 0x30A2;
  15395. t['akatakanahalfwidth'] = 0xFF71;
  15396. t['akorean'] = 0x314F;
  15397. t['alef'] = 0x05D0;
  15398. t['alefarabic'] = 0x0627;
  15399. t['alefdageshhebrew'] = 0xFB30;
  15400. t['aleffinalarabic'] = 0xFE8E;
  15401. t['alefhamzaabovearabic'] = 0x0623;
  15402. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15403. t['alefhamzabelowarabic'] = 0x0625;
  15404. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15405. t['alefhebrew'] = 0x05D0;
  15406. t['aleflamedhebrew'] = 0xFB4F;
  15407. t['alefmaddaabovearabic'] = 0x0622;
  15408. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15409. t['alefmaksuraarabic'] = 0x0649;
  15410. t['alefmaksurafinalarabic'] = 0xFEF0;
  15411. t['alefmaksurainitialarabic'] = 0xFEF3;
  15412. t['alefmaksuramedialarabic'] = 0xFEF4;
  15413. t['alefpatahhebrew'] = 0xFB2E;
  15414. t['alefqamatshebrew'] = 0xFB2F;
  15415. t['aleph'] = 0x2135;
  15416. t['allequal'] = 0x224C;
  15417. t['alpha'] = 0x03B1;
  15418. t['alphatonos'] = 0x03AC;
  15419. t['amacron'] = 0x0101;
  15420. t['amonospace'] = 0xFF41;
  15421. t['ampersand'] = 0x0026;
  15422. t['ampersandmonospace'] = 0xFF06;
  15423. t['ampersandsmall'] = 0xF726;
  15424. t['amsquare'] = 0x33C2;
  15425. t['anbopomofo'] = 0x3122;
  15426. t['angbopomofo'] = 0x3124;
  15427. t['angbracketleft'] = 0x3008;
  15428. t['angbracketright'] = 0x3009;
  15429. t['angkhankhuthai'] = 0x0E5A;
  15430. t['angle'] = 0x2220;
  15431. t['anglebracketleft'] = 0x3008;
  15432. t['anglebracketleftvertical'] = 0xFE3F;
  15433. t['anglebracketright'] = 0x3009;
  15434. t['anglebracketrightvertical'] = 0xFE40;
  15435. t['angleleft'] = 0x2329;
  15436. t['angleright'] = 0x232A;
  15437. t['angstrom'] = 0x212B;
  15438. t['anoteleia'] = 0x0387;
  15439. t['anudattadeva'] = 0x0952;
  15440. t['anusvarabengali'] = 0x0982;
  15441. t['anusvaradeva'] = 0x0902;
  15442. t['anusvaragujarati'] = 0x0A82;
  15443. t['aogonek'] = 0x0105;
  15444. t['apaatosquare'] = 0x3300;
  15445. t['aparen'] = 0x249C;
  15446. t['apostrophearmenian'] = 0x055A;
  15447. t['apostrophemod'] = 0x02BC;
  15448. t['apple'] = 0xF8FF;
  15449. t['approaches'] = 0x2250;
  15450. t['approxequal'] = 0x2248;
  15451. t['approxequalorimage'] = 0x2252;
  15452. t['approximatelyequal'] = 0x2245;
  15453. t['araeaekorean'] = 0x318E;
  15454. t['araeakorean'] = 0x318D;
  15455. t['arc'] = 0x2312;
  15456. t['arighthalfring'] = 0x1E9A;
  15457. t['aring'] = 0x00E5;
  15458. t['aringacute'] = 0x01FB;
  15459. t['aringbelow'] = 0x1E01;
  15460. t['arrowboth'] = 0x2194;
  15461. t['arrowdashdown'] = 0x21E3;
  15462. t['arrowdashleft'] = 0x21E0;
  15463. t['arrowdashright'] = 0x21E2;
  15464. t['arrowdashup'] = 0x21E1;
  15465. t['arrowdblboth'] = 0x21D4;
  15466. t['arrowdbldown'] = 0x21D3;
  15467. t['arrowdblleft'] = 0x21D0;
  15468. t['arrowdblright'] = 0x21D2;
  15469. t['arrowdblup'] = 0x21D1;
  15470. t['arrowdown'] = 0x2193;
  15471. t['arrowdownleft'] = 0x2199;
  15472. t['arrowdownright'] = 0x2198;
  15473. t['arrowdownwhite'] = 0x21E9;
  15474. t['arrowheaddownmod'] = 0x02C5;
  15475. t['arrowheadleftmod'] = 0x02C2;
  15476. t['arrowheadrightmod'] = 0x02C3;
  15477. t['arrowheadupmod'] = 0x02C4;
  15478. t['arrowhorizex'] = 0xF8E7;
  15479. t['arrowleft'] = 0x2190;
  15480. t['arrowleftdbl'] = 0x21D0;
  15481. t['arrowleftdblstroke'] = 0x21CD;
  15482. t['arrowleftoverright'] = 0x21C6;
  15483. t['arrowleftwhite'] = 0x21E6;
  15484. t['arrowright'] = 0x2192;
  15485. t['arrowrightdblstroke'] = 0x21CF;
  15486. t['arrowrightheavy'] = 0x279E;
  15487. t['arrowrightoverleft'] = 0x21C4;
  15488. t['arrowrightwhite'] = 0x21E8;
  15489. t['arrowtableft'] = 0x21E4;
  15490. t['arrowtabright'] = 0x21E5;
  15491. t['arrowup'] = 0x2191;
  15492. t['arrowupdn'] = 0x2195;
  15493. t['arrowupdnbse'] = 0x21A8;
  15494. t['arrowupdownbase'] = 0x21A8;
  15495. t['arrowupleft'] = 0x2196;
  15496. t['arrowupleftofdown'] = 0x21C5;
  15497. t['arrowupright'] = 0x2197;
  15498. t['arrowupwhite'] = 0x21E7;
  15499. t['arrowvertex'] = 0xF8E6;
  15500. t['asciicircum'] = 0x005E;
  15501. t['asciicircummonospace'] = 0xFF3E;
  15502. t['asciitilde'] = 0x007E;
  15503. t['asciitildemonospace'] = 0xFF5E;
  15504. t['ascript'] = 0x0251;
  15505. t['ascriptturned'] = 0x0252;
  15506. t['asmallhiragana'] = 0x3041;
  15507. t['asmallkatakana'] = 0x30A1;
  15508. t['asmallkatakanahalfwidth'] = 0xFF67;
  15509. t['asterisk'] = 0x002A;
  15510. t['asteriskaltonearabic'] = 0x066D;
  15511. t['asteriskarabic'] = 0x066D;
  15512. t['asteriskmath'] = 0x2217;
  15513. t['asteriskmonospace'] = 0xFF0A;
  15514. t['asterisksmall'] = 0xFE61;
  15515. t['asterism'] = 0x2042;
  15516. t['asuperior'] = 0xF6E9;
  15517. t['asymptoticallyequal'] = 0x2243;
  15518. t['at'] = 0x0040;
  15519. t['atilde'] = 0x00E3;
  15520. t['atmonospace'] = 0xFF20;
  15521. t['atsmall'] = 0xFE6B;
  15522. t['aturned'] = 0x0250;
  15523. t['aubengali'] = 0x0994;
  15524. t['aubopomofo'] = 0x3120;
  15525. t['audeva'] = 0x0914;
  15526. t['augujarati'] = 0x0A94;
  15527. t['augurmukhi'] = 0x0A14;
  15528. t['aulengthmarkbengali'] = 0x09D7;
  15529. t['aumatragurmukhi'] = 0x0A4C;
  15530. t['auvowelsignbengali'] = 0x09CC;
  15531. t['auvowelsigndeva'] = 0x094C;
  15532. t['auvowelsigngujarati'] = 0x0ACC;
  15533. t['avagrahadeva'] = 0x093D;
  15534. t['aybarmenian'] = 0x0561;
  15535. t['ayin'] = 0x05E2;
  15536. t['ayinaltonehebrew'] = 0xFB20;
  15537. t['ayinhebrew'] = 0x05E2;
  15538. t['b'] = 0x0062;
  15539. t['babengali'] = 0x09AC;
  15540. t['backslash'] = 0x005C;
  15541. t['backslashmonospace'] = 0xFF3C;
  15542. t['badeva'] = 0x092C;
  15543. t['bagujarati'] = 0x0AAC;
  15544. t['bagurmukhi'] = 0x0A2C;
  15545. t['bahiragana'] = 0x3070;
  15546. t['bahtthai'] = 0x0E3F;
  15547. t['bakatakana'] = 0x30D0;
  15548. t['bar'] = 0x007C;
  15549. t['barmonospace'] = 0xFF5C;
  15550. t['bbopomofo'] = 0x3105;
  15551. t['bcircle'] = 0x24D1;
  15552. t['bdotaccent'] = 0x1E03;
  15553. t['bdotbelow'] = 0x1E05;
  15554. t['beamedsixteenthnotes'] = 0x266C;
  15555. t['because'] = 0x2235;
  15556. t['becyrillic'] = 0x0431;
  15557. t['beharabic'] = 0x0628;
  15558. t['behfinalarabic'] = 0xFE90;
  15559. t['behinitialarabic'] = 0xFE91;
  15560. t['behiragana'] = 0x3079;
  15561. t['behmedialarabic'] = 0xFE92;
  15562. t['behmeeminitialarabic'] = 0xFC9F;
  15563. t['behmeemisolatedarabic'] = 0xFC08;
  15564. t['behnoonfinalarabic'] = 0xFC6D;
  15565. t['bekatakana'] = 0x30D9;
  15566. t['benarmenian'] = 0x0562;
  15567. t['bet'] = 0x05D1;
  15568. t['beta'] = 0x03B2;
  15569. t['betasymbolgreek'] = 0x03D0;
  15570. t['betdagesh'] = 0xFB31;
  15571. t['betdageshhebrew'] = 0xFB31;
  15572. t['bethebrew'] = 0x05D1;
  15573. t['betrafehebrew'] = 0xFB4C;
  15574. t['bhabengali'] = 0x09AD;
  15575. t['bhadeva'] = 0x092D;
  15576. t['bhagujarati'] = 0x0AAD;
  15577. t['bhagurmukhi'] = 0x0A2D;
  15578. t['bhook'] = 0x0253;
  15579. t['bihiragana'] = 0x3073;
  15580. t['bikatakana'] = 0x30D3;
  15581. t['bilabialclick'] = 0x0298;
  15582. t['bindigurmukhi'] = 0x0A02;
  15583. t['birusquare'] = 0x3331;
  15584. t['blackcircle'] = 0x25CF;
  15585. t['blackdiamond'] = 0x25C6;
  15586. t['blackdownpointingtriangle'] = 0x25BC;
  15587. t['blackleftpointingpointer'] = 0x25C4;
  15588. t['blackleftpointingtriangle'] = 0x25C0;
  15589. t['blacklenticularbracketleft'] = 0x3010;
  15590. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15591. t['blacklenticularbracketright'] = 0x3011;
  15592. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15593. t['blacklowerlefttriangle'] = 0x25E3;
  15594. t['blacklowerrighttriangle'] = 0x25E2;
  15595. t['blackrectangle'] = 0x25AC;
  15596. t['blackrightpointingpointer'] = 0x25BA;
  15597. t['blackrightpointingtriangle'] = 0x25B6;
  15598. t['blacksmallsquare'] = 0x25AA;
  15599. t['blacksmilingface'] = 0x263B;
  15600. t['blacksquare'] = 0x25A0;
  15601. t['blackstar'] = 0x2605;
  15602. t['blackupperlefttriangle'] = 0x25E4;
  15603. t['blackupperrighttriangle'] = 0x25E5;
  15604. t['blackuppointingsmalltriangle'] = 0x25B4;
  15605. t['blackuppointingtriangle'] = 0x25B2;
  15606. t['blank'] = 0x2423;
  15607. t['blinebelow'] = 0x1E07;
  15608. t['block'] = 0x2588;
  15609. t['bmonospace'] = 0xFF42;
  15610. t['bobaimaithai'] = 0x0E1A;
  15611. t['bohiragana'] = 0x307C;
  15612. t['bokatakana'] = 0x30DC;
  15613. t['bparen'] = 0x249D;
  15614. t['bqsquare'] = 0x33C3;
  15615. t['braceex'] = 0xF8F4;
  15616. t['braceleft'] = 0x007B;
  15617. t['braceleftbt'] = 0xF8F3;
  15618. t['braceleftmid'] = 0xF8F2;
  15619. t['braceleftmonospace'] = 0xFF5B;
  15620. t['braceleftsmall'] = 0xFE5B;
  15621. t['bracelefttp'] = 0xF8F1;
  15622. t['braceleftvertical'] = 0xFE37;
  15623. t['braceright'] = 0x007D;
  15624. t['bracerightbt'] = 0xF8FE;
  15625. t['bracerightmid'] = 0xF8FD;
  15626. t['bracerightmonospace'] = 0xFF5D;
  15627. t['bracerightsmall'] = 0xFE5C;
  15628. t['bracerighttp'] = 0xF8FC;
  15629. t['bracerightvertical'] = 0xFE38;
  15630. t['bracketleft'] = 0x005B;
  15631. t['bracketleftbt'] = 0xF8F0;
  15632. t['bracketleftex'] = 0xF8EF;
  15633. t['bracketleftmonospace'] = 0xFF3B;
  15634. t['bracketlefttp'] = 0xF8EE;
  15635. t['bracketright'] = 0x005D;
  15636. t['bracketrightbt'] = 0xF8FB;
  15637. t['bracketrightex'] = 0xF8FA;
  15638. t['bracketrightmonospace'] = 0xFF3D;
  15639. t['bracketrighttp'] = 0xF8F9;
  15640. t['breve'] = 0x02D8;
  15641. t['brevebelowcmb'] = 0x032E;
  15642. t['brevecmb'] = 0x0306;
  15643. t['breveinvertedbelowcmb'] = 0x032F;
  15644. t['breveinvertedcmb'] = 0x0311;
  15645. t['breveinverteddoublecmb'] = 0x0361;
  15646. t['bridgebelowcmb'] = 0x032A;
  15647. t['bridgeinvertedbelowcmb'] = 0x033A;
  15648. t['brokenbar'] = 0x00A6;
  15649. t['bstroke'] = 0x0180;
  15650. t['bsuperior'] = 0xF6EA;
  15651. t['btopbar'] = 0x0183;
  15652. t['buhiragana'] = 0x3076;
  15653. t['bukatakana'] = 0x30D6;
  15654. t['bullet'] = 0x2022;
  15655. t['bulletinverse'] = 0x25D8;
  15656. t['bulletoperator'] = 0x2219;
  15657. t['bullseye'] = 0x25CE;
  15658. t['c'] = 0x0063;
  15659. t['caarmenian'] = 0x056E;
  15660. t['cabengali'] = 0x099A;
  15661. t['cacute'] = 0x0107;
  15662. t['cadeva'] = 0x091A;
  15663. t['cagujarati'] = 0x0A9A;
  15664. t['cagurmukhi'] = 0x0A1A;
  15665. t['calsquare'] = 0x3388;
  15666. t['candrabindubengali'] = 0x0981;
  15667. t['candrabinducmb'] = 0x0310;
  15668. t['candrabindudeva'] = 0x0901;
  15669. t['candrabindugujarati'] = 0x0A81;
  15670. t['capslock'] = 0x21EA;
  15671. t['careof'] = 0x2105;
  15672. t['caron'] = 0x02C7;
  15673. t['caronbelowcmb'] = 0x032C;
  15674. t['caroncmb'] = 0x030C;
  15675. t['carriagereturn'] = 0x21B5;
  15676. t['cbopomofo'] = 0x3118;
  15677. t['ccaron'] = 0x010D;
  15678. t['ccedilla'] = 0x00E7;
  15679. t['ccedillaacute'] = 0x1E09;
  15680. t['ccircle'] = 0x24D2;
  15681. t['ccircumflex'] = 0x0109;
  15682. t['ccurl'] = 0x0255;
  15683. t['cdot'] = 0x010B;
  15684. t['cdotaccent'] = 0x010B;
  15685. t['cdsquare'] = 0x33C5;
  15686. t['cedilla'] = 0x00B8;
  15687. t['cedillacmb'] = 0x0327;
  15688. t['cent'] = 0x00A2;
  15689. t['centigrade'] = 0x2103;
  15690. t['centinferior'] = 0xF6DF;
  15691. t['centmonospace'] = 0xFFE0;
  15692. t['centoldstyle'] = 0xF7A2;
  15693. t['centsuperior'] = 0xF6E0;
  15694. t['chaarmenian'] = 0x0579;
  15695. t['chabengali'] = 0x099B;
  15696. t['chadeva'] = 0x091B;
  15697. t['chagujarati'] = 0x0A9B;
  15698. t['chagurmukhi'] = 0x0A1B;
  15699. t['chbopomofo'] = 0x3114;
  15700. t['cheabkhasiancyrillic'] = 0x04BD;
  15701. t['checkmark'] = 0x2713;
  15702. t['checyrillic'] = 0x0447;
  15703. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15704. t['chedescendercyrillic'] = 0x04B7;
  15705. t['chedieresiscyrillic'] = 0x04F5;
  15706. t['cheharmenian'] = 0x0573;
  15707. t['chekhakassiancyrillic'] = 0x04CC;
  15708. t['cheverticalstrokecyrillic'] = 0x04B9;
  15709. t['chi'] = 0x03C7;
  15710. t['chieuchacirclekorean'] = 0x3277;
  15711. t['chieuchaparenkorean'] = 0x3217;
  15712. t['chieuchcirclekorean'] = 0x3269;
  15713. t['chieuchkorean'] = 0x314A;
  15714. t['chieuchparenkorean'] = 0x3209;
  15715. t['chochangthai'] = 0x0E0A;
  15716. t['chochanthai'] = 0x0E08;
  15717. t['chochingthai'] = 0x0E09;
  15718. t['chochoethai'] = 0x0E0C;
  15719. t['chook'] = 0x0188;
  15720. t['cieucacirclekorean'] = 0x3276;
  15721. t['cieucaparenkorean'] = 0x3216;
  15722. t['cieuccirclekorean'] = 0x3268;
  15723. t['cieuckorean'] = 0x3148;
  15724. t['cieucparenkorean'] = 0x3208;
  15725. t['cieucuparenkorean'] = 0x321C;
  15726. t['circle'] = 0x25CB;
  15727. t['circlecopyrt'] = 0x00A9;
  15728. t['circlemultiply'] = 0x2297;
  15729. t['circleot'] = 0x2299;
  15730. t['circleplus'] = 0x2295;
  15731. t['circlepostalmark'] = 0x3036;
  15732. t['circlewithlefthalfblack'] = 0x25D0;
  15733. t['circlewithrighthalfblack'] = 0x25D1;
  15734. t['circumflex'] = 0x02C6;
  15735. t['circumflexbelowcmb'] = 0x032D;
  15736. t['circumflexcmb'] = 0x0302;
  15737. t['clear'] = 0x2327;
  15738. t['clickalveolar'] = 0x01C2;
  15739. t['clickdental'] = 0x01C0;
  15740. t['clicklateral'] = 0x01C1;
  15741. t['clickretroflex'] = 0x01C3;
  15742. t['club'] = 0x2663;
  15743. t['clubsuitblack'] = 0x2663;
  15744. t['clubsuitwhite'] = 0x2667;
  15745. t['cmcubedsquare'] = 0x33A4;
  15746. t['cmonospace'] = 0xFF43;
  15747. t['cmsquaredsquare'] = 0x33A0;
  15748. t['coarmenian'] = 0x0581;
  15749. t['colon'] = 0x003A;
  15750. t['colonmonetary'] = 0x20A1;
  15751. t['colonmonospace'] = 0xFF1A;
  15752. t['colonsign'] = 0x20A1;
  15753. t['colonsmall'] = 0xFE55;
  15754. t['colontriangularhalfmod'] = 0x02D1;
  15755. t['colontriangularmod'] = 0x02D0;
  15756. t['comma'] = 0x002C;
  15757. t['commaabovecmb'] = 0x0313;
  15758. t['commaaboverightcmb'] = 0x0315;
  15759. t['commaaccent'] = 0xF6C3;
  15760. t['commaarabic'] = 0x060C;
  15761. t['commaarmenian'] = 0x055D;
  15762. t['commainferior'] = 0xF6E1;
  15763. t['commamonospace'] = 0xFF0C;
  15764. t['commareversedabovecmb'] = 0x0314;
  15765. t['commareversedmod'] = 0x02BD;
  15766. t['commasmall'] = 0xFE50;
  15767. t['commasuperior'] = 0xF6E2;
  15768. t['commaturnedabovecmb'] = 0x0312;
  15769. t['commaturnedmod'] = 0x02BB;
  15770. t['compass'] = 0x263C;
  15771. t['congruent'] = 0x2245;
  15772. t['contourintegral'] = 0x222E;
  15773. t['control'] = 0x2303;
  15774. t['controlACK'] = 0x0006;
  15775. t['controlBEL'] = 0x0007;
  15776. t['controlBS'] = 0x0008;
  15777. t['controlCAN'] = 0x0018;
  15778. t['controlCR'] = 0x000D;
  15779. t['controlDC1'] = 0x0011;
  15780. t['controlDC2'] = 0x0012;
  15781. t['controlDC3'] = 0x0013;
  15782. t['controlDC4'] = 0x0014;
  15783. t['controlDEL'] = 0x007F;
  15784. t['controlDLE'] = 0x0010;
  15785. t['controlEM'] = 0x0019;
  15786. t['controlENQ'] = 0x0005;
  15787. t['controlEOT'] = 0x0004;
  15788. t['controlESC'] = 0x001B;
  15789. t['controlETB'] = 0x0017;
  15790. t['controlETX'] = 0x0003;
  15791. t['controlFF'] = 0x000C;
  15792. t['controlFS'] = 0x001C;
  15793. t['controlGS'] = 0x001D;
  15794. t['controlHT'] = 0x0009;
  15795. t['controlLF'] = 0x000A;
  15796. t['controlNAK'] = 0x0015;
  15797. t['controlNULL'] = 0x0000;
  15798. t['controlRS'] = 0x001E;
  15799. t['controlSI'] = 0x000F;
  15800. t['controlSO'] = 0x000E;
  15801. t['controlSOT'] = 0x0002;
  15802. t['controlSTX'] = 0x0001;
  15803. t['controlSUB'] = 0x001A;
  15804. t['controlSYN'] = 0x0016;
  15805. t['controlUS'] = 0x001F;
  15806. t['controlVT'] = 0x000B;
  15807. t['copyright'] = 0x00A9;
  15808. t['copyrightsans'] = 0xF8E9;
  15809. t['copyrightserif'] = 0xF6D9;
  15810. t['cornerbracketleft'] = 0x300C;
  15811. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15812. t['cornerbracketleftvertical'] = 0xFE41;
  15813. t['cornerbracketright'] = 0x300D;
  15814. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15815. t['cornerbracketrightvertical'] = 0xFE42;
  15816. t['corporationsquare'] = 0x337F;
  15817. t['cosquare'] = 0x33C7;
  15818. t['coverkgsquare'] = 0x33C6;
  15819. t['cparen'] = 0x249E;
  15820. t['cruzeiro'] = 0x20A2;
  15821. t['cstretched'] = 0x0297;
  15822. t['curlyand'] = 0x22CF;
  15823. t['curlyor'] = 0x22CE;
  15824. t['currency'] = 0x00A4;
  15825. t['cyrBreve'] = 0xF6D1;
  15826. t['cyrFlex'] = 0xF6D2;
  15827. t['cyrbreve'] = 0xF6D4;
  15828. t['cyrflex'] = 0xF6D5;
  15829. t['d'] = 0x0064;
  15830. t['daarmenian'] = 0x0564;
  15831. t['dabengali'] = 0x09A6;
  15832. t['dadarabic'] = 0x0636;
  15833. t['dadeva'] = 0x0926;
  15834. t['dadfinalarabic'] = 0xFEBE;
  15835. t['dadinitialarabic'] = 0xFEBF;
  15836. t['dadmedialarabic'] = 0xFEC0;
  15837. t['dagesh'] = 0x05BC;
  15838. t['dageshhebrew'] = 0x05BC;
  15839. t['dagger'] = 0x2020;
  15840. t['daggerdbl'] = 0x2021;
  15841. t['dagujarati'] = 0x0AA6;
  15842. t['dagurmukhi'] = 0x0A26;
  15843. t['dahiragana'] = 0x3060;
  15844. t['dakatakana'] = 0x30C0;
  15845. t['dalarabic'] = 0x062F;
  15846. t['dalet'] = 0x05D3;
  15847. t['daletdagesh'] = 0xFB33;
  15848. t['daletdageshhebrew'] = 0xFB33;
  15849. t['dalethebrew'] = 0x05D3;
  15850. t['dalfinalarabic'] = 0xFEAA;
  15851. t['dammaarabic'] = 0x064F;
  15852. t['dammalowarabic'] = 0x064F;
  15853. t['dammatanaltonearabic'] = 0x064C;
  15854. t['dammatanarabic'] = 0x064C;
  15855. t['danda'] = 0x0964;
  15856. t['dargahebrew'] = 0x05A7;
  15857. t['dargalefthebrew'] = 0x05A7;
  15858. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15859. t['dblGrave'] = 0xF6D3;
  15860. t['dblanglebracketleft'] = 0x300A;
  15861. t['dblanglebracketleftvertical'] = 0xFE3D;
  15862. t['dblanglebracketright'] = 0x300B;
  15863. t['dblanglebracketrightvertical'] = 0xFE3E;
  15864. t['dblarchinvertedbelowcmb'] = 0x032B;
  15865. t['dblarrowleft'] = 0x21D4;
  15866. t['dblarrowright'] = 0x21D2;
  15867. t['dbldanda'] = 0x0965;
  15868. t['dblgrave'] = 0xF6D6;
  15869. t['dblgravecmb'] = 0x030F;
  15870. t['dblintegral'] = 0x222C;
  15871. t['dbllowline'] = 0x2017;
  15872. t['dbllowlinecmb'] = 0x0333;
  15873. t['dbloverlinecmb'] = 0x033F;
  15874. t['dblprimemod'] = 0x02BA;
  15875. t['dblverticalbar'] = 0x2016;
  15876. t['dblverticallineabovecmb'] = 0x030E;
  15877. t['dbopomofo'] = 0x3109;
  15878. t['dbsquare'] = 0x33C8;
  15879. t['dcaron'] = 0x010F;
  15880. t['dcedilla'] = 0x1E11;
  15881. t['dcircle'] = 0x24D3;
  15882. t['dcircumflexbelow'] = 0x1E13;
  15883. t['dcroat'] = 0x0111;
  15884. t['ddabengali'] = 0x09A1;
  15885. t['ddadeva'] = 0x0921;
  15886. t['ddagujarati'] = 0x0AA1;
  15887. t['ddagurmukhi'] = 0x0A21;
  15888. t['ddalarabic'] = 0x0688;
  15889. t['ddalfinalarabic'] = 0xFB89;
  15890. t['dddhadeva'] = 0x095C;
  15891. t['ddhabengali'] = 0x09A2;
  15892. t['ddhadeva'] = 0x0922;
  15893. t['ddhagujarati'] = 0x0AA2;
  15894. t['ddhagurmukhi'] = 0x0A22;
  15895. t['ddotaccent'] = 0x1E0B;
  15896. t['ddotbelow'] = 0x1E0D;
  15897. t['decimalseparatorarabic'] = 0x066B;
  15898. t['decimalseparatorpersian'] = 0x066B;
  15899. t['decyrillic'] = 0x0434;
  15900. t['degree'] = 0x00B0;
  15901. t['dehihebrew'] = 0x05AD;
  15902. t['dehiragana'] = 0x3067;
  15903. t['deicoptic'] = 0x03EF;
  15904. t['dekatakana'] = 0x30C7;
  15905. t['deleteleft'] = 0x232B;
  15906. t['deleteright'] = 0x2326;
  15907. t['delta'] = 0x03B4;
  15908. t['deltaturned'] = 0x018D;
  15909. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15910. t['dezh'] = 0x02A4;
  15911. t['dhabengali'] = 0x09A7;
  15912. t['dhadeva'] = 0x0927;
  15913. t['dhagujarati'] = 0x0AA7;
  15914. t['dhagurmukhi'] = 0x0A27;
  15915. t['dhook'] = 0x0257;
  15916. t['dialytikatonos'] = 0x0385;
  15917. t['dialytikatonoscmb'] = 0x0344;
  15918. t['diamond'] = 0x2666;
  15919. t['diamondsuitwhite'] = 0x2662;
  15920. t['dieresis'] = 0x00A8;
  15921. t['dieresisacute'] = 0xF6D7;
  15922. t['dieresisbelowcmb'] = 0x0324;
  15923. t['dieresiscmb'] = 0x0308;
  15924. t['dieresisgrave'] = 0xF6D8;
  15925. t['dieresistonos'] = 0x0385;
  15926. t['dihiragana'] = 0x3062;
  15927. t['dikatakana'] = 0x30C2;
  15928. t['dittomark'] = 0x3003;
  15929. t['divide'] = 0x00F7;
  15930. t['divides'] = 0x2223;
  15931. t['divisionslash'] = 0x2215;
  15932. t['djecyrillic'] = 0x0452;
  15933. t['dkshade'] = 0x2593;
  15934. t['dlinebelow'] = 0x1E0F;
  15935. t['dlsquare'] = 0x3397;
  15936. t['dmacron'] = 0x0111;
  15937. t['dmonospace'] = 0xFF44;
  15938. t['dnblock'] = 0x2584;
  15939. t['dochadathai'] = 0x0E0E;
  15940. t['dodekthai'] = 0x0E14;
  15941. t['dohiragana'] = 0x3069;
  15942. t['dokatakana'] = 0x30C9;
  15943. t['dollar'] = 0x0024;
  15944. t['dollarinferior'] = 0xF6E3;
  15945. t['dollarmonospace'] = 0xFF04;
  15946. t['dollaroldstyle'] = 0xF724;
  15947. t['dollarsmall'] = 0xFE69;
  15948. t['dollarsuperior'] = 0xF6E4;
  15949. t['dong'] = 0x20AB;
  15950. t['dorusquare'] = 0x3326;
  15951. t['dotaccent'] = 0x02D9;
  15952. t['dotaccentcmb'] = 0x0307;
  15953. t['dotbelowcmb'] = 0x0323;
  15954. t['dotbelowcomb'] = 0x0323;
  15955. t['dotkatakana'] = 0x30FB;
  15956. t['dotlessi'] = 0x0131;
  15957. t['dotlessj'] = 0xF6BE;
  15958. t['dotlessjstrokehook'] = 0x0284;
  15959. t['dotmath'] = 0x22C5;
  15960. t['dottedcircle'] = 0x25CC;
  15961. t['doubleyodpatah'] = 0xFB1F;
  15962. t['doubleyodpatahhebrew'] = 0xFB1F;
  15963. t['downtackbelowcmb'] = 0x031E;
  15964. t['downtackmod'] = 0x02D5;
  15965. t['dparen'] = 0x249F;
  15966. t['dsuperior'] = 0xF6EB;
  15967. t['dtail'] = 0x0256;
  15968. t['dtopbar'] = 0x018C;
  15969. t['duhiragana'] = 0x3065;
  15970. t['dukatakana'] = 0x30C5;
  15971. t['dz'] = 0x01F3;
  15972. t['dzaltone'] = 0x02A3;
  15973. t['dzcaron'] = 0x01C6;
  15974. t['dzcurl'] = 0x02A5;
  15975. t['dzeabkhasiancyrillic'] = 0x04E1;
  15976. t['dzecyrillic'] = 0x0455;
  15977. t['dzhecyrillic'] = 0x045F;
  15978. t['e'] = 0x0065;
  15979. t['eacute'] = 0x00E9;
  15980. t['earth'] = 0x2641;
  15981. t['ebengali'] = 0x098F;
  15982. t['ebopomofo'] = 0x311C;
  15983. t['ebreve'] = 0x0115;
  15984. t['ecandradeva'] = 0x090D;
  15985. t['ecandragujarati'] = 0x0A8D;
  15986. t['ecandravowelsigndeva'] = 0x0945;
  15987. t['ecandravowelsigngujarati'] = 0x0AC5;
  15988. t['ecaron'] = 0x011B;
  15989. t['ecedillabreve'] = 0x1E1D;
  15990. t['echarmenian'] = 0x0565;
  15991. t['echyiwnarmenian'] = 0x0587;
  15992. t['ecircle'] = 0x24D4;
  15993. t['ecircumflex'] = 0x00EA;
  15994. t['ecircumflexacute'] = 0x1EBF;
  15995. t['ecircumflexbelow'] = 0x1E19;
  15996. t['ecircumflexdotbelow'] = 0x1EC7;
  15997. t['ecircumflexgrave'] = 0x1EC1;
  15998. t['ecircumflexhookabove'] = 0x1EC3;
  15999. t['ecircumflextilde'] = 0x1EC5;
  16000. t['ecyrillic'] = 0x0454;
  16001. t['edblgrave'] = 0x0205;
  16002. t['edeva'] = 0x090F;
  16003. t['edieresis'] = 0x00EB;
  16004. t['edot'] = 0x0117;
  16005. t['edotaccent'] = 0x0117;
  16006. t['edotbelow'] = 0x1EB9;
  16007. t['eegurmukhi'] = 0x0A0F;
  16008. t['eematragurmukhi'] = 0x0A47;
  16009. t['efcyrillic'] = 0x0444;
  16010. t['egrave'] = 0x00E8;
  16011. t['egujarati'] = 0x0A8F;
  16012. t['eharmenian'] = 0x0567;
  16013. t['ehbopomofo'] = 0x311D;
  16014. t['ehiragana'] = 0x3048;
  16015. t['ehookabove'] = 0x1EBB;
  16016. t['eibopomofo'] = 0x311F;
  16017. t['eight'] = 0x0038;
  16018. t['eightarabic'] = 0x0668;
  16019. t['eightbengali'] = 0x09EE;
  16020. t['eightcircle'] = 0x2467;
  16021. t['eightcircleinversesansserif'] = 0x2791;
  16022. t['eightdeva'] = 0x096E;
  16023. t['eighteencircle'] = 0x2471;
  16024. t['eighteenparen'] = 0x2485;
  16025. t['eighteenperiod'] = 0x2499;
  16026. t['eightgujarati'] = 0x0AEE;
  16027. t['eightgurmukhi'] = 0x0A6E;
  16028. t['eighthackarabic'] = 0x0668;
  16029. t['eighthangzhou'] = 0x3028;
  16030. t['eighthnotebeamed'] = 0x266B;
  16031. t['eightideographicparen'] = 0x3227;
  16032. t['eightinferior'] = 0x2088;
  16033. t['eightmonospace'] = 0xFF18;
  16034. t['eightoldstyle'] = 0xF738;
  16035. t['eightparen'] = 0x247B;
  16036. t['eightperiod'] = 0x248F;
  16037. t['eightpersian'] = 0x06F8;
  16038. t['eightroman'] = 0x2177;
  16039. t['eightsuperior'] = 0x2078;
  16040. t['eightthai'] = 0x0E58;
  16041. t['einvertedbreve'] = 0x0207;
  16042. t['eiotifiedcyrillic'] = 0x0465;
  16043. t['ekatakana'] = 0x30A8;
  16044. t['ekatakanahalfwidth'] = 0xFF74;
  16045. t['ekonkargurmukhi'] = 0x0A74;
  16046. t['ekorean'] = 0x3154;
  16047. t['elcyrillic'] = 0x043B;
  16048. t['element'] = 0x2208;
  16049. t['elevencircle'] = 0x246A;
  16050. t['elevenparen'] = 0x247E;
  16051. t['elevenperiod'] = 0x2492;
  16052. t['elevenroman'] = 0x217A;
  16053. t['ellipsis'] = 0x2026;
  16054. t['ellipsisvertical'] = 0x22EE;
  16055. t['emacron'] = 0x0113;
  16056. t['emacronacute'] = 0x1E17;
  16057. t['emacrongrave'] = 0x1E15;
  16058. t['emcyrillic'] = 0x043C;
  16059. t['emdash'] = 0x2014;
  16060. t['emdashvertical'] = 0xFE31;
  16061. t['emonospace'] = 0xFF45;
  16062. t['emphasismarkarmenian'] = 0x055B;
  16063. t['emptyset'] = 0x2205;
  16064. t['enbopomofo'] = 0x3123;
  16065. t['encyrillic'] = 0x043D;
  16066. t['endash'] = 0x2013;
  16067. t['endashvertical'] = 0xFE32;
  16068. t['endescendercyrillic'] = 0x04A3;
  16069. t['eng'] = 0x014B;
  16070. t['engbopomofo'] = 0x3125;
  16071. t['enghecyrillic'] = 0x04A5;
  16072. t['enhookcyrillic'] = 0x04C8;
  16073. t['enspace'] = 0x2002;
  16074. t['eogonek'] = 0x0119;
  16075. t['eokorean'] = 0x3153;
  16076. t['eopen'] = 0x025B;
  16077. t['eopenclosed'] = 0x029A;
  16078. t['eopenreversed'] = 0x025C;
  16079. t['eopenreversedclosed'] = 0x025E;
  16080. t['eopenreversedhook'] = 0x025D;
  16081. t['eparen'] = 0x24A0;
  16082. t['epsilon'] = 0x03B5;
  16083. t['epsilontonos'] = 0x03AD;
  16084. t['equal'] = 0x003D;
  16085. t['equalmonospace'] = 0xFF1D;
  16086. t['equalsmall'] = 0xFE66;
  16087. t['equalsuperior'] = 0x207C;
  16088. t['equivalence'] = 0x2261;
  16089. t['erbopomofo'] = 0x3126;
  16090. t['ercyrillic'] = 0x0440;
  16091. t['ereversed'] = 0x0258;
  16092. t['ereversedcyrillic'] = 0x044D;
  16093. t['escyrillic'] = 0x0441;
  16094. t['esdescendercyrillic'] = 0x04AB;
  16095. t['esh'] = 0x0283;
  16096. t['eshcurl'] = 0x0286;
  16097. t['eshortdeva'] = 0x090E;
  16098. t['eshortvowelsigndeva'] = 0x0946;
  16099. t['eshreversedloop'] = 0x01AA;
  16100. t['eshsquatreversed'] = 0x0285;
  16101. t['esmallhiragana'] = 0x3047;
  16102. t['esmallkatakana'] = 0x30A7;
  16103. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16104. t['estimated'] = 0x212E;
  16105. t['esuperior'] = 0xF6EC;
  16106. t['eta'] = 0x03B7;
  16107. t['etarmenian'] = 0x0568;
  16108. t['etatonos'] = 0x03AE;
  16109. t['eth'] = 0x00F0;
  16110. t['etilde'] = 0x1EBD;
  16111. t['etildebelow'] = 0x1E1B;
  16112. t['etnahtafoukhhebrew'] = 0x0591;
  16113. t['etnahtafoukhlefthebrew'] = 0x0591;
  16114. t['etnahtahebrew'] = 0x0591;
  16115. t['etnahtalefthebrew'] = 0x0591;
  16116. t['eturned'] = 0x01DD;
  16117. t['eukorean'] = 0x3161;
  16118. t['euro'] = 0x20AC;
  16119. t['evowelsignbengali'] = 0x09C7;
  16120. t['evowelsigndeva'] = 0x0947;
  16121. t['evowelsigngujarati'] = 0x0AC7;
  16122. t['exclam'] = 0x0021;
  16123. t['exclamarmenian'] = 0x055C;
  16124. t['exclamdbl'] = 0x203C;
  16125. t['exclamdown'] = 0x00A1;
  16126. t['exclamdownsmall'] = 0xF7A1;
  16127. t['exclammonospace'] = 0xFF01;
  16128. t['exclamsmall'] = 0xF721;
  16129. t['existential'] = 0x2203;
  16130. t['ezh'] = 0x0292;
  16131. t['ezhcaron'] = 0x01EF;
  16132. t['ezhcurl'] = 0x0293;
  16133. t['ezhreversed'] = 0x01B9;
  16134. t['ezhtail'] = 0x01BA;
  16135. t['f'] = 0x0066;
  16136. t['fadeva'] = 0x095E;
  16137. t['fagurmukhi'] = 0x0A5E;
  16138. t['fahrenheit'] = 0x2109;
  16139. t['fathaarabic'] = 0x064E;
  16140. t['fathalowarabic'] = 0x064E;
  16141. t['fathatanarabic'] = 0x064B;
  16142. t['fbopomofo'] = 0x3108;
  16143. t['fcircle'] = 0x24D5;
  16144. t['fdotaccent'] = 0x1E1F;
  16145. t['feharabic'] = 0x0641;
  16146. t['feharmenian'] = 0x0586;
  16147. t['fehfinalarabic'] = 0xFED2;
  16148. t['fehinitialarabic'] = 0xFED3;
  16149. t['fehmedialarabic'] = 0xFED4;
  16150. t['feicoptic'] = 0x03E5;
  16151. t['female'] = 0x2640;
  16152. t['ff'] = 0xFB00;
  16153. t['ffi'] = 0xFB03;
  16154. t['ffl'] = 0xFB04;
  16155. t['fi'] = 0xFB01;
  16156. t['fifteencircle'] = 0x246E;
  16157. t['fifteenparen'] = 0x2482;
  16158. t['fifteenperiod'] = 0x2496;
  16159. t['figuredash'] = 0x2012;
  16160. t['filledbox'] = 0x25A0;
  16161. t['filledrect'] = 0x25AC;
  16162. t['finalkaf'] = 0x05DA;
  16163. t['finalkafdagesh'] = 0xFB3A;
  16164. t['finalkafdageshhebrew'] = 0xFB3A;
  16165. t['finalkafhebrew'] = 0x05DA;
  16166. t['finalmem'] = 0x05DD;
  16167. t['finalmemhebrew'] = 0x05DD;
  16168. t['finalnun'] = 0x05DF;
  16169. t['finalnunhebrew'] = 0x05DF;
  16170. t['finalpe'] = 0x05E3;
  16171. t['finalpehebrew'] = 0x05E3;
  16172. t['finaltsadi'] = 0x05E5;
  16173. t['finaltsadihebrew'] = 0x05E5;
  16174. t['firsttonechinese'] = 0x02C9;
  16175. t['fisheye'] = 0x25C9;
  16176. t['fitacyrillic'] = 0x0473;
  16177. t['five'] = 0x0035;
  16178. t['fivearabic'] = 0x0665;
  16179. t['fivebengali'] = 0x09EB;
  16180. t['fivecircle'] = 0x2464;
  16181. t['fivecircleinversesansserif'] = 0x278E;
  16182. t['fivedeva'] = 0x096B;
  16183. t['fiveeighths'] = 0x215D;
  16184. t['fivegujarati'] = 0x0AEB;
  16185. t['fivegurmukhi'] = 0x0A6B;
  16186. t['fivehackarabic'] = 0x0665;
  16187. t['fivehangzhou'] = 0x3025;
  16188. t['fiveideographicparen'] = 0x3224;
  16189. t['fiveinferior'] = 0x2085;
  16190. t['fivemonospace'] = 0xFF15;
  16191. t['fiveoldstyle'] = 0xF735;
  16192. t['fiveparen'] = 0x2478;
  16193. t['fiveperiod'] = 0x248C;
  16194. t['fivepersian'] = 0x06F5;
  16195. t['fiveroman'] = 0x2174;
  16196. t['fivesuperior'] = 0x2075;
  16197. t['fivethai'] = 0x0E55;
  16198. t['fl'] = 0xFB02;
  16199. t['florin'] = 0x0192;
  16200. t['fmonospace'] = 0xFF46;
  16201. t['fmsquare'] = 0x3399;
  16202. t['fofanthai'] = 0x0E1F;
  16203. t['fofathai'] = 0x0E1D;
  16204. t['fongmanthai'] = 0x0E4F;
  16205. t['forall'] = 0x2200;
  16206. t['four'] = 0x0034;
  16207. t['fourarabic'] = 0x0664;
  16208. t['fourbengali'] = 0x09EA;
  16209. t['fourcircle'] = 0x2463;
  16210. t['fourcircleinversesansserif'] = 0x278D;
  16211. t['fourdeva'] = 0x096A;
  16212. t['fourgujarati'] = 0x0AEA;
  16213. t['fourgurmukhi'] = 0x0A6A;
  16214. t['fourhackarabic'] = 0x0664;
  16215. t['fourhangzhou'] = 0x3024;
  16216. t['fourideographicparen'] = 0x3223;
  16217. t['fourinferior'] = 0x2084;
  16218. t['fourmonospace'] = 0xFF14;
  16219. t['fournumeratorbengali'] = 0x09F7;
  16220. t['fouroldstyle'] = 0xF734;
  16221. t['fourparen'] = 0x2477;
  16222. t['fourperiod'] = 0x248B;
  16223. t['fourpersian'] = 0x06F4;
  16224. t['fourroman'] = 0x2173;
  16225. t['foursuperior'] = 0x2074;
  16226. t['fourteencircle'] = 0x246D;
  16227. t['fourteenparen'] = 0x2481;
  16228. t['fourteenperiod'] = 0x2495;
  16229. t['fourthai'] = 0x0E54;
  16230. t['fourthtonechinese'] = 0x02CB;
  16231. t['fparen'] = 0x24A1;
  16232. t['fraction'] = 0x2044;
  16233. t['franc'] = 0x20A3;
  16234. t['g'] = 0x0067;
  16235. t['gabengali'] = 0x0997;
  16236. t['gacute'] = 0x01F5;
  16237. t['gadeva'] = 0x0917;
  16238. t['gafarabic'] = 0x06AF;
  16239. t['gaffinalarabic'] = 0xFB93;
  16240. t['gafinitialarabic'] = 0xFB94;
  16241. t['gafmedialarabic'] = 0xFB95;
  16242. t['gagujarati'] = 0x0A97;
  16243. t['gagurmukhi'] = 0x0A17;
  16244. t['gahiragana'] = 0x304C;
  16245. t['gakatakana'] = 0x30AC;
  16246. t['gamma'] = 0x03B3;
  16247. t['gammalatinsmall'] = 0x0263;
  16248. t['gammasuperior'] = 0x02E0;
  16249. t['gangiacoptic'] = 0x03EB;
  16250. t['gbopomofo'] = 0x310D;
  16251. t['gbreve'] = 0x011F;
  16252. t['gcaron'] = 0x01E7;
  16253. t['gcedilla'] = 0x0123;
  16254. t['gcircle'] = 0x24D6;
  16255. t['gcircumflex'] = 0x011D;
  16256. t['gcommaaccent'] = 0x0123;
  16257. t['gdot'] = 0x0121;
  16258. t['gdotaccent'] = 0x0121;
  16259. t['gecyrillic'] = 0x0433;
  16260. t['gehiragana'] = 0x3052;
  16261. t['gekatakana'] = 0x30B2;
  16262. t['geometricallyequal'] = 0x2251;
  16263. t['gereshaccenthebrew'] = 0x059C;
  16264. t['gereshhebrew'] = 0x05F3;
  16265. t['gereshmuqdamhebrew'] = 0x059D;
  16266. t['germandbls'] = 0x00DF;
  16267. t['gershayimaccenthebrew'] = 0x059E;
  16268. t['gershayimhebrew'] = 0x05F4;
  16269. t['getamark'] = 0x3013;
  16270. t['ghabengali'] = 0x0998;
  16271. t['ghadarmenian'] = 0x0572;
  16272. t['ghadeva'] = 0x0918;
  16273. t['ghagujarati'] = 0x0A98;
  16274. t['ghagurmukhi'] = 0x0A18;
  16275. t['ghainarabic'] = 0x063A;
  16276. t['ghainfinalarabic'] = 0xFECE;
  16277. t['ghaininitialarabic'] = 0xFECF;
  16278. t['ghainmedialarabic'] = 0xFED0;
  16279. t['ghemiddlehookcyrillic'] = 0x0495;
  16280. t['ghestrokecyrillic'] = 0x0493;
  16281. t['gheupturncyrillic'] = 0x0491;
  16282. t['ghhadeva'] = 0x095A;
  16283. t['ghhagurmukhi'] = 0x0A5A;
  16284. t['ghook'] = 0x0260;
  16285. t['ghzsquare'] = 0x3393;
  16286. t['gihiragana'] = 0x304E;
  16287. t['gikatakana'] = 0x30AE;
  16288. t['gimarmenian'] = 0x0563;
  16289. t['gimel'] = 0x05D2;
  16290. t['gimeldagesh'] = 0xFB32;
  16291. t['gimeldageshhebrew'] = 0xFB32;
  16292. t['gimelhebrew'] = 0x05D2;
  16293. t['gjecyrillic'] = 0x0453;
  16294. t['glottalinvertedstroke'] = 0x01BE;
  16295. t['glottalstop'] = 0x0294;
  16296. t['glottalstopinverted'] = 0x0296;
  16297. t['glottalstopmod'] = 0x02C0;
  16298. t['glottalstopreversed'] = 0x0295;
  16299. t['glottalstopreversedmod'] = 0x02C1;
  16300. t['glottalstopreversedsuperior'] = 0x02E4;
  16301. t['glottalstopstroke'] = 0x02A1;
  16302. t['glottalstopstrokereversed'] = 0x02A2;
  16303. t['gmacron'] = 0x1E21;
  16304. t['gmonospace'] = 0xFF47;
  16305. t['gohiragana'] = 0x3054;
  16306. t['gokatakana'] = 0x30B4;
  16307. t['gparen'] = 0x24A2;
  16308. t['gpasquare'] = 0x33AC;
  16309. t['gradient'] = 0x2207;
  16310. t['grave'] = 0x0060;
  16311. t['gravebelowcmb'] = 0x0316;
  16312. t['gravecmb'] = 0x0300;
  16313. t['gravecomb'] = 0x0300;
  16314. t['gravedeva'] = 0x0953;
  16315. t['gravelowmod'] = 0x02CE;
  16316. t['gravemonospace'] = 0xFF40;
  16317. t['gravetonecmb'] = 0x0340;
  16318. t['greater'] = 0x003E;
  16319. t['greaterequal'] = 0x2265;
  16320. t['greaterequalorless'] = 0x22DB;
  16321. t['greatermonospace'] = 0xFF1E;
  16322. t['greaterorequivalent'] = 0x2273;
  16323. t['greaterorless'] = 0x2277;
  16324. t['greateroverequal'] = 0x2267;
  16325. t['greatersmall'] = 0xFE65;
  16326. t['gscript'] = 0x0261;
  16327. t['gstroke'] = 0x01E5;
  16328. t['guhiragana'] = 0x3050;
  16329. t['guillemotleft'] = 0x00AB;
  16330. t['guillemotright'] = 0x00BB;
  16331. t['guilsinglleft'] = 0x2039;
  16332. t['guilsinglright'] = 0x203A;
  16333. t['gukatakana'] = 0x30B0;
  16334. t['guramusquare'] = 0x3318;
  16335. t['gysquare'] = 0x33C9;
  16336. t['h'] = 0x0068;
  16337. t['haabkhasiancyrillic'] = 0x04A9;
  16338. t['haaltonearabic'] = 0x06C1;
  16339. t['habengali'] = 0x09B9;
  16340. t['hadescendercyrillic'] = 0x04B3;
  16341. t['hadeva'] = 0x0939;
  16342. t['hagujarati'] = 0x0AB9;
  16343. t['hagurmukhi'] = 0x0A39;
  16344. t['haharabic'] = 0x062D;
  16345. t['hahfinalarabic'] = 0xFEA2;
  16346. t['hahinitialarabic'] = 0xFEA3;
  16347. t['hahiragana'] = 0x306F;
  16348. t['hahmedialarabic'] = 0xFEA4;
  16349. t['haitusquare'] = 0x332A;
  16350. t['hakatakana'] = 0x30CF;
  16351. t['hakatakanahalfwidth'] = 0xFF8A;
  16352. t['halantgurmukhi'] = 0x0A4D;
  16353. t['hamzaarabic'] = 0x0621;
  16354. t['hamzalowarabic'] = 0x0621;
  16355. t['hangulfiller'] = 0x3164;
  16356. t['hardsigncyrillic'] = 0x044A;
  16357. t['harpoonleftbarbup'] = 0x21BC;
  16358. t['harpoonrightbarbup'] = 0x21C0;
  16359. t['hasquare'] = 0x33CA;
  16360. t['hatafpatah'] = 0x05B2;
  16361. t['hatafpatah16'] = 0x05B2;
  16362. t['hatafpatah23'] = 0x05B2;
  16363. t['hatafpatah2f'] = 0x05B2;
  16364. t['hatafpatahhebrew'] = 0x05B2;
  16365. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16366. t['hatafpatahquarterhebrew'] = 0x05B2;
  16367. t['hatafpatahwidehebrew'] = 0x05B2;
  16368. t['hatafqamats'] = 0x05B3;
  16369. t['hatafqamats1b'] = 0x05B3;
  16370. t['hatafqamats28'] = 0x05B3;
  16371. t['hatafqamats34'] = 0x05B3;
  16372. t['hatafqamatshebrew'] = 0x05B3;
  16373. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16374. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16375. t['hatafqamatswidehebrew'] = 0x05B3;
  16376. t['hatafsegol'] = 0x05B1;
  16377. t['hatafsegol17'] = 0x05B1;
  16378. t['hatafsegol24'] = 0x05B1;
  16379. t['hatafsegol30'] = 0x05B1;
  16380. t['hatafsegolhebrew'] = 0x05B1;
  16381. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16382. t['hatafsegolquarterhebrew'] = 0x05B1;
  16383. t['hatafsegolwidehebrew'] = 0x05B1;
  16384. t['hbar'] = 0x0127;
  16385. t['hbopomofo'] = 0x310F;
  16386. t['hbrevebelow'] = 0x1E2B;
  16387. t['hcedilla'] = 0x1E29;
  16388. t['hcircle'] = 0x24D7;
  16389. t['hcircumflex'] = 0x0125;
  16390. t['hdieresis'] = 0x1E27;
  16391. t['hdotaccent'] = 0x1E23;
  16392. t['hdotbelow'] = 0x1E25;
  16393. t['he'] = 0x05D4;
  16394. t['heart'] = 0x2665;
  16395. t['heartsuitblack'] = 0x2665;
  16396. t['heartsuitwhite'] = 0x2661;
  16397. t['hedagesh'] = 0xFB34;
  16398. t['hedageshhebrew'] = 0xFB34;
  16399. t['hehaltonearabic'] = 0x06C1;
  16400. t['heharabic'] = 0x0647;
  16401. t['hehebrew'] = 0x05D4;
  16402. t['hehfinalaltonearabic'] = 0xFBA7;
  16403. t['hehfinalalttwoarabic'] = 0xFEEA;
  16404. t['hehfinalarabic'] = 0xFEEA;
  16405. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16406. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16407. t['hehinitialaltonearabic'] = 0xFBA8;
  16408. t['hehinitialarabic'] = 0xFEEB;
  16409. t['hehiragana'] = 0x3078;
  16410. t['hehmedialaltonearabic'] = 0xFBA9;
  16411. t['hehmedialarabic'] = 0xFEEC;
  16412. t['heiseierasquare'] = 0x337B;
  16413. t['hekatakana'] = 0x30D8;
  16414. t['hekatakanahalfwidth'] = 0xFF8D;
  16415. t['hekutaarusquare'] = 0x3336;
  16416. t['henghook'] = 0x0267;
  16417. t['herutusquare'] = 0x3339;
  16418. t['het'] = 0x05D7;
  16419. t['hethebrew'] = 0x05D7;
  16420. t['hhook'] = 0x0266;
  16421. t['hhooksuperior'] = 0x02B1;
  16422. t['hieuhacirclekorean'] = 0x327B;
  16423. t['hieuhaparenkorean'] = 0x321B;
  16424. t['hieuhcirclekorean'] = 0x326D;
  16425. t['hieuhkorean'] = 0x314E;
  16426. t['hieuhparenkorean'] = 0x320D;
  16427. t['hihiragana'] = 0x3072;
  16428. t['hikatakana'] = 0x30D2;
  16429. t['hikatakanahalfwidth'] = 0xFF8B;
  16430. t['hiriq'] = 0x05B4;
  16431. t['hiriq14'] = 0x05B4;
  16432. t['hiriq21'] = 0x05B4;
  16433. t['hiriq2d'] = 0x05B4;
  16434. t['hiriqhebrew'] = 0x05B4;
  16435. t['hiriqnarrowhebrew'] = 0x05B4;
  16436. t['hiriqquarterhebrew'] = 0x05B4;
  16437. t['hiriqwidehebrew'] = 0x05B4;
  16438. t['hlinebelow'] = 0x1E96;
  16439. t['hmonospace'] = 0xFF48;
  16440. t['hoarmenian'] = 0x0570;
  16441. t['hohipthai'] = 0x0E2B;
  16442. t['hohiragana'] = 0x307B;
  16443. t['hokatakana'] = 0x30DB;
  16444. t['hokatakanahalfwidth'] = 0xFF8E;
  16445. t['holam'] = 0x05B9;
  16446. t['holam19'] = 0x05B9;
  16447. t['holam26'] = 0x05B9;
  16448. t['holam32'] = 0x05B9;
  16449. t['holamhebrew'] = 0x05B9;
  16450. t['holamnarrowhebrew'] = 0x05B9;
  16451. t['holamquarterhebrew'] = 0x05B9;
  16452. t['holamwidehebrew'] = 0x05B9;
  16453. t['honokhukthai'] = 0x0E2E;
  16454. t['hookabovecomb'] = 0x0309;
  16455. t['hookcmb'] = 0x0309;
  16456. t['hookpalatalizedbelowcmb'] = 0x0321;
  16457. t['hookretroflexbelowcmb'] = 0x0322;
  16458. t['hoonsquare'] = 0x3342;
  16459. t['horicoptic'] = 0x03E9;
  16460. t['horizontalbar'] = 0x2015;
  16461. t['horncmb'] = 0x031B;
  16462. t['hotsprings'] = 0x2668;
  16463. t['house'] = 0x2302;
  16464. t['hparen'] = 0x24A3;
  16465. t['hsuperior'] = 0x02B0;
  16466. t['hturned'] = 0x0265;
  16467. t['huhiragana'] = 0x3075;
  16468. t['huiitosquare'] = 0x3333;
  16469. t['hukatakana'] = 0x30D5;
  16470. t['hukatakanahalfwidth'] = 0xFF8C;
  16471. t['hungarumlaut'] = 0x02DD;
  16472. t['hungarumlautcmb'] = 0x030B;
  16473. t['hv'] = 0x0195;
  16474. t['hyphen'] = 0x002D;
  16475. t['hypheninferior'] = 0xF6E5;
  16476. t['hyphenmonospace'] = 0xFF0D;
  16477. t['hyphensmall'] = 0xFE63;
  16478. t['hyphensuperior'] = 0xF6E6;
  16479. t['hyphentwo'] = 0x2010;
  16480. t['i'] = 0x0069;
  16481. t['iacute'] = 0x00ED;
  16482. t['iacyrillic'] = 0x044F;
  16483. t['ibengali'] = 0x0987;
  16484. t['ibopomofo'] = 0x3127;
  16485. t['ibreve'] = 0x012D;
  16486. t['icaron'] = 0x01D0;
  16487. t['icircle'] = 0x24D8;
  16488. t['icircumflex'] = 0x00EE;
  16489. t['icyrillic'] = 0x0456;
  16490. t['idblgrave'] = 0x0209;
  16491. t['ideographearthcircle'] = 0x328F;
  16492. t['ideographfirecircle'] = 0x328B;
  16493. t['ideographicallianceparen'] = 0x323F;
  16494. t['ideographiccallparen'] = 0x323A;
  16495. t['ideographiccentrecircle'] = 0x32A5;
  16496. t['ideographicclose'] = 0x3006;
  16497. t['ideographiccomma'] = 0x3001;
  16498. t['ideographiccommaleft'] = 0xFF64;
  16499. t['ideographiccongratulationparen'] = 0x3237;
  16500. t['ideographiccorrectcircle'] = 0x32A3;
  16501. t['ideographicearthparen'] = 0x322F;
  16502. t['ideographicenterpriseparen'] = 0x323D;
  16503. t['ideographicexcellentcircle'] = 0x329D;
  16504. t['ideographicfestivalparen'] = 0x3240;
  16505. t['ideographicfinancialcircle'] = 0x3296;
  16506. t['ideographicfinancialparen'] = 0x3236;
  16507. t['ideographicfireparen'] = 0x322B;
  16508. t['ideographichaveparen'] = 0x3232;
  16509. t['ideographichighcircle'] = 0x32A4;
  16510. t['ideographiciterationmark'] = 0x3005;
  16511. t['ideographiclaborcircle'] = 0x3298;
  16512. t['ideographiclaborparen'] = 0x3238;
  16513. t['ideographicleftcircle'] = 0x32A7;
  16514. t['ideographiclowcircle'] = 0x32A6;
  16515. t['ideographicmedicinecircle'] = 0x32A9;
  16516. t['ideographicmetalparen'] = 0x322E;
  16517. t['ideographicmoonparen'] = 0x322A;
  16518. t['ideographicnameparen'] = 0x3234;
  16519. t['ideographicperiod'] = 0x3002;
  16520. t['ideographicprintcircle'] = 0x329E;
  16521. t['ideographicreachparen'] = 0x3243;
  16522. t['ideographicrepresentparen'] = 0x3239;
  16523. t['ideographicresourceparen'] = 0x323E;
  16524. t['ideographicrightcircle'] = 0x32A8;
  16525. t['ideographicsecretcircle'] = 0x3299;
  16526. t['ideographicselfparen'] = 0x3242;
  16527. t['ideographicsocietyparen'] = 0x3233;
  16528. t['ideographicspace'] = 0x3000;
  16529. t['ideographicspecialparen'] = 0x3235;
  16530. t['ideographicstockparen'] = 0x3231;
  16531. t['ideographicstudyparen'] = 0x323B;
  16532. t['ideographicsunparen'] = 0x3230;
  16533. t['ideographicsuperviseparen'] = 0x323C;
  16534. t['ideographicwaterparen'] = 0x322C;
  16535. t['ideographicwoodparen'] = 0x322D;
  16536. t['ideographiczero'] = 0x3007;
  16537. t['ideographmetalcircle'] = 0x328E;
  16538. t['ideographmooncircle'] = 0x328A;
  16539. t['ideographnamecircle'] = 0x3294;
  16540. t['ideographsuncircle'] = 0x3290;
  16541. t['ideographwatercircle'] = 0x328C;
  16542. t['ideographwoodcircle'] = 0x328D;
  16543. t['ideva'] = 0x0907;
  16544. t['idieresis'] = 0x00EF;
  16545. t['idieresisacute'] = 0x1E2F;
  16546. t['idieresiscyrillic'] = 0x04E5;
  16547. t['idotbelow'] = 0x1ECB;
  16548. t['iebrevecyrillic'] = 0x04D7;
  16549. t['iecyrillic'] = 0x0435;
  16550. t['ieungacirclekorean'] = 0x3275;
  16551. t['ieungaparenkorean'] = 0x3215;
  16552. t['ieungcirclekorean'] = 0x3267;
  16553. t['ieungkorean'] = 0x3147;
  16554. t['ieungparenkorean'] = 0x3207;
  16555. t['igrave'] = 0x00EC;
  16556. t['igujarati'] = 0x0A87;
  16557. t['igurmukhi'] = 0x0A07;
  16558. t['ihiragana'] = 0x3044;
  16559. t['ihookabove'] = 0x1EC9;
  16560. t['iibengali'] = 0x0988;
  16561. t['iicyrillic'] = 0x0438;
  16562. t['iideva'] = 0x0908;
  16563. t['iigujarati'] = 0x0A88;
  16564. t['iigurmukhi'] = 0x0A08;
  16565. t['iimatragurmukhi'] = 0x0A40;
  16566. t['iinvertedbreve'] = 0x020B;
  16567. t['iishortcyrillic'] = 0x0439;
  16568. t['iivowelsignbengali'] = 0x09C0;
  16569. t['iivowelsigndeva'] = 0x0940;
  16570. t['iivowelsigngujarati'] = 0x0AC0;
  16571. t['ij'] = 0x0133;
  16572. t['ikatakana'] = 0x30A4;
  16573. t['ikatakanahalfwidth'] = 0xFF72;
  16574. t['ikorean'] = 0x3163;
  16575. t['ilde'] = 0x02DC;
  16576. t['iluyhebrew'] = 0x05AC;
  16577. t['imacron'] = 0x012B;
  16578. t['imacroncyrillic'] = 0x04E3;
  16579. t['imageorapproximatelyequal'] = 0x2253;
  16580. t['imatragurmukhi'] = 0x0A3F;
  16581. t['imonospace'] = 0xFF49;
  16582. t['increment'] = 0x2206;
  16583. t['infinity'] = 0x221E;
  16584. t['iniarmenian'] = 0x056B;
  16585. t['integral'] = 0x222B;
  16586. t['integralbottom'] = 0x2321;
  16587. t['integralbt'] = 0x2321;
  16588. t['integralex'] = 0xF8F5;
  16589. t['integraltop'] = 0x2320;
  16590. t['integraltp'] = 0x2320;
  16591. t['intersection'] = 0x2229;
  16592. t['intisquare'] = 0x3305;
  16593. t['invbullet'] = 0x25D8;
  16594. t['invcircle'] = 0x25D9;
  16595. t['invsmileface'] = 0x263B;
  16596. t['iocyrillic'] = 0x0451;
  16597. t['iogonek'] = 0x012F;
  16598. t['iota'] = 0x03B9;
  16599. t['iotadieresis'] = 0x03CA;
  16600. t['iotadieresistonos'] = 0x0390;
  16601. t['iotalatin'] = 0x0269;
  16602. t['iotatonos'] = 0x03AF;
  16603. t['iparen'] = 0x24A4;
  16604. t['irigurmukhi'] = 0x0A72;
  16605. t['ismallhiragana'] = 0x3043;
  16606. t['ismallkatakana'] = 0x30A3;
  16607. t['ismallkatakanahalfwidth'] = 0xFF68;
  16608. t['issharbengali'] = 0x09FA;
  16609. t['istroke'] = 0x0268;
  16610. t['isuperior'] = 0xF6ED;
  16611. t['iterationhiragana'] = 0x309D;
  16612. t['iterationkatakana'] = 0x30FD;
  16613. t['itilde'] = 0x0129;
  16614. t['itildebelow'] = 0x1E2D;
  16615. t['iubopomofo'] = 0x3129;
  16616. t['iucyrillic'] = 0x044E;
  16617. t['ivowelsignbengali'] = 0x09BF;
  16618. t['ivowelsigndeva'] = 0x093F;
  16619. t['ivowelsigngujarati'] = 0x0ABF;
  16620. t['izhitsacyrillic'] = 0x0475;
  16621. t['izhitsadblgravecyrillic'] = 0x0477;
  16622. t['j'] = 0x006A;
  16623. t['jaarmenian'] = 0x0571;
  16624. t['jabengali'] = 0x099C;
  16625. t['jadeva'] = 0x091C;
  16626. t['jagujarati'] = 0x0A9C;
  16627. t['jagurmukhi'] = 0x0A1C;
  16628. t['jbopomofo'] = 0x3110;
  16629. t['jcaron'] = 0x01F0;
  16630. t['jcircle'] = 0x24D9;
  16631. t['jcircumflex'] = 0x0135;
  16632. t['jcrossedtail'] = 0x029D;
  16633. t['jdotlessstroke'] = 0x025F;
  16634. t['jecyrillic'] = 0x0458;
  16635. t['jeemarabic'] = 0x062C;
  16636. t['jeemfinalarabic'] = 0xFE9E;
  16637. t['jeeminitialarabic'] = 0xFE9F;
  16638. t['jeemmedialarabic'] = 0xFEA0;
  16639. t['jeharabic'] = 0x0698;
  16640. t['jehfinalarabic'] = 0xFB8B;
  16641. t['jhabengali'] = 0x099D;
  16642. t['jhadeva'] = 0x091D;
  16643. t['jhagujarati'] = 0x0A9D;
  16644. t['jhagurmukhi'] = 0x0A1D;
  16645. t['jheharmenian'] = 0x057B;
  16646. t['jis'] = 0x3004;
  16647. t['jmonospace'] = 0xFF4A;
  16648. t['jparen'] = 0x24A5;
  16649. t['jsuperior'] = 0x02B2;
  16650. t['k'] = 0x006B;
  16651. t['kabashkircyrillic'] = 0x04A1;
  16652. t['kabengali'] = 0x0995;
  16653. t['kacute'] = 0x1E31;
  16654. t['kacyrillic'] = 0x043A;
  16655. t['kadescendercyrillic'] = 0x049B;
  16656. t['kadeva'] = 0x0915;
  16657. t['kaf'] = 0x05DB;
  16658. t['kafarabic'] = 0x0643;
  16659. t['kafdagesh'] = 0xFB3B;
  16660. t['kafdageshhebrew'] = 0xFB3B;
  16661. t['kaffinalarabic'] = 0xFEDA;
  16662. t['kafhebrew'] = 0x05DB;
  16663. t['kafinitialarabic'] = 0xFEDB;
  16664. t['kafmedialarabic'] = 0xFEDC;
  16665. t['kafrafehebrew'] = 0xFB4D;
  16666. t['kagujarati'] = 0x0A95;
  16667. t['kagurmukhi'] = 0x0A15;
  16668. t['kahiragana'] = 0x304B;
  16669. t['kahookcyrillic'] = 0x04C4;
  16670. t['kakatakana'] = 0x30AB;
  16671. t['kakatakanahalfwidth'] = 0xFF76;
  16672. t['kappa'] = 0x03BA;
  16673. t['kappasymbolgreek'] = 0x03F0;
  16674. t['kapyeounmieumkorean'] = 0x3171;
  16675. t['kapyeounphieuphkorean'] = 0x3184;
  16676. t['kapyeounpieupkorean'] = 0x3178;
  16677. t['kapyeounssangpieupkorean'] = 0x3179;
  16678. t['karoriisquare'] = 0x330D;
  16679. t['kashidaautoarabic'] = 0x0640;
  16680. t['kashidaautonosidebearingarabic'] = 0x0640;
  16681. t['kasmallkatakana'] = 0x30F5;
  16682. t['kasquare'] = 0x3384;
  16683. t['kasraarabic'] = 0x0650;
  16684. t['kasratanarabic'] = 0x064D;
  16685. t['kastrokecyrillic'] = 0x049F;
  16686. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16687. t['kaverticalstrokecyrillic'] = 0x049D;
  16688. t['kbopomofo'] = 0x310E;
  16689. t['kcalsquare'] = 0x3389;
  16690. t['kcaron'] = 0x01E9;
  16691. t['kcedilla'] = 0x0137;
  16692. t['kcircle'] = 0x24DA;
  16693. t['kcommaaccent'] = 0x0137;
  16694. t['kdotbelow'] = 0x1E33;
  16695. t['keharmenian'] = 0x0584;
  16696. t['kehiragana'] = 0x3051;
  16697. t['kekatakana'] = 0x30B1;
  16698. t['kekatakanahalfwidth'] = 0xFF79;
  16699. t['kenarmenian'] = 0x056F;
  16700. t['kesmallkatakana'] = 0x30F6;
  16701. t['kgreenlandic'] = 0x0138;
  16702. t['khabengali'] = 0x0996;
  16703. t['khacyrillic'] = 0x0445;
  16704. t['khadeva'] = 0x0916;
  16705. t['khagujarati'] = 0x0A96;
  16706. t['khagurmukhi'] = 0x0A16;
  16707. t['khaharabic'] = 0x062E;
  16708. t['khahfinalarabic'] = 0xFEA6;
  16709. t['khahinitialarabic'] = 0xFEA7;
  16710. t['khahmedialarabic'] = 0xFEA8;
  16711. t['kheicoptic'] = 0x03E7;
  16712. t['khhadeva'] = 0x0959;
  16713. t['khhagurmukhi'] = 0x0A59;
  16714. t['khieukhacirclekorean'] = 0x3278;
  16715. t['khieukhaparenkorean'] = 0x3218;
  16716. t['khieukhcirclekorean'] = 0x326A;
  16717. t['khieukhkorean'] = 0x314B;
  16718. t['khieukhparenkorean'] = 0x320A;
  16719. t['khokhaithai'] = 0x0E02;
  16720. t['khokhonthai'] = 0x0E05;
  16721. t['khokhuatthai'] = 0x0E03;
  16722. t['khokhwaithai'] = 0x0E04;
  16723. t['khomutthai'] = 0x0E5B;
  16724. t['khook'] = 0x0199;
  16725. t['khorakhangthai'] = 0x0E06;
  16726. t['khzsquare'] = 0x3391;
  16727. t['kihiragana'] = 0x304D;
  16728. t['kikatakana'] = 0x30AD;
  16729. t['kikatakanahalfwidth'] = 0xFF77;
  16730. t['kiroguramusquare'] = 0x3315;
  16731. t['kiromeetorusquare'] = 0x3316;
  16732. t['kirosquare'] = 0x3314;
  16733. t['kiyeokacirclekorean'] = 0x326E;
  16734. t['kiyeokaparenkorean'] = 0x320E;
  16735. t['kiyeokcirclekorean'] = 0x3260;
  16736. t['kiyeokkorean'] = 0x3131;
  16737. t['kiyeokparenkorean'] = 0x3200;
  16738. t['kiyeoksioskorean'] = 0x3133;
  16739. t['kjecyrillic'] = 0x045C;
  16740. t['klinebelow'] = 0x1E35;
  16741. t['klsquare'] = 0x3398;
  16742. t['kmcubedsquare'] = 0x33A6;
  16743. t['kmonospace'] = 0xFF4B;
  16744. t['kmsquaredsquare'] = 0x33A2;
  16745. t['kohiragana'] = 0x3053;
  16746. t['kohmsquare'] = 0x33C0;
  16747. t['kokaithai'] = 0x0E01;
  16748. t['kokatakana'] = 0x30B3;
  16749. t['kokatakanahalfwidth'] = 0xFF7A;
  16750. t['kooposquare'] = 0x331E;
  16751. t['koppacyrillic'] = 0x0481;
  16752. t['koreanstandardsymbol'] = 0x327F;
  16753. t['koroniscmb'] = 0x0343;
  16754. t['kparen'] = 0x24A6;
  16755. t['kpasquare'] = 0x33AA;
  16756. t['ksicyrillic'] = 0x046F;
  16757. t['ktsquare'] = 0x33CF;
  16758. t['kturned'] = 0x029E;
  16759. t['kuhiragana'] = 0x304F;
  16760. t['kukatakana'] = 0x30AF;
  16761. t['kukatakanahalfwidth'] = 0xFF78;
  16762. t['kvsquare'] = 0x33B8;
  16763. t['kwsquare'] = 0x33BE;
  16764. t['l'] = 0x006C;
  16765. t['labengali'] = 0x09B2;
  16766. t['lacute'] = 0x013A;
  16767. t['ladeva'] = 0x0932;
  16768. t['lagujarati'] = 0x0AB2;
  16769. t['lagurmukhi'] = 0x0A32;
  16770. t['lakkhangyaothai'] = 0x0E45;
  16771. t['lamaleffinalarabic'] = 0xFEFC;
  16772. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16773. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16774. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16775. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16776. t['lamalefisolatedarabic'] = 0xFEFB;
  16777. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16778. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16779. t['lamarabic'] = 0x0644;
  16780. t['lambda'] = 0x03BB;
  16781. t['lambdastroke'] = 0x019B;
  16782. t['lamed'] = 0x05DC;
  16783. t['lameddagesh'] = 0xFB3C;
  16784. t['lameddageshhebrew'] = 0xFB3C;
  16785. t['lamedhebrew'] = 0x05DC;
  16786. t['lamfinalarabic'] = 0xFEDE;
  16787. t['lamhahinitialarabic'] = 0xFCCA;
  16788. t['laminitialarabic'] = 0xFEDF;
  16789. t['lamjeeminitialarabic'] = 0xFCC9;
  16790. t['lamkhahinitialarabic'] = 0xFCCB;
  16791. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16792. t['lammedialarabic'] = 0xFEE0;
  16793. t['lammeemhahinitialarabic'] = 0xFD88;
  16794. t['lammeeminitialarabic'] = 0xFCCC;
  16795. t['largecircle'] = 0x25EF;
  16796. t['lbar'] = 0x019A;
  16797. t['lbelt'] = 0x026C;
  16798. t['lbopomofo'] = 0x310C;
  16799. t['lcaron'] = 0x013E;
  16800. t['lcedilla'] = 0x013C;
  16801. t['lcircle'] = 0x24DB;
  16802. t['lcircumflexbelow'] = 0x1E3D;
  16803. t['lcommaaccent'] = 0x013C;
  16804. t['ldot'] = 0x0140;
  16805. t['ldotaccent'] = 0x0140;
  16806. t['ldotbelow'] = 0x1E37;
  16807. t['ldotbelowmacron'] = 0x1E39;
  16808. t['leftangleabovecmb'] = 0x031A;
  16809. t['lefttackbelowcmb'] = 0x0318;
  16810. t['less'] = 0x003C;
  16811. t['lessequal'] = 0x2264;
  16812. t['lessequalorgreater'] = 0x22DA;
  16813. t['lessmonospace'] = 0xFF1C;
  16814. t['lessorequivalent'] = 0x2272;
  16815. t['lessorgreater'] = 0x2276;
  16816. t['lessoverequal'] = 0x2266;
  16817. t['lesssmall'] = 0xFE64;
  16818. t['lezh'] = 0x026E;
  16819. t['lfblock'] = 0x258C;
  16820. t['lhookretroflex'] = 0x026D;
  16821. t['lira'] = 0x20A4;
  16822. t['liwnarmenian'] = 0x056C;
  16823. t['lj'] = 0x01C9;
  16824. t['ljecyrillic'] = 0x0459;
  16825. t['ll'] = 0xF6C0;
  16826. t['lladeva'] = 0x0933;
  16827. t['llagujarati'] = 0x0AB3;
  16828. t['llinebelow'] = 0x1E3B;
  16829. t['llladeva'] = 0x0934;
  16830. t['llvocalicbengali'] = 0x09E1;
  16831. t['llvocalicdeva'] = 0x0961;
  16832. t['llvocalicvowelsignbengali'] = 0x09E3;
  16833. t['llvocalicvowelsigndeva'] = 0x0963;
  16834. t['lmiddletilde'] = 0x026B;
  16835. t['lmonospace'] = 0xFF4C;
  16836. t['lmsquare'] = 0x33D0;
  16837. t['lochulathai'] = 0x0E2C;
  16838. t['logicaland'] = 0x2227;
  16839. t['logicalnot'] = 0x00AC;
  16840. t['logicalnotreversed'] = 0x2310;
  16841. t['logicalor'] = 0x2228;
  16842. t['lolingthai'] = 0x0E25;
  16843. t['longs'] = 0x017F;
  16844. t['lowlinecenterline'] = 0xFE4E;
  16845. t['lowlinecmb'] = 0x0332;
  16846. t['lowlinedashed'] = 0xFE4D;
  16847. t['lozenge'] = 0x25CA;
  16848. t['lparen'] = 0x24A7;
  16849. t['lslash'] = 0x0142;
  16850. t['lsquare'] = 0x2113;
  16851. t['lsuperior'] = 0xF6EE;
  16852. t['ltshade'] = 0x2591;
  16853. t['luthai'] = 0x0E26;
  16854. t['lvocalicbengali'] = 0x098C;
  16855. t['lvocalicdeva'] = 0x090C;
  16856. t['lvocalicvowelsignbengali'] = 0x09E2;
  16857. t['lvocalicvowelsigndeva'] = 0x0962;
  16858. t['lxsquare'] = 0x33D3;
  16859. t['m'] = 0x006D;
  16860. t['mabengali'] = 0x09AE;
  16861. t['macron'] = 0x00AF;
  16862. t['macronbelowcmb'] = 0x0331;
  16863. t['macroncmb'] = 0x0304;
  16864. t['macronlowmod'] = 0x02CD;
  16865. t['macronmonospace'] = 0xFFE3;
  16866. t['macute'] = 0x1E3F;
  16867. t['madeva'] = 0x092E;
  16868. t['magujarati'] = 0x0AAE;
  16869. t['magurmukhi'] = 0x0A2E;
  16870. t['mahapakhhebrew'] = 0x05A4;
  16871. t['mahapakhlefthebrew'] = 0x05A4;
  16872. t['mahiragana'] = 0x307E;
  16873. t['maichattawalowleftthai'] = 0xF895;
  16874. t['maichattawalowrightthai'] = 0xF894;
  16875. t['maichattawathai'] = 0x0E4B;
  16876. t['maichattawaupperleftthai'] = 0xF893;
  16877. t['maieklowleftthai'] = 0xF88C;
  16878. t['maieklowrightthai'] = 0xF88B;
  16879. t['maiekthai'] = 0x0E48;
  16880. t['maiekupperleftthai'] = 0xF88A;
  16881. t['maihanakatleftthai'] = 0xF884;
  16882. t['maihanakatthai'] = 0x0E31;
  16883. t['maitaikhuleftthai'] = 0xF889;
  16884. t['maitaikhuthai'] = 0x0E47;
  16885. t['maitholowleftthai'] = 0xF88F;
  16886. t['maitholowrightthai'] = 0xF88E;
  16887. t['maithothai'] = 0x0E49;
  16888. t['maithoupperleftthai'] = 0xF88D;
  16889. t['maitrilowleftthai'] = 0xF892;
  16890. t['maitrilowrightthai'] = 0xF891;
  16891. t['maitrithai'] = 0x0E4A;
  16892. t['maitriupperleftthai'] = 0xF890;
  16893. t['maiyamokthai'] = 0x0E46;
  16894. t['makatakana'] = 0x30DE;
  16895. t['makatakanahalfwidth'] = 0xFF8F;
  16896. t['male'] = 0x2642;
  16897. t['mansyonsquare'] = 0x3347;
  16898. t['maqafhebrew'] = 0x05BE;
  16899. t['mars'] = 0x2642;
  16900. t['masoracirclehebrew'] = 0x05AF;
  16901. t['masquare'] = 0x3383;
  16902. t['mbopomofo'] = 0x3107;
  16903. t['mbsquare'] = 0x33D4;
  16904. t['mcircle'] = 0x24DC;
  16905. t['mcubedsquare'] = 0x33A5;
  16906. t['mdotaccent'] = 0x1E41;
  16907. t['mdotbelow'] = 0x1E43;
  16908. t['meemarabic'] = 0x0645;
  16909. t['meemfinalarabic'] = 0xFEE2;
  16910. t['meeminitialarabic'] = 0xFEE3;
  16911. t['meemmedialarabic'] = 0xFEE4;
  16912. t['meemmeeminitialarabic'] = 0xFCD1;
  16913. t['meemmeemisolatedarabic'] = 0xFC48;
  16914. t['meetorusquare'] = 0x334D;
  16915. t['mehiragana'] = 0x3081;
  16916. t['meizierasquare'] = 0x337E;
  16917. t['mekatakana'] = 0x30E1;
  16918. t['mekatakanahalfwidth'] = 0xFF92;
  16919. t['mem'] = 0x05DE;
  16920. t['memdagesh'] = 0xFB3E;
  16921. t['memdageshhebrew'] = 0xFB3E;
  16922. t['memhebrew'] = 0x05DE;
  16923. t['menarmenian'] = 0x0574;
  16924. t['merkhahebrew'] = 0x05A5;
  16925. t['merkhakefulahebrew'] = 0x05A6;
  16926. t['merkhakefulalefthebrew'] = 0x05A6;
  16927. t['merkhalefthebrew'] = 0x05A5;
  16928. t['mhook'] = 0x0271;
  16929. t['mhzsquare'] = 0x3392;
  16930. t['middledotkatakanahalfwidth'] = 0xFF65;
  16931. t['middot'] = 0x00B7;
  16932. t['mieumacirclekorean'] = 0x3272;
  16933. t['mieumaparenkorean'] = 0x3212;
  16934. t['mieumcirclekorean'] = 0x3264;
  16935. t['mieumkorean'] = 0x3141;
  16936. t['mieumpansioskorean'] = 0x3170;
  16937. t['mieumparenkorean'] = 0x3204;
  16938. t['mieumpieupkorean'] = 0x316E;
  16939. t['mieumsioskorean'] = 0x316F;
  16940. t['mihiragana'] = 0x307F;
  16941. t['mikatakana'] = 0x30DF;
  16942. t['mikatakanahalfwidth'] = 0xFF90;
  16943. t['minus'] = 0x2212;
  16944. t['minusbelowcmb'] = 0x0320;
  16945. t['minuscircle'] = 0x2296;
  16946. t['minusmod'] = 0x02D7;
  16947. t['minusplus'] = 0x2213;
  16948. t['minute'] = 0x2032;
  16949. t['miribaarusquare'] = 0x334A;
  16950. t['mirisquare'] = 0x3349;
  16951. t['mlonglegturned'] = 0x0270;
  16952. t['mlsquare'] = 0x3396;
  16953. t['mmcubedsquare'] = 0x33A3;
  16954. t['mmonospace'] = 0xFF4D;
  16955. t['mmsquaredsquare'] = 0x339F;
  16956. t['mohiragana'] = 0x3082;
  16957. t['mohmsquare'] = 0x33C1;
  16958. t['mokatakana'] = 0x30E2;
  16959. t['mokatakanahalfwidth'] = 0xFF93;
  16960. t['molsquare'] = 0x33D6;
  16961. t['momathai'] = 0x0E21;
  16962. t['moverssquare'] = 0x33A7;
  16963. t['moverssquaredsquare'] = 0x33A8;
  16964. t['mparen'] = 0x24A8;
  16965. t['mpasquare'] = 0x33AB;
  16966. t['mssquare'] = 0x33B3;
  16967. t['msuperior'] = 0xF6EF;
  16968. t['mturned'] = 0x026F;
  16969. t['mu'] = 0x00B5;
  16970. t['mu1'] = 0x00B5;
  16971. t['muasquare'] = 0x3382;
  16972. t['muchgreater'] = 0x226B;
  16973. t['muchless'] = 0x226A;
  16974. t['mufsquare'] = 0x338C;
  16975. t['mugreek'] = 0x03BC;
  16976. t['mugsquare'] = 0x338D;
  16977. t['muhiragana'] = 0x3080;
  16978. t['mukatakana'] = 0x30E0;
  16979. t['mukatakanahalfwidth'] = 0xFF91;
  16980. t['mulsquare'] = 0x3395;
  16981. t['multiply'] = 0x00D7;
  16982. t['mumsquare'] = 0x339B;
  16983. t['munahhebrew'] = 0x05A3;
  16984. t['munahlefthebrew'] = 0x05A3;
  16985. t['musicalnote'] = 0x266A;
  16986. t['musicalnotedbl'] = 0x266B;
  16987. t['musicflatsign'] = 0x266D;
  16988. t['musicsharpsign'] = 0x266F;
  16989. t['mussquare'] = 0x33B2;
  16990. t['muvsquare'] = 0x33B6;
  16991. t['muwsquare'] = 0x33BC;
  16992. t['mvmegasquare'] = 0x33B9;
  16993. t['mvsquare'] = 0x33B7;
  16994. t['mwmegasquare'] = 0x33BF;
  16995. t['mwsquare'] = 0x33BD;
  16996. t['n'] = 0x006E;
  16997. t['nabengali'] = 0x09A8;
  16998. t['nabla'] = 0x2207;
  16999. t['nacute'] = 0x0144;
  17000. t['nadeva'] = 0x0928;
  17001. t['nagujarati'] = 0x0AA8;
  17002. t['nagurmukhi'] = 0x0A28;
  17003. t['nahiragana'] = 0x306A;
  17004. t['nakatakana'] = 0x30CA;
  17005. t['nakatakanahalfwidth'] = 0xFF85;
  17006. t['napostrophe'] = 0x0149;
  17007. t['nasquare'] = 0x3381;
  17008. t['nbopomofo'] = 0x310B;
  17009. t['nbspace'] = 0x00A0;
  17010. t['ncaron'] = 0x0148;
  17011. t['ncedilla'] = 0x0146;
  17012. t['ncircle'] = 0x24DD;
  17013. t['ncircumflexbelow'] = 0x1E4B;
  17014. t['ncommaaccent'] = 0x0146;
  17015. t['ndotaccent'] = 0x1E45;
  17016. t['ndotbelow'] = 0x1E47;
  17017. t['nehiragana'] = 0x306D;
  17018. t['nekatakana'] = 0x30CD;
  17019. t['nekatakanahalfwidth'] = 0xFF88;
  17020. t['newsheqelsign'] = 0x20AA;
  17021. t['nfsquare'] = 0x338B;
  17022. t['ngabengali'] = 0x0999;
  17023. t['ngadeva'] = 0x0919;
  17024. t['ngagujarati'] = 0x0A99;
  17025. t['ngagurmukhi'] = 0x0A19;
  17026. t['ngonguthai'] = 0x0E07;
  17027. t['nhiragana'] = 0x3093;
  17028. t['nhookleft'] = 0x0272;
  17029. t['nhookretroflex'] = 0x0273;
  17030. t['nieunacirclekorean'] = 0x326F;
  17031. t['nieunaparenkorean'] = 0x320F;
  17032. t['nieuncieuckorean'] = 0x3135;
  17033. t['nieuncirclekorean'] = 0x3261;
  17034. t['nieunhieuhkorean'] = 0x3136;
  17035. t['nieunkorean'] = 0x3134;
  17036. t['nieunpansioskorean'] = 0x3168;
  17037. t['nieunparenkorean'] = 0x3201;
  17038. t['nieunsioskorean'] = 0x3167;
  17039. t['nieuntikeutkorean'] = 0x3166;
  17040. t['nihiragana'] = 0x306B;
  17041. t['nikatakana'] = 0x30CB;
  17042. t['nikatakanahalfwidth'] = 0xFF86;
  17043. t['nikhahitleftthai'] = 0xF899;
  17044. t['nikhahitthai'] = 0x0E4D;
  17045. t['nine'] = 0x0039;
  17046. t['ninearabic'] = 0x0669;
  17047. t['ninebengali'] = 0x09EF;
  17048. t['ninecircle'] = 0x2468;
  17049. t['ninecircleinversesansserif'] = 0x2792;
  17050. t['ninedeva'] = 0x096F;
  17051. t['ninegujarati'] = 0x0AEF;
  17052. t['ninegurmukhi'] = 0x0A6F;
  17053. t['ninehackarabic'] = 0x0669;
  17054. t['ninehangzhou'] = 0x3029;
  17055. t['nineideographicparen'] = 0x3228;
  17056. t['nineinferior'] = 0x2089;
  17057. t['ninemonospace'] = 0xFF19;
  17058. t['nineoldstyle'] = 0xF739;
  17059. t['nineparen'] = 0x247C;
  17060. t['nineperiod'] = 0x2490;
  17061. t['ninepersian'] = 0x06F9;
  17062. t['nineroman'] = 0x2178;
  17063. t['ninesuperior'] = 0x2079;
  17064. t['nineteencircle'] = 0x2472;
  17065. t['nineteenparen'] = 0x2486;
  17066. t['nineteenperiod'] = 0x249A;
  17067. t['ninethai'] = 0x0E59;
  17068. t['nj'] = 0x01CC;
  17069. t['njecyrillic'] = 0x045A;
  17070. t['nkatakana'] = 0x30F3;
  17071. t['nkatakanahalfwidth'] = 0xFF9D;
  17072. t['nlegrightlong'] = 0x019E;
  17073. t['nlinebelow'] = 0x1E49;
  17074. t['nmonospace'] = 0xFF4E;
  17075. t['nmsquare'] = 0x339A;
  17076. t['nnabengali'] = 0x09A3;
  17077. t['nnadeva'] = 0x0923;
  17078. t['nnagujarati'] = 0x0AA3;
  17079. t['nnagurmukhi'] = 0x0A23;
  17080. t['nnnadeva'] = 0x0929;
  17081. t['nohiragana'] = 0x306E;
  17082. t['nokatakana'] = 0x30CE;
  17083. t['nokatakanahalfwidth'] = 0xFF89;
  17084. t['nonbreakingspace'] = 0x00A0;
  17085. t['nonenthai'] = 0x0E13;
  17086. t['nonuthai'] = 0x0E19;
  17087. t['noonarabic'] = 0x0646;
  17088. t['noonfinalarabic'] = 0xFEE6;
  17089. t['noonghunnaarabic'] = 0x06BA;
  17090. t['noonghunnafinalarabic'] = 0xFB9F;
  17091. t['nooninitialarabic'] = 0xFEE7;
  17092. t['noonjeeminitialarabic'] = 0xFCD2;
  17093. t['noonjeemisolatedarabic'] = 0xFC4B;
  17094. t['noonmedialarabic'] = 0xFEE8;
  17095. t['noonmeeminitialarabic'] = 0xFCD5;
  17096. t['noonmeemisolatedarabic'] = 0xFC4E;
  17097. t['noonnoonfinalarabic'] = 0xFC8D;
  17098. t['notcontains'] = 0x220C;
  17099. t['notelement'] = 0x2209;
  17100. t['notelementof'] = 0x2209;
  17101. t['notequal'] = 0x2260;
  17102. t['notgreater'] = 0x226F;
  17103. t['notgreaternorequal'] = 0x2271;
  17104. t['notgreaternorless'] = 0x2279;
  17105. t['notidentical'] = 0x2262;
  17106. t['notless'] = 0x226E;
  17107. t['notlessnorequal'] = 0x2270;
  17108. t['notparallel'] = 0x2226;
  17109. t['notprecedes'] = 0x2280;
  17110. t['notsubset'] = 0x2284;
  17111. t['notsucceeds'] = 0x2281;
  17112. t['notsuperset'] = 0x2285;
  17113. t['nowarmenian'] = 0x0576;
  17114. t['nparen'] = 0x24A9;
  17115. t['nssquare'] = 0x33B1;
  17116. t['nsuperior'] = 0x207F;
  17117. t['ntilde'] = 0x00F1;
  17118. t['nu'] = 0x03BD;
  17119. t['nuhiragana'] = 0x306C;
  17120. t['nukatakana'] = 0x30CC;
  17121. t['nukatakanahalfwidth'] = 0xFF87;
  17122. t['nuktabengali'] = 0x09BC;
  17123. t['nuktadeva'] = 0x093C;
  17124. t['nuktagujarati'] = 0x0ABC;
  17125. t['nuktagurmukhi'] = 0x0A3C;
  17126. t['numbersign'] = 0x0023;
  17127. t['numbersignmonospace'] = 0xFF03;
  17128. t['numbersignsmall'] = 0xFE5F;
  17129. t['numeralsigngreek'] = 0x0374;
  17130. t['numeralsignlowergreek'] = 0x0375;
  17131. t['numero'] = 0x2116;
  17132. t['nun'] = 0x05E0;
  17133. t['nundagesh'] = 0xFB40;
  17134. t['nundageshhebrew'] = 0xFB40;
  17135. t['nunhebrew'] = 0x05E0;
  17136. t['nvsquare'] = 0x33B5;
  17137. t['nwsquare'] = 0x33BB;
  17138. t['nyabengali'] = 0x099E;
  17139. t['nyadeva'] = 0x091E;
  17140. t['nyagujarati'] = 0x0A9E;
  17141. t['nyagurmukhi'] = 0x0A1E;
  17142. t['o'] = 0x006F;
  17143. t['oacute'] = 0x00F3;
  17144. t['oangthai'] = 0x0E2D;
  17145. t['obarred'] = 0x0275;
  17146. t['obarredcyrillic'] = 0x04E9;
  17147. t['obarreddieresiscyrillic'] = 0x04EB;
  17148. t['obengali'] = 0x0993;
  17149. t['obopomofo'] = 0x311B;
  17150. t['obreve'] = 0x014F;
  17151. t['ocandradeva'] = 0x0911;
  17152. t['ocandragujarati'] = 0x0A91;
  17153. t['ocandravowelsigndeva'] = 0x0949;
  17154. t['ocandravowelsigngujarati'] = 0x0AC9;
  17155. t['ocaron'] = 0x01D2;
  17156. t['ocircle'] = 0x24DE;
  17157. t['ocircumflex'] = 0x00F4;
  17158. t['ocircumflexacute'] = 0x1ED1;
  17159. t['ocircumflexdotbelow'] = 0x1ED9;
  17160. t['ocircumflexgrave'] = 0x1ED3;
  17161. t['ocircumflexhookabove'] = 0x1ED5;
  17162. t['ocircumflextilde'] = 0x1ED7;
  17163. t['ocyrillic'] = 0x043E;
  17164. t['odblacute'] = 0x0151;
  17165. t['odblgrave'] = 0x020D;
  17166. t['odeva'] = 0x0913;
  17167. t['odieresis'] = 0x00F6;
  17168. t['odieresiscyrillic'] = 0x04E7;
  17169. t['odotbelow'] = 0x1ECD;
  17170. t['oe'] = 0x0153;
  17171. t['oekorean'] = 0x315A;
  17172. t['ogonek'] = 0x02DB;
  17173. t['ogonekcmb'] = 0x0328;
  17174. t['ograve'] = 0x00F2;
  17175. t['ogujarati'] = 0x0A93;
  17176. t['oharmenian'] = 0x0585;
  17177. t['ohiragana'] = 0x304A;
  17178. t['ohookabove'] = 0x1ECF;
  17179. t['ohorn'] = 0x01A1;
  17180. t['ohornacute'] = 0x1EDB;
  17181. t['ohorndotbelow'] = 0x1EE3;
  17182. t['ohorngrave'] = 0x1EDD;
  17183. t['ohornhookabove'] = 0x1EDF;
  17184. t['ohorntilde'] = 0x1EE1;
  17185. t['ohungarumlaut'] = 0x0151;
  17186. t['oi'] = 0x01A3;
  17187. t['oinvertedbreve'] = 0x020F;
  17188. t['okatakana'] = 0x30AA;
  17189. t['okatakanahalfwidth'] = 0xFF75;
  17190. t['okorean'] = 0x3157;
  17191. t['olehebrew'] = 0x05AB;
  17192. t['omacron'] = 0x014D;
  17193. t['omacronacute'] = 0x1E53;
  17194. t['omacrongrave'] = 0x1E51;
  17195. t['omdeva'] = 0x0950;
  17196. t['omega'] = 0x03C9;
  17197. t['omega1'] = 0x03D6;
  17198. t['omegacyrillic'] = 0x0461;
  17199. t['omegalatinclosed'] = 0x0277;
  17200. t['omegaroundcyrillic'] = 0x047B;
  17201. t['omegatitlocyrillic'] = 0x047D;
  17202. t['omegatonos'] = 0x03CE;
  17203. t['omgujarati'] = 0x0AD0;
  17204. t['omicron'] = 0x03BF;
  17205. t['omicrontonos'] = 0x03CC;
  17206. t['omonospace'] = 0xFF4F;
  17207. t['one'] = 0x0031;
  17208. t['onearabic'] = 0x0661;
  17209. t['onebengali'] = 0x09E7;
  17210. t['onecircle'] = 0x2460;
  17211. t['onecircleinversesansserif'] = 0x278A;
  17212. t['onedeva'] = 0x0967;
  17213. t['onedotenleader'] = 0x2024;
  17214. t['oneeighth'] = 0x215B;
  17215. t['onefitted'] = 0xF6DC;
  17216. t['onegujarati'] = 0x0AE7;
  17217. t['onegurmukhi'] = 0x0A67;
  17218. t['onehackarabic'] = 0x0661;
  17219. t['onehalf'] = 0x00BD;
  17220. t['onehangzhou'] = 0x3021;
  17221. t['oneideographicparen'] = 0x3220;
  17222. t['oneinferior'] = 0x2081;
  17223. t['onemonospace'] = 0xFF11;
  17224. t['onenumeratorbengali'] = 0x09F4;
  17225. t['oneoldstyle'] = 0xF731;
  17226. t['oneparen'] = 0x2474;
  17227. t['oneperiod'] = 0x2488;
  17228. t['onepersian'] = 0x06F1;
  17229. t['onequarter'] = 0x00BC;
  17230. t['oneroman'] = 0x2170;
  17231. t['onesuperior'] = 0x00B9;
  17232. t['onethai'] = 0x0E51;
  17233. t['onethird'] = 0x2153;
  17234. t['oogonek'] = 0x01EB;
  17235. t['oogonekmacron'] = 0x01ED;
  17236. t['oogurmukhi'] = 0x0A13;
  17237. t['oomatragurmukhi'] = 0x0A4B;
  17238. t['oopen'] = 0x0254;
  17239. t['oparen'] = 0x24AA;
  17240. t['openbullet'] = 0x25E6;
  17241. t['option'] = 0x2325;
  17242. t['ordfeminine'] = 0x00AA;
  17243. t['ordmasculine'] = 0x00BA;
  17244. t['orthogonal'] = 0x221F;
  17245. t['oshortdeva'] = 0x0912;
  17246. t['oshortvowelsigndeva'] = 0x094A;
  17247. t['oslash'] = 0x00F8;
  17248. t['oslashacute'] = 0x01FF;
  17249. t['osmallhiragana'] = 0x3049;
  17250. t['osmallkatakana'] = 0x30A9;
  17251. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17252. t['ostrokeacute'] = 0x01FF;
  17253. t['osuperior'] = 0xF6F0;
  17254. t['otcyrillic'] = 0x047F;
  17255. t['otilde'] = 0x00F5;
  17256. t['otildeacute'] = 0x1E4D;
  17257. t['otildedieresis'] = 0x1E4F;
  17258. t['oubopomofo'] = 0x3121;
  17259. t['overline'] = 0x203E;
  17260. t['overlinecenterline'] = 0xFE4A;
  17261. t['overlinecmb'] = 0x0305;
  17262. t['overlinedashed'] = 0xFE49;
  17263. t['overlinedblwavy'] = 0xFE4C;
  17264. t['overlinewavy'] = 0xFE4B;
  17265. t['overscore'] = 0x00AF;
  17266. t['ovowelsignbengali'] = 0x09CB;
  17267. t['ovowelsigndeva'] = 0x094B;
  17268. t['ovowelsigngujarati'] = 0x0ACB;
  17269. t['p'] = 0x0070;
  17270. t['paampssquare'] = 0x3380;
  17271. t['paasentosquare'] = 0x332B;
  17272. t['pabengali'] = 0x09AA;
  17273. t['pacute'] = 0x1E55;
  17274. t['padeva'] = 0x092A;
  17275. t['pagedown'] = 0x21DF;
  17276. t['pageup'] = 0x21DE;
  17277. t['pagujarati'] = 0x0AAA;
  17278. t['pagurmukhi'] = 0x0A2A;
  17279. t['pahiragana'] = 0x3071;
  17280. t['paiyannoithai'] = 0x0E2F;
  17281. t['pakatakana'] = 0x30D1;
  17282. t['palatalizationcyrilliccmb'] = 0x0484;
  17283. t['palochkacyrillic'] = 0x04C0;
  17284. t['pansioskorean'] = 0x317F;
  17285. t['paragraph'] = 0x00B6;
  17286. t['parallel'] = 0x2225;
  17287. t['parenleft'] = 0x0028;
  17288. t['parenleftaltonearabic'] = 0xFD3E;
  17289. t['parenleftbt'] = 0xF8ED;
  17290. t['parenleftex'] = 0xF8EC;
  17291. t['parenleftinferior'] = 0x208D;
  17292. t['parenleftmonospace'] = 0xFF08;
  17293. t['parenleftsmall'] = 0xFE59;
  17294. t['parenleftsuperior'] = 0x207D;
  17295. t['parenlefttp'] = 0xF8EB;
  17296. t['parenleftvertical'] = 0xFE35;
  17297. t['parenright'] = 0x0029;
  17298. t['parenrightaltonearabic'] = 0xFD3F;
  17299. t['parenrightbt'] = 0xF8F8;
  17300. t['parenrightex'] = 0xF8F7;
  17301. t['parenrightinferior'] = 0x208E;
  17302. t['parenrightmonospace'] = 0xFF09;
  17303. t['parenrightsmall'] = 0xFE5A;
  17304. t['parenrightsuperior'] = 0x207E;
  17305. t['parenrighttp'] = 0xF8F6;
  17306. t['parenrightvertical'] = 0xFE36;
  17307. t['partialdiff'] = 0x2202;
  17308. t['paseqhebrew'] = 0x05C0;
  17309. t['pashtahebrew'] = 0x0599;
  17310. t['pasquare'] = 0x33A9;
  17311. t['patah'] = 0x05B7;
  17312. t['patah11'] = 0x05B7;
  17313. t['patah1d'] = 0x05B7;
  17314. t['patah2a'] = 0x05B7;
  17315. t['patahhebrew'] = 0x05B7;
  17316. t['patahnarrowhebrew'] = 0x05B7;
  17317. t['patahquarterhebrew'] = 0x05B7;
  17318. t['patahwidehebrew'] = 0x05B7;
  17319. t['pazerhebrew'] = 0x05A1;
  17320. t['pbopomofo'] = 0x3106;
  17321. t['pcircle'] = 0x24DF;
  17322. t['pdotaccent'] = 0x1E57;
  17323. t['pe'] = 0x05E4;
  17324. t['pecyrillic'] = 0x043F;
  17325. t['pedagesh'] = 0xFB44;
  17326. t['pedageshhebrew'] = 0xFB44;
  17327. t['peezisquare'] = 0x333B;
  17328. t['pefinaldageshhebrew'] = 0xFB43;
  17329. t['peharabic'] = 0x067E;
  17330. t['peharmenian'] = 0x057A;
  17331. t['pehebrew'] = 0x05E4;
  17332. t['pehfinalarabic'] = 0xFB57;
  17333. t['pehinitialarabic'] = 0xFB58;
  17334. t['pehiragana'] = 0x307A;
  17335. t['pehmedialarabic'] = 0xFB59;
  17336. t['pekatakana'] = 0x30DA;
  17337. t['pemiddlehookcyrillic'] = 0x04A7;
  17338. t['perafehebrew'] = 0xFB4E;
  17339. t['percent'] = 0x0025;
  17340. t['percentarabic'] = 0x066A;
  17341. t['percentmonospace'] = 0xFF05;
  17342. t['percentsmall'] = 0xFE6A;
  17343. t['period'] = 0x002E;
  17344. t['periodarmenian'] = 0x0589;
  17345. t['periodcentered'] = 0x00B7;
  17346. t['periodhalfwidth'] = 0xFF61;
  17347. t['periodinferior'] = 0xF6E7;
  17348. t['periodmonospace'] = 0xFF0E;
  17349. t['periodsmall'] = 0xFE52;
  17350. t['periodsuperior'] = 0xF6E8;
  17351. t['perispomenigreekcmb'] = 0x0342;
  17352. t['perpendicular'] = 0x22A5;
  17353. t['perthousand'] = 0x2030;
  17354. t['peseta'] = 0x20A7;
  17355. t['pfsquare'] = 0x338A;
  17356. t['phabengali'] = 0x09AB;
  17357. t['phadeva'] = 0x092B;
  17358. t['phagujarati'] = 0x0AAB;
  17359. t['phagurmukhi'] = 0x0A2B;
  17360. t['phi'] = 0x03C6;
  17361. t['phi1'] = 0x03D5;
  17362. t['phieuphacirclekorean'] = 0x327A;
  17363. t['phieuphaparenkorean'] = 0x321A;
  17364. t['phieuphcirclekorean'] = 0x326C;
  17365. t['phieuphkorean'] = 0x314D;
  17366. t['phieuphparenkorean'] = 0x320C;
  17367. t['philatin'] = 0x0278;
  17368. t['phinthuthai'] = 0x0E3A;
  17369. t['phisymbolgreek'] = 0x03D5;
  17370. t['phook'] = 0x01A5;
  17371. t['phophanthai'] = 0x0E1E;
  17372. t['phophungthai'] = 0x0E1C;
  17373. t['phosamphaothai'] = 0x0E20;
  17374. t['pi'] = 0x03C0;
  17375. t['pieupacirclekorean'] = 0x3273;
  17376. t['pieupaparenkorean'] = 0x3213;
  17377. t['pieupcieuckorean'] = 0x3176;
  17378. t['pieupcirclekorean'] = 0x3265;
  17379. t['pieupkiyeokkorean'] = 0x3172;
  17380. t['pieupkorean'] = 0x3142;
  17381. t['pieupparenkorean'] = 0x3205;
  17382. t['pieupsioskiyeokkorean'] = 0x3174;
  17383. t['pieupsioskorean'] = 0x3144;
  17384. t['pieupsiostikeutkorean'] = 0x3175;
  17385. t['pieupthieuthkorean'] = 0x3177;
  17386. t['pieuptikeutkorean'] = 0x3173;
  17387. t['pihiragana'] = 0x3074;
  17388. t['pikatakana'] = 0x30D4;
  17389. t['pisymbolgreek'] = 0x03D6;
  17390. t['piwrarmenian'] = 0x0583;
  17391. t['plus'] = 0x002B;
  17392. t['plusbelowcmb'] = 0x031F;
  17393. t['pluscircle'] = 0x2295;
  17394. t['plusminus'] = 0x00B1;
  17395. t['plusmod'] = 0x02D6;
  17396. t['plusmonospace'] = 0xFF0B;
  17397. t['plussmall'] = 0xFE62;
  17398. t['plussuperior'] = 0x207A;
  17399. t['pmonospace'] = 0xFF50;
  17400. t['pmsquare'] = 0x33D8;
  17401. t['pohiragana'] = 0x307D;
  17402. t['pointingindexdownwhite'] = 0x261F;
  17403. t['pointingindexleftwhite'] = 0x261C;
  17404. t['pointingindexrightwhite'] = 0x261E;
  17405. t['pointingindexupwhite'] = 0x261D;
  17406. t['pokatakana'] = 0x30DD;
  17407. t['poplathai'] = 0x0E1B;
  17408. t['postalmark'] = 0x3012;
  17409. t['postalmarkface'] = 0x3020;
  17410. t['pparen'] = 0x24AB;
  17411. t['precedes'] = 0x227A;
  17412. t['prescription'] = 0x211E;
  17413. t['primemod'] = 0x02B9;
  17414. t['primereversed'] = 0x2035;
  17415. t['product'] = 0x220F;
  17416. t['projective'] = 0x2305;
  17417. t['prolongedkana'] = 0x30FC;
  17418. t['propellor'] = 0x2318;
  17419. t['propersubset'] = 0x2282;
  17420. t['propersuperset'] = 0x2283;
  17421. t['proportion'] = 0x2237;
  17422. t['proportional'] = 0x221D;
  17423. t['psi'] = 0x03C8;
  17424. t['psicyrillic'] = 0x0471;
  17425. t['psilipneumatacyrilliccmb'] = 0x0486;
  17426. t['pssquare'] = 0x33B0;
  17427. t['puhiragana'] = 0x3077;
  17428. t['pukatakana'] = 0x30D7;
  17429. t['pvsquare'] = 0x33B4;
  17430. t['pwsquare'] = 0x33BA;
  17431. t['q'] = 0x0071;
  17432. t['qadeva'] = 0x0958;
  17433. t['qadmahebrew'] = 0x05A8;
  17434. t['qafarabic'] = 0x0642;
  17435. t['qaffinalarabic'] = 0xFED6;
  17436. t['qafinitialarabic'] = 0xFED7;
  17437. t['qafmedialarabic'] = 0xFED8;
  17438. t['qamats'] = 0x05B8;
  17439. t['qamats10'] = 0x05B8;
  17440. t['qamats1a'] = 0x05B8;
  17441. t['qamats1c'] = 0x05B8;
  17442. t['qamats27'] = 0x05B8;
  17443. t['qamats29'] = 0x05B8;
  17444. t['qamats33'] = 0x05B8;
  17445. t['qamatsde'] = 0x05B8;
  17446. t['qamatshebrew'] = 0x05B8;
  17447. t['qamatsnarrowhebrew'] = 0x05B8;
  17448. t['qamatsqatanhebrew'] = 0x05B8;
  17449. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17450. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17451. t['qamatsqatanwidehebrew'] = 0x05B8;
  17452. t['qamatsquarterhebrew'] = 0x05B8;
  17453. t['qamatswidehebrew'] = 0x05B8;
  17454. t['qarneyparahebrew'] = 0x059F;
  17455. t['qbopomofo'] = 0x3111;
  17456. t['qcircle'] = 0x24E0;
  17457. t['qhook'] = 0x02A0;
  17458. t['qmonospace'] = 0xFF51;
  17459. t['qof'] = 0x05E7;
  17460. t['qofdagesh'] = 0xFB47;
  17461. t['qofdageshhebrew'] = 0xFB47;
  17462. t['qofhebrew'] = 0x05E7;
  17463. t['qparen'] = 0x24AC;
  17464. t['quarternote'] = 0x2669;
  17465. t['qubuts'] = 0x05BB;
  17466. t['qubuts18'] = 0x05BB;
  17467. t['qubuts25'] = 0x05BB;
  17468. t['qubuts31'] = 0x05BB;
  17469. t['qubutshebrew'] = 0x05BB;
  17470. t['qubutsnarrowhebrew'] = 0x05BB;
  17471. t['qubutsquarterhebrew'] = 0x05BB;
  17472. t['qubutswidehebrew'] = 0x05BB;
  17473. t['question'] = 0x003F;
  17474. t['questionarabic'] = 0x061F;
  17475. t['questionarmenian'] = 0x055E;
  17476. t['questiondown'] = 0x00BF;
  17477. t['questiondownsmall'] = 0xF7BF;
  17478. t['questiongreek'] = 0x037E;
  17479. t['questionmonospace'] = 0xFF1F;
  17480. t['questionsmall'] = 0xF73F;
  17481. t['quotedbl'] = 0x0022;
  17482. t['quotedblbase'] = 0x201E;
  17483. t['quotedblleft'] = 0x201C;
  17484. t['quotedblmonospace'] = 0xFF02;
  17485. t['quotedblprime'] = 0x301E;
  17486. t['quotedblprimereversed'] = 0x301D;
  17487. t['quotedblright'] = 0x201D;
  17488. t['quoteleft'] = 0x2018;
  17489. t['quoteleftreversed'] = 0x201B;
  17490. t['quotereversed'] = 0x201B;
  17491. t['quoteright'] = 0x2019;
  17492. t['quoterightn'] = 0x0149;
  17493. t['quotesinglbase'] = 0x201A;
  17494. t['quotesingle'] = 0x0027;
  17495. t['quotesinglemonospace'] = 0xFF07;
  17496. t['r'] = 0x0072;
  17497. t['raarmenian'] = 0x057C;
  17498. t['rabengali'] = 0x09B0;
  17499. t['racute'] = 0x0155;
  17500. t['radeva'] = 0x0930;
  17501. t['radical'] = 0x221A;
  17502. t['radicalex'] = 0xF8E5;
  17503. t['radoverssquare'] = 0x33AE;
  17504. t['radoverssquaredsquare'] = 0x33AF;
  17505. t['radsquare'] = 0x33AD;
  17506. t['rafe'] = 0x05BF;
  17507. t['rafehebrew'] = 0x05BF;
  17508. t['ragujarati'] = 0x0AB0;
  17509. t['ragurmukhi'] = 0x0A30;
  17510. t['rahiragana'] = 0x3089;
  17511. t['rakatakana'] = 0x30E9;
  17512. t['rakatakanahalfwidth'] = 0xFF97;
  17513. t['ralowerdiagonalbengali'] = 0x09F1;
  17514. t['ramiddlediagonalbengali'] = 0x09F0;
  17515. t['ramshorn'] = 0x0264;
  17516. t['ratio'] = 0x2236;
  17517. t['rbopomofo'] = 0x3116;
  17518. t['rcaron'] = 0x0159;
  17519. t['rcedilla'] = 0x0157;
  17520. t['rcircle'] = 0x24E1;
  17521. t['rcommaaccent'] = 0x0157;
  17522. t['rdblgrave'] = 0x0211;
  17523. t['rdotaccent'] = 0x1E59;
  17524. t['rdotbelow'] = 0x1E5B;
  17525. t['rdotbelowmacron'] = 0x1E5D;
  17526. t['referencemark'] = 0x203B;
  17527. t['reflexsubset'] = 0x2286;
  17528. t['reflexsuperset'] = 0x2287;
  17529. t['registered'] = 0x00AE;
  17530. t['registersans'] = 0xF8E8;
  17531. t['registerserif'] = 0xF6DA;
  17532. t['reharabic'] = 0x0631;
  17533. t['reharmenian'] = 0x0580;
  17534. t['rehfinalarabic'] = 0xFEAE;
  17535. t['rehiragana'] = 0x308C;
  17536. t['rekatakana'] = 0x30EC;
  17537. t['rekatakanahalfwidth'] = 0xFF9A;
  17538. t['resh'] = 0x05E8;
  17539. t['reshdageshhebrew'] = 0xFB48;
  17540. t['reshhebrew'] = 0x05E8;
  17541. t['reversedtilde'] = 0x223D;
  17542. t['reviahebrew'] = 0x0597;
  17543. t['reviamugrashhebrew'] = 0x0597;
  17544. t['revlogicalnot'] = 0x2310;
  17545. t['rfishhook'] = 0x027E;
  17546. t['rfishhookreversed'] = 0x027F;
  17547. t['rhabengali'] = 0x09DD;
  17548. t['rhadeva'] = 0x095D;
  17549. t['rho'] = 0x03C1;
  17550. t['rhook'] = 0x027D;
  17551. t['rhookturned'] = 0x027B;
  17552. t['rhookturnedsuperior'] = 0x02B5;
  17553. t['rhosymbolgreek'] = 0x03F1;
  17554. t['rhotichookmod'] = 0x02DE;
  17555. t['rieulacirclekorean'] = 0x3271;
  17556. t['rieulaparenkorean'] = 0x3211;
  17557. t['rieulcirclekorean'] = 0x3263;
  17558. t['rieulhieuhkorean'] = 0x3140;
  17559. t['rieulkiyeokkorean'] = 0x313A;
  17560. t['rieulkiyeoksioskorean'] = 0x3169;
  17561. t['rieulkorean'] = 0x3139;
  17562. t['rieulmieumkorean'] = 0x313B;
  17563. t['rieulpansioskorean'] = 0x316C;
  17564. t['rieulparenkorean'] = 0x3203;
  17565. t['rieulphieuphkorean'] = 0x313F;
  17566. t['rieulpieupkorean'] = 0x313C;
  17567. t['rieulpieupsioskorean'] = 0x316B;
  17568. t['rieulsioskorean'] = 0x313D;
  17569. t['rieulthieuthkorean'] = 0x313E;
  17570. t['rieultikeutkorean'] = 0x316A;
  17571. t['rieulyeorinhieuhkorean'] = 0x316D;
  17572. t['rightangle'] = 0x221F;
  17573. t['righttackbelowcmb'] = 0x0319;
  17574. t['righttriangle'] = 0x22BF;
  17575. t['rihiragana'] = 0x308A;
  17576. t['rikatakana'] = 0x30EA;
  17577. t['rikatakanahalfwidth'] = 0xFF98;
  17578. t['ring'] = 0x02DA;
  17579. t['ringbelowcmb'] = 0x0325;
  17580. t['ringcmb'] = 0x030A;
  17581. t['ringhalfleft'] = 0x02BF;
  17582. t['ringhalfleftarmenian'] = 0x0559;
  17583. t['ringhalfleftbelowcmb'] = 0x031C;
  17584. t['ringhalfleftcentered'] = 0x02D3;
  17585. t['ringhalfright'] = 0x02BE;
  17586. t['ringhalfrightbelowcmb'] = 0x0339;
  17587. t['ringhalfrightcentered'] = 0x02D2;
  17588. t['rinvertedbreve'] = 0x0213;
  17589. t['rittorusquare'] = 0x3351;
  17590. t['rlinebelow'] = 0x1E5F;
  17591. t['rlongleg'] = 0x027C;
  17592. t['rlonglegturned'] = 0x027A;
  17593. t['rmonospace'] = 0xFF52;
  17594. t['rohiragana'] = 0x308D;
  17595. t['rokatakana'] = 0x30ED;
  17596. t['rokatakanahalfwidth'] = 0xFF9B;
  17597. t['roruathai'] = 0x0E23;
  17598. t['rparen'] = 0x24AD;
  17599. t['rrabengali'] = 0x09DC;
  17600. t['rradeva'] = 0x0931;
  17601. t['rragurmukhi'] = 0x0A5C;
  17602. t['rreharabic'] = 0x0691;
  17603. t['rrehfinalarabic'] = 0xFB8D;
  17604. t['rrvocalicbengali'] = 0x09E0;
  17605. t['rrvocalicdeva'] = 0x0960;
  17606. t['rrvocalicgujarati'] = 0x0AE0;
  17607. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17608. t['rrvocalicvowelsigndeva'] = 0x0944;
  17609. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17610. t['rsuperior'] = 0xF6F1;
  17611. t['rtblock'] = 0x2590;
  17612. t['rturned'] = 0x0279;
  17613. t['rturnedsuperior'] = 0x02B4;
  17614. t['ruhiragana'] = 0x308B;
  17615. t['rukatakana'] = 0x30EB;
  17616. t['rukatakanahalfwidth'] = 0xFF99;
  17617. t['rupeemarkbengali'] = 0x09F2;
  17618. t['rupeesignbengali'] = 0x09F3;
  17619. t['rupiah'] = 0xF6DD;
  17620. t['ruthai'] = 0x0E24;
  17621. t['rvocalicbengali'] = 0x098B;
  17622. t['rvocalicdeva'] = 0x090B;
  17623. t['rvocalicgujarati'] = 0x0A8B;
  17624. t['rvocalicvowelsignbengali'] = 0x09C3;
  17625. t['rvocalicvowelsigndeva'] = 0x0943;
  17626. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17627. t['s'] = 0x0073;
  17628. t['sabengali'] = 0x09B8;
  17629. t['sacute'] = 0x015B;
  17630. t['sacutedotaccent'] = 0x1E65;
  17631. t['sadarabic'] = 0x0635;
  17632. t['sadeva'] = 0x0938;
  17633. t['sadfinalarabic'] = 0xFEBA;
  17634. t['sadinitialarabic'] = 0xFEBB;
  17635. t['sadmedialarabic'] = 0xFEBC;
  17636. t['sagujarati'] = 0x0AB8;
  17637. t['sagurmukhi'] = 0x0A38;
  17638. t['sahiragana'] = 0x3055;
  17639. t['sakatakana'] = 0x30B5;
  17640. t['sakatakanahalfwidth'] = 0xFF7B;
  17641. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17642. t['samekh'] = 0x05E1;
  17643. t['samekhdagesh'] = 0xFB41;
  17644. t['samekhdageshhebrew'] = 0xFB41;
  17645. t['samekhhebrew'] = 0x05E1;
  17646. t['saraaathai'] = 0x0E32;
  17647. t['saraaethai'] = 0x0E41;
  17648. t['saraaimaimalaithai'] = 0x0E44;
  17649. t['saraaimaimuanthai'] = 0x0E43;
  17650. t['saraamthai'] = 0x0E33;
  17651. t['saraathai'] = 0x0E30;
  17652. t['saraethai'] = 0x0E40;
  17653. t['saraiileftthai'] = 0xF886;
  17654. t['saraiithai'] = 0x0E35;
  17655. t['saraileftthai'] = 0xF885;
  17656. t['saraithai'] = 0x0E34;
  17657. t['saraothai'] = 0x0E42;
  17658. t['saraueeleftthai'] = 0xF888;
  17659. t['saraueethai'] = 0x0E37;
  17660. t['saraueleftthai'] = 0xF887;
  17661. t['sarauethai'] = 0x0E36;
  17662. t['sarauthai'] = 0x0E38;
  17663. t['sarauuthai'] = 0x0E39;
  17664. t['sbopomofo'] = 0x3119;
  17665. t['scaron'] = 0x0161;
  17666. t['scarondotaccent'] = 0x1E67;
  17667. t['scedilla'] = 0x015F;
  17668. t['schwa'] = 0x0259;
  17669. t['schwacyrillic'] = 0x04D9;
  17670. t['schwadieresiscyrillic'] = 0x04DB;
  17671. t['schwahook'] = 0x025A;
  17672. t['scircle'] = 0x24E2;
  17673. t['scircumflex'] = 0x015D;
  17674. t['scommaaccent'] = 0x0219;
  17675. t['sdotaccent'] = 0x1E61;
  17676. t['sdotbelow'] = 0x1E63;
  17677. t['sdotbelowdotaccent'] = 0x1E69;
  17678. t['seagullbelowcmb'] = 0x033C;
  17679. t['second'] = 0x2033;
  17680. t['secondtonechinese'] = 0x02CA;
  17681. t['section'] = 0x00A7;
  17682. t['seenarabic'] = 0x0633;
  17683. t['seenfinalarabic'] = 0xFEB2;
  17684. t['seeninitialarabic'] = 0xFEB3;
  17685. t['seenmedialarabic'] = 0xFEB4;
  17686. t['segol'] = 0x05B6;
  17687. t['segol13'] = 0x05B6;
  17688. t['segol1f'] = 0x05B6;
  17689. t['segol2c'] = 0x05B6;
  17690. t['segolhebrew'] = 0x05B6;
  17691. t['segolnarrowhebrew'] = 0x05B6;
  17692. t['segolquarterhebrew'] = 0x05B6;
  17693. t['segoltahebrew'] = 0x0592;
  17694. t['segolwidehebrew'] = 0x05B6;
  17695. t['seharmenian'] = 0x057D;
  17696. t['sehiragana'] = 0x305B;
  17697. t['sekatakana'] = 0x30BB;
  17698. t['sekatakanahalfwidth'] = 0xFF7E;
  17699. t['semicolon'] = 0x003B;
  17700. t['semicolonarabic'] = 0x061B;
  17701. t['semicolonmonospace'] = 0xFF1B;
  17702. t['semicolonsmall'] = 0xFE54;
  17703. t['semivoicedmarkkana'] = 0x309C;
  17704. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17705. t['sentisquare'] = 0x3322;
  17706. t['sentosquare'] = 0x3323;
  17707. t['seven'] = 0x0037;
  17708. t['sevenarabic'] = 0x0667;
  17709. t['sevenbengali'] = 0x09ED;
  17710. t['sevencircle'] = 0x2466;
  17711. t['sevencircleinversesansserif'] = 0x2790;
  17712. t['sevendeva'] = 0x096D;
  17713. t['seveneighths'] = 0x215E;
  17714. t['sevengujarati'] = 0x0AED;
  17715. t['sevengurmukhi'] = 0x0A6D;
  17716. t['sevenhackarabic'] = 0x0667;
  17717. t['sevenhangzhou'] = 0x3027;
  17718. t['sevenideographicparen'] = 0x3226;
  17719. t['seveninferior'] = 0x2087;
  17720. t['sevenmonospace'] = 0xFF17;
  17721. t['sevenoldstyle'] = 0xF737;
  17722. t['sevenparen'] = 0x247A;
  17723. t['sevenperiod'] = 0x248E;
  17724. t['sevenpersian'] = 0x06F7;
  17725. t['sevenroman'] = 0x2176;
  17726. t['sevensuperior'] = 0x2077;
  17727. t['seventeencircle'] = 0x2470;
  17728. t['seventeenparen'] = 0x2484;
  17729. t['seventeenperiod'] = 0x2498;
  17730. t['seventhai'] = 0x0E57;
  17731. t['sfthyphen'] = 0x00AD;
  17732. t['shaarmenian'] = 0x0577;
  17733. t['shabengali'] = 0x09B6;
  17734. t['shacyrillic'] = 0x0448;
  17735. t['shaddaarabic'] = 0x0651;
  17736. t['shaddadammaarabic'] = 0xFC61;
  17737. t['shaddadammatanarabic'] = 0xFC5E;
  17738. t['shaddafathaarabic'] = 0xFC60;
  17739. t['shaddakasraarabic'] = 0xFC62;
  17740. t['shaddakasratanarabic'] = 0xFC5F;
  17741. t['shade'] = 0x2592;
  17742. t['shadedark'] = 0x2593;
  17743. t['shadelight'] = 0x2591;
  17744. t['shademedium'] = 0x2592;
  17745. t['shadeva'] = 0x0936;
  17746. t['shagujarati'] = 0x0AB6;
  17747. t['shagurmukhi'] = 0x0A36;
  17748. t['shalshelethebrew'] = 0x0593;
  17749. t['shbopomofo'] = 0x3115;
  17750. t['shchacyrillic'] = 0x0449;
  17751. t['sheenarabic'] = 0x0634;
  17752. t['sheenfinalarabic'] = 0xFEB6;
  17753. t['sheeninitialarabic'] = 0xFEB7;
  17754. t['sheenmedialarabic'] = 0xFEB8;
  17755. t['sheicoptic'] = 0x03E3;
  17756. t['sheqel'] = 0x20AA;
  17757. t['sheqelhebrew'] = 0x20AA;
  17758. t['sheva'] = 0x05B0;
  17759. t['sheva115'] = 0x05B0;
  17760. t['sheva15'] = 0x05B0;
  17761. t['sheva22'] = 0x05B0;
  17762. t['sheva2e'] = 0x05B0;
  17763. t['shevahebrew'] = 0x05B0;
  17764. t['shevanarrowhebrew'] = 0x05B0;
  17765. t['shevaquarterhebrew'] = 0x05B0;
  17766. t['shevawidehebrew'] = 0x05B0;
  17767. t['shhacyrillic'] = 0x04BB;
  17768. t['shimacoptic'] = 0x03ED;
  17769. t['shin'] = 0x05E9;
  17770. t['shindagesh'] = 0xFB49;
  17771. t['shindageshhebrew'] = 0xFB49;
  17772. t['shindageshshindot'] = 0xFB2C;
  17773. t['shindageshshindothebrew'] = 0xFB2C;
  17774. t['shindageshsindot'] = 0xFB2D;
  17775. t['shindageshsindothebrew'] = 0xFB2D;
  17776. t['shindothebrew'] = 0x05C1;
  17777. t['shinhebrew'] = 0x05E9;
  17778. t['shinshindot'] = 0xFB2A;
  17779. t['shinshindothebrew'] = 0xFB2A;
  17780. t['shinsindot'] = 0xFB2B;
  17781. t['shinsindothebrew'] = 0xFB2B;
  17782. t['shook'] = 0x0282;
  17783. t['sigma'] = 0x03C3;
  17784. t['sigma1'] = 0x03C2;
  17785. t['sigmafinal'] = 0x03C2;
  17786. t['sigmalunatesymbolgreek'] = 0x03F2;
  17787. t['sihiragana'] = 0x3057;
  17788. t['sikatakana'] = 0x30B7;
  17789. t['sikatakanahalfwidth'] = 0xFF7C;
  17790. t['siluqhebrew'] = 0x05BD;
  17791. t['siluqlefthebrew'] = 0x05BD;
  17792. t['similar'] = 0x223C;
  17793. t['sindothebrew'] = 0x05C2;
  17794. t['siosacirclekorean'] = 0x3274;
  17795. t['siosaparenkorean'] = 0x3214;
  17796. t['sioscieuckorean'] = 0x317E;
  17797. t['sioscirclekorean'] = 0x3266;
  17798. t['sioskiyeokkorean'] = 0x317A;
  17799. t['sioskorean'] = 0x3145;
  17800. t['siosnieunkorean'] = 0x317B;
  17801. t['siosparenkorean'] = 0x3206;
  17802. t['siospieupkorean'] = 0x317D;
  17803. t['siostikeutkorean'] = 0x317C;
  17804. t['six'] = 0x0036;
  17805. t['sixarabic'] = 0x0666;
  17806. t['sixbengali'] = 0x09EC;
  17807. t['sixcircle'] = 0x2465;
  17808. t['sixcircleinversesansserif'] = 0x278F;
  17809. t['sixdeva'] = 0x096C;
  17810. t['sixgujarati'] = 0x0AEC;
  17811. t['sixgurmukhi'] = 0x0A6C;
  17812. t['sixhackarabic'] = 0x0666;
  17813. t['sixhangzhou'] = 0x3026;
  17814. t['sixideographicparen'] = 0x3225;
  17815. t['sixinferior'] = 0x2086;
  17816. t['sixmonospace'] = 0xFF16;
  17817. t['sixoldstyle'] = 0xF736;
  17818. t['sixparen'] = 0x2479;
  17819. t['sixperiod'] = 0x248D;
  17820. t['sixpersian'] = 0x06F6;
  17821. t['sixroman'] = 0x2175;
  17822. t['sixsuperior'] = 0x2076;
  17823. t['sixteencircle'] = 0x246F;
  17824. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17825. t['sixteenparen'] = 0x2483;
  17826. t['sixteenperiod'] = 0x2497;
  17827. t['sixthai'] = 0x0E56;
  17828. t['slash'] = 0x002F;
  17829. t['slashmonospace'] = 0xFF0F;
  17830. t['slong'] = 0x017F;
  17831. t['slongdotaccent'] = 0x1E9B;
  17832. t['smileface'] = 0x263A;
  17833. t['smonospace'] = 0xFF53;
  17834. t['sofpasuqhebrew'] = 0x05C3;
  17835. t['softhyphen'] = 0x00AD;
  17836. t['softsigncyrillic'] = 0x044C;
  17837. t['sohiragana'] = 0x305D;
  17838. t['sokatakana'] = 0x30BD;
  17839. t['sokatakanahalfwidth'] = 0xFF7F;
  17840. t['soliduslongoverlaycmb'] = 0x0338;
  17841. t['solidusshortoverlaycmb'] = 0x0337;
  17842. t['sorusithai'] = 0x0E29;
  17843. t['sosalathai'] = 0x0E28;
  17844. t['sosothai'] = 0x0E0B;
  17845. t['sosuathai'] = 0x0E2A;
  17846. t['space'] = 0x0020;
  17847. t['spacehackarabic'] = 0x0020;
  17848. t['spade'] = 0x2660;
  17849. t['spadesuitblack'] = 0x2660;
  17850. t['spadesuitwhite'] = 0x2664;
  17851. t['sparen'] = 0x24AE;
  17852. t['squarebelowcmb'] = 0x033B;
  17853. t['squarecc'] = 0x33C4;
  17854. t['squarecm'] = 0x339D;
  17855. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17856. t['squarehorizontalfill'] = 0x25A4;
  17857. t['squarekg'] = 0x338F;
  17858. t['squarekm'] = 0x339E;
  17859. t['squarekmcapital'] = 0x33CE;
  17860. t['squareln'] = 0x33D1;
  17861. t['squarelog'] = 0x33D2;
  17862. t['squaremg'] = 0x338E;
  17863. t['squaremil'] = 0x33D5;
  17864. t['squaremm'] = 0x339C;
  17865. t['squaremsquared'] = 0x33A1;
  17866. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17867. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17868. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17869. t['squareverticalfill'] = 0x25A5;
  17870. t['squarewhitewithsmallblack'] = 0x25A3;
  17871. t['srsquare'] = 0x33DB;
  17872. t['ssabengali'] = 0x09B7;
  17873. t['ssadeva'] = 0x0937;
  17874. t['ssagujarati'] = 0x0AB7;
  17875. t['ssangcieuckorean'] = 0x3149;
  17876. t['ssanghieuhkorean'] = 0x3185;
  17877. t['ssangieungkorean'] = 0x3180;
  17878. t['ssangkiyeokkorean'] = 0x3132;
  17879. t['ssangnieunkorean'] = 0x3165;
  17880. t['ssangpieupkorean'] = 0x3143;
  17881. t['ssangsioskorean'] = 0x3146;
  17882. t['ssangtikeutkorean'] = 0x3138;
  17883. t['ssuperior'] = 0xF6F2;
  17884. t['sterling'] = 0x00A3;
  17885. t['sterlingmonospace'] = 0xFFE1;
  17886. t['strokelongoverlaycmb'] = 0x0336;
  17887. t['strokeshortoverlaycmb'] = 0x0335;
  17888. t['subset'] = 0x2282;
  17889. t['subsetnotequal'] = 0x228A;
  17890. t['subsetorequal'] = 0x2286;
  17891. t['succeeds'] = 0x227B;
  17892. t['suchthat'] = 0x220B;
  17893. t['suhiragana'] = 0x3059;
  17894. t['sukatakana'] = 0x30B9;
  17895. t['sukatakanahalfwidth'] = 0xFF7D;
  17896. t['sukunarabic'] = 0x0652;
  17897. t['summation'] = 0x2211;
  17898. t['sun'] = 0x263C;
  17899. t['superset'] = 0x2283;
  17900. t['supersetnotequal'] = 0x228B;
  17901. t['supersetorequal'] = 0x2287;
  17902. t['svsquare'] = 0x33DC;
  17903. t['syouwaerasquare'] = 0x337C;
  17904. t['t'] = 0x0074;
  17905. t['tabengali'] = 0x09A4;
  17906. t['tackdown'] = 0x22A4;
  17907. t['tackleft'] = 0x22A3;
  17908. t['tadeva'] = 0x0924;
  17909. t['tagujarati'] = 0x0AA4;
  17910. t['tagurmukhi'] = 0x0A24;
  17911. t['taharabic'] = 0x0637;
  17912. t['tahfinalarabic'] = 0xFEC2;
  17913. t['tahinitialarabic'] = 0xFEC3;
  17914. t['tahiragana'] = 0x305F;
  17915. t['tahmedialarabic'] = 0xFEC4;
  17916. t['taisyouerasquare'] = 0x337D;
  17917. t['takatakana'] = 0x30BF;
  17918. t['takatakanahalfwidth'] = 0xFF80;
  17919. t['tatweelarabic'] = 0x0640;
  17920. t['tau'] = 0x03C4;
  17921. t['tav'] = 0x05EA;
  17922. t['tavdages'] = 0xFB4A;
  17923. t['tavdagesh'] = 0xFB4A;
  17924. t['tavdageshhebrew'] = 0xFB4A;
  17925. t['tavhebrew'] = 0x05EA;
  17926. t['tbar'] = 0x0167;
  17927. t['tbopomofo'] = 0x310A;
  17928. t['tcaron'] = 0x0165;
  17929. t['tccurl'] = 0x02A8;
  17930. t['tcedilla'] = 0x0163;
  17931. t['tcheharabic'] = 0x0686;
  17932. t['tchehfinalarabic'] = 0xFB7B;
  17933. t['tchehinitialarabic'] = 0xFB7C;
  17934. t['tchehmedialarabic'] = 0xFB7D;
  17935. t['tcircle'] = 0x24E3;
  17936. t['tcircumflexbelow'] = 0x1E71;
  17937. t['tcommaaccent'] = 0x0163;
  17938. t['tdieresis'] = 0x1E97;
  17939. t['tdotaccent'] = 0x1E6B;
  17940. t['tdotbelow'] = 0x1E6D;
  17941. t['tecyrillic'] = 0x0442;
  17942. t['tedescendercyrillic'] = 0x04AD;
  17943. t['teharabic'] = 0x062A;
  17944. t['tehfinalarabic'] = 0xFE96;
  17945. t['tehhahinitialarabic'] = 0xFCA2;
  17946. t['tehhahisolatedarabic'] = 0xFC0C;
  17947. t['tehinitialarabic'] = 0xFE97;
  17948. t['tehiragana'] = 0x3066;
  17949. t['tehjeeminitialarabic'] = 0xFCA1;
  17950. t['tehjeemisolatedarabic'] = 0xFC0B;
  17951. t['tehmarbutaarabic'] = 0x0629;
  17952. t['tehmarbutafinalarabic'] = 0xFE94;
  17953. t['tehmedialarabic'] = 0xFE98;
  17954. t['tehmeeminitialarabic'] = 0xFCA4;
  17955. t['tehmeemisolatedarabic'] = 0xFC0E;
  17956. t['tehnoonfinalarabic'] = 0xFC73;
  17957. t['tekatakana'] = 0x30C6;
  17958. t['tekatakanahalfwidth'] = 0xFF83;
  17959. t['telephone'] = 0x2121;
  17960. t['telephoneblack'] = 0x260E;
  17961. t['telishagedolahebrew'] = 0x05A0;
  17962. t['telishaqetanahebrew'] = 0x05A9;
  17963. t['tencircle'] = 0x2469;
  17964. t['tenideographicparen'] = 0x3229;
  17965. t['tenparen'] = 0x247D;
  17966. t['tenperiod'] = 0x2491;
  17967. t['tenroman'] = 0x2179;
  17968. t['tesh'] = 0x02A7;
  17969. t['tet'] = 0x05D8;
  17970. t['tetdagesh'] = 0xFB38;
  17971. t['tetdageshhebrew'] = 0xFB38;
  17972. t['tethebrew'] = 0x05D8;
  17973. t['tetsecyrillic'] = 0x04B5;
  17974. t['tevirhebrew'] = 0x059B;
  17975. t['tevirlefthebrew'] = 0x059B;
  17976. t['thabengali'] = 0x09A5;
  17977. t['thadeva'] = 0x0925;
  17978. t['thagujarati'] = 0x0AA5;
  17979. t['thagurmukhi'] = 0x0A25;
  17980. t['thalarabic'] = 0x0630;
  17981. t['thalfinalarabic'] = 0xFEAC;
  17982. t['thanthakhatlowleftthai'] = 0xF898;
  17983. t['thanthakhatlowrightthai'] = 0xF897;
  17984. t['thanthakhatthai'] = 0x0E4C;
  17985. t['thanthakhatupperleftthai'] = 0xF896;
  17986. t['theharabic'] = 0x062B;
  17987. t['thehfinalarabic'] = 0xFE9A;
  17988. t['thehinitialarabic'] = 0xFE9B;
  17989. t['thehmedialarabic'] = 0xFE9C;
  17990. t['thereexists'] = 0x2203;
  17991. t['therefore'] = 0x2234;
  17992. t['theta'] = 0x03B8;
  17993. t['theta1'] = 0x03D1;
  17994. t['thetasymbolgreek'] = 0x03D1;
  17995. t['thieuthacirclekorean'] = 0x3279;
  17996. t['thieuthaparenkorean'] = 0x3219;
  17997. t['thieuthcirclekorean'] = 0x326B;
  17998. t['thieuthkorean'] = 0x314C;
  17999. t['thieuthparenkorean'] = 0x320B;
  18000. t['thirteencircle'] = 0x246C;
  18001. t['thirteenparen'] = 0x2480;
  18002. t['thirteenperiod'] = 0x2494;
  18003. t['thonangmonthothai'] = 0x0E11;
  18004. t['thook'] = 0x01AD;
  18005. t['thophuthaothai'] = 0x0E12;
  18006. t['thorn'] = 0x00FE;
  18007. t['thothahanthai'] = 0x0E17;
  18008. t['thothanthai'] = 0x0E10;
  18009. t['thothongthai'] = 0x0E18;
  18010. t['thothungthai'] = 0x0E16;
  18011. t['thousandcyrillic'] = 0x0482;
  18012. t['thousandsseparatorarabic'] = 0x066C;
  18013. t['thousandsseparatorpersian'] = 0x066C;
  18014. t['three'] = 0x0033;
  18015. t['threearabic'] = 0x0663;
  18016. t['threebengali'] = 0x09E9;
  18017. t['threecircle'] = 0x2462;
  18018. t['threecircleinversesansserif'] = 0x278C;
  18019. t['threedeva'] = 0x0969;
  18020. t['threeeighths'] = 0x215C;
  18021. t['threegujarati'] = 0x0AE9;
  18022. t['threegurmukhi'] = 0x0A69;
  18023. t['threehackarabic'] = 0x0663;
  18024. t['threehangzhou'] = 0x3023;
  18025. t['threeideographicparen'] = 0x3222;
  18026. t['threeinferior'] = 0x2083;
  18027. t['threemonospace'] = 0xFF13;
  18028. t['threenumeratorbengali'] = 0x09F6;
  18029. t['threeoldstyle'] = 0xF733;
  18030. t['threeparen'] = 0x2476;
  18031. t['threeperiod'] = 0x248A;
  18032. t['threepersian'] = 0x06F3;
  18033. t['threequarters'] = 0x00BE;
  18034. t['threequartersemdash'] = 0xF6DE;
  18035. t['threeroman'] = 0x2172;
  18036. t['threesuperior'] = 0x00B3;
  18037. t['threethai'] = 0x0E53;
  18038. t['thzsquare'] = 0x3394;
  18039. t['tihiragana'] = 0x3061;
  18040. t['tikatakana'] = 0x30C1;
  18041. t['tikatakanahalfwidth'] = 0xFF81;
  18042. t['tikeutacirclekorean'] = 0x3270;
  18043. t['tikeutaparenkorean'] = 0x3210;
  18044. t['tikeutcirclekorean'] = 0x3262;
  18045. t['tikeutkorean'] = 0x3137;
  18046. t['tikeutparenkorean'] = 0x3202;
  18047. t['tilde'] = 0x02DC;
  18048. t['tildebelowcmb'] = 0x0330;
  18049. t['tildecmb'] = 0x0303;
  18050. t['tildecomb'] = 0x0303;
  18051. t['tildedoublecmb'] = 0x0360;
  18052. t['tildeoperator'] = 0x223C;
  18053. t['tildeoverlaycmb'] = 0x0334;
  18054. t['tildeverticalcmb'] = 0x033E;
  18055. t['timescircle'] = 0x2297;
  18056. t['tipehahebrew'] = 0x0596;
  18057. t['tipehalefthebrew'] = 0x0596;
  18058. t['tippigurmukhi'] = 0x0A70;
  18059. t['titlocyrilliccmb'] = 0x0483;
  18060. t['tiwnarmenian'] = 0x057F;
  18061. t['tlinebelow'] = 0x1E6F;
  18062. t['tmonospace'] = 0xFF54;
  18063. t['toarmenian'] = 0x0569;
  18064. t['tohiragana'] = 0x3068;
  18065. t['tokatakana'] = 0x30C8;
  18066. t['tokatakanahalfwidth'] = 0xFF84;
  18067. t['tonebarextrahighmod'] = 0x02E5;
  18068. t['tonebarextralowmod'] = 0x02E9;
  18069. t['tonebarhighmod'] = 0x02E6;
  18070. t['tonebarlowmod'] = 0x02E8;
  18071. t['tonebarmidmod'] = 0x02E7;
  18072. t['tonefive'] = 0x01BD;
  18073. t['tonesix'] = 0x0185;
  18074. t['tonetwo'] = 0x01A8;
  18075. t['tonos'] = 0x0384;
  18076. t['tonsquare'] = 0x3327;
  18077. t['topatakthai'] = 0x0E0F;
  18078. t['tortoiseshellbracketleft'] = 0x3014;
  18079. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18080. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18081. t['tortoiseshellbracketright'] = 0x3015;
  18082. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18083. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18084. t['totaothai'] = 0x0E15;
  18085. t['tpalatalhook'] = 0x01AB;
  18086. t['tparen'] = 0x24AF;
  18087. t['trademark'] = 0x2122;
  18088. t['trademarksans'] = 0xF8EA;
  18089. t['trademarkserif'] = 0xF6DB;
  18090. t['tretroflexhook'] = 0x0288;
  18091. t['triagdn'] = 0x25BC;
  18092. t['triaglf'] = 0x25C4;
  18093. t['triagrt'] = 0x25BA;
  18094. t['triagup'] = 0x25B2;
  18095. t['ts'] = 0x02A6;
  18096. t['tsadi'] = 0x05E6;
  18097. t['tsadidagesh'] = 0xFB46;
  18098. t['tsadidageshhebrew'] = 0xFB46;
  18099. t['tsadihebrew'] = 0x05E6;
  18100. t['tsecyrillic'] = 0x0446;
  18101. t['tsere'] = 0x05B5;
  18102. t['tsere12'] = 0x05B5;
  18103. t['tsere1e'] = 0x05B5;
  18104. t['tsere2b'] = 0x05B5;
  18105. t['tserehebrew'] = 0x05B5;
  18106. t['tserenarrowhebrew'] = 0x05B5;
  18107. t['tserequarterhebrew'] = 0x05B5;
  18108. t['tserewidehebrew'] = 0x05B5;
  18109. t['tshecyrillic'] = 0x045B;
  18110. t['tsuperior'] = 0xF6F3;
  18111. t['ttabengali'] = 0x099F;
  18112. t['ttadeva'] = 0x091F;
  18113. t['ttagujarati'] = 0x0A9F;
  18114. t['ttagurmukhi'] = 0x0A1F;
  18115. t['tteharabic'] = 0x0679;
  18116. t['ttehfinalarabic'] = 0xFB67;
  18117. t['ttehinitialarabic'] = 0xFB68;
  18118. t['ttehmedialarabic'] = 0xFB69;
  18119. t['tthabengali'] = 0x09A0;
  18120. t['tthadeva'] = 0x0920;
  18121. t['tthagujarati'] = 0x0AA0;
  18122. t['tthagurmukhi'] = 0x0A20;
  18123. t['tturned'] = 0x0287;
  18124. t['tuhiragana'] = 0x3064;
  18125. t['tukatakana'] = 0x30C4;
  18126. t['tukatakanahalfwidth'] = 0xFF82;
  18127. t['tusmallhiragana'] = 0x3063;
  18128. t['tusmallkatakana'] = 0x30C3;
  18129. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18130. t['twelvecircle'] = 0x246B;
  18131. t['twelveparen'] = 0x247F;
  18132. t['twelveperiod'] = 0x2493;
  18133. t['twelveroman'] = 0x217B;
  18134. t['twentycircle'] = 0x2473;
  18135. t['twentyhangzhou'] = 0x5344;
  18136. t['twentyparen'] = 0x2487;
  18137. t['twentyperiod'] = 0x249B;
  18138. t['two'] = 0x0032;
  18139. t['twoarabic'] = 0x0662;
  18140. t['twobengali'] = 0x09E8;
  18141. t['twocircle'] = 0x2461;
  18142. t['twocircleinversesansserif'] = 0x278B;
  18143. t['twodeva'] = 0x0968;
  18144. t['twodotenleader'] = 0x2025;
  18145. t['twodotleader'] = 0x2025;
  18146. t['twodotleadervertical'] = 0xFE30;
  18147. t['twogujarati'] = 0x0AE8;
  18148. t['twogurmukhi'] = 0x0A68;
  18149. t['twohackarabic'] = 0x0662;
  18150. t['twohangzhou'] = 0x3022;
  18151. t['twoideographicparen'] = 0x3221;
  18152. t['twoinferior'] = 0x2082;
  18153. t['twomonospace'] = 0xFF12;
  18154. t['twonumeratorbengali'] = 0x09F5;
  18155. t['twooldstyle'] = 0xF732;
  18156. t['twoparen'] = 0x2475;
  18157. t['twoperiod'] = 0x2489;
  18158. t['twopersian'] = 0x06F2;
  18159. t['tworoman'] = 0x2171;
  18160. t['twostroke'] = 0x01BB;
  18161. t['twosuperior'] = 0x00B2;
  18162. t['twothai'] = 0x0E52;
  18163. t['twothirds'] = 0x2154;
  18164. t['u'] = 0x0075;
  18165. t['uacute'] = 0x00FA;
  18166. t['ubar'] = 0x0289;
  18167. t['ubengali'] = 0x0989;
  18168. t['ubopomofo'] = 0x3128;
  18169. t['ubreve'] = 0x016D;
  18170. t['ucaron'] = 0x01D4;
  18171. t['ucircle'] = 0x24E4;
  18172. t['ucircumflex'] = 0x00FB;
  18173. t['ucircumflexbelow'] = 0x1E77;
  18174. t['ucyrillic'] = 0x0443;
  18175. t['udattadeva'] = 0x0951;
  18176. t['udblacute'] = 0x0171;
  18177. t['udblgrave'] = 0x0215;
  18178. t['udeva'] = 0x0909;
  18179. t['udieresis'] = 0x00FC;
  18180. t['udieresisacute'] = 0x01D8;
  18181. t['udieresisbelow'] = 0x1E73;
  18182. t['udieresiscaron'] = 0x01DA;
  18183. t['udieresiscyrillic'] = 0x04F1;
  18184. t['udieresisgrave'] = 0x01DC;
  18185. t['udieresismacron'] = 0x01D6;
  18186. t['udotbelow'] = 0x1EE5;
  18187. t['ugrave'] = 0x00F9;
  18188. t['ugujarati'] = 0x0A89;
  18189. t['ugurmukhi'] = 0x0A09;
  18190. t['uhiragana'] = 0x3046;
  18191. t['uhookabove'] = 0x1EE7;
  18192. t['uhorn'] = 0x01B0;
  18193. t['uhornacute'] = 0x1EE9;
  18194. t['uhorndotbelow'] = 0x1EF1;
  18195. t['uhorngrave'] = 0x1EEB;
  18196. t['uhornhookabove'] = 0x1EED;
  18197. t['uhorntilde'] = 0x1EEF;
  18198. t['uhungarumlaut'] = 0x0171;
  18199. t['uhungarumlautcyrillic'] = 0x04F3;
  18200. t['uinvertedbreve'] = 0x0217;
  18201. t['ukatakana'] = 0x30A6;
  18202. t['ukatakanahalfwidth'] = 0xFF73;
  18203. t['ukcyrillic'] = 0x0479;
  18204. t['ukorean'] = 0x315C;
  18205. t['umacron'] = 0x016B;
  18206. t['umacroncyrillic'] = 0x04EF;
  18207. t['umacrondieresis'] = 0x1E7B;
  18208. t['umatragurmukhi'] = 0x0A41;
  18209. t['umonospace'] = 0xFF55;
  18210. t['underscore'] = 0x005F;
  18211. t['underscoredbl'] = 0x2017;
  18212. t['underscoremonospace'] = 0xFF3F;
  18213. t['underscorevertical'] = 0xFE33;
  18214. t['underscorewavy'] = 0xFE4F;
  18215. t['union'] = 0x222A;
  18216. t['universal'] = 0x2200;
  18217. t['uogonek'] = 0x0173;
  18218. t['uparen'] = 0x24B0;
  18219. t['upblock'] = 0x2580;
  18220. t['upperdothebrew'] = 0x05C4;
  18221. t['upsilon'] = 0x03C5;
  18222. t['upsilondieresis'] = 0x03CB;
  18223. t['upsilondieresistonos'] = 0x03B0;
  18224. t['upsilonlatin'] = 0x028A;
  18225. t['upsilontonos'] = 0x03CD;
  18226. t['uptackbelowcmb'] = 0x031D;
  18227. t['uptackmod'] = 0x02D4;
  18228. t['uragurmukhi'] = 0x0A73;
  18229. t['uring'] = 0x016F;
  18230. t['ushortcyrillic'] = 0x045E;
  18231. t['usmallhiragana'] = 0x3045;
  18232. t['usmallkatakana'] = 0x30A5;
  18233. t['usmallkatakanahalfwidth'] = 0xFF69;
  18234. t['ustraightcyrillic'] = 0x04AF;
  18235. t['ustraightstrokecyrillic'] = 0x04B1;
  18236. t['utilde'] = 0x0169;
  18237. t['utildeacute'] = 0x1E79;
  18238. t['utildebelow'] = 0x1E75;
  18239. t['uubengali'] = 0x098A;
  18240. t['uudeva'] = 0x090A;
  18241. t['uugujarati'] = 0x0A8A;
  18242. t['uugurmukhi'] = 0x0A0A;
  18243. t['uumatragurmukhi'] = 0x0A42;
  18244. t['uuvowelsignbengali'] = 0x09C2;
  18245. t['uuvowelsigndeva'] = 0x0942;
  18246. t['uuvowelsigngujarati'] = 0x0AC2;
  18247. t['uvowelsignbengali'] = 0x09C1;
  18248. t['uvowelsigndeva'] = 0x0941;
  18249. t['uvowelsigngujarati'] = 0x0AC1;
  18250. t['v'] = 0x0076;
  18251. t['vadeva'] = 0x0935;
  18252. t['vagujarati'] = 0x0AB5;
  18253. t['vagurmukhi'] = 0x0A35;
  18254. t['vakatakana'] = 0x30F7;
  18255. t['vav'] = 0x05D5;
  18256. t['vavdagesh'] = 0xFB35;
  18257. t['vavdagesh65'] = 0xFB35;
  18258. t['vavdageshhebrew'] = 0xFB35;
  18259. t['vavhebrew'] = 0x05D5;
  18260. t['vavholam'] = 0xFB4B;
  18261. t['vavholamhebrew'] = 0xFB4B;
  18262. t['vavvavhebrew'] = 0x05F0;
  18263. t['vavyodhebrew'] = 0x05F1;
  18264. t['vcircle'] = 0x24E5;
  18265. t['vdotbelow'] = 0x1E7F;
  18266. t['vecyrillic'] = 0x0432;
  18267. t['veharabic'] = 0x06A4;
  18268. t['vehfinalarabic'] = 0xFB6B;
  18269. t['vehinitialarabic'] = 0xFB6C;
  18270. t['vehmedialarabic'] = 0xFB6D;
  18271. t['vekatakana'] = 0x30F9;
  18272. t['venus'] = 0x2640;
  18273. t['verticalbar'] = 0x007C;
  18274. t['verticallineabovecmb'] = 0x030D;
  18275. t['verticallinebelowcmb'] = 0x0329;
  18276. t['verticallinelowmod'] = 0x02CC;
  18277. t['verticallinemod'] = 0x02C8;
  18278. t['vewarmenian'] = 0x057E;
  18279. t['vhook'] = 0x028B;
  18280. t['vikatakana'] = 0x30F8;
  18281. t['viramabengali'] = 0x09CD;
  18282. t['viramadeva'] = 0x094D;
  18283. t['viramagujarati'] = 0x0ACD;
  18284. t['visargabengali'] = 0x0983;
  18285. t['visargadeva'] = 0x0903;
  18286. t['visargagujarati'] = 0x0A83;
  18287. t['vmonospace'] = 0xFF56;
  18288. t['voarmenian'] = 0x0578;
  18289. t['voicediterationhiragana'] = 0x309E;
  18290. t['voicediterationkatakana'] = 0x30FE;
  18291. t['voicedmarkkana'] = 0x309B;
  18292. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18293. t['vokatakana'] = 0x30FA;
  18294. t['vparen'] = 0x24B1;
  18295. t['vtilde'] = 0x1E7D;
  18296. t['vturned'] = 0x028C;
  18297. t['vuhiragana'] = 0x3094;
  18298. t['vukatakana'] = 0x30F4;
  18299. t['w'] = 0x0077;
  18300. t['wacute'] = 0x1E83;
  18301. t['waekorean'] = 0x3159;
  18302. t['wahiragana'] = 0x308F;
  18303. t['wakatakana'] = 0x30EF;
  18304. t['wakatakanahalfwidth'] = 0xFF9C;
  18305. t['wakorean'] = 0x3158;
  18306. t['wasmallhiragana'] = 0x308E;
  18307. t['wasmallkatakana'] = 0x30EE;
  18308. t['wattosquare'] = 0x3357;
  18309. t['wavedash'] = 0x301C;
  18310. t['wavyunderscorevertical'] = 0xFE34;
  18311. t['wawarabic'] = 0x0648;
  18312. t['wawfinalarabic'] = 0xFEEE;
  18313. t['wawhamzaabovearabic'] = 0x0624;
  18314. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18315. t['wbsquare'] = 0x33DD;
  18316. t['wcircle'] = 0x24E6;
  18317. t['wcircumflex'] = 0x0175;
  18318. t['wdieresis'] = 0x1E85;
  18319. t['wdotaccent'] = 0x1E87;
  18320. t['wdotbelow'] = 0x1E89;
  18321. t['wehiragana'] = 0x3091;
  18322. t['weierstrass'] = 0x2118;
  18323. t['wekatakana'] = 0x30F1;
  18324. t['wekorean'] = 0x315E;
  18325. t['weokorean'] = 0x315D;
  18326. t['wgrave'] = 0x1E81;
  18327. t['whitebullet'] = 0x25E6;
  18328. t['whitecircle'] = 0x25CB;
  18329. t['whitecircleinverse'] = 0x25D9;
  18330. t['whitecornerbracketleft'] = 0x300E;
  18331. t['whitecornerbracketleftvertical'] = 0xFE43;
  18332. t['whitecornerbracketright'] = 0x300F;
  18333. t['whitecornerbracketrightvertical'] = 0xFE44;
  18334. t['whitediamond'] = 0x25C7;
  18335. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18336. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18337. t['whitedownpointingtriangle'] = 0x25BD;
  18338. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18339. t['whiteleftpointingtriangle'] = 0x25C1;
  18340. t['whitelenticularbracketleft'] = 0x3016;
  18341. t['whitelenticularbracketright'] = 0x3017;
  18342. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18343. t['whiterightpointingtriangle'] = 0x25B7;
  18344. t['whitesmallsquare'] = 0x25AB;
  18345. t['whitesmilingface'] = 0x263A;
  18346. t['whitesquare'] = 0x25A1;
  18347. t['whitestar'] = 0x2606;
  18348. t['whitetelephone'] = 0x260F;
  18349. t['whitetortoiseshellbracketleft'] = 0x3018;
  18350. t['whitetortoiseshellbracketright'] = 0x3019;
  18351. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18352. t['whiteuppointingtriangle'] = 0x25B3;
  18353. t['wihiragana'] = 0x3090;
  18354. t['wikatakana'] = 0x30F0;
  18355. t['wikorean'] = 0x315F;
  18356. t['wmonospace'] = 0xFF57;
  18357. t['wohiragana'] = 0x3092;
  18358. t['wokatakana'] = 0x30F2;
  18359. t['wokatakanahalfwidth'] = 0xFF66;
  18360. t['won'] = 0x20A9;
  18361. t['wonmonospace'] = 0xFFE6;
  18362. t['wowaenthai'] = 0x0E27;
  18363. t['wparen'] = 0x24B2;
  18364. t['wring'] = 0x1E98;
  18365. t['wsuperior'] = 0x02B7;
  18366. t['wturned'] = 0x028D;
  18367. t['wynn'] = 0x01BF;
  18368. t['x'] = 0x0078;
  18369. t['xabovecmb'] = 0x033D;
  18370. t['xbopomofo'] = 0x3112;
  18371. t['xcircle'] = 0x24E7;
  18372. t['xdieresis'] = 0x1E8D;
  18373. t['xdotaccent'] = 0x1E8B;
  18374. t['xeharmenian'] = 0x056D;
  18375. t['xi'] = 0x03BE;
  18376. t['xmonospace'] = 0xFF58;
  18377. t['xparen'] = 0x24B3;
  18378. t['xsuperior'] = 0x02E3;
  18379. t['y'] = 0x0079;
  18380. t['yaadosquare'] = 0x334E;
  18381. t['yabengali'] = 0x09AF;
  18382. t['yacute'] = 0x00FD;
  18383. t['yadeva'] = 0x092F;
  18384. t['yaekorean'] = 0x3152;
  18385. t['yagujarati'] = 0x0AAF;
  18386. t['yagurmukhi'] = 0x0A2F;
  18387. t['yahiragana'] = 0x3084;
  18388. t['yakatakana'] = 0x30E4;
  18389. t['yakatakanahalfwidth'] = 0xFF94;
  18390. t['yakorean'] = 0x3151;
  18391. t['yamakkanthai'] = 0x0E4E;
  18392. t['yasmallhiragana'] = 0x3083;
  18393. t['yasmallkatakana'] = 0x30E3;
  18394. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18395. t['yatcyrillic'] = 0x0463;
  18396. t['ycircle'] = 0x24E8;
  18397. t['ycircumflex'] = 0x0177;
  18398. t['ydieresis'] = 0x00FF;
  18399. t['ydotaccent'] = 0x1E8F;
  18400. t['ydotbelow'] = 0x1EF5;
  18401. t['yeharabic'] = 0x064A;
  18402. t['yehbarreearabic'] = 0x06D2;
  18403. t['yehbarreefinalarabic'] = 0xFBAF;
  18404. t['yehfinalarabic'] = 0xFEF2;
  18405. t['yehhamzaabovearabic'] = 0x0626;
  18406. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18407. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18408. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18409. t['yehinitialarabic'] = 0xFEF3;
  18410. t['yehmedialarabic'] = 0xFEF4;
  18411. t['yehmeeminitialarabic'] = 0xFCDD;
  18412. t['yehmeemisolatedarabic'] = 0xFC58;
  18413. t['yehnoonfinalarabic'] = 0xFC94;
  18414. t['yehthreedotsbelowarabic'] = 0x06D1;
  18415. t['yekorean'] = 0x3156;
  18416. t['yen'] = 0x00A5;
  18417. t['yenmonospace'] = 0xFFE5;
  18418. t['yeokorean'] = 0x3155;
  18419. t['yeorinhieuhkorean'] = 0x3186;
  18420. t['yerahbenyomohebrew'] = 0x05AA;
  18421. t['yerahbenyomolefthebrew'] = 0x05AA;
  18422. t['yericyrillic'] = 0x044B;
  18423. t['yerudieresiscyrillic'] = 0x04F9;
  18424. t['yesieungkorean'] = 0x3181;
  18425. t['yesieungpansioskorean'] = 0x3183;
  18426. t['yesieungsioskorean'] = 0x3182;
  18427. t['yetivhebrew'] = 0x059A;
  18428. t['ygrave'] = 0x1EF3;
  18429. t['yhook'] = 0x01B4;
  18430. t['yhookabove'] = 0x1EF7;
  18431. t['yiarmenian'] = 0x0575;
  18432. t['yicyrillic'] = 0x0457;
  18433. t['yikorean'] = 0x3162;
  18434. t['yinyang'] = 0x262F;
  18435. t['yiwnarmenian'] = 0x0582;
  18436. t['ymonospace'] = 0xFF59;
  18437. t['yod'] = 0x05D9;
  18438. t['yoddagesh'] = 0xFB39;
  18439. t['yoddageshhebrew'] = 0xFB39;
  18440. t['yodhebrew'] = 0x05D9;
  18441. t['yodyodhebrew'] = 0x05F2;
  18442. t['yodyodpatahhebrew'] = 0xFB1F;
  18443. t['yohiragana'] = 0x3088;
  18444. t['yoikorean'] = 0x3189;
  18445. t['yokatakana'] = 0x30E8;
  18446. t['yokatakanahalfwidth'] = 0xFF96;
  18447. t['yokorean'] = 0x315B;
  18448. t['yosmallhiragana'] = 0x3087;
  18449. t['yosmallkatakana'] = 0x30E7;
  18450. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18451. t['yotgreek'] = 0x03F3;
  18452. t['yoyaekorean'] = 0x3188;
  18453. t['yoyakorean'] = 0x3187;
  18454. t['yoyakthai'] = 0x0E22;
  18455. t['yoyingthai'] = 0x0E0D;
  18456. t['yparen'] = 0x24B4;
  18457. t['ypogegrammeni'] = 0x037A;
  18458. t['ypogegrammenigreekcmb'] = 0x0345;
  18459. t['yr'] = 0x01A6;
  18460. t['yring'] = 0x1E99;
  18461. t['ysuperior'] = 0x02B8;
  18462. t['ytilde'] = 0x1EF9;
  18463. t['yturned'] = 0x028E;
  18464. t['yuhiragana'] = 0x3086;
  18465. t['yuikorean'] = 0x318C;
  18466. t['yukatakana'] = 0x30E6;
  18467. t['yukatakanahalfwidth'] = 0xFF95;
  18468. t['yukorean'] = 0x3160;
  18469. t['yusbigcyrillic'] = 0x046B;
  18470. t['yusbigiotifiedcyrillic'] = 0x046D;
  18471. t['yuslittlecyrillic'] = 0x0467;
  18472. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18473. t['yusmallhiragana'] = 0x3085;
  18474. t['yusmallkatakana'] = 0x30E5;
  18475. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18476. t['yuyekorean'] = 0x318B;
  18477. t['yuyeokorean'] = 0x318A;
  18478. t['yyabengali'] = 0x09DF;
  18479. t['yyadeva'] = 0x095F;
  18480. t['z'] = 0x007A;
  18481. t['zaarmenian'] = 0x0566;
  18482. t['zacute'] = 0x017A;
  18483. t['zadeva'] = 0x095B;
  18484. t['zagurmukhi'] = 0x0A5B;
  18485. t['zaharabic'] = 0x0638;
  18486. t['zahfinalarabic'] = 0xFEC6;
  18487. t['zahinitialarabic'] = 0xFEC7;
  18488. t['zahiragana'] = 0x3056;
  18489. t['zahmedialarabic'] = 0xFEC8;
  18490. t['zainarabic'] = 0x0632;
  18491. t['zainfinalarabic'] = 0xFEB0;
  18492. t['zakatakana'] = 0x30B6;
  18493. t['zaqefgadolhebrew'] = 0x0595;
  18494. t['zaqefqatanhebrew'] = 0x0594;
  18495. t['zarqahebrew'] = 0x0598;
  18496. t['zayin'] = 0x05D6;
  18497. t['zayindagesh'] = 0xFB36;
  18498. t['zayindageshhebrew'] = 0xFB36;
  18499. t['zayinhebrew'] = 0x05D6;
  18500. t['zbopomofo'] = 0x3117;
  18501. t['zcaron'] = 0x017E;
  18502. t['zcircle'] = 0x24E9;
  18503. t['zcircumflex'] = 0x1E91;
  18504. t['zcurl'] = 0x0291;
  18505. t['zdot'] = 0x017C;
  18506. t['zdotaccent'] = 0x017C;
  18507. t['zdotbelow'] = 0x1E93;
  18508. t['zecyrillic'] = 0x0437;
  18509. t['zedescendercyrillic'] = 0x0499;
  18510. t['zedieresiscyrillic'] = 0x04DF;
  18511. t['zehiragana'] = 0x305C;
  18512. t['zekatakana'] = 0x30BC;
  18513. t['zero'] = 0x0030;
  18514. t['zeroarabic'] = 0x0660;
  18515. t['zerobengali'] = 0x09E6;
  18516. t['zerodeva'] = 0x0966;
  18517. t['zerogujarati'] = 0x0AE6;
  18518. t['zerogurmukhi'] = 0x0A66;
  18519. t['zerohackarabic'] = 0x0660;
  18520. t['zeroinferior'] = 0x2080;
  18521. t['zeromonospace'] = 0xFF10;
  18522. t['zerooldstyle'] = 0xF730;
  18523. t['zeropersian'] = 0x06F0;
  18524. t['zerosuperior'] = 0x2070;
  18525. t['zerothai'] = 0x0E50;
  18526. t['zerowidthjoiner'] = 0xFEFF;
  18527. t['zerowidthnonjoiner'] = 0x200C;
  18528. t['zerowidthspace'] = 0x200B;
  18529. t['zeta'] = 0x03B6;
  18530. t['zhbopomofo'] = 0x3113;
  18531. t['zhearmenian'] = 0x056A;
  18532. t['zhebrevecyrillic'] = 0x04C2;
  18533. t['zhecyrillic'] = 0x0436;
  18534. t['zhedescendercyrillic'] = 0x0497;
  18535. t['zhedieresiscyrillic'] = 0x04DD;
  18536. t['zihiragana'] = 0x3058;
  18537. t['zikatakana'] = 0x30B8;
  18538. t['zinorhebrew'] = 0x05AE;
  18539. t['zlinebelow'] = 0x1E95;
  18540. t['zmonospace'] = 0xFF5A;
  18541. t['zohiragana'] = 0x305E;
  18542. t['zokatakana'] = 0x30BE;
  18543. t['zparen'] = 0x24B5;
  18544. t['zretroflexhook'] = 0x0290;
  18545. t['zstroke'] = 0x01B6;
  18546. t['zuhiragana'] = 0x305A;
  18547. t['zukatakana'] = 0x30BA;
  18548. t['.notdef'] = 0x0000;
  18549. t['angbracketleftbig'] = 0x2329;
  18550. t['angbracketleftBig'] = 0x2329;
  18551. t['angbracketleftbigg'] = 0x2329;
  18552. t['angbracketleftBigg'] = 0x2329;
  18553. t['angbracketrightBig'] = 0x232A;
  18554. t['angbracketrightbig'] = 0x232A;
  18555. t['angbracketrightBigg'] = 0x232A;
  18556. t['angbracketrightbigg'] = 0x232A;
  18557. t['arrowhookleft'] = 0x21AA;
  18558. t['arrowhookright'] = 0x21A9;
  18559. t['arrowlefttophalf'] = 0x21BC;
  18560. t['arrowleftbothalf'] = 0x21BD;
  18561. t['arrownortheast'] = 0x2197;
  18562. t['arrownorthwest'] = 0x2196;
  18563. t['arrowrighttophalf'] = 0x21C0;
  18564. t['arrowrightbothalf'] = 0x21C1;
  18565. t['arrowsoutheast'] = 0x2198;
  18566. t['arrowsouthwest'] = 0x2199;
  18567. t['backslashbig'] = 0x2216;
  18568. t['backslashBig'] = 0x2216;
  18569. t['backslashBigg'] = 0x2216;
  18570. t['backslashbigg'] = 0x2216;
  18571. t['bardbl'] = 0x2016;
  18572. t['bracehtipdownleft'] = 0xFE37;
  18573. t['bracehtipdownright'] = 0xFE37;
  18574. t['bracehtipupleft'] = 0xFE38;
  18575. t['bracehtipupright'] = 0xFE38;
  18576. t['braceleftBig'] = 0x007B;
  18577. t['braceleftbig'] = 0x007B;
  18578. t['braceleftbigg'] = 0x007B;
  18579. t['braceleftBigg'] = 0x007B;
  18580. t['bracerightBig'] = 0x007D;
  18581. t['bracerightbig'] = 0x007D;
  18582. t['bracerightbigg'] = 0x007D;
  18583. t['bracerightBigg'] = 0x007D;
  18584. t['bracketleftbig'] = 0x005B;
  18585. t['bracketleftBig'] = 0x005B;
  18586. t['bracketleftbigg'] = 0x005B;
  18587. t['bracketleftBigg'] = 0x005B;
  18588. t['bracketrightBig'] = 0x005D;
  18589. t['bracketrightbig'] = 0x005D;
  18590. t['bracketrightbigg'] = 0x005D;
  18591. t['bracketrightBigg'] = 0x005D;
  18592. t['ceilingleftbig'] = 0x2308;
  18593. t['ceilingleftBig'] = 0x2308;
  18594. t['ceilingleftBigg'] = 0x2308;
  18595. t['ceilingleftbigg'] = 0x2308;
  18596. t['ceilingrightbig'] = 0x2309;
  18597. t['ceilingrightBig'] = 0x2309;
  18598. t['ceilingrightbigg'] = 0x2309;
  18599. t['ceilingrightBigg'] = 0x2309;
  18600. t['circledotdisplay'] = 0x2299;
  18601. t['circledottext'] = 0x2299;
  18602. t['circlemultiplydisplay'] = 0x2297;
  18603. t['circlemultiplytext'] = 0x2297;
  18604. t['circleplusdisplay'] = 0x2295;
  18605. t['circleplustext'] = 0x2295;
  18606. t['contintegraldisplay'] = 0x222E;
  18607. t['contintegraltext'] = 0x222E;
  18608. t['coproductdisplay'] = 0x2210;
  18609. t['coproducttext'] = 0x2210;
  18610. t['floorleftBig'] = 0x230A;
  18611. t['floorleftbig'] = 0x230A;
  18612. t['floorleftbigg'] = 0x230A;
  18613. t['floorleftBigg'] = 0x230A;
  18614. t['floorrightbig'] = 0x230B;
  18615. t['floorrightBig'] = 0x230B;
  18616. t['floorrightBigg'] = 0x230B;
  18617. t['floorrightbigg'] = 0x230B;
  18618. t['hatwide'] = 0x0302;
  18619. t['hatwider'] = 0x0302;
  18620. t['hatwidest'] = 0x0302;
  18621. t['intercal'] = 0x1D40;
  18622. t['integraldisplay'] = 0x222B;
  18623. t['integraltext'] = 0x222B;
  18624. t['intersectiondisplay'] = 0x22C2;
  18625. t['intersectiontext'] = 0x22C2;
  18626. t['logicalanddisplay'] = 0x2227;
  18627. t['logicalandtext'] = 0x2227;
  18628. t['logicalordisplay'] = 0x2228;
  18629. t['logicalortext'] = 0x2228;
  18630. t['parenleftBig'] = 0x0028;
  18631. t['parenleftbig'] = 0x0028;
  18632. t['parenleftBigg'] = 0x0028;
  18633. t['parenleftbigg'] = 0x0028;
  18634. t['parenrightBig'] = 0x0029;
  18635. t['parenrightbig'] = 0x0029;
  18636. t['parenrightBigg'] = 0x0029;
  18637. t['parenrightbigg'] = 0x0029;
  18638. t['prime'] = 0x2032;
  18639. t['productdisplay'] = 0x220F;
  18640. t['producttext'] = 0x220F;
  18641. t['radicalbig'] = 0x221A;
  18642. t['radicalBig'] = 0x221A;
  18643. t['radicalBigg'] = 0x221A;
  18644. t['radicalbigg'] = 0x221A;
  18645. t['radicalbt'] = 0x221A;
  18646. t['radicaltp'] = 0x221A;
  18647. t['radicalvertex'] = 0x221A;
  18648. t['slashbig'] = 0x002F;
  18649. t['slashBig'] = 0x002F;
  18650. t['slashBigg'] = 0x002F;
  18651. t['slashbigg'] = 0x002F;
  18652. t['summationdisplay'] = 0x2211;
  18653. t['summationtext'] = 0x2211;
  18654. t['tildewide'] = 0x02DC;
  18655. t['tildewider'] = 0x02DC;
  18656. t['tildewidest'] = 0x02DC;
  18657. t['uniondisplay'] = 0x22C3;
  18658. t['unionmultidisplay'] = 0x228E;
  18659. t['unionmultitext'] = 0x228E;
  18660. t['unionsqdisplay'] = 0x2294;
  18661. t['unionsqtext'] = 0x2294;
  18662. t['uniontext'] = 0x22C3;
  18663. t['vextenddouble'] = 0x2225;
  18664. t['vextendsingle'] = 0x2223;
  18665. });
  18666. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18667. t['space'] = 0x0020;
  18668. t['a1'] = 0x2701;
  18669. t['a2'] = 0x2702;
  18670. t['a202'] = 0x2703;
  18671. t['a3'] = 0x2704;
  18672. t['a4'] = 0x260E;
  18673. t['a5'] = 0x2706;
  18674. t['a119'] = 0x2707;
  18675. t['a118'] = 0x2708;
  18676. t['a117'] = 0x2709;
  18677. t['a11'] = 0x261B;
  18678. t['a12'] = 0x261E;
  18679. t['a13'] = 0x270C;
  18680. t['a14'] = 0x270D;
  18681. t['a15'] = 0x270E;
  18682. t['a16'] = 0x270F;
  18683. t['a105'] = 0x2710;
  18684. t['a17'] = 0x2711;
  18685. t['a18'] = 0x2712;
  18686. t['a19'] = 0x2713;
  18687. t['a20'] = 0x2714;
  18688. t['a21'] = 0x2715;
  18689. t['a22'] = 0x2716;
  18690. t['a23'] = 0x2717;
  18691. t['a24'] = 0x2718;
  18692. t['a25'] = 0x2719;
  18693. t['a26'] = 0x271A;
  18694. t['a27'] = 0x271B;
  18695. t['a28'] = 0x271C;
  18696. t['a6'] = 0x271D;
  18697. t['a7'] = 0x271E;
  18698. t['a8'] = 0x271F;
  18699. t['a9'] = 0x2720;
  18700. t['a10'] = 0x2721;
  18701. t['a29'] = 0x2722;
  18702. t['a30'] = 0x2723;
  18703. t['a31'] = 0x2724;
  18704. t['a32'] = 0x2725;
  18705. t['a33'] = 0x2726;
  18706. t['a34'] = 0x2727;
  18707. t['a35'] = 0x2605;
  18708. t['a36'] = 0x2729;
  18709. t['a37'] = 0x272A;
  18710. t['a38'] = 0x272B;
  18711. t['a39'] = 0x272C;
  18712. t['a40'] = 0x272D;
  18713. t['a41'] = 0x272E;
  18714. t['a42'] = 0x272F;
  18715. t['a43'] = 0x2730;
  18716. t['a44'] = 0x2731;
  18717. t['a45'] = 0x2732;
  18718. t['a46'] = 0x2733;
  18719. t['a47'] = 0x2734;
  18720. t['a48'] = 0x2735;
  18721. t['a49'] = 0x2736;
  18722. t['a50'] = 0x2737;
  18723. t['a51'] = 0x2738;
  18724. t['a52'] = 0x2739;
  18725. t['a53'] = 0x273A;
  18726. t['a54'] = 0x273B;
  18727. t['a55'] = 0x273C;
  18728. t['a56'] = 0x273D;
  18729. t['a57'] = 0x273E;
  18730. t['a58'] = 0x273F;
  18731. t['a59'] = 0x2740;
  18732. t['a60'] = 0x2741;
  18733. t['a61'] = 0x2742;
  18734. t['a62'] = 0x2743;
  18735. t['a63'] = 0x2744;
  18736. t['a64'] = 0x2745;
  18737. t['a65'] = 0x2746;
  18738. t['a66'] = 0x2747;
  18739. t['a67'] = 0x2748;
  18740. t['a68'] = 0x2749;
  18741. t['a69'] = 0x274A;
  18742. t['a70'] = 0x274B;
  18743. t['a71'] = 0x25CF;
  18744. t['a72'] = 0x274D;
  18745. t['a73'] = 0x25A0;
  18746. t['a74'] = 0x274F;
  18747. t['a203'] = 0x2750;
  18748. t['a75'] = 0x2751;
  18749. t['a204'] = 0x2752;
  18750. t['a76'] = 0x25B2;
  18751. t['a77'] = 0x25BC;
  18752. t['a78'] = 0x25C6;
  18753. t['a79'] = 0x2756;
  18754. t['a81'] = 0x25D7;
  18755. t['a82'] = 0x2758;
  18756. t['a83'] = 0x2759;
  18757. t['a84'] = 0x275A;
  18758. t['a97'] = 0x275B;
  18759. t['a98'] = 0x275C;
  18760. t['a99'] = 0x275D;
  18761. t['a100'] = 0x275E;
  18762. t['a101'] = 0x2761;
  18763. t['a102'] = 0x2762;
  18764. t['a103'] = 0x2763;
  18765. t['a104'] = 0x2764;
  18766. t['a106'] = 0x2765;
  18767. t['a107'] = 0x2766;
  18768. t['a108'] = 0x2767;
  18769. t['a112'] = 0x2663;
  18770. t['a111'] = 0x2666;
  18771. t['a110'] = 0x2665;
  18772. t['a109'] = 0x2660;
  18773. t['a120'] = 0x2460;
  18774. t['a121'] = 0x2461;
  18775. t['a122'] = 0x2462;
  18776. t['a123'] = 0x2463;
  18777. t['a124'] = 0x2464;
  18778. t['a125'] = 0x2465;
  18779. t['a126'] = 0x2466;
  18780. t['a127'] = 0x2467;
  18781. t['a128'] = 0x2468;
  18782. t['a129'] = 0x2469;
  18783. t['a130'] = 0x2776;
  18784. t['a131'] = 0x2777;
  18785. t['a132'] = 0x2778;
  18786. t['a133'] = 0x2779;
  18787. t['a134'] = 0x277A;
  18788. t['a135'] = 0x277B;
  18789. t['a136'] = 0x277C;
  18790. t['a137'] = 0x277D;
  18791. t['a138'] = 0x277E;
  18792. t['a139'] = 0x277F;
  18793. t['a140'] = 0x2780;
  18794. t['a141'] = 0x2781;
  18795. t['a142'] = 0x2782;
  18796. t['a143'] = 0x2783;
  18797. t['a144'] = 0x2784;
  18798. t['a145'] = 0x2785;
  18799. t['a146'] = 0x2786;
  18800. t['a147'] = 0x2787;
  18801. t['a148'] = 0x2788;
  18802. t['a149'] = 0x2789;
  18803. t['a150'] = 0x278A;
  18804. t['a151'] = 0x278B;
  18805. t['a152'] = 0x278C;
  18806. t['a153'] = 0x278D;
  18807. t['a154'] = 0x278E;
  18808. t['a155'] = 0x278F;
  18809. t['a156'] = 0x2790;
  18810. t['a157'] = 0x2791;
  18811. t['a158'] = 0x2792;
  18812. t['a159'] = 0x2793;
  18813. t['a160'] = 0x2794;
  18814. t['a161'] = 0x2192;
  18815. t['a163'] = 0x2194;
  18816. t['a164'] = 0x2195;
  18817. t['a196'] = 0x2798;
  18818. t['a165'] = 0x2799;
  18819. t['a192'] = 0x279A;
  18820. t['a166'] = 0x279B;
  18821. t['a167'] = 0x279C;
  18822. t['a168'] = 0x279D;
  18823. t['a169'] = 0x279E;
  18824. t['a170'] = 0x279F;
  18825. t['a171'] = 0x27A0;
  18826. t['a172'] = 0x27A1;
  18827. t['a173'] = 0x27A2;
  18828. t['a162'] = 0x27A3;
  18829. t['a174'] = 0x27A4;
  18830. t['a175'] = 0x27A5;
  18831. t['a176'] = 0x27A6;
  18832. t['a177'] = 0x27A7;
  18833. t['a178'] = 0x27A8;
  18834. t['a179'] = 0x27A9;
  18835. t['a193'] = 0x27AA;
  18836. t['a180'] = 0x27AB;
  18837. t['a199'] = 0x27AC;
  18838. t['a181'] = 0x27AD;
  18839. t['a200'] = 0x27AE;
  18840. t['a182'] = 0x27AF;
  18841. t['a201'] = 0x27B1;
  18842. t['a183'] = 0x27B2;
  18843. t['a184'] = 0x27B3;
  18844. t['a197'] = 0x27B4;
  18845. t['a185'] = 0x27B5;
  18846. t['a194'] = 0x27B6;
  18847. t['a198'] = 0x27B7;
  18848. t['a186'] = 0x27B8;
  18849. t['a195'] = 0x27B9;
  18850. t['a187'] = 0x27BA;
  18851. t['a188'] = 0x27BB;
  18852. t['a189'] = 0x27BC;
  18853. t['a190'] = 0x27BD;
  18854. t['a191'] = 0x27BE;
  18855. t['a89'] = 0x2768;
  18856. t['a90'] = 0x2769;
  18857. t['a93'] = 0x276A;
  18858. t['a94'] = 0x276B;
  18859. t['a91'] = 0x276C;
  18860. t['a92'] = 0x276D;
  18861. t['a205'] = 0x276E;
  18862. t['a85'] = 0x276F;
  18863. t['a206'] = 0x2770;
  18864. t['a86'] = 0x2771;
  18865. t['a87'] = 0x2772;
  18866. t['a88'] = 0x2773;
  18867. t['a95'] = 0x2774;
  18868. t['a96'] = 0x2775;
  18869. t['.notdef'] = 0x0000;
  18870. });
  18871. exports.getGlyphsUnicode = getGlyphsUnicode;
  18872. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18873. /***/ }),
  18874. /* 9 */
  18875. /***/ (function(module, exports, __w_pdfjs_require__) {
  18876. "use strict";
  18877. var sharedUtil = __w_pdfjs_require__(0);
  18878. var displayDOMUtils = __w_pdfjs_require__(3);
  18879. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18880. var AnnotationType = sharedUtil.AnnotationType;
  18881. var stringToPDFString = sharedUtil.stringToPDFString;
  18882. var Util = sharedUtil.Util;
  18883. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18884. var LinkTarget = displayDOMUtils.LinkTarget;
  18885. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18886. var warn = sharedUtil.warn;
  18887. var CustomStyle = displayDOMUtils.CustomStyle;
  18888. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18889. function AnnotationElementFactory() {
  18890. }
  18891. AnnotationElementFactory.prototype = {
  18892. create: function AnnotationElementFactory_create(parameters) {
  18893. var subtype = parameters.data.annotationType;
  18894. switch (subtype) {
  18895. case AnnotationType.LINK:
  18896. return new LinkAnnotationElement(parameters);
  18897. case AnnotationType.TEXT:
  18898. return new TextAnnotationElement(parameters);
  18899. case AnnotationType.WIDGET:
  18900. var fieldType = parameters.data.fieldType;
  18901. switch (fieldType) {
  18902. case 'Tx':
  18903. return new TextWidgetAnnotationElement(parameters);
  18904. case 'Btn':
  18905. if (parameters.data.radioButton) {
  18906. return new RadioButtonWidgetAnnotationElement(parameters);
  18907. } else if (parameters.data.checkBox) {
  18908. return new CheckboxWidgetAnnotationElement(parameters);
  18909. }
  18910. warn('Unimplemented button widget annotation: pushbutton');
  18911. break;
  18912. case 'Ch':
  18913. return new ChoiceWidgetAnnotationElement(parameters);
  18914. }
  18915. return new WidgetAnnotationElement(parameters);
  18916. case AnnotationType.POPUP:
  18917. return new PopupAnnotationElement(parameters);
  18918. case AnnotationType.HIGHLIGHT:
  18919. return new HighlightAnnotationElement(parameters);
  18920. case AnnotationType.UNDERLINE:
  18921. return new UnderlineAnnotationElement(parameters);
  18922. case AnnotationType.SQUIGGLY:
  18923. return new SquigglyAnnotationElement(parameters);
  18924. case AnnotationType.STRIKEOUT:
  18925. return new StrikeOutAnnotationElement(parameters);
  18926. case AnnotationType.FILEATTACHMENT:
  18927. return new FileAttachmentAnnotationElement(parameters);
  18928. default:
  18929. return new AnnotationElement(parameters);
  18930. }
  18931. }
  18932. };
  18933. var AnnotationElement = function AnnotationElementClosure() {
  18934. function AnnotationElement(parameters, isRenderable) {
  18935. this.isRenderable = isRenderable || false;
  18936. this.data = parameters.data;
  18937. this.layer = parameters.layer;
  18938. this.page = parameters.page;
  18939. this.viewport = parameters.viewport;
  18940. this.linkService = parameters.linkService;
  18941. this.downloadManager = parameters.downloadManager;
  18942. this.imageResourcesPath = parameters.imageResourcesPath;
  18943. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18944. if (isRenderable) {
  18945. this.container = this._createContainer();
  18946. }
  18947. }
  18948. AnnotationElement.prototype = {
  18949. _createContainer: function AnnotationElement_createContainer() {
  18950. var data = this.data, page = this.page, viewport = this.viewport;
  18951. var container = document.createElement('section');
  18952. var width = data.rect[2] - data.rect[0];
  18953. var height = data.rect[3] - data.rect[1];
  18954. container.setAttribute('data-annotation-id', data.id);
  18955. var rect = Util.normalizeRect([
  18956. data.rect[0],
  18957. page.view[3] - data.rect[1] + page.view[1],
  18958. data.rect[2],
  18959. page.view[3] - data.rect[3] + page.view[1]
  18960. ]);
  18961. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18962. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18963. if (data.borderStyle.width > 0) {
  18964. container.style.borderWidth = data.borderStyle.width + 'px';
  18965. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18966. width = width - 2 * data.borderStyle.width;
  18967. height = height - 2 * data.borderStyle.width;
  18968. }
  18969. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18970. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18971. if (horizontalRadius > 0 || verticalRadius > 0) {
  18972. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18973. CustomStyle.setProp('borderRadius', container, radius);
  18974. }
  18975. switch (data.borderStyle.style) {
  18976. case AnnotationBorderStyleType.SOLID:
  18977. container.style.borderStyle = 'solid';
  18978. break;
  18979. case AnnotationBorderStyleType.DASHED:
  18980. container.style.borderStyle = 'dashed';
  18981. break;
  18982. case AnnotationBorderStyleType.BEVELED:
  18983. warn('Unimplemented border style: beveled');
  18984. break;
  18985. case AnnotationBorderStyleType.INSET:
  18986. warn('Unimplemented border style: inset');
  18987. break;
  18988. case AnnotationBorderStyleType.UNDERLINE:
  18989. container.style.borderBottomStyle = 'solid';
  18990. break;
  18991. default:
  18992. break;
  18993. }
  18994. if (data.color) {
  18995. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18996. } else {
  18997. container.style.borderWidth = 0;
  18998. }
  18999. }
  19000. container.style.left = rect[0] + 'px';
  19001. container.style.top = rect[1] + 'px';
  19002. container.style.width = width + 'px';
  19003. container.style.height = height + 'px';
  19004. return container;
  19005. },
  19006. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19007. if (!trigger) {
  19008. trigger = document.createElement('div');
  19009. trigger.style.height = container.style.height;
  19010. trigger.style.width = container.style.width;
  19011. container.appendChild(trigger);
  19012. }
  19013. var popupElement = new PopupElement({
  19014. container: container,
  19015. trigger: trigger,
  19016. color: data.color,
  19017. title: data.title,
  19018. contents: data.contents,
  19019. hideWrapper: true
  19020. });
  19021. var popup = popupElement.render();
  19022. popup.style.left = container.style.width;
  19023. container.appendChild(popup);
  19024. },
  19025. render: function AnnotationElement_render() {
  19026. throw new Error('Abstract method AnnotationElement.render called');
  19027. }
  19028. };
  19029. return AnnotationElement;
  19030. }();
  19031. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19032. function LinkAnnotationElement(parameters) {
  19033. AnnotationElement.call(this, parameters, true);
  19034. }
  19035. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19036. render: function LinkAnnotationElement_render() {
  19037. this.container.className = 'linkAnnotation';
  19038. var link = document.createElement('a');
  19039. addLinkAttributes(link, {
  19040. url: this.data.url,
  19041. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19042. });
  19043. if (!this.data.url) {
  19044. if (this.data.action) {
  19045. this._bindNamedAction(link, this.data.action);
  19046. } else {
  19047. this._bindLink(link, this.data.dest);
  19048. }
  19049. }
  19050. this.container.appendChild(link);
  19051. return this.container;
  19052. },
  19053. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19054. var self = this;
  19055. link.href = this.linkService.getDestinationHash(destination);
  19056. link.onclick = function () {
  19057. if (destination) {
  19058. self.linkService.navigateTo(destination);
  19059. }
  19060. return false;
  19061. };
  19062. if (destination) {
  19063. link.className = 'internalLink';
  19064. }
  19065. },
  19066. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19067. var self = this;
  19068. link.href = this.linkService.getAnchorUrl('');
  19069. link.onclick = function () {
  19070. self.linkService.executeNamedAction(action);
  19071. return false;
  19072. };
  19073. link.className = 'internalLink';
  19074. }
  19075. });
  19076. return LinkAnnotationElement;
  19077. }();
  19078. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19079. function TextAnnotationElement(parameters) {
  19080. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19081. AnnotationElement.call(this, parameters, isRenderable);
  19082. }
  19083. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19084. render: function TextAnnotationElement_render() {
  19085. this.container.className = 'textAnnotation';
  19086. var image = document.createElement('img');
  19087. image.style.height = this.container.style.height;
  19088. image.style.width = this.container.style.width;
  19089. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19090. image.alt = '[{{type}} Annotation]';
  19091. image.dataset.l10nId = 'text_annotation_type';
  19092. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19093. if (!this.data.hasPopup) {
  19094. this._createPopup(this.container, image, this.data);
  19095. }
  19096. this.container.appendChild(image);
  19097. return this.container;
  19098. }
  19099. });
  19100. return TextAnnotationElement;
  19101. }();
  19102. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19103. function WidgetAnnotationElement(parameters, isRenderable) {
  19104. AnnotationElement.call(this, parameters, isRenderable);
  19105. }
  19106. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19107. render: function WidgetAnnotationElement_render() {
  19108. return this.container;
  19109. }
  19110. });
  19111. return WidgetAnnotationElement;
  19112. }();
  19113. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19114. var TEXT_ALIGNMENT = [
  19115. 'left',
  19116. 'center',
  19117. 'right'
  19118. ];
  19119. function TextWidgetAnnotationElement(parameters) {
  19120. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19121. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19122. }
  19123. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19124. render: function TextWidgetAnnotationElement_render() {
  19125. this.container.className = 'textWidgetAnnotation';
  19126. var element = null;
  19127. if (this.renderInteractiveForms) {
  19128. if (this.data.multiLine) {
  19129. element = document.createElement('textarea');
  19130. element.textContent = this.data.fieldValue;
  19131. } else {
  19132. element = document.createElement('input');
  19133. element.type = 'text';
  19134. element.setAttribute('value', this.data.fieldValue);
  19135. }
  19136. element.disabled = this.data.readOnly;
  19137. if (this.data.maxLen !== null) {
  19138. element.maxLength = this.data.maxLen;
  19139. }
  19140. if (this.data.comb) {
  19141. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19142. var combWidth = fieldWidth / this.data.maxLen;
  19143. element.classList.add('comb');
  19144. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19145. }
  19146. } else {
  19147. element = document.createElement('div');
  19148. element.textContent = this.data.fieldValue;
  19149. element.style.verticalAlign = 'middle';
  19150. element.style.display = 'table-cell';
  19151. var font = null;
  19152. if (this.data.fontRefName) {
  19153. font = this.page.commonObjs.getData(this.data.fontRefName);
  19154. }
  19155. this._setTextStyle(element, font);
  19156. }
  19157. if (this.data.textAlignment !== null) {
  19158. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19159. }
  19160. this.container.appendChild(element);
  19161. return this.container;
  19162. },
  19163. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19164. var style = element.style;
  19165. style.fontSize = this.data.fontSize + 'px';
  19166. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19167. if (!font) {
  19168. return;
  19169. }
  19170. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19171. style.fontStyle = font.italic ? 'italic' : 'normal';
  19172. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19173. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19174. style.fontFamily = fontFamily + fallbackName;
  19175. }
  19176. });
  19177. return TextWidgetAnnotationElement;
  19178. }();
  19179. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19180. function CheckboxWidgetAnnotationElement(parameters) {
  19181. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19182. }
  19183. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19184. render: function CheckboxWidgetAnnotationElement_render() {
  19185. this.container.className = 'buttonWidgetAnnotation checkBox';
  19186. var element = document.createElement('input');
  19187. element.disabled = this.data.readOnly;
  19188. element.type = 'checkbox';
  19189. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19190. element.setAttribute('checked', true);
  19191. }
  19192. this.container.appendChild(element);
  19193. return this.container;
  19194. }
  19195. });
  19196. return CheckboxWidgetAnnotationElement;
  19197. }();
  19198. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19199. function RadioButtonWidgetAnnotationElement(parameters) {
  19200. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19201. }
  19202. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19203. render: function RadioButtonWidgetAnnotationElement_render() {
  19204. this.container.className = 'buttonWidgetAnnotation radioButton';
  19205. var element = document.createElement('input');
  19206. element.disabled = this.data.readOnly;
  19207. element.type = 'radio';
  19208. element.name = this.data.fieldName;
  19209. if (this.data.fieldValue === this.data.buttonValue) {
  19210. element.setAttribute('checked', true);
  19211. }
  19212. this.container.appendChild(element);
  19213. return this.container;
  19214. }
  19215. });
  19216. return RadioButtonWidgetAnnotationElement;
  19217. }();
  19218. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19219. function ChoiceWidgetAnnotationElement(parameters) {
  19220. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19221. }
  19222. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19223. render: function ChoiceWidgetAnnotationElement_render() {
  19224. this.container.className = 'choiceWidgetAnnotation';
  19225. var selectElement = document.createElement('select');
  19226. selectElement.disabled = this.data.readOnly;
  19227. if (!this.data.combo) {
  19228. selectElement.size = this.data.options.length;
  19229. if (this.data.multiSelect) {
  19230. selectElement.multiple = true;
  19231. }
  19232. }
  19233. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19234. var option = this.data.options[i];
  19235. var optionElement = document.createElement('option');
  19236. optionElement.textContent = option.displayValue;
  19237. optionElement.value = option.exportValue;
  19238. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19239. optionElement.setAttribute('selected', true);
  19240. }
  19241. selectElement.appendChild(optionElement);
  19242. }
  19243. this.container.appendChild(selectElement);
  19244. return this.container;
  19245. }
  19246. });
  19247. return ChoiceWidgetAnnotationElement;
  19248. }();
  19249. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19250. function PopupAnnotationElement(parameters) {
  19251. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19252. AnnotationElement.call(this, parameters, isRenderable);
  19253. }
  19254. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19255. render: function PopupAnnotationElement_render() {
  19256. this.container.className = 'popupAnnotation';
  19257. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19258. var parentElement = this.layer.querySelector(selector);
  19259. if (!parentElement) {
  19260. return this.container;
  19261. }
  19262. var popup = new PopupElement({
  19263. container: this.container,
  19264. trigger: parentElement,
  19265. color: this.data.color,
  19266. title: this.data.title,
  19267. contents: this.data.contents
  19268. });
  19269. var parentLeft = parseFloat(parentElement.style.left);
  19270. var parentWidth = parseFloat(parentElement.style.width);
  19271. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19272. this.container.style.left = parentLeft + parentWidth + 'px';
  19273. this.container.appendChild(popup.render());
  19274. return this.container;
  19275. }
  19276. });
  19277. return PopupAnnotationElement;
  19278. }();
  19279. var PopupElement = function PopupElementClosure() {
  19280. var BACKGROUND_ENLIGHT = 0.7;
  19281. function PopupElement(parameters) {
  19282. this.container = parameters.container;
  19283. this.trigger = parameters.trigger;
  19284. this.color = parameters.color;
  19285. this.title = parameters.title;
  19286. this.contents = parameters.contents;
  19287. this.hideWrapper = parameters.hideWrapper || false;
  19288. this.pinned = false;
  19289. }
  19290. PopupElement.prototype = {
  19291. render: function PopupElement_render() {
  19292. var wrapper = document.createElement('div');
  19293. wrapper.className = 'popupWrapper';
  19294. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19295. this.hideElement.setAttribute('hidden', true);
  19296. var popup = document.createElement('div');
  19297. popup.className = 'popup';
  19298. var color = this.color;
  19299. if (color) {
  19300. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19301. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19302. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19303. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19304. }
  19305. var contents = this._formatContents(this.contents);
  19306. var title = document.createElement('h1');
  19307. title.textContent = this.title;
  19308. this.trigger.addEventListener('click', this._toggle.bind(this));
  19309. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19310. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19311. popup.addEventListener('click', this._hide.bind(this, true));
  19312. popup.appendChild(title);
  19313. popup.appendChild(contents);
  19314. wrapper.appendChild(popup);
  19315. return wrapper;
  19316. },
  19317. _formatContents: function PopupElement_formatContents(contents) {
  19318. var p = document.createElement('p');
  19319. var lines = contents.split(/(?:\r\n?|\n)/);
  19320. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19321. var line = lines[i];
  19322. p.appendChild(document.createTextNode(line));
  19323. if (i < ii - 1) {
  19324. p.appendChild(document.createElement('br'));
  19325. }
  19326. }
  19327. return p;
  19328. },
  19329. _toggle: function PopupElement_toggle() {
  19330. if (this.pinned) {
  19331. this._hide(true);
  19332. } else {
  19333. this._show(true);
  19334. }
  19335. },
  19336. _show: function PopupElement_show(pin) {
  19337. if (pin) {
  19338. this.pinned = true;
  19339. }
  19340. if (this.hideElement.hasAttribute('hidden')) {
  19341. this.hideElement.removeAttribute('hidden');
  19342. this.container.style.zIndex += 1;
  19343. }
  19344. },
  19345. _hide: function PopupElement_hide(unpin) {
  19346. if (unpin) {
  19347. this.pinned = false;
  19348. }
  19349. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19350. this.hideElement.setAttribute('hidden', true);
  19351. this.container.style.zIndex -= 1;
  19352. }
  19353. }
  19354. };
  19355. return PopupElement;
  19356. }();
  19357. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19358. function HighlightAnnotationElement(parameters) {
  19359. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19360. AnnotationElement.call(this, parameters, isRenderable);
  19361. }
  19362. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19363. render: function HighlightAnnotationElement_render() {
  19364. this.container.className = 'highlightAnnotation';
  19365. if (!this.data.hasPopup) {
  19366. this._createPopup(this.container, null, this.data);
  19367. }
  19368. return this.container;
  19369. }
  19370. });
  19371. return HighlightAnnotationElement;
  19372. }();
  19373. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19374. function UnderlineAnnotationElement(parameters) {
  19375. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19376. AnnotationElement.call(this, parameters, isRenderable);
  19377. }
  19378. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19379. render: function UnderlineAnnotationElement_render() {
  19380. this.container.className = 'underlineAnnotation';
  19381. if (!this.data.hasPopup) {
  19382. this._createPopup(this.container, null, this.data);
  19383. }
  19384. return this.container;
  19385. }
  19386. });
  19387. return UnderlineAnnotationElement;
  19388. }();
  19389. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19390. function SquigglyAnnotationElement(parameters) {
  19391. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19392. AnnotationElement.call(this, parameters, isRenderable);
  19393. }
  19394. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19395. render: function SquigglyAnnotationElement_render() {
  19396. this.container.className = 'squigglyAnnotation';
  19397. if (!this.data.hasPopup) {
  19398. this._createPopup(this.container, null, this.data);
  19399. }
  19400. return this.container;
  19401. }
  19402. });
  19403. return SquigglyAnnotationElement;
  19404. }();
  19405. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19406. function StrikeOutAnnotationElement(parameters) {
  19407. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19408. AnnotationElement.call(this, parameters, isRenderable);
  19409. }
  19410. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19411. render: function StrikeOutAnnotationElement_render() {
  19412. this.container.className = 'strikeoutAnnotation';
  19413. if (!this.data.hasPopup) {
  19414. this._createPopup(this.container, null, this.data);
  19415. }
  19416. return this.container;
  19417. }
  19418. });
  19419. return StrikeOutAnnotationElement;
  19420. }();
  19421. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19422. function FileAttachmentAnnotationElement(parameters) {
  19423. AnnotationElement.call(this, parameters, true);
  19424. var file = this.data.file;
  19425. this.filename = getFilenameFromUrl(file.filename);
  19426. this.content = file.content;
  19427. this.linkService.onFileAttachmentAnnotation({
  19428. id: stringToPDFString(file.filename),
  19429. filename: file.filename,
  19430. content: file.content
  19431. });
  19432. }
  19433. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19434. render: function FileAttachmentAnnotationElement_render() {
  19435. this.container.className = 'fileAttachmentAnnotation';
  19436. var trigger = document.createElement('div');
  19437. trigger.style.height = this.container.style.height;
  19438. trigger.style.width = this.container.style.width;
  19439. trigger.addEventListener('dblclick', this._download.bind(this));
  19440. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19441. this._createPopup(this.container, trigger, this.data);
  19442. }
  19443. this.container.appendChild(trigger);
  19444. return this.container;
  19445. },
  19446. _download: function FileAttachmentAnnotationElement_download() {
  19447. if (!this.downloadManager) {
  19448. warn('Download cannot be started due to unavailable download manager');
  19449. return;
  19450. }
  19451. this.downloadManager.downloadData(this.content, this.filename, '');
  19452. }
  19453. });
  19454. return FileAttachmentAnnotationElement;
  19455. }();
  19456. var AnnotationLayer = function AnnotationLayerClosure() {
  19457. return {
  19458. render: function AnnotationLayer_render(parameters) {
  19459. var annotationElementFactory = new AnnotationElementFactory();
  19460. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19461. var data = parameters.annotations[i];
  19462. if (!data) {
  19463. continue;
  19464. }
  19465. var element = annotationElementFactory.create({
  19466. data: data,
  19467. layer: parameters.div,
  19468. page: parameters.page,
  19469. viewport: parameters.viewport,
  19470. linkService: parameters.linkService,
  19471. downloadManager: parameters.downloadManager,
  19472. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19473. renderInteractiveForms: parameters.renderInteractiveForms || false
  19474. });
  19475. if (element.isRenderable) {
  19476. parameters.div.appendChild(element.render());
  19477. }
  19478. }
  19479. },
  19480. update: function AnnotationLayer_update(parameters) {
  19481. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19482. var data = parameters.annotations[i];
  19483. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19484. if (element) {
  19485. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19486. }
  19487. }
  19488. parameters.div.removeAttribute('hidden');
  19489. }
  19490. };
  19491. }();
  19492. exports.AnnotationLayer = AnnotationLayer;
  19493. /***/ }),
  19494. /* 10 */
  19495. /***/ (function(module, exports, __w_pdfjs_require__) {
  19496. "use strict";
  19497. var sharedUtil = __w_pdfjs_require__(0);
  19498. var displayFontLoader = __w_pdfjs_require__(46);
  19499. var displayCanvas = __w_pdfjs_require__(45);
  19500. var displayMetadata = __w_pdfjs_require__(23);
  19501. var displayDOMUtils = __w_pdfjs_require__(3);
  19502. var amdRequire;
  19503. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19504. var MessageHandler = sharedUtil.MessageHandler;
  19505. var MissingPDFException = sharedUtil.MissingPDFException;
  19506. var PageViewport = sharedUtil.PageViewport;
  19507. var PasswordException = sharedUtil.PasswordException;
  19508. var StatTimer = sharedUtil.StatTimer;
  19509. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19510. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19511. var Util = sharedUtil.Util;
  19512. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19513. var error = sharedUtil.error;
  19514. var deprecated = sharedUtil.deprecated;
  19515. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19516. var info = sharedUtil.info;
  19517. var isInt = sharedUtil.isInt;
  19518. var isArray = sharedUtil.isArray;
  19519. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19520. var isSameOrigin = sharedUtil.isSameOrigin;
  19521. var loadJpegStream = sharedUtil.loadJpegStream;
  19522. var stringToBytes = sharedUtil.stringToBytes;
  19523. var globalScope = sharedUtil.globalScope;
  19524. var warn = sharedUtil.warn;
  19525. var FontFaceObject = displayFontLoader.FontFaceObject;
  19526. var FontLoader = displayFontLoader.FontLoader;
  19527. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19528. var Metadata = displayMetadata.Metadata;
  19529. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19530. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19531. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19532. var isWorkerDisabled = false;
  19533. var workerSrc;
  19534. var isPostMessageTransfersDisabled = false;
  19535. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19536. var fakeWorkerFilesLoader = null;
  19537. var useRequireEnsure = false;
  19538. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19539. var task = new PDFDocumentLoadingTask();
  19540. if (arguments.length > 1) {
  19541. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19542. }
  19543. if (pdfDataRangeTransport) {
  19544. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19545. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19546. pdfDataRangeTransport.length = src.length;
  19547. pdfDataRangeTransport.initialData = src.initialData;
  19548. if (!pdfDataRangeTransport.abort) {
  19549. pdfDataRangeTransport.abort = function () {
  19550. };
  19551. }
  19552. }
  19553. src = Object.create(src);
  19554. src.range = pdfDataRangeTransport;
  19555. }
  19556. task.onPassword = passwordCallback || null;
  19557. task.onProgress = progressCallback || null;
  19558. var source;
  19559. if (typeof src === 'string') {
  19560. source = { url: src };
  19561. } else if (isArrayBuffer(src)) {
  19562. source = { data: src };
  19563. } else if (src instanceof PDFDataRangeTransport) {
  19564. source = { range: src };
  19565. } else {
  19566. if (typeof src !== 'object') {
  19567. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19568. }
  19569. if (!src.url && !src.data && !src.range) {
  19570. error('Invalid parameter object: need either .data, .range or .url');
  19571. }
  19572. source = src;
  19573. }
  19574. var params = {};
  19575. var rangeTransport = null;
  19576. var worker = null;
  19577. for (var key in source) {
  19578. if (key === 'url' && typeof window !== 'undefined') {
  19579. params[key] = new URL(source[key], window.location).href;
  19580. continue;
  19581. } else if (key === 'range') {
  19582. rangeTransport = source[key];
  19583. continue;
  19584. } else if (key === 'worker') {
  19585. worker = source[key];
  19586. continue;
  19587. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19588. var pdfBytes = source[key];
  19589. if (typeof pdfBytes === 'string') {
  19590. params[key] = stringToBytes(pdfBytes);
  19591. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19592. params[key] = new Uint8Array(pdfBytes);
  19593. } else if (isArrayBuffer(pdfBytes)) {
  19594. params[key] = new Uint8Array(pdfBytes);
  19595. } else {
  19596. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19597. }
  19598. continue;
  19599. }
  19600. params[key] = source[key];
  19601. }
  19602. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19603. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19604. if (!worker) {
  19605. worker = new PDFWorker();
  19606. task._worker = worker;
  19607. }
  19608. var docId = task.docId;
  19609. worker.promise.then(function () {
  19610. if (task.destroyed) {
  19611. throw new Error('Loading aborted');
  19612. }
  19613. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19614. if (task.destroyed) {
  19615. throw new Error('Loading aborted');
  19616. }
  19617. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19618. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  19619. task._transport = transport;
  19620. messageHandler.send('Ready', null);
  19621. });
  19622. }).catch(task._capability.reject);
  19623. return task;
  19624. }
  19625. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19626. if (worker.destroyed) {
  19627. return Promise.reject(new Error('Worker was destroyed'));
  19628. }
  19629. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19630. source.disableStream = getDefaultSetting('disableStream');
  19631. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19632. if (pdfDataRangeTransport) {
  19633. source.length = pdfDataRangeTransport.length;
  19634. source.initialData = pdfDataRangeTransport.initialData;
  19635. }
  19636. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19637. docId: docId,
  19638. source: source,
  19639. disableRange: getDefaultSetting('disableRange'),
  19640. maxImageSize: getDefaultSetting('maxImageSize'),
  19641. cMapUrl: getDefaultSetting('cMapUrl'),
  19642. cMapPacked: getDefaultSetting('cMapPacked'),
  19643. disableFontFace: getDefaultSetting('disableFontFace'),
  19644. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19645. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19646. docBaseUrl: source.docBaseUrl,
  19647. disableNativeImageDecoder: source.disableNativeImageDecoder
  19648. }).then(function (workerId) {
  19649. if (worker.destroyed) {
  19650. throw new Error('Worker was destroyed');
  19651. }
  19652. return workerId;
  19653. });
  19654. }
  19655. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19656. var nextDocumentId = 0;
  19657. function PDFDocumentLoadingTask() {
  19658. this._capability = createPromiseCapability();
  19659. this._transport = null;
  19660. this._worker = null;
  19661. this.docId = 'd' + nextDocumentId++;
  19662. this.destroyed = false;
  19663. this.onPassword = null;
  19664. this.onProgress = null;
  19665. this.onUnsupportedFeature = null;
  19666. }
  19667. PDFDocumentLoadingTask.prototype = {
  19668. get promise() {
  19669. return this._capability.promise;
  19670. },
  19671. destroy: function () {
  19672. this.destroyed = true;
  19673. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19674. return transportDestroyed.then(function () {
  19675. this._transport = null;
  19676. if (this._worker) {
  19677. this._worker.destroy();
  19678. this._worker = null;
  19679. }
  19680. }.bind(this));
  19681. },
  19682. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19683. return this.promise.then.apply(this.promise, arguments);
  19684. }
  19685. };
  19686. return PDFDocumentLoadingTask;
  19687. }();
  19688. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19689. function PDFDataRangeTransport(length, initialData) {
  19690. this.length = length;
  19691. this.initialData = initialData;
  19692. this._rangeListeners = [];
  19693. this._progressListeners = [];
  19694. this._progressiveReadListeners = [];
  19695. this._readyCapability = createPromiseCapability();
  19696. }
  19697. PDFDataRangeTransport.prototype = {
  19698. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19699. this._rangeListeners.push(listener);
  19700. },
  19701. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19702. this._progressListeners.push(listener);
  19703. },
  19704. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19705. this._progressiveReadListeners.push(listener);
  19706. },
  19707. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19708. var listeners = this._rangeListeners;
  19709. for (var i = 0, n = listeners.length; i < n; ++i) {
  19710. listeners[i](begin, chunk);
  19711. }
  19712. },
  19713. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19714. this._readyCapability.promise.then(function () {
  19715. var listeners = this._progressListeners;
  19716. for (var i = 0, n = listeners.length; i < n; ++i) {
  19717. listeners[i](loaded);
  19718. }
  19719. }.bind(this));
  19720. },
  19721. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19722. this._readyCapability.promise.then(function () {
  19723. var listeners = this._progressiveReadListeners;
  19724. for (var i = 0, n = listeners.length; i < n; ++i) {
  19725. listeners[i](chunk);
  19726. }
  19727. }.bind(this));
  19728. },
  19729. transportReady: function PDFDataRangeTransport_transportReady() {
  19730. this._readyCapability.resolve();
  19731. },
  19732. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19733. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19734. },
  19735. abort: function PDFDataRangeTransport_abort() {
  19736. }
  19737. };
  19738. return PDFDataRangeTransport;
  19739. }();
  19740. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19741. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19742. this.pdfInfo = pdfInfo;
  19743. this.transport = transport;
  19744. this.loadingTask = loadingTask;
  19745. }
  19746. PDFDocumentProxy.prototype = {
  19747. get numPages() {
  19748. return this.pdfInfo.numPages;
  19749. },
  19750. get fingerprint() {
  19751. return this.pdfInfo.fingerprint;
  19752. },
  19753. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19754. return this.transport.getPage(pageNumber);
  19755. },
  19756. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19757. return this.transport.getPageIndex(ref);
  19758. },
  19759. getDestinations: function PDFDocumentProxy_getDestinations() {
  19760. return this.transport.getDestinations();
  19761. },
  19762. getDestination: function PDFDocumentProxy_getDestination(id) {
  19763. return this.transport.getDestination(id);
  19764. },
  19765. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19766. return this.transport.getPageLabels();
  19767. },
  19768. getAttachments: function PDFDocumentProxy_getAttachments() {
  19769. return this.transport.getAttachments();
  19770. },
  19771. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19772. return this.transport.getJavaScript();
  19773. },
  19774. getOutline: function PDFDocumentProxy_getOutline() {
  19775. return this.transport.getOutline();
  19776. },
  19777. getMetadata: function PDFDocumentProxy_getMetadata() {
  19778. return this.transport.getMetadata();
  19779. },
  19780. getData: function PDFDocumentProxy_getData() {
  19781. return this.transport.getData();
  19782. },
  19783. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19784. return this.transport.downloadInfoCapability.promise;
  19785. },
  19786. getStats: function PDFDocumentProxy_getStats() {
  19787. return this.transport.getStats();
  19788. },
  19789. cleanup: function PDFDocumentProxy_cleanup() {
  19790. this.transport.startCleanup();
  19791. },
  19792. destroy: function PDFDocumentProxy_destroy() {
  19793. return this.loadingTask.destroy();
  19794. }
  19795. };
  19796. return PDFDocumentProxy;
  19797. }();
  19798. var PDFPageProxy = function PDFPageProxyClosure() {
  19799. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19800. this.pageIndex = pageIndex;
  19801. this.pageInfo = pageInfo;
  19802. this.transport = transport;
  19803. this.stats = new StatTimer();
  19804. this.stats.enabled = getDefaultSetting('enableStats');
  19805. this.commonObjs = transport.commonObjs;
  19806. this.objs = new PDFObjects();
  19807. this.cleanupAfterRender = false;
  19808. this.pendingCleanup = false;
  19809. this.intentStates = Object.create(null);
  19810. this.destroyed = false;
  19811. }
  19812. PDFPageProxy.prototype = {
  19813. get pageNumber() {
  19814. return this.pageIndex + 1;
  19815. },
  19816. get rotate() {
  19817. return this.pageInfo.rotate;
  19818. },
  19819. get ref() {
  19820. return this.pageInfo.ref;
  19821. },
  19822. get userUnit() {
  19823. return this.pageInfo.userUnit;
  19824. },
  19825. get view() {
  19826. return this.pageInfo.view;
  19827. },
  19828. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19829. if (arguments.length < 2) {
  19830. rotate = this.rotate;
  19831. }
  19832. return new PageViewport(this.view, scale, rotate, 0, 0);
  19833. },
  19834. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19835. var intent = params && params.intent || null;
  19836. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19837. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19838. this.annotationsIntent = intent;
  19839. }
  19840. return this.annotationsPromise;
  19841. },
  19842. render: function PDFPageProxy_render(params) {
  19843. var stats = this.stats;
  19844. stats.time('Overall');
  19845. this.pendingCleanup = false;
  19846. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19847. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19848. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19849. if (!this.intentStates[renderingIntent]) {
  19850. this.intentStates[renderingIntent] = Object.create(null);
  19851. }
  19852. var intentState = this.intentStates[renderingIntent];
  19853. if (!intentState.displayReadyCapability) {
  19854. intentState.receivingOperatorList = true;
  19855. intentState.displayReadyCapability = createPromiseCapability();
  19856. intentState.operatorList = {
  19857. fnArray: [],
  19858. argsArray: [],
  19859. lastChunk: false
  19860. };
  19861. this.stats.time('Page Request');
  19862. this.transport.messageHandler.send('RenderPageRequest', {
  19863. pageIndex: this.pageNumber - 1,
  19864. intent: renderingIntent,
  19865. renderInteractiveForms: renderInteractiveForms
  19866. });
  19867. }
  19868. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19869. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19870. if (!intentState.renderTasks) {
  19871. intentState.renderTasks = [];
  19872. }
  19873. intentState.renderTasks.push(internalRenderTask);
  19874. var renderTask = internalRenderTask.task;
  19875. if (params.continueCallback) {
  19876. deprecated('render is used with continueCallback parameter');
  19877. renderTask.onContinue = params.continueCallback;
  19878. }
  19879. var self = this;
  19880. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19881. if (self.pendingCleanup) {
  19882. complete();
  19883. return;
  19884. }
  19885. stats.time('Rendering');
  19886. internalRenderTask.initializeGraphics(transparency);
  19887. internalRenderTask.operatorListChanged();
  19888. }, function pageDisplayReadPromiseError(reason) {
  19889. complete(reason);
  19890. });
  19891. function complete(error) {
  19892. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19893. if (i >= 0) {
  19894. intentState.renderTasks.splice(i, 1);
  19895. }
  19896. if (self.cleanupAfterRender) {
  19897. self.pendingCleanup = true;
  19898. }
  19899. self._tryCleanup();
  19900. if (error) {
  19901. internalRenderTask.capability.reject(error);
  19902. } else {
  19903. internalRenderTask.capability.resolve();
  19904. }
  19905. stats.timeEnd('Rendering');
  19906. stats.timeEnd('Overall');
  19907. }
  19908. return renderTask;
  19909. },
  19910. getOperatorList: function PDFPageProxy_getOperatorList() {
  19911. function operatorListChanged() {
  19912. if (intentState.operatorList.lastChunk) {
  19913. intentState.opListReadCapability.resolve(intentState.operatorList);
  19914. var i = intentState.renderTasks.indexOf(opListTask);
  19915. if (i >= 0) {
  19916. intentState.renderTasks.splice(i, 1);
  19917. }
  19918. }
  19919. }
  19920. var renderingIntent = 'oplist';
  19921. if (!this.intentStates[renderingIntent]) {
  19922. this.intentStates[renderingIntent] = Object.create(null);
  19923. }
  19924. var intentState = this.intentStates[renderingIntent];
  19925. var opListTask;
  19926. if (!intentState.opListReadCapability) {
  19927. opListTask = {};
  19928. opListTask.operatorListChanged = operatorListChanged;
  19929. intentState.receivingOperatorList = true;
  19930. intentState.opListReadCapability = createPromiseCapability();
  19931. intentState.renderTasks = [];
  19932. intentState.renderTasks.push(opListTask);
  19933. intentState.operatorList = {
  19934. fnArray: [],
  19935. argsArray: [],
  19936. lastChunk: false
  19937. };
  19938. this.transport.messageHandler.send('RenderPageRequest', {
  19939. pageIndex: this.pageIndex,
  19940. intent: renderingIntent
  19941. });
  19942. }
  19943. return intentState.opListReadCapability.promise;
  19944. },
  19945. getTextContent: function PDFPageProxy_getTextContent(params) {
  19946. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19947. pageIndex: this.pageNumber - 1,
  19948. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19949. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19950. });
  19951. },
  19952. _destroy: function PDFPageProxy_destroy() {
  19953. this.destroyed = true;
  19954. this.transport.pageCache[this.pageIndex] = null;
  19955. var waitOn = [];
  19956. Object.keys(this.intentStates).forEach(function (intent) {
  19957. if (intent === 'oplist') {
  19958. return;
  19959. }
  19960. var intentState = this.intentStates[intent];
  19961. intentState.renderTasks.forEach(function (renderTask) {
  19962. var renderCompleted = renderTask.capability.promise.catch(function () {
  19963. });
  19964. waitOn.push(renderCompleted);
  19965. renderTask.cancel();
  19966. });
  19967. }, this);
  19968. this.objs.clear();
  19969. this.annotationsPromise = null;
  19970. this.pendingCleanup = false;
  19971. return Promise.all(waitOn);
  19972. },
  19973. destroy: function () {
  19974. deprecated('page destroy method, use cleanup() instead');
  19975. this.cleanup();
  19976. },
  19977. cleanup: function PDFPageProxy_cleanup() {
  19978. this.pendingCleanup = true;
  19979. this._tryCleanup();
  19980. },
  19981. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19982. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19983. var intentState = this.intentStates[intent];
  19984. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19985. }, this)) {
  19986. return;
  19987. }
  19988. Object.keys(this.intentStates).forEach(function (intent) {
  19989. delete this.intentStates[intent];
  19990. }, this);
  19991. this.objs.clear();
  19992. this.annotationsPromise = null;
  19993. this.pendingCleanup = false;
  19994. },
  19995. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19996. var intentState = this.intentStates[intent];
  19997. if (intentState.displayReadyCapability) {
  19998. intentState.displayReadyCapability.resolve(transparency);
  19999. }
  20000. },
  20001. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20002. var intentState = this.intentStates[intent];
  20003. var i, ii;
  20004. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20005. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20006. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20007. }
  20008. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20009. for (i = 0; i < intentState.renderTasks.length; i++) {
  20010. intentState.renderTasks[i].operatorListChanged();
  20011. }
  20012. if (operatorListChunk.lastChunk) {
  20013. intentState.receivingOperatorList = false;
  20014. this._tryCleanup();
  20015. }
  20016. }
  20017. };
  20018. return PDFPageProxy;
  20019. }();
  20020. var PDFWorker = function PDFWorkerClosure() {
  20021. var nextFakeWorkerId = 0;
  20022. function getWorkerSrc() {
  20023. if (typeof workerSrc !== 'undefined') {
  20024. return workerSrc;
  20025. }
  20026. if (getDefaultSetting('workerSrc')) {
  20027. return getDefaultSetting('workerSrc');
  20028. }
  20029. if (pdfjsFilePath) {
  20030. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20031. }
  20032. error('No PDFJS.workerSrc specified');
  20033. }
  20034. var fakeWorkerFilesLoadedCapability;
  20035. function setupFakeWorkerGlobal() {
  20036. var WorkerMessageHandler;
  20037. if (fakeWorkerFilesLoadedCapability) {
  20038. return fakeWorkerFilesLoadedCapability.promise;
  20039. }
  20040. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20041. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20042. __w_pdfjs_require__(40);
  20043. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20044. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20045. return fakeWorkerFilesLoadedCapability.promise;
  20046. }
  20047. function FakeWorkerPort(defer) {
  20048. this._listeners = [];
  20049. this._defer = defer;
  20050. this._deferred = Promise.resolve(undefined);
  20051. }
  20052. FakeWorkerPort.prototype = {
  20053. postMessage: function (obj, transfers) {
  20054. function cloneValue(value) {
  20055. if (typeof value !== 'object' || value === null) {
  20056. return value;
  20057. }
  20058. if (cloned.has(value)) {
  20059. return cloned.get(value);
  20060. }
  20061. var result;
  20062. var buffer;
  20063. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20064. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20065. if (value === buffer) {
  20066. result = value;
  20067. } else if (transferable) {
  20068. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20069. } else {
  20070. result = new value.constructor(value);
  20071. }
  20072. cloned.set(value, result);
  20073. return result;
  20074. }
  20075. result = isArray(value) ? [] : {};
  20076. cloned.set(value, result);
  20077. for (var i in value) {
  20078. var desc, p = value;
  20079. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20080. p = Object.getPrototypeOf(p);
  20081. }
  20082. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20083. continue;
  20084. }
  20085. result[i] = cloneValue(desc.value);
  20086. }
  20087. return result;
  20088. }
  20089. if (!this._defer) {
  20090. this._listeners.forEach(function (listener) {
  20091. listener.call(this, { data: obj });
  20092. }, this);
  20093. return;
  20094. }
  20095. var cloned = new WeakMap();
  20096. var e = { data: cloneValue(obj) };
  20097. this._deferred.then(function () {
  20098. this._listeners.forEach(function (listener) {
  20099. listener.call(this, e);
  20100. }, this);
  20101. }.bind(this));
  20102. },
  20103. addEventListener: function (name, listener) {
  20104. this._listeners.push(listener);
  20105. },
  20106. removeEventListener: function (name, listener) {
  20107. var i = this._listeners.indexOf(listener);
  20108. this._listeners.splice(i, 1);
  20109. },
  20110. terminate: function () {
  20111. this._listeners = [];
  20112. }
  20113. };
  20114. function createCDNWrapper(url) {
  20115. var wrapper = 'importScripts(\'' + url + '\');';
  20116. return URL.createObjectURL(new Blob([wrapper]));
  20117. }
  20118. function PDFWorker(name) {
  20119. this.name = name;
  20120. this.destroyed = false;
  20121. this._readyCapability = createPromiseCapability();
  20122. this._port = null;
  20123. this._webWorker = null;
  20124. this._messageHandler = null;
  20125. this._initialize();
  20126. }
  20127. PDFWorker.prototype = {
  20128. get promise() {
  20129. return this._readyCapability.promise;
  20130. },
  20131. get port() {
  20132. return this._port;
  20133. },
  20134. get messageHandler() {
  20135. return this._messageHandler;
  20136. },
  20137. _initialize: function PDFWorker_initialize() {
  20138. this._setupFakeWorker();
  20139. },
  20140. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20141. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20142. warn('Setting up fake worker.');
  20143. isWorkerDisabled = true;
  20144. }
  20145. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20146. if (this.destroyed) {
  20147. this._readyCapability.reject(new Error('Worker was destroyed'));
  20148. return;
  20149. }
  20150. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20151. var port = new FakeWorkerPort(isTypedArraysPresent);
  20152. this._port = port;
  20153. var id = 'fake' + nextFakeWorkerId++;
  20154. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20155. WorkerMessageHandler.setup(workerHandler, port);
  20156. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20157. this._messageHandler = messageHandler;
  20158. this._readyCapability.resolve();
  20159. }.bind(this));
  20160. },
  20161. destroy: function PDFWorker_destroy() {
  20162. this.destroyed = true;
  20163. if (this._webWorker) {
  20164. this._webWorker.terminate();
  20165. this._webWorker = null;
  20166. }
  20167. this._port = null;
  20168. if (this._messageHandler) {
  20169. this._messageHandler.destroy();
  20170. this._messageHandler = null;
  20171. }
  20172. }
  20173. };
  20174. return PDFWorker;
  20175. }();
  20176. var WorkerTransport = function WorkerTransportClosure() {
  20177. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  20178. this.messageHandler = messageHandler;
  20179. this.loadingTask = loadingTask;
  20180. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20181. this.commonObjs = new PDFObjects();
  20182. this.fontLoader = new FontLoader(loadingTask.docId);
  20183. this.destroyed = false;
  20184. this.destroyCapability = null;
  20185. this._passwordCapability = null;
  20186. this.pageCache = [];
  20187. this.pagePromises = [];
  20188. this.downloadInfoCapability = createPromiseCapability();
  20189. this.setupMessageHandler();
  20190. }
  20191. WorkerTransport.prototype = {
  20192. destroy: function WorkerTransport_destroy() {
  20193. if (this.destroyCapability) {
  20194. return this.destroyCapability.promise;
  20195. }
  20196. this.destroyed = true;
  20197. this.destroyCapability = createPromiseCapability();
  20198. if (this._passwordCapability) {
  20199. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20200. }
  20201. var waitOn = [];
  20202. this.pageCache.forEach(function (page) {
  20203. if (page) {
  20204. waitOn.push(page._destroy());
  20205. }
  20206. });
  20207. this.pageCache = [];
  20208. this.pagePromises = [];
  20209. var self = this;
  20210. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20211. waitOn.push(terminated);
  20212. Promise.all(waitOn).then(function () {
  20213. self.fontLoader.clear();
  20214. if (self.pdfDataRangeTransport) {
  20215. self.pdfDataRangeTransport.abort();
  20216. self.pdfDataRangeTransport = null;
  20217. }
  20218. if (self.messageHandler) {
  20219. self.messageHandler.destroy();
  20220. self.messageHandler = null;
  20221. }
  20222. self.destroyCapability.resolve();
  20223. }, this.destroyCapability.reject);
  20224. return this.destroyCapability.promise;
  20225. },
  20226. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20227. var messageHandler = this.messageHandler;
  20228. var loadingTask = this.loadingTask;
  20229. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20230. if (pdfDataRangeTransport) {
  20231. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20232. messageHandler.send('OnDataRange', {
  20233. begin: begin,
  20234. chunk: chunk
  20235. });
  20236. });
  20237. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20238. messageHandler.send('OnDataProgress', { loaded: loaded });
  20239. });
  20240. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20241. messageHandler.send('OnDataRange', { chunk: chunk });
  20242. });
  20243. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20244. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20245. }, this);
  20246. }
  20247. messageHandler.on('GetDoc', function transportDoc(data) {
  20248. var pdfInfo = data.pdfInfo;
  20249. this.numPages = data.pdfInfo.numPages;
  20250. var loadingTask = this.loadingTask;
  20251. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20252. this.pdfDocument = pdfDocument;
  20253. loadingTask._capability.resolve(pdfDocument);
  20254. }, this);
  20255. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20256. this._passwordCapability = createPromiseCapability();
  20257. if (loadingTask.onPassword) {
  20258. var updatePassword = function (password) {
  20259. this._passwordCapability.resolve({ password: password });
  20260. }.bind(this);
  20261. loadingTask.onPassword(updatePassword, exception.code);
  20262. } else {
  20263. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20264. }
  20265. return this._passwordCapability.promise;
  20266. }, this);
  20267. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20268. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20269. }, this);
  20270. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20271. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20272. }, this);
  20273. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20274. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20275. }, this);
  20276. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20277. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20278. }, this);
  20279. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20280. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20281. }, this);
  20282. messageHandler.on('DataLoaded', function transportPage(data) {
  20283. this.downloadInfoCapability.resolve(data);
  20284. }, this);
  20285. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20286. if (this.pdfDataRangeTransport) {
  20287. this.pdfDataRangeTransport.transportReady();
  20288. }
  20289. }, this);
  20290. messageHandler.on('StartRenderPage', function transportRender(data) {
  20291. if (this.destroyed) {
  20292. return;
  20293. }
  20294. var page = this.pageCache[data.pageIndex];
  20295. page.stats.timeEnd('Page Request');
  20296. page._startRenderPage(data.transparency, data.intent);
  20297. }, this);
  20298. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20299. if (this.destroyed) {
  20300. return;
  20301. }
  20302. var page = this.pageCache[data.pageIndex];
  20303. page._renderPageChunk(data.operatorList, data.intent);
  20304. }, this);
  20305. messageHandler.on('commonobj', function transportObj(data) {
  20306. if (this.destroyed) {
  20307. return;
  20308. }
  20309. var id = data[0];
  20310. var type = data[1];
  20311. if (this.commonObjs.hasData(id)) {
  20312. return;
  20313. }
  20314. switch (type) {
  20315. case 'Font':
  20316. var exportedData = data[2];
  20317. if ('error' in exportedData) {
  20318. var exportedError = exportedData.error;
  20319. warn('Error during font loading: ' + exportedError);
  20320. this.commonObjs.resolve(id, exportedError);
  20321. break;
  20322. }
  20323. var fontRegistry = null;
  20324. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20325. fontRegistry = {
  20326. registerFont: function (font, url) {
  20327. globalScope['FontInspector'].fontAdded(font, url);
  20328. }
  20329. };
  20330. }
  20331. var font = new FontFaceObject(exportedData, {
  20332. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20333. disableFontFace: getDefaultSetting('disableFontFace'),
  20334. fontRegistry: fontRegistry
  20335. });
  20336. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20337. this.commonObjs.resolve(id, font);
  20338. }.bind(this));
  20339. break;
  20340. case 'FontPath':
  20341. this.commonObjs.resolve(id, data[2]);
  20342. break;
  20343. default:
  20344. error('Got unknown common object type ' + type);
  20345. }
  20346. }, this);
  20347. messageHandler.on('obj', function transportObj(data) {
  20348. if (this.destroyed) {
  20349. return;
  20350. }
  20351. var id = data[0];
  20352. var pageIndex = data[1];
  20353. var type = data[2];
  20354. var pageProxy = this.pageCache[pageIndex];
  20355. var imageData;
  20356. if (pageProxy.objs.hasData(id)) {
  20357. return;
  20358. }
  20359. switch (type) {
  20360. case 'JpegStream':
  20361. imageData = data[3];
  20362. loadJpegStream(id, imageData, pageProxy.objs);
  20363. break;
  20364. case 'Image':
  20365. imageData = data[3];
  20366. pageProxy.objs.resolve(id, imageData);
  20367. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20368. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20369. pageProxy.cleanupAfterRender = true;
  20370. }
  20371. break;
  20372. default:
  20373. error('Got unknown object type ' + type);
  20374. }
  20375. }, this);
  20376. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20377. if (this.destroyed) {
  20378. return;
  20379. }
  20380. var loadingTask = this.loadingTask;
  20381. if (loadingTask.onProgress) {
  20382. loadingTask.onProgress({
  20383. loaded: data.loaded,
  20384. total: data.total
  20385. });
  20386. }
  20387. }, this);
  20388. messageHandler.on('PageError', function transportError(data) {
  20389. if (this.destroyed) {
  20390. return;
  20391. }
  20392. var page = this.pageCache[data.pageNum - 1];
  20393. var intentState = page.intentStates[data.intent];
  20394. if (intentState.displayReadyCapability) {
  20395. intentState.displayReadyCapability.reject(data.error);
  20396. } else {
  20397. error(data.error);
  20398. }
  20399. if (intentState.operatorList) {
  20400. intentState.operatorList.lastChunk = true;
  20401. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20402. intentState.renderTasks[i].operatorListChanged();
  20403. }
  20404. }
  20405. }, this);
  20406. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20407. if (this.destroyed) {
  20408. return;
  20409. }
  20410. var featureId = data.featureId;
  20411. var loadingTask = this.loadingTask;
  20412. if (loadingTask.onUnsupportedFeature) {
  20413. loadingTask.onUnsupportedFeature(featureId);
  20414. }
  20415. _UnsupportedManager.notify(featureId);
  20416. }, this);
  20417. messageHandler.on('JpegDecode', function (data) {
  20418. if (this.destroyed) {
  20419. return Promise.reject(new Error('Worker was destroyed'));
  20420. }
  20421. if (typeof document === 'undefined') {
  20422. return Promise.reject(new Error('"document" is not defined.'));
  20423. }
  20424. var imageUrl = data[0];
  20425. var components = data[1];
  20426. if (components !== 3 && components !== 1) {
  20427. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20428. }
  20429. return new Promise(function (resolve, reject) {
  20430. var img = new Image();
  20431. img.onload = function () {
  20432. var width = img.width;
  20433. var height = img.height;
  20434. var size = width * height;
  20435. var rgbaLength = size * 4;
  20436. var buf = new Uint8Array(size * components);
  20437. var tmpCanvas = document.createElement('canvas');
  20438. tmpCanvas.width = width;
  20439. tmpCanvas.height = height;
  20440. var tmpCtx = tmpCanvas.getContext('2d');
  20441. tmpCtx.drawImage(img, 0, 0);
  20442. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20443. var i, j;
  20444. if (components === 3) {
  20445. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20446. buf[j] = data[i];
  20447. buf[j + 1] = data[i + 1];
  20448. buf[j + 2] = data[i + 2];
  20449. }
  20450. } else if (components === 1) {
  20451. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20452. buf[j] = data[i];
  20453. }
  20454. }
  20455. resolve({
  20456. data: buf,
  20457. width: width,
  20458. height: height
  20459. });
  20460. };
  20461. img.onerror = function () {
  20462. reject(new Error('JpegDecode failed to load image'));
  20463. };
  20464. img.src = imageUrl;
  20465. });
  20466. }, this);
  20467. },
  20468. getData: function WorkerTransport_getData() {
  20469. return this.messageHandler.sendWithPromise('GetData', null);
  20470. },
  20471. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20472. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20473. return Promise.reject(new Error('Invalid page request'));
  20474. }
  20475. var pageIndex = pageNumber - 1;
  20476. if (pageIndex in this.pagePromises) {
  20477. return this.pagePromises[pageIndex];
  20478. }
  20479. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20480. if (this.destroyed) {
  20481. throw new Error('Transport destroyed');
  20482. }
  20483. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20484. this.pageCache[pageIndex] = page;
  20485. return page;
  20486. }.bind(this));
  20487. this.pagePromises[pageIndex] = promise;
  20488. return promise;
  20489. },
  20490. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20491. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20492. return Promise.reject(new Error(reason));
  20493. });
  20494. },
  20495. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20496. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20497. pageIndex: pageIndex,
  20498. intent: intent
  20499. });
  20500. },
  20501. getDestinations: function WorkerTransport_getDestinations() {
  20502. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20503. },
  20504. getDestination: function WorkerTransport_getDestination(id) {
  20505. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20506. },
  20507. getPageLabels: function WorkerTransport_getPageLabels() {
  20508. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20509. },
  20510. getAttachments: function WorkerTransport_getAttachments() {
  20511. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20512. },
  20513. getJavaScript: function WorkerTransport_getJavaScript() {
  20514. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20515. },
  20516. getOutline: function WorkerTransport_getOutline() {
  20517. return this.messageHandler.sendWithPromise('GetOutline', null);
  20518. },
  20519. getMetadata: function WorkerTransport_getMetadata() {
  20520. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20521. return {
  20522. info: results[0],
  20523. metadata: results[1] ? new Metadata(results[1]) : null
  20524. };
  20525. });
  20526. },
  20527. getStats: function WorkerTransport_getStats() {
  20528. return this.messageHandler.sendWithPromise('GetStats', null);
  20529. },
  20530. startCleanup: function WorkerTransport_startCleanup() {
  20531. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20532. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20533. var page = this.pageCache[i];
  20534. if (page) {
  20535. page.cleanup();
  20536. }
  20537. }
  20538. this.commonObjs.clear();
  20539. this.fontLoader.clear();
  20540. }.bind(this));
  20541. }
  20542. };
  20543. return WorkerTransport;
  20544. }();
  20545. var PDFObjects = function PDFObjectsClosure() {
  20546. function PDFObjects() {
  20547. this.objs = Object.create(null);
  20548. }
  20549. PDFObjects.prototype = {
  20550. ensureObj: function PDFObjects_ensureObj(objId) {
  20551. if (this.objs[objId]) {
  20552. return this.objs[objId];
  20553. }
  20554. var obj = {
  20555. capability: createPromiseCapability(),
  20556. data: null,
  20557. resolved: false
  20558. };
  20559. this.objs[objId] = obj;
  20560. return obj;
  20561. },
  20562. get: function PDFObjects_get(objId, callback) {
  20563. if (callback) {
  20564. this.ensureObj(objId).capability.promise.then(callback);
  20565. return null;
  20566. }
  20567. var obj = this.objs[objId];
  20568. if (!obj || !obj.resolved) {
  20569. error('Requesting object that isn\'t resolved yet ' + objId);
  20570. }
  20571. return obj.data;
  20572. },
  20573. resolve: function PDFObjects_resolve(objId, data) {
  20574. var obj = this.ensureObj(objId);
  20575. obj.resolved = true;
  20576. obj.data = data;
  20577. obj.capability.resolve(data);
  20578. },
  20579. isResolved: function PDFObjects_isResolved(objId) {
  20580. var objs = this.objs;
  20581. if (!objs[objId]) {
  20582. return false;
  20583. }
  20584. return objs[objId].resolved;
  20585. },
  20586. hasData: function PDFObjects_hasData(objId) {
  20587. return this.isResolved(objId);
  20588. },
  20589. getData: function PDFObjects_getData(objId) {
  20590. var objs = this.objs;
  20591. if (!objs[objId] || !objs[objId].resolved) {
  20592. return null;
  20593. }
  20594. return objs[objId].data;
  20595. },
  20596. clear: function PDFObjects_clear() {
  20597. this.objs = Object.create(null);
  20598. }
  20599. };
  20600. return PDFObjects;
  20601. }();
  20602. var RenderTask = function RenderTaskClosure() {
  20603. function RenderTask(internalRenderTask) {
  20604. this._internalRenderTask = internalRenderTask;
  20605. this.onContinue = null;
  20606. }
  20607. RenderTask.prototype = {
  20608. get promise() {
  20609. return this._internalRenderTask.capability.promise;
  20610. },
  20611. cancel: function RenderTask_cancel() {
  20612. this._internalRenderTask.cancel();
  20613. },
  20614. then: function RenderTask_then(onFulfilled, onRejected) {
  20615. return this.promise.then.apply(this.promise, arguments);
  20616. }
  20617. };
  20618. return RenderTask;
  20619. }();
  20620. var InternalRenderTask = function InternalRenderTaskClosure() {
  20621. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20622. this.callback = callback;
  20623. this.params = params;
  20624. this.objs = objs;
  20625. this.commonObjs = commonObjs;
  20626. this.operatorListIdx = null;
  20627. this.operatorList = operatorList;
  20628. this.pageNumber = pageNumber;
  20629. this.canvasFactory = canvasFactory;
  20630. this.running = false;
  20631. this.graphicsReadyCallback = null;
  20632. this.graphicsReady = false;
  20633. this.useRequestAnimationFrame = false;
  20634. this.cancelled = false;
  20635. this.capability = createPromiseCapability();
  20636. this.task = new RenderTask(this);
  20637. this._continueBound = this._continue.bind(this);
  20638. this._scheduleNextBound = this._scheduleNext.bind(this);
  20639. this._nextBound = this._next.bind(this);
  20640. }
  20641. InternalRenderTask.prototype = {
  20642. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20643. if (this.cancelled) {
  20644. return;
  20645. }
  20646. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20647. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20648. this.stepper.init(this.operatorList);
  20649. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20650. }
  20651. var params = this.params;
  20652. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20653. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20654. this.operatorListIdx = 0;
  20655. this.graphicsReady = true;
  20656. if (this.graphicsReadyCallback) {
  20657. this.graphicsReadyCallback();
  20658. }
  20659. },
  20660. cancel: function InternalRenderTask_cancel() {
  20661. this.running = false;
  20662. this.cancelled = true;
  20663. this.callback('cancelled');
  20664. },
  20665. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20666. if (!this.graphicsReady) {
  20667. if (!this.graphicsReadyCallback) {
  20668. this.graphicsReadyCallback = this._continueBound;
  20669. }
  20670. return;
  20671. }
  20672. if (this.stepper) {
  20673. this.stepper.updateOperatorList(this.operatorList);
  20674. }
  20675. if (this.running) {
  20676. return;
  20677. }
  20678. this._continue();
  20679. },
  20680. _continue: function InternalRenderTask__continue() {
  20681. this.running = true;
  20682. if (this.cancelled) {
  20683. return;
  20684. }
  20685. if (this.task.onContinue) {
  20686. this.task.onContinue(this._scheduleNextBound);
  20687. } else {
  20688. this._scheduleNext();
  20689. }
  20690. },
  20691. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20692. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20693. window.requestAnimationFrame(this._nextBound);
  20694. } else {
  20695. Promise.resolve(undefined).then(this._nextBound);
  20696. }
  20697. },
  20698. _next: function InternalRenderTask__next() {
  20699. if (this.cancelled) {
  20700. return;
  20701. }
  20702. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20703. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20704. this.running = false;
  20705. if (this.operatorList.lastChunk) {
  20706. this.gfx.endDrawing();
  20707. this.callback();
  20708. }
  20709. }
  20710. }
  20711. };
  20712. return InternalRenderTask;
  20713. }();
  20714. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20715. var listeners = [];
  20716. return {
  20717. listen: function (cb) {
  20718. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20719. listeners.push(cb);
  20720. },
  20721. notify: function (featureId) {
  20722. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20723. listeners[i](featureId);
  20724. }
  20725. }
  20726. };
  20727. }();
  20728. exports.version = '1.7.290';
  20729. exports.build = 'b509a3f8';
  20730. exports.getDocument = getDocument;
  20731. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20732. exports.PDFWorker = PDFWorker;
  20733. exports.PDFDocumentProxy = PDFDocumentProxy;
  20734. exports.PDFPageProxy = PDFPageProxy;
  20735. exports._UnsupportedManager = _UnsupportedManager;
  20736. /***/ }),
  20737. /* 11 */
  20738. /***/ (function(module, exports, __w_pdfjs_require__) {
  20739. "use strict";
  20740. var sharedUtil = __w_pdfjs_require__(0);
  20741. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20742. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20743. var ImageKind = sharedUtil.ImageKind;
  20744. var OPS = sharedUtil.OPS;
  20745. var Util = sharedUtil.Util;
  20746. var isNum = sharedUtil.isNum;
  20747. var isArray = sharedUtil.isArray;
  20748. var warn = sharedUtil.warn;
  20749. var createObjectURL = sharedUtil.createObjectURL;
  20750. var SVG_DEFAULTS = {
  20751. fontStyle: 'normal',
  20752. fontWeight: 'normal',
  20753. fillColor: '#000000'
  20754. };
  20755. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20756. var PNG_HEADER = new Uint8Array([
  20757. 0x89,
  20758. 0x50,
  20759. 0x4e,
  20760. 0x47,
  20761. 0x0d,
  20762. 0x0a,
  20763. 0x1a,
  20764. 0x0a
  20765. ]);
  20766. var CHUNK_WRAPPER_SIZE = 12;
  20767. var crcTable = new Int32Array(256);
  20768. for (var i = 0; i < 256; i++) {
  20769. var c = i;
  20770. for (var h = 0; h < 8; h++) {
  20771. if (c & 1) {
  20772. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20773. } else {
  20774. c = c >> 1 & 0x7fffffff;
  20775. }
  20776. }
  20777. crcTable[i] = c;
  20778. }
  20779. function crc32(data, start, end) {
  20780. var crc = -1;
  20781. for (var i = start; i < end; i++) {
  20782. var a = (crc ^ data[i]) & 0xff;
  20783. var b = crcTable[a];
  20784. crc = crc >>> 8 ^ b;
  20785. }
  20786. return crc ^ -1;
  20787. }
  20788. function writePngChunk(type, body, data, offset) {
  20789. var p = offset;
  20790. var len = body.length;
  20791. data[p] = len >> 24 & 0xff;
  20792. data[p + 1] = len >> 16 & 0xff;
  20793. data[p + 2] = len >> 8 & 0xff;
  20794. data[p + 3] = len & 0xff;
  20795. p += 4;
  20796. data[p] = type.charCodeAt(0) & 0xff;
  20797. data[p + 1] = type.charCodeAt(1) & 0xff;
  20798. data[p + 2] = type.charCodeAt(2) & 0xff;
  20799. data[p + 3] = type.charCodeAt(3) & 0xff;
  20800. p += 4;
  20801. data.set(body, p);
  20802. p += body.length;
  20803. var crc = crc32(data, offset + 4, p);
  20804. data[p] = crc >> 24 & 0xff;
  20805. data[p + 1] = crc >> 16 & 0xff;
  20806. data[p + 2] = crc >> 8 & 0xff;
  20807. data[p + 3] = crc & 0xff;
  20808. }
  20809. function adler32(data, start, end) {
  20810. var a = 1;
  20811. var b = 0;
  20812. for (var i = start; i < end; ++i) {
  20813. a = (a + (data[i] & 0xff)) % 65521;
  20814. b = (b + a) % 65521;
  20815. }
  20816. return b << 16 | a;
  20817. }
  20818. function encode(imgData, kind, forceDataSchema) {
  20819. var width = imgData.width;
  20820. var height = imgData.height;
  20821. var bitDepth, colorType, lineSize;
  20822. var bytes = imgData.data;
  20823. switch (kind) {
  20824. case ImageKind.GRAYSCALE_1BPP:
  20825. colorType = 0;
  20826. bitDepth = 1;
  20827. lineSize = width + 7 >> 3;
  20828. break;
  20829. case ImageKind.RGB_24BPP:
  20830. colorType = 2;
  20831. bitDepth = 8;
  20832. lineSize = width * 3;
  20833. break;
  20834. case ImageKind.RGBA_32BPP:
  20835. colorType = 6;
  20836. bitDepth = 8;
  20837. lineSize = width * 4;
  20838. break;
  20839. default:
  20840. throw new Error('invalid format');
  20841. }
  20842. var literals = new Uint8Array((1 + lineSize) * height);
  20843. var offsetLiterals = 0, offsetBytes = 0;
  20844. var y, i;
  20845. for (y = 0; y < height; ++y) {
  20846. literals[offsetLiterals++] = 0;
  20847. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20848. offsetBytes += lineSize;
  20849. offsetLiterals += lineSize;
  20850. }
  20851. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20852. offsetLiterals = 0;
  20853. for (y = 0; y < height; y++) {
  20854. offsetLiterals++;
  20855. for (i = 0; i < lineSize; i++) {
  20856. literals[offsetLiterals++] ^= 0xFF;
  20857. }
  20858. }
  20859. }
  20860. var ihdr = new Uint8Array([
  20861. width >> 24 & 0xff,
  20862. width >> 16 & 0xff,
  20863. width >> 8 & 0xff,
  20864. width & 0xff,
  20865. height >> 24 & 0xff,
  20866. height >> 16 & 0xff,
  20867. height >> 8 & 0xff,
  20868. height & 0xff,
  20869. bitDepth,
  20870. colorType,
  20871. 0x00,
  20872. 0x00,
  20873. 0x00
  20874. ]);
  20875. var len = literals.length;
  20876. var maxBlockLength = 0xFFFF;
  20877. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20878. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20879. var pi = 0;
  20880. idat[pi++] = 0x78;
  20881. idat[pi++] = 0x9c;
  20882. var pos = 0;
  20883. while (len > maxBlockLength) {
  20884. idat[pi++] = 0x00;
  20885. idat[pi++] = 0xff;
  20886. idat[pi++] = 0xff;
  20887. idat[pi++] = 0x00;
  20888. idat[pi++] = 0x00;
  20889. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20890. pi += maxBlockLength;
  20891. pos += maxBlockLength;
  20892. len -= maxBlockLength;
  20893. }
  20894. idat[pi++] = 0x01;
  20895. idat[pi++] = len & 0xff;
  20896. idat[pi++] = len >> 8 & 0xff;
  20897. idat[pi++] = ~len & 0xffff & 0xff;
  20898. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20899. idat.set(literals.subarray(pos), pi);
  20900. pi += literals.length - pos;
  20901. var adler = adler32(literals, 0, literals.length);
  20902. idat[pi++] = adler >> 24 & 0xff;
  20903. idat[pi++] = adler >> 16 & 0xff;
  20904. idat[pi++] = adler >> 8 & 0xff;
  20905. idat[pi++] = adler & 0xff;
  20906. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20907. var data = new Uint8Array(pngLength);
  20908. var offset = 0;
  20909. data.set(PNG_HEADER, offset);
  20910. offset += PNG_HEADER.length;
  20911. writePngChunk('IHDR', ihdr, data, offset);
  20912. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20913. writePngChunk('IDATA', idat, data, offset);
  20914. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20915. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20916. return createObjectURL(data, 'image/png', forceDataSchema);
  20917. }
  20918. return function convertImgDataToPng(imgData, forceDataSchema) {
  20919. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20920. return encode(imgData, kind, forceDataSchema);
  20921. };
  20922. }();
  20923. var SVGExtraState = function SVGExtraStateClosure() {
  20924. function SVGExtraState() {
  20925. this.fontSizeScale = 1;
  20926. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20927. this.fontSize = 0;
  20928. this.textMatrix = IDENTITY_MATRIX;
  20929. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20930. this.leading = 0;
  20931. this.x = 0;
  20932. this.y = 0;
  20933. this.lineX = 0;
  20934. this.lineY = 0;
  20935. this.charSpacing = 0;
  20936. this.wordSpacing = 0;
  20937. this.textHScale = 1;
  20938. this.textRise = 0;
  20939. this.fillColor = SVG_DEFAULTS.fillColor;
  20940. this.strokeColor = '#000000';
  20941. this.fillAlpha = 1;
  20942. this.strokeAlpha = 1;
  20943. this.lineWidth = 1;
  20944. this.lineJoin = '';
  20945. this.lineCap = '';
  20946. this.miterLimit = 0;
  20947. this.dashArray = [];
  20948. this.dashPhase = 0;
  20949. this.dependencies = [];
  20950. this.activeClipUrl = null;
  20951. this.clipGroup = null;
  20952. this.maskId = '';
  20953. }
  20954. SVGExtraState.prototype = {
  20955. clone: function SVGExtraState_clone() {
  20956. return Object.create(this);
  20957. },
  20958. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20959. this.x = x;
  20960. this.y = y;
  20961. }
  20962. };
  20963. return SVGExtraState;
  20964. }();
  20965. var SVGGraphics = function SVGGraphicsClosure() {
  20966. function opListToTree(opList) {
  20967. var opTree = [];
  20968. var tmp = [];
  20969. var opListLen = opList.length;
  20970. for (var x = 0; x < opListLen; x++) {
  20971. if (opList[x].fn === 'save') {
  20972. opTree.push({
  20973. 'fnId': 92,
  20974. 'fn': 'group',
  20975. 'items': []
  20976. });
  20977. tmp.push(opTree);
  20978. opTree = opTree[opTree.length - 1].items;
  20979. continue;
  20980. }
  20981. if (opList[x].fn === 'restore') {
  20982. opTree = tmp.pop();
  20983. } else {
  20984. opTree.push(opList[x]);
  20985. }
  20986. }
  20987. return opTree;
  20988. }
  20989. function pf(value) {
  20990. if (value === (value | 0)) {
  20991. return value.toString();
  20992. }
  20993. var s = value.toFixed(10);
  20994. var i = s.length - 1;
  20995. if (s[i] !== '0') {
  20996. return s;
  20997. }
  20998. do {
  20999. i--;
  21000. } while (s[i] === '0');
  21001. return s.substr(0, s[i] === '.' ? i : i + 1);
  21002. }
  21003. function pm(m) {
  21004. if (m[4] === 0 && m[5] === 0) {
  21005. if (m[1] === 0 && m[2] === 0) {
  21006. if (m[0] === 1 && m[3] === 1) {
  21007. return '';
  21008. }
  21009. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21010. }
  21011. if (m[0] === m[3] && m[1] === -m[2]) {
  21012. var a = Math.acos(m[0]) * 180 / Math.PI;
  21013. return 'rotate(' + pf(a) + ')';
  21014. }
  21015. } else {
  21016. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21017. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21018. }
  21019. }
  21020. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21021. }
  21022. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21023. this.current = new SVGExtraState();
  21024. this.transformMatrix = IDENTITY_MATRIX;
  21025. this.transformStack = [];
  21026. this.extraStack = [];
  21027. this.commonObjs = commonObjs;
  21028. this.objs = objs;
  21029. this.pendingEOFill = false;
  21030. this.embedFonts = false;
  21031. this.embeddedFonts = Object.create(null);
  21032. this.cssStyle = null;
  21033. this.forceDataSchema = !!forceDataSchema;
  21034. }
  21035. var NS = 'http://www.w3.org/2000/svg';
  21036. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21037. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21038. var LINE_CAP_STYLES = [
  21039. 'butt',
  21040. 'round',
  21041. 'square'
  21042. ];
  21043. var LINE_JOIN_STYLES = [
  21044. 'miter',
  21045. 'round',
  21046. 'bevel'
  21047. ];
  21048. var clipCount = 0;
  21049. var maskCount = 0;
  21050. SVGGraphics.prototype = {
  21051. save: function SVGGraphics_save() {
  21052. this.transformStack.push(this.transformMatrix);
  21053. var old = this.current;
  21054. this.extraStack.push(old);
  21055. this.current = old.clone();
  21056. },
  21057. restore: function SVGGraphics_restore() {
  21058. this.transformMatrix = this.transformStack.pop();
  21059. this.current = this.extraStack.pop();
  21060. this.tgrp = null;
  21061. },
  21062. group: function SVGGraphics_group(items) {
  21063. this.save();
  21064. this.executeOpTree(items);
  21065. this.restore();
  21066. },
  21067. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21068. var fnArray = operatorList.fnArray;
  21069. var fnArrayLen = fnArray.length;
  21070. var argsArray = operatorList.argsArray;
  21071. var self = this;
  21072. for (var i = 0; i < fnArrayLen; i++) {
  21073. if (OPS.dependency === fnArray[i]) {
  21074. var deps = argsArray[i];
  21075. for (var n = 0, nn = deps.length; n < nn; n++) {
  21076. var obj = deps[n];
  21077. var common = obj.substring(0, 2) === 'g_';
  21078. var promise;
  21079. if (common) {
  21080. promise = new Promise(function (resolve) {
  21081. self.commonObjs.get(obj, resolve);
  21082. });
  21083. } else {
  21084. promise = new Promise(function (resolve) {
  21085. self.objs.get(obj, resolve);
  21086. });
  21087. }
  21088. this.current.dependencies.push(promise);
  21089. }
  21090. }
  21091. }
  21092. return Promise.all(this.current.dependencies);
  21093. },
  21094. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21095. var transformMatrix = [
  21096. a,
  21097. b,
  21098. c,
  21099. d,
  21100. e,
  21101. f
  21102. ];
  21103. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21104. this.tgrp = null;
  21105. },
  21106. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21107. this.viewport = viewport;
  21108. var svgElement = this._initialize(viewport);
  21109. return this.loadDependencies(operatorList).then(function () {
  21110. this.transformMatrix = IDENTITY_MATRIX;
  21111. var opTree = this.convertOpList(operatorList);
  21112. this.executeOpTree(opTree);
  21113. return svgElement;
  21114. }.bind(this));
  21115. },
  21116. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21117. var argsArray = operatorList.argsArray;
  21118. var fnArray = operatorList.fnArray;
  21119. var fnArrayLen = fnArray.length;
  21120. var REVOPS = [];
  21121. var opList = [];
  21122. for (var op in OPS) {
  21123. REVOPS[OPS[op]] = op;
  21124. }
  21125. for (var x = 0; x < fnArrayLen; x++) {
  21126. var fnId = fnArray[x];
  21127. opList.push({
  21128. 'fnId': fnId,
  21129. 'fn': REVOPS[fnId],
  21130. 'args': argsArray[x]
  21131. });
  21132. }
  21133. return opListToTree(opList);
  21134. },
  21135. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21136. var opTreeLen = opTree.length;
  21137. for (var x = 0; x < opTreeLen; x++) {
  21138. var fn = opTree[x].fn;
  21139. var fnId = opTree[x].fnId;
  21140. var args = opTree[x].args;
  21141. switch (fnId | 0) {
  21142. case OPS.beginText:
  21143. this.beginText();
  21144. break;
  21145. case OPS.setLeading:
  21146. this.setLeading(args);
  21147. break;
  21148. case OPS.setLeadingMoveText:
  21149. this.setLeadingMoveText(args[0], args[1]);
  21150. break;
  21151. case OPS.setFont:
  21152. this.setFont(args);
  21153. break;
  21154. case OPS.showText:
  21155. this.showText(args[0]);
  21156. break;
  21157. case OPS.showSpacedText:
  21158. this.showText(args[0]);
  21159. break;
  21160. case OPS.endText:
  21161. this.endText();
  21162. break;
  21163. case OPS.moveText:
  21164. this.moveText(args[0], args[1]);
  21165. break;
  21166. case OPS.setCharSpacing:
  21167. this.setCharSpacing(args[0]);
  21168. break;
  21169. case OPS.setWordSpacing:
  21170. this.setWordSpacing(args[0]);
  21171. break;
  21172. case OPS.setHScale:
  21173. this.setHScale(args[0]);
  21174. break;
  21175. case OPS.setTextMatrix:
  21176. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21177. break;
  21178. case OPS.setLineWidth:
  21179. this.setLineWidth(args[0]);
  21180. break;
  21181. case OPS.setLineJoin:
  21182. this.setLineJoin(args[0]);
  21183. break;
  21184. case OPS.setLineCap:
  21185. this.setLineCap(args[0]);
  21186. break;
  21187. case OPS.setMiterLimit:
  21188. this.setMiterLimit(args[0]);
  21189. break;
  21190. case OPS.setFillRGBColor:
  21191. this.setFillRGBColor(args[0], args[1], args[2]);
  21192. break;
  21193. case OPS.setStrokeRGBColor:
  21194. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21195. break;
  21196. case OPS.setDash:
  21197. this.setDash(args[0], args[1]);
  21198. break;
  21199. case OPS.setGState:
  21200. this.setGState(args[0]);
  21201. break;
  21202. case OPS.fill:
  21203. this.fill();
  21204. break;
  21205. case OPS.eoFill:
  21206. this.eoFill();
  21207. break;
  21208. case OPS.stroke:
  21209. this.stroke();
  21210. break;
  21211. case OPS.fillStroke:
  21212. this.fillStroke();
  21213. break;
  21214. case OPS.eoFillStroke:
  21215. this.eoFillStroke();
  21216. break;
  21217. case OPS.clip:
  21218. this.clip('nonzero');
  21219. break;
  21220. case OPS.eoClip:
  21221. this.clip('evenodd');
  21222. break;
  21223. case OPS.paintSolidColorImageMask:
  21224. this.paintSolidColorImageMask();
  21225. break;
  21226. case OPS.paintJpegXObject:
  21227. this.paintJpegXObject(args[0], args[1], args[2]);
  21228. break;
  21229. case OPS.paintImageXObject:
  21230. this.paintImageXObject(args[0]);
  21231. break;
  21232. case OPS.paintInlineImageXObject:
  21233. this.paintInlineImageXObject(args[0]);
  21234. break;
  21235. case OPS.paintImageMaskXObject:
  21236. this.paintImageMaskXObject(args[0]);
  21237. break;
  21238. case OPS.paintFormXObjectBegin:
  21239. this.paintFormXObjectBegin(args[0], args[1]);
  21240. break;
  21241. case OPS.paintFormXObjectEnd:
  21242. this.paintFormXObjectEnd();
  21243. break;
  21244. case OPS.closePath:
  21245. this.closePath();
  21246. break;
  21247. case OPS.closeStroke:
  21248. this.closeStroke();
  21249. break;
  21250. case OPS.closeFillStroke:
  21251. this.closeFillStroke();
  21252. break;
  21253. case OPS.nextLine:
  21254. this.nextLine();
  21255. break;
  21256. case OPS.transform:
  21257. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21258. break;
  21259. case OPS.constructPath:
  21260. this.constructPath(args[0], args[1]);
  21261. break;
  21262. case OPS.endPath:
  21263. this.endPath();
  21264. break;
  21265. case 92:
  21266. this.group(opTree[x].items);
  21267. break;
  21268. default:
  21269. warn('Unimplemented operator ' + fn);
  21270. break;
  21271. }
  21272. }
  21273. },
  21274. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21275. this.current.wordSpacing = wordSpacing;
  21276. },
  21277. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21278. this.current.charSpacing = charSpacing;
  21279. },
  21280. nextLine: function SVGGraphics_nextLine() {
  21281. this.moveText(0, this.current.leading);
  21282. },
  21283. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21284. var current = this.current;
  21285. this.current.textMatrix = this.current.lineMatrix = [
  21286. a,
  21287. b,
  21288. c,
  21289. d,
  21290. e,
  21291. f
  21292. ];
  21293. this.current.x = this.current.lineX = 0;
  21294. this.current.y = this.current.lineY = 0;
  21295. current.xcoords = [];
  21296. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21297. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21298. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21299. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21300. current.txtElement = document.createElementNS(NS, 'svg:text');
  21301. current.txtElement.appendChild(current.tspan);
  21302. },
  21303. beginText: function SVGGraphics_beginText() {
  21304. this.current.x = this.current.lineX = 0;
  21305. this.current.y = this.current.lineY = 0;
  21306. this.current.textMatrix = IDENTITY_MATRIX;
  21307. this.current.lineMatrix = IDENTITY_MATRIX;
  21308. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21309. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21310. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21311. this.current.xcoords = [];
  21312. },
  21313. moveText: function SVGGraphics_moveText(x, y) {
  21314. var current = this.current;
  21315. this.current.x = this.current.lineX += x;
  21316. this.current.y = this.current.lineY += y;
  21317. current.xcoords = [];
  21318. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21319. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21320. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21321. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21322. },
  21323. showText: function SVGGraphics_showText(glyphs) {
  21324. var current = this.current;
  21325. var font = current.font;
  21326. var fontSize = current.fontSize;
  21327. if (fontSize === 0) {
  21328. return;
  21329. }
  21330. var charSpacing = current.charSpacing;
  21331. var wordSpacing = current.wordSpacing;
  21332. var fontDirection = current.fontDirection;
  21333. var textHScale = current.textHScale * fontDirection;
  21334. var glyphsLength = glyphs.length;
  21335. var vertical = font.vertical;
  21336. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21337. var x = 0, i;
  21338. for (i = 0; i < glyphsLength; ++i) {
  21339. var glyph = glyphs[i];
  21340. if (glyph === null) {
  21341. x += fontDirection * wordSpacing;
  21342. continue;
  21343. } else if (isNum(glyph)) {
  21344. x += -glyph * fontSize * 0.001;
  21345. continue;
  21346. }
  21347. current.xcoords.push(current.x + x * textHScale);
  21348. var width = glyph.width;
  21349. var character = glyph.fontChar;
  21350. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21351. x += charWidth;
  21352. current.tspan.textContent += character;
  21353. }
  21354. if (vertical) {
  21355. current.y -= x * textHScale;
  21356. } else {
  21357. current.x += x * textHScale;
  21358. }
  21359. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21360. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21361. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21362. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21363. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21364. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21365. }
  21366. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21367. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21368. }
  21369. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21370. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21371. }
  21372. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21373. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21374. current.txtElement.appendChild(current.tspan);
  21375. current.txtgrp.appendChild(current.txtElement);
  21376. this._ensureTransformGroup().appendChild(current.txtElement);
  21377. },
  21378. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21379. this.setLeading(-y);
  21380. this.moveText(x, y);
  21381. },
  21382. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21383. if (!this.cssStyle) {
  21384. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21385. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21386. this.defs.appendChild(this.cssStyle);
  21387. }
  21388. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21389. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21390. },
  21391. setFont: function SVGGraphics_setFont(details) {
  21392. var current = this.current;
  21393. var fontObj = this.commonObjs.get(details[0]);
  21394. var size = details[1];
  21395. this.current.font = fontObj;
  21396. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21397. this.addFontStyle(fontObj);
  21398. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21399. }
  21400. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21401. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21402. var italic = fontObj.italic ? 'italic' : 'normal';
  21403. if (size < 0) {
  21404. size = -size;
  21405. current.fontDirection = -1;
  21406. } else {
  21407. current.fontDirection = 1;
  21408. }
  21409. current.fontSize = size;
  21410. current.fontFamily = fontObj.loadedName;
  21411. current.fontWeight = bold;
  21412. current.fontStyle = italic;
  21413. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21414. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21415. current.xcoords = [];
  21416. },
  21417. endText: function SVGGraphics_endText() {
  21418. },
  21419. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21420. this.current.lineWidth = width;
  21421. },
  21422. setLineCap: function SVGGraphics_setLineCap(style) {
  21423. this.current.lineCap = LINE_CAP_STYLES[style];
  21424. },
  21425. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21426. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21427. },
  21428. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21429. this.current.miterLimit = limit;
  21430. },
  21431. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21432. var color = Util.makeCssRgb(r, g, b);
  21433. this.current.strokeColor = color;
  21434. },
  21435. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21436. var color = Util.makeCssRgb(r, g, b);
  21437. this.current.fillColor = color;
  21438. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21439. this.current.xcoords = [];
  21440. },
  21441. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21442. this.current.dashArray = dashArray;
  21443. this.current.dashPhase = dashPhase;
  21444. },
  21445. constructPath: function SVGGraphics_constructPath(ops, args) {
  21446. var current = this.current;
  21447. var x = current.x, y = current.y;
  21448. current.path = document.createElementNS(NS, 'svg:path');
  21449. var d = [];
  21450. var opLength = ops.length;
  21451. for (var i = 0, j = 0; i < opLength; i++) {
  21452. switch (ops[i] | 0) {
  21453. case OPS.rectangle:
  21454. x = args[j++];
  21455. y = args[j++];
  21456. var width = args[j++];
  21457. var height = args[j++];
  21458. var xw = x + width;
  21459. var yh = y + height;
  21460. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21461. break;
  21462. case OPS.moveTo:
  21463. x = args[j++];
  21464. y = args[j++];
  21465. d.push('M', pf(x), pf(y));
  21466. break;
  21467. case OPS.lineTo:
  21468. x = args[j++];
  21469. y = args[j++];
  21470. d.push('L', pf(x), pf(y));
  21471. break;
  21472. case OPS.curveTo:
  21473. x = args[j + 4];
  21474. y = args[j + 5];
  21475. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21476. j += 6;
  21477. break;
  21478. case OPS.curveTo2:
  21479. x = args[j + 2];
  21480. y = args[j + 3];
  21481. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21482. j += 4;
  21483. break;
  21484. case OPS.curveTo3:
  21485. x = args[j + 2];
  21486. y = args[j + 3];
  21487. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21488. j += 4;
  21489. break;
  21490. case OPS.closePath:
  21491. d.push('Z');
  21492. break;
  21493. }
  21494. }
  21495. current.path.setAttributeNS(null, 'd', d.join(' '));
  21496. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21497. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21498. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21499. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21500. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21501. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21502. current.path.setAttributeNS(null, 'fill', 'none');
  21503. this._ensureTransformGroup().appendChild(current.path);
  21504. current.element = current.path;
  21505. current.setCurrentPoint(x, y);
  21506. },
  21507. endPath: function SVGGraphics_endPath() {
  21508. },
  21509. clip: function SVGGraphics_clip(type) {
  21510. var current = this.current;
  21511. var clipId = 'clippath' + clipCount;
  21512. clipCount++;
  21513. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21514. clipPath.setAttributeNS(null, 'id', clipId);
  21515. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21516. var clipElement = current.element.cloneNode();
  21517. if (type === 'evenodd') {
  21518. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21519. } else {
  21520. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21521. }
  21522. clipPath.appendChild(clipElement);
  21523. this.defs.appendChild(clipPath);
  21524. if (current.activeClipUrl) {
  21525. current.clipGroup = null;
  21526. this.extraStack.forEach(function (prev) {
  21527. prev.clipGroup = null;
  21528. });
  21529. }
  21530. current.activeClipUrl = 'url(#' + clipId + ')';
  21531. this.tgrp = null;
  21532. },
  21533. closePath: function SVGGraphics_closePath() {
  21534. var current = this.current;
  21535. var d = current.path.getAttributeNS(null, 'd');
  21536. d += 'Z';
  21537. current.path.setAttributeNS(null, 'd', d);
  21538. },
  21539. setLeading: function SVGGraphics_setLeading(leading) {
  21540. this.current.leading = -leading;
  21541. },
  21542. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21543. this.current.textRise = textRise;
  21544. },
  21545. setHScale: function SVGGraphics_setHScale(scale) {
  21546. this.current.textHScale = scale / 100;
  21547. },
  21548. setGState: function SVGGraphics_setGState(states) {
  21549. for (var i = 0, ii = states.length; i < ii; i++) {
  21550. var state = states[i];
  21551. var key = state[0];
  21552. var value = state[1];
  21553. switch (key) {
  21554. case 'LW':
  21555. this.setLineWidth(value);
  21556. break;
  21557. case 'LC':
  21558. this.setLineCap(value);
  21559. break;
  21560. case 'LJ':
  21561. this.setLineJoin(value);
  21562. break;
  21563. case 'ML':
  21564. this.setMiterLimit(value);
  21565. break;
  21566. case 'D':
  21567. this.setDash(value[0], value[1]);
  21568. break;
  21569. case 'Font':
  21570. this.setFont(value);
  21571. break;
  21572. default:
  21573. warn('Unimplemented graphic state ' + key);
  21574. break;
  21575. }
  21576. }
  21577. },
  21578. fill: function SVGGraphics_fill() {
  21579. var current = this.current;
  21580. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21581. },
  21582. stroke: function SVGGraphics_stroke() {
  21583. var current = this.current;
  21584. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21585. current.element.setAttributeNS(null, 'fill', 'none');
  21586. },
  21587. eoFill: function SVGGraphics_eoFill() {
  21588. var current = this.current;
  21589. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21590. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21591. },
  21592. fillStroke: function SVGGraphics_fillStroke() {
  21593. this.stroke();
  21594. this.fill();
  21595. },
  21596. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21597. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21598. this.fillStroke();
  21599. },
  21600. closeStroke: function SVGGraphics_closeStroke() {
  21601. this.closePath();
  21602. this.stroke();
  21603. },
  21604. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21605. this.closePath();
  21606. this.fillStroke();
  21607. },
  21608. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21609. var current = this.current;
  21610. var rect = document.createElementNS(NS, 'svg:rect');
  21611. rect.setAttributeNS(null, 'x', '0');
  21612. rect.setAttributeNS(null, 'y', '0');
  21613. rect.setAttributeNS(null, 'width', '1px');
  21614. rect.setAttributeNS(null, 'height', '1px');
  21615. rect.setAttributeNS(null, 'fill', current.fillColor);
  21616. this._ensureTransformGroup().appendChild(rect);
  21617. },
  21618. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21619. var imgObj = this.objs.get(objId);
  21620. var imgEl = document.createElementNS(NS, 'svg:image');
  21621. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21622. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21623. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21624. imgEl.setAttributeNS(null, 'x', '0');
  21625. imgEl.setAttributeNS(null, 'y', pf(-h));
  21626. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21627. this._ensureTransformGroup().appendChild(imgEl);
  21628. },
  21629. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21630. var imgData = this.objs.get(objId);
  21631. if (!imgData) {
  21632. warn('Dependent image isn\'t ready yet');
  21633. return;
  21634. }
  21635. this.paintInlineImageXObject(imgData);
  21636. },
  21637. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21638. var width = imgData.width;
  21639. var height = imgData.height;
  21640. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21641. var cliprect = document.createElementNS(NS, 'svg:rect');
  21642. cliprect.setAttributeNS(null, 'x', '0');
  21643. cliprect.setAttributeNS(null, 'y', '0');
  21644. cliprect.setAttributeNS(null, 'width', pf(width));
  21645. cliprect.setAttributeNS(null, 'height', pf(height));
  21646. this.current.element = cliprect;
  21647. this.clip('nonzero');
  21648. var imgEl = document.createElementNS(NS, 'svg:image');
  21649. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21650. imgEl.setAttributeNS(null, 'x', '0');
  21651. imgEl.setAttributeNS(null, 'y', pf(-height));
  21652. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21653. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21654. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21655. if (mask) {
  21656. mask.appendChild(imgEl);
  21657. } else {
  21658. this._ensureTransformGroup().appendChild(imgEl);
  21659. }
  21660. },
  21661. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21662. var current = this.current;
  21663. var width = imgData.width;
  21664. var height = imgData.height;
  21665. var fillColor = current.fillColor;
  21666. current.maskId = 'mask' + maskCount++;
  21667. var mask = document.createElementNS(NS, 'svg:mask');
  21668. mask.setAttributeNS(null, 'id', current.maskId);
  21669. var rect = document.createElementNS(NS, 'svg:rect');
  21670. rect.setAttributeNS(null, 'x', '0');
  21671. rect.setAttributeNS(null, 'y', '0');
  21672. rect.setAttributeNS(null, 'width', pf(width));
  21673. rect.setAttributeNS(null, 'height', pf(height));
  21674. rect.setAttributeNS(null, 'fill', fillColor);
  21675. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21676. this.defs.appendChild(mask);
  21677. this._ensureTransformGroup().appendChild(rect);
  21678. this.paintInlineImageXObject(imgData, mask);
  21679. },
  21680. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21681. if (isArray(matrix) && matrix.length === 6) {
  21682. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21683. }
  21684. if (isArray(bbox) && bbox.length === 4) {
  21685. var width = bbox[2] - bbox[0];
  21686. var height = bbox[3] - bbox[1];
  21687. var cliprect = document.createElementNS(NS, 'svg:rect');
  21688. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21689. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21690. cliprect.setAttributeNS(null, 'width', pf(width));
  21691. cliprect.setAttributeNS(null, 'height', pf(height));
  21692. this.current.element = cliprect;
  21693. this.clip('nonzero');
  21694. this.endPath();
  21695. }
  21696. },
  21697. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21698. },
  21699. _initialize: function SVGGraphics_initialize(viewport) {
  21700. var svg = document.createElementNS(NS, 'svg:svg');
  21701. svg.setAttributeNS(null, 'version', '1.1');
  21702. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21703. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21704. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21705. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21706. var definitions = document.createElementNS(NS, 'svg:defs');
  21707. svg.appendChild(definitions);
  21708. this.defs = definitions;
  21709. var rootGroup = document.createElementNS(NS, 'svg:g');
  21710. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21711. svg.appendChild(rootGroup);
  21712. this.svg = rootGroup;
  21713. return svg;
  21714. },
  21715. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21716. if (!this.current.clipGroup) {
  21717. var clipGroup = document.createElementNS(NS, 'svg:g');
  21718. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21719. this.svg.appendChild(clipGroup);
  21720. this.current.clipGroup = clipGroup;
  21721. }
  21722. return this.current.clipGroup;
  21723. },
  21724. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21725. if (!this.tgrp) {
  21726. this.tgrp = document.createElementNS(NS, 'svg:g');
  21727. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21728. if (this.current.activeClipUrl) {
  21729. this._ensureClipGroup().appendChild(this.tgrp);
  21730. } else {
  21731. this.svg.appendChild(this.tgrp);
  21732. }
  21733. }
  21734. return this.tgrp;
  21735. }
  21736. };
  21737. return SVGGraphics;
  21738. }();
  21739. exports.SVGGraphics = SVGGraphics;
  21740. /***/ }),
  21741. /* 12 */
  21742. /***/ (function(module, exports, __w_pdfjs_require__) {
  21743. "use strict";
  21744. var sharedUtil = __w_pdfjs_require__(0);
  21745. var displayDOMUtils = __w_pdfjs_require__(3);
  21746. var Util = sharedUtil.Util;
  21747. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21748. var CustomStyle = displayDOMUtils.CustomStyle;
  21749. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21750. var renderTextLayer = function renderTextLayerClosure() {
  21751. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21752. var NonWhitespaceRegexp = /\S/;
  21753. function isAllWhitespace(str) {
  21754. return !NonWhitespaceRegexp.test(str);
  21755. }
  21756. var styleBuf = [
  21757. 'left: ',
  21758. 0,
  21759. 'px; top: ',
  21760. 0,
  21761. 'px; font-size: ',
  21762. 0,
  21763. 'px; font-family: ',
  21764. '',
  21765. ';'
  21766. ];
  21767. function appendText(task, geom, styles) {
  21768. var textDiv = document.createElement('div');
  21769. var textDivProperties = {
  21770. style: null,
  21771. angle: 0,
  21772. canvasWidth: 0,
  21773. isWhitespace: false,
  21774. originalTransform: null,
  21775. paddingBottom: 0,
  21776. paddingLeft: 0,
  21777. paddingRight: 0,
  21778. paddingTop: 0,
  21779. scale: 1
  21780. };
  21781. task._textDivs.push(textDiv);
  21782. if (isAllWhitespace(geom.str)) {
  21783. textDivProperties.isWhitespace = true;
  21784. task._textDivProperties.set(textDiv, textDivProperties);
  21785. return;
  21786. }
  21787. var tx = Util.transform(task._viewport.transform, geom.transform);
  21788. var angle = Math.atan2(tx[1], tx[0]);
  21789. var style = styles[geom.fontName];
  21790. if (style.vertical) {
  21791. angle += Math.PI / 2;
  21792. }
  21793. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21794. var fontAscent = fontHeight;
  21795. if (style.ascent) {
  21796. fontAscent = style.ascent * fontAscent;
  21797. } else if (style.descent) {
  21798. fontAscent = (1 + style.descent) * fontAscent;
  21799. }
  21800. var left;
  21801. var top;
  21802. if (angle === 0) {
  21803. left = tx[4];
  21804. top = tx[5] - fontAscent;
  21805. } else {
  21806. left = tx[4] + fontAscent * Math.sin(angle);
  21807. top = tx[5] - fontAscent * Math.cos(angle);
  21808. }
  21809. styleBuf[1] = left;
  21810. styleBuf[3] = top;
  21811. styleBuf[5] = fontHeight;
  21812. styleBuf[7] = style.fontFamily;
  21813. textDivProperties.style = styleBuf.join('');
  21814. textDiv.setAttribute('style', textDivProperties.style);
  21815. textDiv.textContent = geom.str;
  21816. if (getDefaultSetting('pdfBug')) {
  21817. textDiv.dataset.fontName = geom.fontName;
  21818. }
  21819. if (angle !== 0) {
  21820. textDivProperties.angle = angle * (180 / Math.PI);
  21821. }
  21822. if (geom.str.length > 1) {
  21823. if (style.vertical) {
  21824. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21825. } else {
  21826. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21827. }
  21828. }
  21829. task._textDivProperties.set(textDiv, textDivProperties);
  21830. if (task._enhanceTextSelection) {
  21831. var angleCos = 1, angleSin = 0;
  21832. if (angle !== 0) {
  21833. angleCos = Math.cos(angle);
  21834. angleSin = Math.sin(angle);
  21835. }
  21836. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21837. var divHeight = fontHeight;
  21838. var m, b;
  21839. if (angle !== 0) {
  21840. m = [
  21841. angleCos,
  21842. angleSin,
  21843. -angleSin,
  21844. angleCos,
  21845. left,
  21846. top
  21847. ];
  21848. b = Util.getAxialAlignedBoundingBox([
  21849. 0,
  21850. 0,
  21851. divWidth,
  21852. divHeight
  21853. ], m);
  21854. } else {
  21855. b = [
  21856. left,
  21857. top,
  21858. left + divWidth,
  21859. top + divHeight
  21860. ];
  21861. }
  21862. task._bounds.push({
  21863. left: b[0],
  21864. top: b[1],
  21865. right: b[2],
  21866. bottom: b[3],
  21867. div: textDiv,
  21868. size: [
  21869. divWidth,
  21870. divHeight
  21871. ],
  21872. m: m
  21873. });
  21874. }
  21875. }
  21876. function render(task) {
  21877. if (task._canceled) {
  21878. return;
  21879. }
  21880. var textLayerFrag = task._container;
  21881. var textDivs = task._textDivs;
  21882. var capability = task._capability;
  21883. var textDivsLength = textDivs.length;
  21884. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21885. task._renderingDone = true;
  21886. capability.resolve();
  21887. return;
  21888. }
  21889. var canvas = document.createElement('canvas');
  21890. var ctx = canvas.getContext('2d', { alpha: false });
  21891. var lastFontSize;
  21892. var lastFontFamily;
  21893. for (var i = 0; i < textDivsLength; i++) {
  21894. var textDiv = textDivs[i];
  21895. var textDivProperties = task._textDivProperties.get(textDiv);
  21896. if (textDivProperties.isWhitespace) {
  21897. continue;
  21898. }
  21899. var fontSize = textDiv.style.fontSize;
  21900. var fontFamily = textDiv.style.fontFamily;
  21901. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21902. ctx.font = fontSize + ' ' + fontFamily;
  21903. lastFontSize = fontSize;
  21904. lastFontFamily = fontFamily;
  21905. }
  21906. var width = ctx.measureText(textDiv.textContent).width;
  21907. textLayerFrag.appendChild(textDiv);
  21908. var transform = '';
  21909. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21910. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21911. transform = 'scaleX(' + textDivProperties.scale + ')';
  21912. }
  21913. if (textDivProperties.angle !== 0) {
  21914. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21915. }
  21916. if (transform !== '') {
  21917. textDivProperties.originalTransform = transform;
  21918. CustomStyle.setProp('transform', textDiv, transform);
  21919. }
  21920. task._textDivProperties.set(textDiv, textDivProperties);
  21921. }
  21922. task._renderingDone = true;
  21923. capability.resolve();
  21924. }
  21925. function expand(task) {
  21926. var bounds = task._bounds;
  21927. var viewport = task._viewport;
  21928. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21929. for (var i = 0; i < expanded.length; i++) {
  21930. var div = bounds[i].div;
  21931. var divProperties = task._textDivProperties.get(div);
  21932. if (divProperties.angle === 0) {
  21933. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21934. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21935. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21936. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21937. task._textDivProperties.set(div, divProperties);
  21938. continue;
  21939. }
  21940. var e = expanded[i], b = bounds[i];
  21941. var m = b.m, c = m[0], s = m[1];
  21942. var points = [
  21943. [
  21944. 0,
  21945. 0
  21946. ],
  21947. [
  21948. 0,
  21949. b.size[1]
  21950. ],
  21951. [
  21952. b.size[0],
  21953. 0
  21954. ],
  21955. b.size
  21956. ];
  21957. var ts = new Float64Array(64);
  21958. points.forEach(function (p, i) {
  21959. var t = Util.applyTransform(p, m);
  21960. ts[i + 0] = c && (e.left - t[0]) / c;
  21961. ts[i + 4] = s && (e.top - t[1]) / s;
  21962. ts[i + 8] = c && (e.right - t[0]) / c;
  21963. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21964. ts[i + 16] = s && (e.left - t[0]) / -s;
  21965. ts[i + 20] = c && (e.top - t[1]) / c;
  21966. ts[i + 24] = s && (e.right - t[0]) / -s;
  21967. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21968. ts[i + 32] = c && (e.left - t[0]) / -c;
  21969. ts[i + 36] = s && (e.top - t[1]) / -s;
  21970. ts[i + 40] = c && (e.right - t[0]) / -c;
  21971. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21972. ts[i + 48] = s && (e.left - t[0]) / s;
  21973. ts[i + 52] = c && (e.top - t[1]) / -c;
  21974. ts[i + 56] = s && (e.right - t[0]) / s;
  21975. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21976. });
  21977. var findPositiveMin = function (ts, offset, count) {
  21978. var result = 0;
  21979. for (var i = 0; i < count; i++) {
  21980. var t = ts[offset++];
  21981. if (t > 0) {
  21982. result = result ? Math.min(t, result) : t;
  21983. }
  21984. }
  21985. return result;
  21986. };
  21987. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21988. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21989. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21990. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21991. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21992. task._textDivProperties.set(div, divProperties);
  21993. }
  21994. }
  21995. function expandBounds(width, height, boxes) {
  21996. var bounds = boxes.map(function (box, i) {
  21997. return {
  21998. x1: box.left,
  21999. y1: box.top,
  22000. x2: box.right,
  22001. y2: box.bottom,
  22002. index: i,
  22003. x1New: undefined,
  22004. x2New: undefined
  22005. };
  22006. });
  22007. expandBoundsLTR(width, bounds);
  22008. var expanded = new Array(boxes.length);
  22009. bounds.forEach(function (b) {
  22010. var i = b.index;
  22011. expanded[i] = {
  22012. left: b.x1New,
  22013. top: 0,
  22014. right: b.x2New,
  22015. bottom: 0
  22016. };
  22017. });
  22018. boxes.map(function (box, i) {
  22019. var e = expanded[i], b = bounds[i];
  22020. b.x1 = box.top;
  22021. b.y1 = width - e.right;
  22022. b.x2 = box.bottom;
  22023. b.y2 = width - e.left;
  22024. b.index = i;
  22025. b.x1New = undefined;
  22026. b.x2New = undefined;
  22027. });
  22028. expandBoundsLTR(height, bounds);
  22029. bounds.forEach(function (b) {
  22030. var i = b.index;
  22031. expanded[i].top = b.x1New;
  22032. expanded[i].bottom = b.x2New;
  22033. });
  22034. return expanded;
  22035. }
  22036. function expandBoundsLTR(width, bounds) {
  22037. bounds.sort(function (a, b) {
  22038. return a.x1 - b.x1 || a.index - b.index;
  22039. });
  22040. var fakeBoundary = {
  22041. x1: -Infinity,
  22042. y1: -Infinity,
  22043. x2: 0,
  22044. y2: Infinity,
  22045. index: -1,
  22046. x1New: 0,
  22047. x2New: 0
  22048. };
  22049. var horizon = [{
  22050. start: -Infinity,
  22051. end: Infinity,
  22052. boundary: fakeBoundary
  22053. }];
  22054. bounds.forEach(function (boundary) {
  22055. var i = 0;
  22056. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22057. i++;
  22058. }
  22059. var j = horizon.length - 1;
  22060. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22061. j--;
  22062. }
  22063. var horizonPart, affectedBoundary;
  22064. var q, k, maxXNew = -Infinity;
  22065. for (q = i; q <= j; q++) {
  22066. horizonPart = horizon[q];
  22067. affectedBoundary = horizonPart.boundary;
  22068. var xNew;
  22069. if (affectedBoundary.x2 > boundary.x1) {
  22070. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22071. } else if (affectedBoundary.x2New === undefined) {
  22072. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22073. } else {
  22074. xNew = affectedBoundary.x2New;
  22075. }
  22076. if (xNew > maxXNew) {
  22077. maxXNew = xNew;
  22078. }
  22079. }
  22080. boundary.x1New = maxXNew;
  22081. for (q = i; q <= j; q++) {
  22082. horizonPart = horizon[q];
  22083. affectedBoundary = horizonPart.boundary;
  22084. if (affectedBoundary.x2New === undefined) {
  22085. if (affectedBoundary.x2 > boundary.x1) {
  22086. if (affectedBoundary.index > boundary.index) {
  22087. affectedBoundary.x2New = affectedBoundary.x2;
  22088. }
  22089. } else {
  22090. affectedBoundary.x2New = maxXNew;
  22091. }
  22092. } else if (affectedBoundary.x2New > maxXNew) {
  22093. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22094. }
  22095. }
  22096. var changedHorizon = [], lastBoundary = null;
  22097. for (q = i; q <= j; q++) {
  22098. horizonPart = horizon[q];
  22099. affectedBoundary = horizonPart.boundary;
  22100. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22101. if (lastBoundary === useBoundary) {
  22102. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22103. } else {
  22104. changedHorizon.push({
  22105. start: horizonPart.start,
  22106. end: horizonPart.end,
  22107. boundary: useBoundary
  22108. });
  22109. lastBoundary = useBoundary;
  22110. }
  22111. }
  22112. if (horizon[i].start < boundary.y1) {
  22113. changedHorizon[0].start = boundary.y1;
  22114. changedHorizon.unshift({
  22115. start: horizon[i].start,
  22116. end: boundary.y1,
  22117. boundary: horizon[i].boundary
  22118. });
  22119. }
  22120. if (boundary.y2 < horizon[j].end) {
  22121. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22122. changedHorizon.push({
  22123. start: boundary.y2,
  22124. end: horizon[j].end,
  22125. boundary: horizon[j].boundary
  22126. });
  22127. }
  22128. for (q = i; q <= j; q++) {
  22129. horizonPart = horizon[q];
  22130. affectedBoundary = horizonPart.boundary;
  22131. if (affectedBoundary.x2New !== undefined) {
  22132. continue;
  22133. }
  22134. var used = false;
  22135. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22136. used = horizon[k].boundary === affectedBoundary;
  22137. }
  22138. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22139. used = horizon[k].boundary === affectedBoundary;
  22140. }
  22141. for (k = 0; !used && k < changedHorizon.length; k++) {
  22142. used = changedHorizon[k].boundary === affectedBoundary;
  22143. }
  22144. if (!used) {
  22145. affectedBoundary.x2New = maxXNew;
  22146. }
  22147. }
  22148. Array.prototype.splice.apply(horizon, [
  22149. i,
  22150. j - i + 1
  22151. ].concat(changedHorizon));
  22152. });
  22153. horizon.forEach(function (horizonPart) {
  22154. var affectedBoundary = horizonPart.boundary;
  22155. if (affectedBoundary.x2New === undefined) {
  22156. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22157. }
  22158. });
  22159. }
  22160. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22161. this._textContent = textContent;
  22162. this._container = container;
  22163. this._viewport = viewport;
  22164. this._textDivs = textDivs || [];
  22165. this._textDivProperties = new WeakMap();
  22166. this._renderingDone = false;
  22167. this._canceled = false;
  22168. this._capability = createPromiseCapability();
  22169. this._renderTimer = null;
  22170. this._bounds = [];
  22171. this._enhanceTextSelection = !!enhanceTextSelection;
  22172. }
  22173. TextLayerRenderTask.prototype = {
  22174. get promise() {
  22175. return this._capability.promise;
  22176. },
  22177. cancel: function TextLayer_cancel() {
  22178. this._canceled = true;
  22179. if (this._renderTimer !== null) {
  22180. clearTimeout(this._renderTimer);
  22181. this._renderTimer = null;
  22182. }
  22183. this._capability.reject('canceled');
  22184. },
  22185. _render: function TextLayer_render(timeout) {
  22186. var textItems = this._textContent.items;
  22187. var textStyles = this._textContent.styles;
  22188. for (var i = 0, len = textItems.length; i < len; i++) {
  22189. appendText(this, textItems[i], textStyles);
  22190. }
  22191. if (!timeout) {
  22192. render(this);
  22193. } else {
  22194. var self = this;
  22195. this._renderTimer = setTimeout(function () {
  22196. render(self);
  22197. self._renderTimer = null;
  22198. }, timeout);
  22199. }
  22200. },
  22201. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22202. if (!this._enhanceTextSelection || !this._renderingDone) {
  22203. return;
  22204. }
  22205. if (this._bounds !== null) {
  22206. expand(this);
  22207. this._bounds = null;
  22208. }
  22209. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22210. var div = this._textDivs[i];
  22211. var divProperties = this._textDivProperties.get(div);
  22212. if (divProperties.isWhitespace) {
  22213. continue;
  22214. }
  22215. if (expandDivs) {
  22216. var transform = '', padding = '';
  22217. if (divProperties.scale !== 1) {
  22218. transform = 'scaleX(' + divProperties.scale + ')';
  22219. }
  22220. if (divProperties.angle !== 0) {
  22221. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22222. }
  22223. if (divProperties.paddingLeft !== 0) {
  22224. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22225. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22226. }
  22227. if (divProperties.paddingTop !== 0) {
  22228. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22229. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22230. }
  22231. if (divProperties.paddingRight !== 0) {
  22232. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22233. }
  22234. if (divProperties.paddingBottom !== 0) {
  22235. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22236. }
  22237. if (padding !== '') {
  22238. div.setAttribute('style', divProperties.style + padding);
  22239. }
  22240. if (transform !== '') {
  22241. CustomStyle.setProp('transform', div, transform);
  22242. }
  22243. } else {
  22244. div.style.padding = 0;
  22245. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22246. }
  22247. }
  22248. }
  22249. };
  22250. function renderTextLayer(renderParameters) {
  22251. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22252. task._render(renderParameters.timeout);
  22253. return task;
  22254. }
  22255. return renderTextLayer;
  22256. }();
  22257. exports.renderTextLayer = renderTextLayer;
  22258. /***/ }),
  22259. /* 13 */
  22260. /***/ (function(module, exports, __w_pdfjs_require__) {
  22261. "use strict";
  22262. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22263. var QeTable = [
  22264. {
  22265. qe: 0x5601,
  22266. nmps: 1,
  22267. nlps: 1,
  22268. switchFlag: 1
  22269. },
  22270. {
  22271. qe: 0x3401,
  22272. nmps: 2,
  22273. nlps: 6,
  22274. switchFlag: 0
  22275. },
  22276. {
  22277. qe: 0x1801,
  22278. nmps: 3,
  22279. nlps: 9,
  22280. switchFlag: 0
  22281. },
  22282. {
  22283. qe: 0x0AC1,
  22284. nmps: 4,
  22285. nlps: 12,
  22286. switchFlag: 0
  22287. },
  22288. {
  22289. qe: 0x0521,
  22290. nmps: 5,
  22291. nlps: 29,
  22292. switchFlag: 0
  22293. },
  22294. {
  22295. qe: 0x0221,
  22296. nmps: 38,
  22297. nlps: 33,
  22298. switchFlag: 0
  22299. },
  22300. {
  22301. qe: 0x5601,
  22302. nmps: 7,
  22303. nlps: 6,
  22304. switchFlag: 1
  22305. },
  22306. {
  22307. qe: 0x5401,
  22308. nmps: 8,
  22309. nlps: 14,
  22310. switchFlag: 0
  22311. },
  22312. {
  22313. qe: 0x4801,
  22314. nmps: 9,
  22315. nlps: 14,
  22316. switchFlag: 0
  22317. },
  22318. {
  22319. qe: 0x3801,
  22320. nmps: 10,
  22321. nlps: 14,
  22322. switchFlag: 0
  22323. },
  22324. {
  22325. qe: 0x3001,
  22326. nmps: 11,
  22327. nlps: 17,
  22328. switchFlag: 0
  22329. },
  22330. {
  22331. qe: 0x2401,
  22332. nmps: 12,
  22333. nlps: 18,
  22334. switchFlag: 0
  22335. },
  22336. {
  22337. qe: 0x1C01,
  22338. nmps: 13,
  22339. nlps: 20,
  22340. switchFlag: 0
  22341. },
  22342. {
  22343. qe: 0x1601,
  22344. nmps: 29,
  22345. nlps: 21,
  22346. switchFlag: 0
  22347. },
  22348. {
  22349. qe: 0x5601,
  22350. nmps: 15,
  22351. nlps: 14,
  22352. switchFlag: 1
  22353. },
  22354. {
  22355. qe: 0x5401,
  22356. nmps: 16,
  22357. nlps: 14,
  22358. switchFlag: 0
  22359. },
  22360. {
  22361. qe: 0x5101,
  22362. nmps: 17,
  22363. nlps: 15,
  22364. switchFlag: 0
  22365. },
  22366. {
  22367. qe: 0x4801,
  22368. nmps: 18,
  22369. nlps: 16,
  22370. switchFlag: 0
  22371. },
  22372. {
  22373. qe: 0x3801,
  22374. nmps: 19,
  22375. nlps: 17,
  22376. switchFlag: 0
  22377. },
  22378. {
  22379. qe: 0x3401,
  22380. nmps: 20,
  22381. nlps: 18,
  22382. switchFlag: 0
  22383. },
  22384. {
  22385. qe: 0x3001,
  22386. nmps: 21,
  22387. nlps: 19,
  22388. switchFlag: 0
  22389. },
  22390. {
  22391. qe: 0x2801,
  22392. nmps: 22,
  22393. nlps: 19,
  22394. switchFlag: 0
  22395. },
  22396. {
  22397. qe: 0x2401,
  22398. nmps: 23,
  22399. nlps: 20,
  22400. switchFlag: 0
  22401. },
  22402. {
  22403. qe: 0x2201,
  22404. nmps: 24,
  22405. nlps: 21,
  22406. switchFlag: 0
  22407. },
  22408. {
  22409. qe: 0x1C01,
  22410. nmps: 25,
  22411. nlps: 22,
  22412. switchFlag: 0
  22413. },
  22414. {
  22415. qe: 0x1801,
  22416. nmps: 26,
  22417. nlps: 23,
  22418. switchFlag: 0
  22419. },
  22420. {
  22421. qe: 0x1601,
  22422. nmps: 27,
  22423. nlps: 24,
  22424. switchFlag: 0
  22425. },
  22426. {
  22427. qe: 0x1401,
  22428. nmps: 28,
  22429. nlps: 25,
  22430. switchFlag: 0
  22431. },
  22432. {
  22433. qe: 0x1201,
  22434. nmps: 29,
  22435. nlps: 26,
  22436. switchFlag: 0
  22437. },
  22438. {
  22439. qe: 0x1101,
  22440. nmps: 30,
  22441. nlps: 27,
  22442. switchFlag: 0
  22443. },
  22444. {
  22445. qe: 0x0AC1,
  22446. nmps: 31,
  22447. nlps: 28,
  22448. switchFlag: 0
  22449. },
  22450. {
  22451. qe: 0x09C1,
  22452. nmps: 32,
  22453. nlps: 29,
  22454. switchFlag: 0
  22455. },
  22456. {
  22457. qe: 0x08A1,
  22458. nmps: 33,
  22459. nlps: 30,
  22460. switchFlag: 0
  22461. },
  22462. {
  22463. qe: 0x0521,
  22464. nmps: 34,
  22465. nlps: 31,
  22466. switchFlag: 0
  22467. },
  22468. {
  22469. qe: 0x0441,
  22470. nmps: 35,
  22471. nlps: 32,
  22472. switchFlag: 0
  22473. },
  22474. {
  22475. qe: 0x02A1,
  22476. nmps: 36,
  22477. nlps: 33,
  22478. switchFlag: 0
  22479. },
  22480. {
  22481. qe: 0x0221,
  22482. nmps: 37,
  22483. nlps: 34,
  22484. switchFlag: 0
  22485. },
  22486. {
  22487. qe: 0x0141,
  22488. nmps: 38,
  22489. nlps: 35,
  22490. switchFlag: 0
  22491. },
  22492. {
  22493. qe: 0x0111,
  22494. nmps: 39,
  22495. nlps: 36,
  22496. switchFlag: 0
  22497. },
  22498. {
  22499. qe: 0x0085,
  22500. nmps: 40,
  22501. nlps: 37,
  22502. switchFlag: 0
  22503. },
  22504. {
  22505. qe: 0x0049,
  22506. nmps: 41,
  22507. nlps: 38,
  22508. switchFlag: 0
  22509. },
  22510. {
  22511. qe: 0x0025,
  22512. nmps: 42,
  22513. nlps: 39,
  22514. switchFlag: 0
  22515. },
  22516. {
  22517. qe: 0x0015,
  22518. nmps: 43,
  22519. nlps: 40,
  22520. switchFlag: 0
  22521. },
  22522. {
  22523. qe: 0x0009,
  22524. nmps: 44,
  22525. nlps: 41,
  22526. switchFlag: 0
  22527. },
  22528. {
  22529. qe: 0x0005,
  22530. nmps: 45,
  22531. nlps: 42,
  22532. switchFlag: 0
  22533. },
  22534. {
  22535. qe: 0x0001,
  22536. nmps: 45,
  22537. nlps: 43,
  22538. switchFlag: 0
  22539. },
  22540. {
  22541. qe: 0x5601,
  22542. nmps: 46,
  22543. nlps: 46,
  22544. switchFlag: 0
  22545. }
  22546. ];
  22547. function ArithmeticDecoder(data, start, end) {
  22548. this.data = data;
  22549. this.bp = start;
  22550. this.dataEnd = end;
  22551. this.chigh = data[start];
  22552. this.clow = 0;
  22553. this.byteIn();
  22554. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22555. this.clow = this.clow << 7 & 0xFFFF;
  22556. this.ct -= 7;
  22557. this.a = 0x8000;
  22558. }
  22559. ArithmeticDecoder.prototype = {
  22560. byteIn: function ArithmeticDecoder_byteIn() {
  22561. var data = this.data;
  22562. var bp = this.bp;
  22563. if (data[bp] === 0xFF) {
  22564. var b1 = data[bp + 1];
  22565. if (b1 > 0x8F) {
  22566. this.clow += 0xFF00;
  22567. this.ct = 8;
  22568. } else {
  22569. bp++;
  22570. this.clow += data[bp] << 9;
  22571. this.ct = 7;
  22572. this.bp = bp;
  22573. }
  22574. } else {
  22575. bp++;
  22576. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22577. this.ct = 8;
  22578. this.bp = bp;
  22579. }
  22580. if (this.clow > 0xFFFF) {
  22581. this.chigh += this.clow >> 16;
  22582. this.clow &= 0xFFFF;
  22583. }
  22584. },
  22585. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22586. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22587. var qeTableIcx = QeTable[cx_index];
  22588. var qeIcx = qeTableIcx.qe;
  22589. var d;
  22590. var a = this.a - qeIcx;
  22591. if (this.chigh < qeIcx) {
  22592. if (a < qeIcx) {
  22593. a = qeIcx;
  22594. d = cx_mps;
  22595. cx_index = qeTableIcx.nmps;
  22596. } else {
  22597. a = qeIcx;
  22598. d = 1 ^ cx_mps;
  22599. if (qeTableIcx.switchFlag === 1) {
  22600. cx_mps = d;
  22601. }
  22602. cx_index = qeTableIcx.nlps;
  22603. }
  22604. } else {
  22605. this.chigh -= qeIcx;
  22606. if ((a & 0x8000) !== 0) {
  22607. this.a = a;
  22608. return cx_mps;
  22609. }
  22610. if (a < qeIcx) {
  22611. d = 1 ^ cx_mps;
  22612. if (qeTableIcx.switchFlag === 1) {
  22613. cx_mps = d;
  22614. }
  22615. cx_index = qeTableIcx.nlps;
  22616. } else {
  22617. d = cx_mps;
  22618. cx_index = qeTableIcx.nmps;
  22619. }
  22620. }
  22621. do {
  22622. if (this.ct === 0) {
  22623. this.byteIn();
  22624. }
  22625. a <<= 1;
  22626. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22627. this.clow = this.clow << 1 & 0xFFFF;
  22628. this.ct--;
  22629. } while ((a & 0x8000) === 0);
  22630. this.a = a;
  22631. contexts[pos] = cx_index << 1 | cx_mps;
  22632. return d;
  22633. }
  22634. };
  22635. return ArithmeticDecoder;
  22636. }();
  22637. exports.ArithmeticDecoder = ArithmeticDecoder;
  22638. /***/ }),
  22639. /* 14 */
  22640. /***/ (function(module, exports, __w_pdfjs_require__) {
  22641. "use strict";
  22642. var sharedUtil = __w_pdfjs_require__(0);
  22643. var coreCharsets = __w_pdfjs_require__(30);
  22644. var coreEncodings = __w_pdfjs_require__(5);
  22645. var error = sharedUtil.error;
  22646. var info = sharedUtil.info;
  22647. var bytesToString = sharedUtil.bytesToString;
  22648. var warn = sharedUtil.warn;
  22649. var isArray = sharedUtil.isArray;
  22650. var Util = sharedUtil.Util;
  22651. var stringToBytes = sharedUtil.stringToBytes;
  22652. var assert = sharedUtil.assert;
  22653. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22654. var ExpertCharset = coreCharsets.ExpertCharset;
  22655. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22656. var StandardEncoding = coreEncodings.StandardEncoding;
  22657. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22658. var MAX_SUBR_NESTING = 10;
  22659. var CFFStandardStrings = [
  22660. '.notdef',
  22661. 'space',
  22662. 'exclam',
  22663. 'quotedbl',
  22664. 'numbersign',
  22665. 'dollar',
  22666. 'percent',
  22667. 'ampersand',
  22668. 'quoteright',
  22669. 'parenleft',
  22670. 'parenright',
  22671. 'asterisk',
  22672. 'plus',
  22673. 'comma',
  22674. 'hyphen',
  22675. 'period',
  22676. 'slash',
  22677. 'zero',
  22678. 'one',
  22679. 'two',
  22680. 'three',
  22681. 'four',
  22682. 'five',
  22683. 'six',
  22684. 'seven',
  22685. 'eight',
  22686. 'nine',
  22687. 'colon',
  22688. 'semicolon',
  22689. 'less',
  22690. 'equal',
  22691. 'greater',
  22692. 'question',
  22693. 'at',
  22694. 'A',
  22695. 'B',
  22696. 'C',
  22697. 'D',
  22698. 'E',
  22699. 'F',
  22700. 'G',
  22701. 'H',
  22702. 'I',
  22703. 'J',
  22704. 'K',
  22705. 'L',
  22706. 'M',
  22707. 'N',
  22708. 'O',
  22709. 'P',
  22710. 'Q',
  22711. 'R',
  22712. 'S',
  22713. 'T',
  22714. 'U',
  22715. 'V',
  22716. 'W',
  22717. 'X',
  22718. 'Y',
  22719. 'Z',
  22720. 'bracketleft',
  22721. 'backslash',
  22722. 'bracketright',
  22723. 'asciicircum',
  22724. 'underscore',
  22725. 'quoteleft',
  22726. 'a',
  22727. 'b',
  22728. 'c',
  22729. 'd',
  22730. 'e',
  22731. 'f',
  22732. 'g',
  22733. 'h',
  22734. 'i',
  22735. 'j',
  22736. 'k',
  22737. 'l',
  22738. 'm',
  22739. 'n',
  22740. 'o',
  22741. 'p',
  22742. 'q',
  22743. 'r',
  22744. 's',
  22745. 't',
  22746. 'u',
  22747. 'v',
  22748. 'w',
  22749. 'x',
  22750. 'y',
  22751. 'z',
  22752. 'braceleft',
  22753. 'bar',
  22754. 'braceright',
  22755. 'asciitilde',
  22756. 'exclamdown',
  22757. 'cent',
  22758. 'sterling',
  22759. 'fraction',
  22760. 'yen',
  22761. 'florin',
  22762. 'section',
  22763. 'currency',
  22764. 'quotesingle',
  22765. 'quotedblleft',
  22766. 'guillemotleft',
  22767. 'guilsinglleft',
  22768. 'guilsinglright',
  22769. 'fi',
  22770. 'fl',
  22771. 'endash',
  22772. 'dagger',
  22773. 'daggerdbl',
  22774. 'periodcentered',
  22775. 'paragraph',
  22776. 'bullet',
  22777. 'quotesinglbase',
  22778. 'quotedblbase',
  22779. 'quotedblright',
  22780. 'guillemotright',
  22781. 'ellipsis',
  22782. 'perthousand',
  22783. 'questiondown',
  22784. 'grave',
  22785. 'acute',
  22786. 'circumflex',
  22787. 'tilde',
  22788. 'macron',
  22789. 'breve',
  22790. 'dotaccent',
  22791. 'dieresis',
  22792. 'ring',
  22793. 'cedilla',
  22794. 'hungarumlaut',
  22795. 'ogonek',
  22796. 'caron',
  22797. 'emdash',
  22798. 'AE',
  22799. 'ordfeminine',
  22800. 'Lslash',
  22801. 'Oslash',
  22802. 'OE',
  22803. 'ordmasculine',
  22804. 'ae',
  22805. 'dotlessi',
  22806. 'lslash',
  22807. 'oslash',
  22808. 'oe',
  22809. 'germandbls',
  22810. 'onesuperior',
  22811. 'logicalnot',
  22812. 'mu',
  22813. 'trademark',
  22814. 'Eth',
  22815. 'onehalf',
  22816. 'plusminus',
  22817. 'Thorn',
  22818. 'onequarter',
  22819. 'divide',
  22820. 'brokenbar',
  22821. 'degree',
  22822. 'thorn',
  22823. 'threequarters',
  22824. 'twosuperior',
  22825. 'registered',
  22826. 'minus',
  22827. 'eth',
  22828. 'multiply',
  22829. 'threesuperior',
  22830. 'copyright',
  22831. 'Aacute',
  22832. 'Acircumflex',
  22833. 'Adieresis',
  22834. 'Agrave',
  22835. 'Aring',
  22836. 'Atilde',
  22837. 'Ccedilla',
  22838. 'Eacute',
  22839. 'Ecircumflex',
  22840. 'Edieresis',
  22841. 'Egrave',
  22842. 'Iacute',
  22843. 'Icircumflex',
  22844. 'Idieresis',
  22845. 'Igrave',
  22846. 'Ntilde',
  22847. 'Oacute',
  22848. 'Ocircumflex',
  22849. 'Odieresis',
  22850. 'Ograve',
  22851. 'Otilde',
  22852. 'Scaron',
  22853. 'Uacute',
  22854. 'Ucircumflex',
  22855. 'Udieresis',
  22856. 'Ugrave',
  22857. 'Yacute',
  22858. 'Ydieresis',
  22859. 'Zcaron',
  22860. 'aacute',
  22861. 'acircumflex',
  22862. 'adieresis',
  22863. 'agrave',
  22864. 'aring',
  22865. 'atilde',
  22866. 'ccedilla',
  22867. 'eacute',
  22868. 'ecircumflex',
  22869. 'edieresis',
  22870. 'egrave',
  22871. 'iacute',
  22872. 'icircumflex',
  22873. 'idieresis',
  22874. 'igrave',
  22875. 'ntilde',
  22876. 'oacute',
  22877. 'ocircumflex',
  22878. 'odieresis',
  22879. 'ograve',
  22880. 'otilde',
  22881. 'scaron',
  22882. 'uacute',
  22883. 'ucircumflex',
  22884. 'udieresis',
  22885. 'ugrave',
  22886. 'yacute',
  22887. 'ydieresis',
  22888. 'zcaron',
  22889. 'exclamsmall',
  22890. 'Hungarumlautsmall',
  22891. 'dollaroldstyle',
  22892. 'dollarsuperior',
  22893. 'ampersandsmall',
  22894. 'Acutesmall',
  22895. 'parenleftsuperior',
  22896. 'parenrightsuperior',
  22897. 'twodotenleader',
  22898. 'onedotenleader',
  22899. 'zerooldstyle',
  22900. 'oneoldstyle',
  22901. 'twooldstyle',
  22902. 'threeoldstyle',
  22903. 'fouroldstyle',
  22904. 'fiveoldstyle',
  22905. 'sixoldstyle',
  22906. 'sevenoldstyle',
  22907. 'eightoldstyle',
  22908. 'nineoldstyle',
  22909. 'commasuperior',
  22910. 'threequartersemdash',
  22911. 'periodsuperior',
  22912. 'questionsmall',
  22913. 'asuperior',
  22914. 'bsuperior',
  22915. 'centsuperior',
  22916. 'dsuperior',
  22917. 'esuperior',
  22918. 'isuperior',
  22919. 'lsuperior',
  22920. 'msuperior',
  22921. 'nsuperior',
  22922. 'osuperior',
  22923. 'rsuperior',
  22924. 'ssuperior',
  22925. 'tsuperior',
  22926. 'ff',
  22927. 'ffi',
  22928. 'ffl',
  22929. 'parenleftinferior',
  22930. 'parenrightinferior',
  22931. 'Circumflexsmall',
  22932. 'hyphensuperior',
  22933. 'Gravesmall',
  22934. 'Asmall',
  22935. 'Bsmall',
  22936. 'Csmall',
  22937. 'Dsmall',
  22938. 'Esmall',
  22939. 'Fsmall',
  22940. 'Gsmall',
  22941. 'Hsmall',
  22942. 'Ismall',
  22943. 'Jsmall',
  22944. 'Ksmall',
  22945. 'Lsmall',
  22946. 'Msmall',
  22947. 'Nsmall',
  22948. 'Osmall',
  22949. 'Psmall',
  22950. 'Qsmall',
  22951. 'Rsmall',
  22952. 'Ssmall',
  22953. 'Tsmall',
  22954. 'Usmall',
  22955. 'Vsmall',
  22956. 'Wsmall',
  22957. 'Xsmall',
  22958. 'Ysmall',
  22959. 'Zsmall',
  22960. 'colonmonetary',
  22961. 'onefitted',
  22962. 'rupiah',
  22963. 'Tildesmall',
  22964. 'exclamdownsmall',
  22965. 'centoldstyle',
  22966. 'Lslashsmall',
  22967. 'Scaronsmall',
  22968. 'Zcaronsmall',
  22969. 'Dieresissmall',
  22970. 'Brevesmall',
  22971. 'Caronsmall',
  22972. 'Dotaccentsmall',
  22973. 'Macronsmall',
  22974. 'figuredash',
  22975. 'hypheninferior',
  22976. 'Ogoneksmall',
  22977. 'Ringsmall',
  22978. 'Cedillasmall',
  22979. 'questiondownsmall',
  22980. 'oneeighth',
  22981. 'threeeighths',
  22982. 'fiveeighths',
  22983. 'seveneighths',
  22984. 'onethird',
  22985. 'twothirds',
  22986. 'zerosuperior',
  22987. 'foursuperior',
  22988. 'fivesuperior',
  22989. 'sixsuperior',
  22990. 'sevensuperior',
  22991. 'eightsuperior',
  22992. 'ninesuperior',
  22993. 'zeroinferior',
  22994. 'oneinferior',
  22995. 'twoinferior',
  22996. 'threeinferior',
  22997. 'fourinferior',
  22998. 'fiveinferior',
  22999. 'sixinferior',
  23000. 'seveninferior',
  23001. 'eightinferior',
  23002. 'nineinferior',
  23003. 'centinferior',
  23004. 'dollarinferior',
  23005. 'periodinferior',
  23006. 'commainferior',
  23007. 'Agravesmall',
  23008. 'Aacutesmall',
  23009. 'Acircumflexsmall',
  23010. 'Atildesmall',
  23011. 'Adieresissmall',
  23012. 'Aringsmall',
  23013. 'AEsmall',
  23014. 'Ccedillasmall',
  23015. 'Egravesmall',
  23016. 'Eacutesmall',
  23017. 'Ecircumflexsmall',
  23018. 'Edieresissmall',
  23019. 'Igravesmall',
  23020. 'Iacutesmall',
  23021. 'Icircumflexsmall',
  23022. 'Idieresissmall',
  23023. 'Ethsmall',
  23024. 'Ntildesmall',
  23025. 'Ogravesmall',
  23026. 'Oacutesmall',
  23027. 'Ocircumflexsmall',
  23028. 'Otildesmall',
  23029. 'Odieresissmall',
  23030. 'OEsmall',
  23031. 'Oslashsmall',
  23032. 'Ugravesmall',
  23033. 'Uacutesmall',
  23034. 'Ucircumflexsmall',
  23035. 'Udieresissmall',
  23036. 'Yacutesmall',
  23037. 'Thornsmall',
  23038. 'Ydieresissmall',
  23039. '001.000',
  23040. '001.001',
  23041. '001.002',
  23042. '001.003',
  23043. 'Black',
  23044. 'Bold',
  23045. 'Book',
  23046. 'Light',
  23047. 'Medium',
  23048. 'Regular',
  23049. 'Roman',
  23050. 'Semibold'
  23051. ];
  23052. var CFFParser = function CFFParserClosure() {
  23053. var CharstringValidationData = [
  23054. null,
  23055. {
  23056. id: 'hstem',
  23057. min: 2,
  23058. stackClearing: true,
  23059. stem: true
  23060. },
  23061. null,
  23062. {
  23063. id: 'vstem',
  23064. min: 2,
  23065. stackClearing: true,
  23066. stem: true
  23067. },
  23068. {
  23069. id: 'vmoveto',
  23070. min: 1,
  23071. stackClearing: true
  23072. },
  23073. {
  23074. id: 'rlineto',
  23075. min: 2,
  23076. resetStack: true
  23077. },
  23078. {
  23079. id: 'hlineto',
  23080. min: 1,
  23081. resetStack: true
  23082. },
  23083. {
  23084. id: 'vlineto',
  23085. min: 1,
  23086. resetStack: true
  23087. },
  23088. {
  23089. id: 'rrcurveto',
  23090. min: 6,
  23091. resetStack: true
  23092. },
  23093. null,
  23094. {
  23095. id: 'callsubr',
  23096. min: 1,
  23097. undefStack: true
  23098. },
  23099. {
  23100. id: 'return',
  23101. min: 0,
  23102. undefStack: true
  23103. },
  23104. null,
  23105. null,
  23106. {
  23107. id: 'endchar',
  23108. min: 0,
  23109. stackClearing: true
  23110. },
  23111. null,
  23112. null,
  23113. null,
  23114. {
  23115. id: 'hstemhm',
  23116. min: 2,
  23117. stackClearing: true,
  23118. stem: true
  23119. },
  23120. {
  23121. id: 'hintmask',
  23122. min: 0,
  23123. stackClearing: true
  23124. },
  23125. {
  23126. id: 'cntrmask',
  23127. min: 0,
  23128. stackClearing: true
  23129. },
  23130. {
  23131. id: 'rmoveto',
  23132. min: 2,
  23133. stackClearing: true
  23134. },
  23135. {
  23136. id: 'hmoveto',
  23137. min: 1,
  23138. stackClearing: true
  23139. },
  23140. {
  23141. id: 'vstemhm',
  23142. min: 2,
  23143. stackClearing: true,
  23144. stem: true
  23145. },
  23146. {
  23147. id: 'rcurveline',
  23148. min: 8,
  23149. resetStack: true
  23150. },
  23151. {
  23152. id: 'rlinecurve',
  23153. min: 8,
  23154. resetStack: true
  23155. },
  23156. {
  23157. id: 'vvcurveto',
  23158. min: 4,
  23159. resetStack: true
  23160. },
  23161. {
  23162. id: 'hhcurveto',
  23163. min: 4,
  23164. resetStack: true
  23165. },
  23166. null,
  23167. {
  23168. id: 'callgsubr',
  23169. min: 1,
  23170. undefStack: true
  23171. },
  23172. {
  23173. id: 'vhcurveto',
  23174. min: 4,
  23175. resetStack: true
  23176. },
  23177. {
  23178. id: 'hvcurveto',
  23179. min: 4,
  23180. resetStack: true
  23181. }
  23182. ];
  23183. var CharstringValidationData12 = [
  23184. null,
  23185. null,
  23186. null,
  23187. {
  23188. id: 'and',
  23189. min: 2,
  23190. stackDelta: -1
  23191. },
  23192. {
  23193. id: 'or',
  23194. min: 2,
  23195. stackDelta: -1
  23196. },
  23197. {
  23198. id: 'not',
  23199. min: 1,
  23200. stackDelta: 0
  23201. },
  23202. null,
  23203. null,
  23204. null,
  23205. {
  23206. id: 'abs',
  23207. min: 1,
  23208. stackDelta: 0
  23209. },
  23210. {
  23211. id: 'add',
  23212. min: 2,
  23213. stackDelta: -1,
  23214. stackFn: function stack_div(stack, index) {
  23215. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23216. }
  23217. },
  23218. {
  23219. id: 'sub',
  23220. min: 2,
  23221. stackDelta: -1,
  23222. stackFn: function stack_div(stack, index) {
  23223. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23224. }
  23225. },
  23226. {
  23227. id: 'div',
  23228. min: 2,
  23229. stackDelta: -1,
  23230. stackFn: function stack_div(stack, index) {
  23231. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23232. }
  23233. },
  23234. null,
  23235. {
  23236. id: 'neg',
  23237. min: 1,
  23238. stackDelta: 0,
  23239. stackFn: function stack_div(stack, index) {
  23240. stack[index - 1] = -stack[index - 1];
  23241. }
  23242. },
  23243. {
  23244. id: 'eq',
  23245. min: 2,
  23246. stackDelta: -1
  23247. },
  23248. null,
  23249. null,
  23250. {
  23251. id: 'drop',
  23252. min: 1,
  23253. stackDelta: -1
  23254. },
  23255. null,
  23256. {
  23257. id: 'put',
  23258. min: 2,
  23259. stackDelta: -2
  23260. },
  23261. {
  23262. id: 'get',
  23263. min: 1,
  23264. stackDelta: 0
  23265. },
  23266. {
  23267. id: 'ifelse',
  23268. min: 4,
  23269. stackDelta: -3
  23270. },
  23271. {
  23272. id: 'random',
  23273. min: 0,
  23274. stackDelta: 1
  23275. },
  23276. {
  23277. id: 'mul',
  23278. min: 2,
  23279. stackDelta: -1,
  23280. stackFn: function stack_div(stack, index) {
  23281. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23282. }
  23283. },
  23284. null,
  23285. {
  23286. id: 'sqrt',
  23287. min: 1,
  23288. stackDelta: 0
  23289. },
  23290. {
  23291. id: 'dup',
  23292. min: 1,
  23293. stackDelta: 1
  23294. },
  23295. {
  23296. id: 'exch',
  23297. min: 2,
  23298. stackDelta: 0
  23299. },
  23300. {
  23301. id: 'index',
  23302. min: 2,
  23303. stackDelta: 0
  23304. },
  23305. {
  23306. id: 'roll',
  23307. min: 3,
  23308. stackDelta: -2
  23309. },
  23310. null,
  23311. null,
  23312. null,
  23313. {
  23314. id: 'hflex',
  23315. min: 7,
  23316. resetStack: true
  23317. },
  23318. {
  23319. id: 'flex',
  23320. min: 13,
  23321. resetStack: true
  23322. },
  23323. {
  23324. id: 'hflex1',
  23325. min: 9,
  23326. resetStack: true
  23327. },
  23328. {
  23329. id: 'flex1',
  23330. min: 11,
  23331. resetStack: true
  23332. }
  23333. ];
  23334. function CFFParser(file, properties, seacAnalysisEnabled) {
  23335. this.bytes = file.getBytes();
  23336. this.properties = properties;
  23337. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23338. }
  23339. CFFParser.prototype = {
  23340. parse: function CFFParser_parse() {
  23341. var properties = this.properties;
  23342. var cff = new CFF();
  23343. this.cff = cff;
  23344. var header = this.parseHeader();
  23345. var nameIndex = this.parseIndex(header.endPos);
  23346. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23347. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23348. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23349. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23350. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23351. cff.header = header.obj;
  23352. cff.names = this.parseNameIndex(nameIndex.obj);
  23353. cff.strings = this.parseStringIndex(stringIndex.obj);
  23354. cff.topDict = topDict;
  23355. cff.globalSubrIndex = globalSubrIndex.obj;
  23356. this.parsePrivateDict(cff.topDict);
  23357. cff.isCIDFont = topDict.hasName('ROS');
  23358. var charStringOffset = topDict.getByName('CharStrings');
  23359. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23360. var fontMatrix = topDict.getByName('FontMatrix');
  23361. if (fontMatrix) {
  23362. properties.fontMatrix = fontMatrix;
  23363. }
  23364. var fontBBox = topDict.getByName('FontBBox');
  23365. if (fontBBox) {
  23366. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23367. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23368. properties.ascentScaled = true;
  23369. }
  23370. var charset, encoding;
  23371. if (cff.isCIDFont) {
  23372. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23373. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23374. var dictRaw = fdArrayIndex.get(i);
  23375. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23376. this.parsePrivateDict(fontDict);
  23377. cff.fdArray.push(fontDict);
  23378. }
  23379. encoding = null;
  23380. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23381. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23382. } else {
  23383. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23384. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23385. }
  23386. cff.charset = charset;
  23387. cff.encoding = encoding;
  23388. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23389. cff.charStrings = charStringsAndSeacs.charStrings;
  23390. cff.seacs = charStringsAndSeacs.seacs;
  23391. cff.widths = charStringsAndSeacs.widths;
  23392. return cff;
  23393. },
  23394. parseHeader: function CFFParser_parseHeader() {
  23395. var bytes = this.bytes;
  23396. var bytesLength = bytes.length;
  23397. var offset = 0;
  23398. while (offset < bytesLength && bytes[offset] !== 1) {
  23399. ++offset;
  23400. }
  23401. if (offset >= bytesLength) {
  23402. error('Invalid CFF header');
  23403. } else if (offset !== 0) {
  23404. info('cff data is shifted');
  23405. bytes = bytes.subarray(offset);
  23406. this.bytes = bytes;
  23407. }
  23408. var major = bytes[0];
  23409. var minor = bytes[1];
  23410. var hdrSize = bytes[2];
  23411. var offSize = bytes[3];
  23412. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23413. return {
  23414. obj: header,
  23415. endPos: hdrSize
  23416. };
  23417. },
  23418. parseDict: function CFFParser_parseDict(dict) {
  23419. var pos = 0;
  23420. function parseOperand() {
  23421. var value = dict[pos++];
  23422. if (value === 30) {
  23423. return parseFloatOperand();
  23424. } else if (value === 28) {
  23425. value = dict[pos++];
  23426. value = (value << 24 | dict[pos++] << 16) >> 16;
  23427. return value;
  23428. } else if (value === 29) {
  23429. value = dict[pos++];
  23430. value = value << 8 | dict[pos++];
  23431. value = value << 8 | dict[pos++];
  23432. value = value << 8 | dict[pos++];
  23433. return value;
  23434. } else if (value >= 32 && value <= 246) {
  23435. return value - 139;
  23436. } else if (value >= 247 && value <= 250) {
  23437. return (value - 247) * 256 + dict[pos++] + 108;
  23438. } else if (value >= 251 && value <= 254) {
  23439. return -((value - 251) * 256) - dict[pos++] - 108;
  23440. }
  23441. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23442. return NaN;
  23443. }
  23444. function parseFloatOperand() {
  23445. var str = '';
  23446. var eof = 15;
  23447. var lookup = [
  23448. '0',
  23449. '1',
  23450. '2',
  23451. '3',
  23452. '4',
  23453. '5',
  23454. '6',
  23455. '7',
  23456. '8',
  23457. '9',
  23458. '.',
  23459. 'E',
  23460. 'E-',
  23461. null,
  23462. '-'
  23463. ];
  23464. var length = dict.length;
  23465. while (pos < length) {
  23466. var b = dict[pos++];
  23467. var b1 = b >> 4;
  23468. var b2 = b & 15;
  23469. if (b1 === eof) {
  23470. break;
  23471. }
  23472. str += lookup[b1];
  23473. if (b2 === eof) {
  23474. break;
  23475. }
  23476. str += lookup[b2];
  23477. }
  23478. return parseFloat(str);
  23479. }
  23480. var operands = [];
  23481. var entries = [];
  23482. pos = 0;
  23483. var end = dict.length;
  23484. while (pos < end) {
  23485. var b = dict[pos];
  23486. if (b <= 21) {
  23487. if (b === 12) {
  23488. b = b << 8 | dict[++pos];
  23489. }
  23490. entries.push([
  23491. b,
  23492. operands
  23493. ]);
  23494. operands = [];
  23495. ++pos;
  23496. } else {
  23497. operands.push(parseOperand());
  23498. }
  23499. }
  23500. return entries;
  23501. },
  23502. parseIndex: function CFFParser_parseIndex(pos) {
  23503. var cffIndex = new CFFIndex();
  23504. var bytes = this.bytes;
  23505. var count = bytes[pos++] << 8 | bytes[pos++];
  23506. var offsets = [];
  23507. var end = pos;
  23508. var i, ii;
  23509. if (count !== 0) {
  23510. var offsetSize = bytes[pos++];
  23511. var startPos = pos + (count + 1) * offsetSize - 1;
  23512. for (i = 0, ii = count + 1; i < ii; ++i) {
  23513. var offset = 0;
  23514. for (var j = 0; j < offsetSize; ++j) {
  23515. offset <<= 8;
  23516. offset += bytes[pos++];
  23517. }
  23518. offsets.push(startPos + offset);
  23519. }
  23520. end = offsets[count];
  23521. }
  23522. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23523. var offsetStart = offsets[i];
  23524. var offsetEnd = offsets[i + 1];
  23525. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23526. }
  23527. return {
  23528. obj: cffIndex,
  23529. endPos: end
  23530. };
  23531. },
  23532. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23533. var names = [];
  23534. for (var i = 0, ii = index.count; i < ii; ++i) {
  23535. var name = index.get(i);
  23536. var length = Math.min(name.length, 127);
  23537. var data = [];
  23538. for (var j = 0; j < length; ++j) {
  23539. var c = name[j];
  23540. if (j === 0 && c === 0) {
  23541. data[j] = c;
  23542. continue;
  23543. }
  23544. 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) {
  23545. data[j] = 95;
  23546. continue;
  23547. }
  23548. data[j] = c;
  23549. }
  23550. names.push(bytesToString(data));
  23551. }
  23552. return names;
  23553. },
  23554. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23555. var strings = new CFFStrings();
  23556. for (var i = 0, ii = index.count; i < ii; ++i) {
  23557. var data = index.get(i);
  23558. strings.add(bytesToString(data));
  23559. }
  23560. return strings;
  23561. },
  23562. createDict: function CFFParser_createDict(Type, dict, strings) {
  23563. var cffDict = new Type(strings);
  23564. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23565. var pair = dict[i];
  23566. var key = pair[0];
  23567. var value = pair[1];
  23568. cffDict.setByKey(key, value);
  23569. }
  23570. return cffDict;
  23571. },
  23572. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23573. if (state.callDepth > MAX_SUBR_NESTING) {
  23574. return false;
  23575. }
  23576. var stackSize = state.stackSize;
  23577. var stack = state.stack;
  23578. var length = data.length;
  23579. for (var j = 0; j < length;) {
  23580. var value = data[j++];
  23581. var validationCommand = null;
  23582. if (value === 12) {
  23583. var q = data[j++];
  23584. if (q === 0) {
  23585. data[j - 2] = 139;
  23586. data[j - 1] = 22;
  23587. stackSize = 0;
  23588. } else {
  23589. validationCommand = CharstringValidationData12[q];
  23590. }
  23591. } else if (value === 28) {
  23592. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23593. j += 2;
  23594. stackSize++;
  23595. } else if (value === 14) {
  23596. if (stackSize >= 4) {
  23597. stackSize -= 4;
  23598. if (this.seacAnalysisEnabled) {
  23599. state.seac = stack.slice(stackSize, stackSize + 4);
  23600. return false;
  23601. }
  23602. }
  23603. validationCommand = CharstringValidationData[value];
  23604. } else if (value >= 32 && value <= 246) {
  23605. stack[stackSize] = value - 139;
  23606. stackSize++;
  23607. } else if (value >= 247 && value <= 254) {
  23608. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23609. j++;
  23610. stackSize++;
  23611. } else if (value === 255) {
  23612. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23613. j += 4;
  23614. stackSize++;
  23615. } else if (value === 19 || value === 20) {
  23616. state.hints += stackSize >> 1;
  23617. j += state.hints + 7 >> 3;
  23618. stackSize %= 2;
  23619. validationCommand = CharstringValidationData[value];
  23620. } else if (value === 10 || value === 29) {
  23621. var subrsIndex;
  23622. if (value === 10) {
  23623. subrsIndex = localSubrIndex;
  23624. } else {
  23625. subrsIndex = globalSubrIndex;
  23626. }
  23627. if (!subrsIndex) {
  23628. validationCommand = CharstringValidationData[value];
  23629. warn('Missing subrsIndex for ' + validationCommand.id);
  23630. return false;
  23631. }
  23632. var bias = 32768;
  23633. if (subrsIndex.count < 1240) {
  23634. bias = 107;
  23635. } else if (subrsIndex.count < 33900) {
  23636. bias = 1131;
  23637. }
  23638. var subrNumber = stack[--stackSize] + bias;
  23639. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23640. validationCommand = CharstringValidationData[value];
  23641. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23642. return false;
  23643. }
  23644. state.stackSize = stackSize;
  23645. state.callDepth++;
  23646. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23647. if (!valid) {
  23648. return false;
  23649. }
  23650. state.callDepth--;
  23651. stackSize = state.stackSize;
  23652. continue;
  23653. } else if (value === 11) {
  23654. state.stackSize = stackSize;
  23655. return true;
  23656. } else {
  23657. validationCommand = CharstringValidationData[value];
  23658. }
  23659. if (validationCommand) {
  23660. if (validationCommand.stem) {
  23661. state.hints += stackSize >> 1;
  23662. }
  23663. if ('min' in validationCommand) {
  23664. if (!state.undefStack && stackSize < validationCommand.min) {
  23665. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23666. return false;
  23667. }
  23668. }
  23669. if (state.firstStackClearing && validationCommand.stackClearing) {
  23670. state.firstStackClearing = false;
  23671. stackSize -= validationCommand.min;
  23672. if (stackSize >= 2 && validationCommand.stem) {
  23673. stackSize %= 2;
  23674. } else if (stackSize > 1) {
  23675. warn('Found too many parameters for stack-clearing command');
  23676. }
  23677. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23678. state.width = stack[stackSize - 1];
  23679. }
  23680. }
  23681. if ('stackDelta' in validationCommand) {
  23682. if ('stackFn' in validationCommand) {
  23683. validationCommand.stackFn(stack, stackSize);
  23684. }
  23685. stackSize += validationCommand.stackDelta;
  23686. } else if (validationCommand.stackClearing) {
  23687. stackSize = 0;
  23688. } else if (validationCommand.resetStack) {
  23689. stackSize = 0;
  23690. state.undefStack = false;
  23691. } else if (validationCommand.undefStack) {
  23692. stackSize = 0;
  23693. state.undefStack = true;
  23694. state.firstStackClearing = false;
  23695. }
  23696. }
  23697. }
  23698. state.stackSize = stackSize;
  23699. return true;
  23700. },
  23701. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23702. var seacs = [];
  23703. var widths = [];
  23704. var count = charStrings.count;
  23705. for (var i = 0; i < count; i++) {
  23706. var charstring = charStrings.get(i);
  23707. var state = {
  23708. callDepth: 0,
  23709. stackSize: 0,
  23710. stack: [],
  23711. undefStack: true,
  23712. hints: 0,
  23713. firstStackClearing: true,
  23714. seac: null,
  23715. width: null
  23716. };
  23717. var valid = true;
  23718. var localSubrToUse = null;
  23719. if (fdSelect && fdArray.length) {
  23720. var fdIndex = fdSelect.getFDIndex(i);
  23721. if (fdIndex === -1) {
  23722. warn('Glyph index is not in fd select.');
  23723. valid = false;
  23724. }
  23725. if (fdIndex >= fdArray.length) {
  23726. warn('Invalid fd index for glyph index.');
  23727. valid = false;
  23728. }
  23729. if (valid) {
  23730. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23731. }
  23732. } else if (localSubrIndex) {
  23733. localSubrToUse = localSubrIndex;
  23734. }
  23735. if (valid) {
  23736. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23737. }
  23738. if (state.width !== null) {
  23739. widths[i] = state.width;
  23740. }
  23741. if (state.seac !== null) {
  23742. seacs[i] = state.seac;
  23743. }
  23744. if (!valid) {
  23745. charStrings.set(i, new Uint8Array([14]));
  23746. }
  23747. }
  23748. return {
  23749. charStrings: charStrings,
  23750. seacs: seacs,
  23751. widths: widths
  23752. };
  23753. },
  23754. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23755. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23756. parentDict.setByKey(18, [
  23757. 0,
  23758. 0
  23759. ]);
  23760. parentDict.privateDict = privateDict;
  23761. },
  23762. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23763. if (!parentDict.hasName('Private')) {
  23764. this.emptyPrivateDictionary(parentDict);
  23765. return;
  23766. }
  23767. var privateOffset = parentDict.getByName('Private');
  23768. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23769. parentDict.removeByName('Private');
  23770. return;
  23771. }
  23772. var size = privateOffset[0];
  23773. var offset = privateOffset[1];
  23774. if (size === 0 || offset >= this.bytes.length) {
  23775. this.emptyPrivateDictionary(parentDict);
  23776. return;
  23777. }
  23778. var privateDictEnd = offset + size;
  23779. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23780. var dict = this.parseDict(dictData);
  23781. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23782. parentDict.privateDict = privateDict;
  23783. if (!privateDict.getByName('Subrs')) {
  23784. return;
  23785. }
  23786. var subrsOffset = privateDict.getByName('Subrs');
  23787. var relativeOffset = offset + subrsOffset;
  23788. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23789. this.emptyPrivateDictionary(parentDict);
  23790. return;
  23791. }
  23792. var subrsIndex = this.parseIndex(relativeOffset);
  23793. privateDict.subrsIndex = subrsIndex.obj;
  23794. },
  23795. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23796. if (pos === 0) {
  23797. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23798. } else if (pos === 1) {
  23799. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23800. } else if (pos === 2) {
  23801. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23802. }
  23803. var bytes = this.bytes;
  23804. var start = pos;
  23805. var format = bytes[pos++];
  23806. var charset = ['.notdef'];
  23807. var id, count, i;
  23808. length -= 1;
  23809. switch (format) {
  23810. case 0:
  23811. for (i = 0; i < length; i++) {
  23812. id = bytes[pos++] << 8 | bytes[pos++];
  23813. charset.push(cid ? id : strings.get(id));
  23814. }
  23815. break;
  23816. case 1:
  23817. while (charset.length <= length) {
  23818. id = bytes[pos++] << 8 | bytes[pos++];
  23819. count = bytes[pos++];
  23820. for (i = 0; i <= count; i++) {
  23821. charset.push(cid ? id++ : strings.get(id++));
  23822. }
  23823. }
  23824. break;
  23825. case 2:
  23826. while (charset.length <= length) {
  23827. id = bytes[pos++] << 8 | bytes[pos++];
  23828. count = bytes[pos++] << 8 | bytes[pos++];
  23829. for (i = 0; i <= count; i++) {
  23830. charset.push(cid ? id++ : strings.get(id++));
  23831. }
  23832. }
  23833. break;
  23834. default:
  23835. error('Unknown charset format');
  23836. }
  23837. var end = pos;
  23838. var raw = bytes.subarray(start, end);
  23839. return new CFFCharset(false, format, charset, raw);
  23840. },
  23841. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23842. var encoding = Object.create(null);
  23843. var bytes = this.bytes;
  23844. var predefined = false;
  23845. var format, i, ii;
  23846. var raw = null;
  23847. function readSupplement() {
  23848. var supplementsCount = bytes[pos++];
  23849. for (i = 0; i < supplementsCount; i++) {
  23850. var code = bytes[pos++];
  23851. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23852. encoding[code] = charset.indexOf(strings.get(sid));
  23853. }
  23854. }
  23855. if (pos === 0 || pos === 1) {
  23856. predefined = true;
  23857. format = pos;
  23858. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23859. for (i = 0, ii = charset.length; i < ii; i++) {
  23860. var index = baseEncoding.indexOf(charset[i]);
  23861. if (index !== -1) {
  23862. encoding[index] = i;
  23863. }
  23864. }
  23865. } else {
  23866. var dataStart = pos;
  23867. format = bytes[pos++];
  23868. switch (format & 0x7f) {
  23869. case 0:
  23870. var glyphsCount = bytes[pos++];
  23871. for (i = 1; i <= glyphsCount; i++) {
  23872. encoding[bytes[pos++]] = i;
  23873. }
  23874. break;
  23875. case 1:
  23876. var rangesCount = bytes[pos++];
  23877. var gid = 1;
  23878. for (i = 0; i < rangesCount; i++) {
  23879. var start = bytes[pos++];
  23880. var left = bytes[pos++];
  23881. for (var j = start; j <= start + left; j++) {
  23882. encoding[j] = gid++;
  23883. }
  23884. }
  23885. break;
  23886. default:
  23887. error('Unknown encoding format: ' + format + ' in CFF');
  23888. break;
  23889. }
  23890. var dataEnd = pos;
  23891. if (format & 0x80) {
  23892. bytes[dataStart] &= 0x7f;
  23893. readSupplement();
  23894. }
  23895. raw = bytes.subarray(dataStart, dataEnd);
  23896. }
  23897. format = format & 0x7f;
  23898. return new CFFEncoding(predefined, format, encoding, raw);
  23899. },
  23900. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23901. var start = pos;
  23902. var bytes = this.bytes;
  23903. var format = bytes[pos++];
  23904. var fdSelect = [], rawBytes;
  23905. var i, invalidFirstGID = false;
  23906. switch (format) {
  23907. case 0:
  23908. for (i = 0; i < length; ++i) {
  23909. var id = bytes[pos++];
  23910. fdSelect.push(id);
  23911. }
  23912. rawBytes = bytes.subarray(start, pos);
  23913. break;
  23914. case 3:
  23915. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23916. for (i = 0; i < rangesCount; ++i) {
  23917. var first = bytes[pos++] << 8 | bytes[pos++];
  23918. if (i === 0 && first !== 0) {
  23919. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23920. invalidFirstGID = true;
  23921. first = 0;
  23922. }
  23923. var fdIndex = bytes[pos++];
  23924. var next = bytes[pos] << 8 | bytes[pos + 1];
  23925. for (var j = first; j < next; ++j) {
  23926. fdSelect.push(fdIndex);
  23927. }
  23928. }
  23929. pos += 2;
  23930. rawBytes = bytes.subarray(start, pos);
  23931. if (invalidFirstGID) {
  23932. rawBytes[3] = rawBytes[4] = 0;
  23933. }
  23934. break;
  23935. default:
  23936. error('parseFDSelect: Unknown format "' + format + '".');
  23937. break;
  23938. }
  23939. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23940. return new CFFFDSelect(fdSelect, rawBytes);
  23941. }
  23942. };
  23943. return CFFParser;
  23944. }();
  23945. var CFF = function CFFClosure() {
  23946. function CFF() {
  23947. this.header = null;
  23948. this.names = [];
  23949. this.topDict = null;
  23950. this.strings = new CFFStrings();
  23951. this.globalSubrIndex = null;
  23952. this.encoding = null;
  23953. this.charset = null;
  23954. this.charStrings = null;
  23955. this.fdArray = [];
  23956. this.fdSelect = null;
  23957. this.isCIDFont = false;
  23958. }
  23959. return CFF;
  23960. }();
  23961. var CFFHeader = function CFFHeaderClosure() {
  23962. function CFFHeader(major, minor, hdrSize, offSize) {
  23963. this.major = major;
  23964. this.minor = minor;
  23965. this.hdrSize = hdrSize;
  23966. this.offSize = offSize;
  23967. }
  23968. return CFFHeader;
  23969. }();
  23970. var CFFStrings = function CFFStringsClosure() {
  23971. function CFFStrings() {
  23972. this.strings = [];
  23973. }
  23974. CFFStrings.prototype = {
  23975. get: function CFFStrings_get(index) {
  23976. if (index >= 0 && index <= 390) {
  23977. return CFFStandardStrings[index];
  23978. }
  23979. if (index - 391 <= this.strings.length) {
  23980. return this.strings[index - 391];
  23981. }
  23982. return CFFStandardStrings[0];
  23983. },
  23984. add: function CFFStrings_add(value) {
  23985. this.strings.push(value);
  23986. },
  23987. get count() {
  23988. return this.strings.length;
  23989. }
  23990. };
  23991. return CFFStrings;
  23992. }();
  23993. var CFFIndex = function CFFIndexClosure() {
  23994. function CFFIndex() {
  23995. this.objects = [];
  23996. this.length = 0;
  23997. }
  23998. CFFIndex.prototype = {
  23999. add: function CFFIndex_add(data) {
  24000. this.length += data.length;
  24001. this.objects.push(data);
  24002. },
  24003. set: function CFFIndex_set(index, data) {
  24004. this.length += data.length - this.objects[index].length;
  24005. this.objects[index] = data;
  24006. },
  24007. get: function CFFIndex_get(index) {
  24008. return this.objects[index];
  24009. },
  24010. get count() {
  24011. return this.objects.length;
  24012. }
  24013. };
  24014. return CFFIndex;
  24015. }();
  24016. var CFFDict = function CFFDictClosure() {
  24017. function CFFDict(tables, strings) {
  24018. this.keyToNameMap = tables.keyToNameMap;
  24019. this.nameToKeyMap = tables.nameToKeyMap;
  24020. this.defaults = tables.defaults;
  24021. this.types = tables.types;
  24022. this.opcodes = tables.opcodes;
  24023. this.order = tables.order;
  24024. this.strings = strings;
  24025. this.values = Object.create(null);
  24026. }
  24027. CFFDict.prototype = {
  24028. setByKey: function CFFDict_setByKey(key, value) {
  24029. if (!(key in this.keyToNameMap)) {
  24030. return false;
  24031. }
  24032. var valueLength = value.length;
  24033. if (valueLength === 0) {
  24034. return true;
  24035. }
  24036. for (var i = 0; i < valueLength; i++) {
  24037. if (isNaN(value[i])) {
  24038. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24039. return true;
  24040. }
  24041. }
  24042. var type = this.types[key];
  24043. if (type === 'num' || type === 'sid' || type === 'offset') {
  24044. value = value[0];
  24045. }
  24046. this.values[key] = value;
  24047. return true;
  24048. },
  24049. setByName: function CFFDict_setByName(name, value) {
  24050. if (!(name in this.nameToKeyMap)) {
  24051. error('Invalid dictionary name "' + name + '"');
  24052. }
  24053. this.values[this.nameToKeyMap[name]] = value;
  24054. },
  24055. hasName: function CFFDict_hasName(name) {
  24056. return this.nameToKeyMap[name] in this.values;
  24057. },
  24058. getByName: function CFFDict_getByName(name) {
  24059. if (!(name in this.nameToKeyMap)) {
  24060. error('Invalid dictionary name "' + name + '"');
  24061. }
  24062. var key = this.nameToKeyMap[name];
  24063. if (!(key in this.values)) {
  24064. return this.defaults[key];
  24065. }
  24066. return this.values[key];
  24067. },
  24068. removeByName: function CFFDict_removeByName(name) {
  24069. delete this.values[this.nameToKeyMap[name]];
  24070. }
  24071. };
  24072. CFFDict.createTables = function CFFDict_createTables(layout) {
  24073. var tables = {
  24074. keyToNameMap: {},
  24075. nameToKeyMap: {},
  24076. defaults: {},
  24077. types: {},
  24078. opcodes: {},
  24079. order: []
  24080. };
  24081. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24082. var entry = layout[i];
  24083. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24084. tables.keyToNameMap[key] = entry[1];
  24085. tables.nameToKeyMap[entry[1]] = key;
  24086. tables.types[key] = entry[2];
  24087. tables.defaults[key] = entry[3];
  24088. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24089. tables.order.push(key);
  24090. }
  24091. return tables;
  24092. };
  24093. return CFFDict;
  24094. }();
  24095. var CFFTopDict = function CFFTopDictClosure() {
  24096. var layout = [
  24097. [
  24098. [
  24099. 12,
  24100. 30
  24101. ],
  24102. 'ROS',
  24103. [
  24104. 'sid',
  24105. 'sid',
  24106. 'num'
  24107. ],
  24108. null
  24109. ],
  24110. [
  24111. [
  24112. 12,
  24113. 20
  24114. ],
  24115. 'SyntheticBase',
  24116. 'num',
  24117. null
  24118. ],
  24119. [
  24120. 0,
  24121. 'version',
  24122. 'sid',
  24123. null
  24124. ],
  24125. [
  24126. 1,
  24127. 'Notice',
  24128. 'sid',
  24129. null
  24130. ],
  24131. [
  24132. [
  24133. 12,
  24134. 0
  24135. ],
  24136. 'Copyright',
  24137. 'sid',
  24138. null
  24139. ],
  24140. [
  24141. 2,
  24142. 'FullName',
  24143. 'sid',
  24144. null
  24145. ],
  24146. [
  24147. 3,
  24148. 'FamilyName',
  24149. 'sid',
  24150. null
  24151. ],
  24152. [
  24153. 4,
  24154. 'Weight',
  24155. 'sid',
  24156. null
  24157. ],
  24158. [
  24159. [
  24160. 12,
  24161. 1
  24162. ],
  24163. 'isFixedPitch',
  24164. 'num',
  24165. 0
  24166. ],
  24167. [
  24168. [
  24169. 12,
  24170. 2
  24171. ],
  24172. 'ItalicAngle',
  24173. 'num',
  24174. 0
  24175. ],
  24176. [
  24177. [
  24178. 12,
  24179. 3
  24180. ],
  24181. 'UnderlinePosition',
  24182. 'num',
  24183. -100
  24184. ],
  24185. [
  24186. [
  24187. 12,
  24188. 4
  24189. ],
  24190. 'UnderlineThickness',
  24191. 'num',
  24192. 50
  24193. ],
  24194. [
  24195. [
  24196. 12,
  24197. 5
  24198. ],
  24199. 'PaintType',
  24200. 'num',
  24201. 0
  24202. ],
  24203. [
  24204. [
  24205. 12,
  24206. 6
  24207. ],
  24208. 'CharstringType',
  24209. 'num',
  24210. 2
  24211. ],
  24212. [
  24213. [
  24214. 12,
  24215. 7
  24216. ],
  24217. 'FontMatrix',
  24218. [
  24219. 'num',
  24220. 'num',
  24221. 'num',
  24222. 'num',
  24223. 'num',
  24224. 'num'
  24225. ],
  24226. [
  24227. 0.001,
  24228. 0,
  24229. 0,
  24230. 0.001,
  24231. 0,
  24232. 0
  24233. ]
  24234. ],
  24235. [
  24236. 13,
  24237. 'UniqueID',
  24238. 'num',
  24239. null
  24240. ],
  24241. [
  24242. 5,
  24243. 'FontBBox',
  24244. [
  24245. 'num',
  24246. 'num',
  24247. 'num',
  24248. 'num'
  24249. ],
  24250. [
  24251. 0,
  24252. 0,
  24253. 0,
  24254. 0
  24255. ]
  24256. ],
  24257. [
  24258. [
  24259. 12,
  24260. 8
  24261. ],
  24262. 'StrokeWidth',
  24263. 'num',
  24264. 0
  24265. ],
  24266. [
  24267. 14,
  24268. 'XUID',
  24269. 'array',
  24270. null
  24271. ],
  24272. [
  24273. 15,
  24274. 'charset',
  24275. 'offset',
  24276. 0
  24277. ],
  24278. [
  24279. 16,
  24280. 'Encoding',
  24281. 'offset',
  24282. 0
  24283. ],
  24284. [
  24285. 17,
  24286. 'CharStrings',
  24287. 'offset',
  24288. 0
  24289. ],
  24290. [
  24291. 18,
  24292. 'Private',
  24293. [
  24294. 'offset',
  24295. 'offset'
  24296. ],
  24297. null
  24298. ],
  24299. [
  24300. [
  24301. 12,
  24302. 21
  24303. ],
  24304. 'PostScript',
  24305. 'sid',
  24306. null
  24307. ],
  24308. [
  24309. [
  24310. 12,
  24311. 22
  24312. ],
  24313. 'BaseFontName',
  24314. 'sid',
  24315. null
  24316. ],
  24317. [
  24318. [
  24319. 12,
  24320. 23
  24321. ],
  24322. 'BaseFontBlend',
  24323. 'delta',
  24324. null
  24325. ],
  24326. [
  24327. [
  24328. 12,
  24329. 31
  24330. ],
  24331. 'CIDFontVersion',
  24332. 'num',
  24333. 0
  24334. ],
  24335. [
  24336. [
  24337. 12,
  24338. 32
  24339. ],
  24340. 'CIDFontRevision',
  24341. 'num',
  24342. 0
  24343. ],
  24344. [
  24345. [
  24346. 12,
  24347. 33
  24348. ],
  24349. 'CIDFontType',
  24350. 'num',
  24351. 0
  24352. ],
  24353. [
  24354. [
  24355. 12,
  24356. 34
  24357. ],
  24358. 'CIDCount',
  24359. 'num',
  24360. 8720
  24361. ],
  24362. [
  24363. [
  24364. 12,
  24365. 35
  24366. ],
  24367. 'UIDBase',
  24368. 'num',
  24369. null
  24370. ],
  24371. [
  24372. [
  24373. 12,
  24374. 37
  24375. ],
  24376. 'FDSelect',
  24377. 'offset',
  24378. null
  24379. ],
  24380. [
  24381. [
  24382. 12,
  24383. 36
  24384. ],
  24385. 'FDArray',
  24386. 'offset',
  24387. null
  24388. ],
  24389. [
  24390. [
  24391. 12,
  24392. 38
  24393. ],
  24394. 'FontName',
  24395. 'sid',
  24396. null
  24397. ]
  24398. ];
  24399. var tables = null;
  24400. function CFFTopDict(strings) {
  24401. if (tables === null) {
  24402. tables = CFFDict.createTables(layout);
  24403. }
  24404. CFFDict.call(this, tables, strings);
  24405. this.privateDict = null;
  24406. }
  24407. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24408. return CFFTopDict;
  24409. }();
  24410. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24411. var layout = [
  24412. [
  24413. 6,
  24414. 'BlueValues',
  24415. 'delta',
  24416. null
  24417. ],
  24418. [
  24419. 7,
  24420. 'OtherBlues',
  24421. 'delta',
  24422. null
  24423. ],
  24424. [
  24425. 8,
  24426. 'FamilyBlues',
  24427. 'delta',
  24428. null
  24429. ],
  24430. [
  24431. 9,
  24432. 'FamilyOtherBlues',
  24433. 'delta',
  24434. null
  24435. ],
  24436. [
  24437. [
  24438. 12,
  24439. 9
  24440. ],
  24441. 'BlueScale',
  24442. 'num',
  24443. 0.039625
  24444. ],
  24445. [
  24446. [
  24447. 12,
  24448. 10
  24449. ],
  24450. 'BlueShift',
  24451. 'num',
  24452. 7
  24453. ],
  24454. [
  24455. [
  24456. 12,
  24457. 11
  24458. ],
  24459. 'BlueFuzz',
  24460. 'num',
  24461. 1
  24462. ],
  24463. [
  24464. 10,
  24465. 'StdHW',
  24466. 'num',
  24467. null
  24468. ],
  24469. [
  24470. 11,
  24471. 'StdVW',
  24472. 'num',
  24473. null
  24474. ],
  24475. [
  24476. [
  24477. 12,
  24478. 12
  24479. ],
  24480. 'StemSnapH',
  24481. 'delta',
  24482. null
  24483. ],
  24484. [
  24485. [
  24486. 12,
  24487. 13
  24488. ],
  24489. 'StemSnapV',
  24490. 'delta',
  24491. null
  24492. ],
  24493. [
  24494. [
  24495. 12,
  24496. 14
  24497. ],
  24498. 'ForceBold',
  24499. 'num',
  24500. 0
  24501. ],
  24502. [
  24503. [
  24504. 12,
  24505. 17
  24506. ],
  24507. 'LanguageGroup',
  24508. 'num',
  24509. 0
  24510. ],
  24511. [
  24512. [
  24513. 12,
  24514. 18
  24515. ],
  24516. 'ExpansionFactor',
  24517. 'num',
  24518. 0.06
  24519. ],
  24520. [
  24521. [
  24522. 12,
  24523. 19
  24524. ],
  24525. 'initialRandomSeed',
  24526. 'num',
  24527. 0
  24528. ],
  24529. [
  24530. 20,
  24531. 'defaultWidthX',
  24532. 'num',
  24533. 0
  24534. ],
  24535. [
  24536. 21,
  24537. 'nominalWidthX',
  24538. 'num',
  24539. 0
  24540. ],
  24541. [
  24542. 19,
  24543. 'Subrs',
  24544. 'offset',
  24545. null
  24546. ]
  24547. ];
  24548. var tables = null;
  24549. function CFFPrivateDict(strings) {
  24550. if (tables === null) {
  24551. tables = CFFDict.createTables(layout);
  24552. }
  24553. CFFDict.call(this, tables, strings);
  24554. this.subrsIndex = null;
  24555. }
  24556. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24557. return CFFPrivateDict;
  24558. }();
  24559. var CFFCharsetPredefinedTypes = {
  24560. ISO_ADOBE: 0,
  24561. EXPERT: 1,
  24562. EXPERT_SUBSET: 2
  24563. };
  24564. var CFFCharset = function CFFCharsetClosure() {
  24565. function CFFCharset(predefined, format, charset, raw) {
  24566. this.predefined = predefined;
  24567. this.format = format;
  24568. this.charset = charset;
  24569. this.raw = raw;
  24570. }
  24571. return CFFCharset;
  24572. }();
  24573. var CFFEncoding = function CFFEncodingClosure() {
  24574. function CFFEncoding(predefined, format, encoding, raw) {
  24575. this.predefined = predefined;
  24576. this.format = format;
  24577. this.encoding = encoding;
  24578. this.raw = raw;
  24579. }
  24580. return CFFEncoding;
  24581. }();
  24582. var CFFFDSelect = function CFFFDSelectClosure() {
  24583. function CFFFDSelect(fdSelect, raw) {
  24584. this.fdSelect = fdSelect;
  24585. this.raw = raw;
  24586. }
  24587. CFFFDSelect.prototype = {
  24588. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24589. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24590. return -1;
  24591. }
  24592. return this.fdSelect[glyphIndex];
  24593. }
  24594. };
  24595. return CFFFDSelect;
  24596. }();
  24597. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24598. function CFFOffsetTracker() {
  24599. this.offsets = Object.create(null);
  24600. }
  24601. CFFOffsetTracker.prototype = {
  24602. isTracking: function CFFOffsetTracker_isTracking(key) {
  24603. return key in this.offsets;
  24604. },
  24605. track: function CFFOffsetTracker_track(key, location) {
  24606. if (key in this.offsets) {
  24607. error('Already tracking location of ' + key);
  24608. }
  24609. this.offsets[key] = location;
  24610. },
  24611. offset: function CFFOffsetTracker_offset(value) {
  24612. for (var key in this.offsets) {
  24613. this.offsets[key] += value;
  24614. }
  24615. },
  24616. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24617. if (!(key in this.offsets)) {
  24618. error('Not tracking location of ' + key);
  24619. }
  24620. var data = output.data;
  24621. var dataOffset = this.offsets[key];
  24622. var size = 5;
  24623. for (var i = 0, ii = values.length; i < ii; ++i) {
  24624. var offset0 = i * size + dataOffset;
  24625. var offset1 = offset0 + 1;
  24626. var offset2 = offset0 + 2;
  24627. var offset3 = offset0 + 3;
  24628. var offset4 = offset0 + 4;
  24629. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24630. error('writing to an offset that is not empty');
  24631. }
  24632. var value = values[i];
  24633. data[offset0] = 0x1d;
  24634. data[offset1] = value >> 24 & 0xFF;
  24635. data[offset2] = value >> 16 & 0xFF;
  24636. data[offset3] = value >> 8 & 0xFF;
  24637. data[offset4] = value & 0xFF;
  24638. }
  24639. }
  24640. };
  24641. return CFFOffsetTracker;
  24642. }();
  24643. var CFFCompiler = function CFFCompilerClosure() {
  24644. function CFFCompiler(cff) {
  24645. this.cff = cff;
  24646. }
  24647. CFFCompiler.prototype = {
  24648. compile: function CFFCompiler_compile() {
  24649. var cff = this.cff;
  24650. var output = {
  24651. data: [],
  24652. length: 0,
  24653. add: function CFFCompiler_add(data) {
  24654. this.data = this.data.concat(data);
  24655. this.length = this.data.length;
  24656. }
  24657. };
  24658. var header = this.compileHeader(cff.header);
  24659. output.add(header);
  24660. var nameIndex = this.compileNameIndex(cff.names);
  24661. output.add(nameIndex);
  24662. if (cff.isCIDFont) {
  24663. if (cff.topDict.hasName('FontMatrix')) {
  24664. var base = cff.topDict.getByName('FontMatrix');
  24665. cff.topDict.removeByName('FontMatrix');
  24666. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24667. var subDict = cff.fdArray[i];
  24668. var matrix = base.slice(0);
  24669. if (subDict.hasName('FontMatrix')) {
  24670. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24671. }
  24672. subDict.setByName('FontMatrix', matrix);
  24673. }
  24674. }
  24675. }
  24676. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24677. output.add(compiled.output);
  24678. var topDictTracker = compiled.trackers[0];
  24679. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24680. output.add(stringIndex);
  24681. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24682. output.add(globalSubrIndex);
  24683. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24684. if (cff.encoding.predefined) {
  24685. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24686. } else {
  24687. var encoding = this.compileEncoding(cff.encoding);
  24688. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24689. output.add(encoding);
  24690. }
  24691. }
  24692. if (cff.charset && cff.topDict.hasName('charset')) {
  24693. if (cff.charset.predefined) {
  24694. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24695. } else {
  24696. var charset = this.compileCharset(cff.charset);
  24697. topDictTracker.setEntryLocation('charset', [output.length], output);
  24698. output.add(charset);
  24699. }
  24700. }
  24701. var charStrings = this.compileCharStrings(cff.charStrings);
  24702. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24703. output.add(charStrings);
  24704. if (cff.isCIDFont) {
  24705. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24706. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24707. output.add(fdSelect);
  24708. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24709. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24710. output.add(compiled.output);
  24711. var fontDictTrackers = compiled.trackers;
  24712. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24713. }
  24714. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24715. output.add([0]);
  24716. return output.data;
  24717. },
  24718. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24719. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24720. return this.encodeInteger(value);
  24721. }
  24722. return this.encodeFloat(value);
  24723. },
  24724. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24725. var value = num.toString();
  24726. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24727. if (m) {
  24728. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24729. value = (Math.round(num * epsilon) / epsilon).toString();
  24730. }
  24731. var nibbles = '';
  24732. var i, ii;
  24733. for (i = 0, ii = value.length; i < ii; ++i) {
  24734. var a = value[i];
  24735. if (a === 'e') {
  24736. nibbles += value[++i] === '-' ? 'c' : 'b';
  24737. } else if (a === '.') {
  24738. nibbles += 'a';
  24739. } else if (a === '-') {
  24740. nibbles += 'e';
  24741. } else {
  24742. nibbles += a;
  24743. }
  24744. }
  24745. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24746. var out = [30];
  24747. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24748. out.push(parseInt(nibbles.substr(i, 2), 16));
  24749. }
  24750. return out;
  24751. },
  24752. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24753. var code;
  24754. if (value >= -107 && value <= 107) {
  24755. code = [value + 139];
  24756. } else if (value >= 108 && value <= 1131) {
  24757. value = value - 108;
  24758. code = [
  24759. (value >> 8) + 247,
  24760. value & 0xFF
  24761. ];
  24762. } else if (value >= -1131 && value <= -108) {
  24763. value = -value - 108;
  24764. code = [
  24765. (value >> 8) + 251,
  24766. value & 0xFF
  24767. ];
  24768. } else if (value >= -32768 && value <= 32767) {
  24769. code = [
  24770. 0x1c,
  24771. value >> 8 & 0xFF,
  24772. value & 0xFF
  24773. ];
  24774. } else {
  24775. code = [
  24776. 0x1d,
  24777. value >> 24 & 0xFF,
  24778. value >> 16 & 0xFF,
  24779. value >> 8 & 0xFF,
  24780. value & 0xFF
  24781. ];
  24782. }
  24783. return code;
  24784. },
  24785. compileHeader: function CFFCompiler_compileHeader(header) {
  24786. return [
  24787. header.major,
  24788. header.minor,
  24789. header.hdrSize,
  24790. header.offSize
  24791. ];
  24792. },
  24793. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24794. var nameIndex = new CFFIndex();
  24795. for (var i = 0, ii = names.length; i < ii; ++i) {
  24796. nameIndex.add(stringToBytes(names[i]));
  24797. }
  24798. return this.compileIndex(nameIndex);
  24799. },
  24800. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24801. var fontDictTrackers = [];
  24802. var fdArrayIndex = new CFFIndex();
  24803. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24804. var fontDict = dicts[i];
  24805. if (removeCidKeys) {
  24806. fontDict.removeByName('CIDFontVersion');
  24807. fontDict.removeByName('CIDFontRevision');
  24808. fontDict.removeByName('CIDFontType');
  24809. fontDict.removeByName('CIDCount');
  24810. fontDict.removeByName('UIDBase');
  24811. }
  24812. var fontDictTracker = new CFFOffsetTracker();
  24813. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24814. fontDictTrackers.push(fontDictTracker);
  24815. fdArrayIndex.add(fontDictData);
  24816. fontDictTracker.offset(length);
  24817. }
  24818. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24819. return {
  24820. trackers: fontDictTrackers,
  24821. output: fdArrayIndex
  24822. };
  24823. },
  24824. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24825. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24826. var fontDict = dicts[i];
  24827. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24828. var privateDict = fontDict.privateDict;
  24829. var privateDictTracker = new CFFOffsetTracker();
  24830. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24831. var outputLength = output.length;
  24832. privateDictTracker.offset(outputLength);
  24833. if (!privateDictData.length) {
  24834. outputLength = 0;
  24835. }
  24836. trackers[i].setEntryLocation('Private', [
  24837. privateDictData.length,
  24838. outputLength
  24839. ], output);
  24840. output.add(privateDictData);
  24841. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24842. var subrs = this.compileIndex(privateDict.subrsIndex);
  24843. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24844. output.add(subrs);
  24845. }
  24846. }
  24847. },
  24848. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24849. var out = [];
  24850. var order = dict.order;
  24851. for (var i = 0; i < order.length; ++i) {
  24852. var key = order[i];
  24853. if (!(key in dict.values)) {
  24854. continue;
  24855. }
  24856. var values = dict.values[key];
  24857. var types = dict.types[key];
  24858. if (!isArray(types)) {
  24859. types = [types];
  24860. }
  24861. if (!isArray(values)) {
  24862. values = [values];
  24863. }
  24864. if (values.length === 0) {
  24865. continue;
  24866. }
  24867. for (var j = 0, jj = types.length; j < jj; ++j) {
  24868. var type = types[j];
  24869. var value = values[j];
  24870. switch (type) {
  24871. case 'num':
  24872. case 'sid':
  24873. out = out.concat(this.encodeNumber(value));
  24874. break;
  24875. case 'offset':
  24876. var name = dict.keyToNameMap[key];
  24877. if (!offsetTracker.isTracking(name)) {
  24878. offsetTracker.track(name, out.length);
  24879. }
  24880. out = out.concat([
  24881. 0x1d,
  24882. 0,
  24883. 0,
  24884. 0,
  24885. 0
  24886. ]);
  24887. break;
  24888. case 'array':
  24889. case 'delta':
  24890. out = out.concat(this.encodeNumber(value));
  24891. for (var k = 1, kk = values.length; k < kk; ++k) {
  24892. out = out.concat(this.encodeNumber(values[k]));
  24893. }
  24894. break;
  24895. default:
  24896. error('Unknown data type of ' + type);
  24897. break;
  24898. }
  24899. }
  24900. out = out.concat(dict.opcodes[key]);
  24901. }
  24902. return out;
  24903. },
  24904. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24905. var stringIndex = new CFFIndex();
  24906. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24907. stringIndex.add(stringToBytes(strings[i]));
  24908. }
  24909. return this.compileIndex(stringIndex);
  24910. },
  24911. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24912. var globalSubrIndex = this.cff.globalSubrIndex;
  24913. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24914. },
  24915. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24916. return this.compileIndex(charStrings);
  24917. },
  24918. compileCharset: function CFFCompiler_compileCharset(charset) {
  24919. return this.compileTypedArray(charset.raw);
  24920. },
  24921. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24922. return this.compileTypedArray(encoding.raw);
  24923. },
  24924. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24925. return this.compileTypedArray(fdSelect);
  24926. },
  24927. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24928. var out = [];
  24929. for (var i = 0, ii = data.length; i < ii; ++i) {
  24930. out[i] = data[i];
  24931. }
  24932. return out;
  24933. },
  24934. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24935. trackers = trackers || [];
  24936. var objects = index.objects;
  24937. var count = objects.length;
  24938. if (count === 0) {
  24939. return [
  24940. 0,
  24941. 0,
  24942. 0
  24943. ];
  24944. }
  24945. var data = [
  24946. count >> 8 & 0xFF,
  24947. count & 0xff
  24948. ];
  24949. var lastOffset = 1, i;
  24950. for (i = 0; i < count; ++i) {
  24951. lastOffset += objects[i].length;
  24952. }
  24953. var offsetSize;
  24954. if (lastOffset < 0x100) {
  24955. offsetSize = 1;
  24956. } else if (lastOffset < 0x10000) {
  24957. offsetSize = 2;
  24958. } else if (lastOffset < 0x1000000) {
  24959. offsetSize = 3;
  24960. } else {
  24961. offsetSize = 4;
  24962. }
  24963. data.push(offsetSize);
  24964. var relativeOffset = 1;
  24965. for (i = 0; i < count + 1; i++) {
  24966. if (offsetSize === 1) {
  24967. data.push(relativeOffset & 0xFF);
  24968. } else if (offsetSize === 2) {
  24969. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24970. } else if (offsetSize === 3) {
  24971. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24972. } else {
  24973. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24974. }
  24975. if (objects[i]) {
  24976. relativeOffset += objects[i].length;
  24977. }
  24978. }
  24979. for (i = 0; i < count; i++) {
  24980. if (trackers[i]) {
  24981. trackers[i].offset(data.length);
  24982. }
  24983. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24984. data.push(objects[i][j]);
  24985. }
  24986. }
  24987. return data;
  24988. }
  24989. };
  24990. return CFFCompiler;
  24991. }();
  24992. exports.CFFStandardStrings = CFFStandardStrings;
  24993. exports.CFFParser = CFFParser;
  24994. exports.CFF = CFF;
  24995. exports.CFFHeader = CFFHeader;
  24996. exports.CFFStrings = CFFStrings;
  24997. exports.CFFIndex = CFFIndex;
  24998. exports.CFFCharset = CFFCharset;
  24999. exports.CFFTopDict = CFFTopDict;
  25000. exports.CFFPrivateDict = CFFPrivateDict;
  25001. exports.CFFCompiler = CFFCompiler;
  25002. /***/ }),
  25003. /* 15 */
  25004. /***/ (function(module, exports, __w_pdfjs_require__) {
  25005. "use strict";
  25006. var sharedUtil = __w_pdfjs_require__(0);
  25007. var MissingDataException = sharedUtil.MissingDataException;
  25008. var arrayByteLength = sharedUtil.arrayByteLength;
  25009. var arraysToBytes = sharedUtil.arraysToBytes;
  25010. var assert = sharedUtil.assert;
  25011. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25012. var isInt = sharedUtil.isInt;
  25013. var isEmptyObj = sharedUtil.isEmptyObj;
  25014. var ChunkedStream = function ChunkedStreamClosure() {
  25015. function ChunkedStream(length, chunkSize, manager) {
  25016. this.bytes = new Uint8Array(length);
  25017. this.start = 0;
  25018. this.pos = 0;
  25019. this.end = length;
  25020. this.chunkSize = chunkSize;
  25021. this.loadedChunks = [];
  25022. this.numChunksLoaded = 0;
  25023. this.numChunks = Math.ceil(length / chunkSize);
  25024. this.manager = manager;
  25025. this.progressiveDataLength = 0;
  25026. this.lastSuccessfulEnsureByteChunk = -1;
  25027. }
  25028. ChunkedStream.prototype = {
  25029. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25030. var chunks = [];
  25031. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25032. if (!this.loadedChunks[chunk]) {
  25033. chunks.push(chunk);
  25034. }
  25035. }
  25036. return chunks;
  25037. },
  25038. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25039. return [this];
  25040. },
  25041. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25042. return this.numChunksLoaded === this.numChunks;
  25043. },
  25044. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25045. var end = begin + chunk.byteLength;
  25046. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25047. var length = this.bytes.length;
  25048. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25049. this.bytes.set(new Uint8Array(chunk), begin);
  25050. var chunkSize = this.chunkSize;
  25051. var beginChunk = Math.floor(begin / chunkSize);
  25052. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25053. var curChunk;
  25054. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25055. if (!this.loadedChunks[curChunk]) {
  25056. this.loadedChunks[curChunk] = true;
  25057. ++this.numChunksLoaded;
  25058. }
  25059. }
  25060. },
  25061. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25062. var position = this.progressiveDataLength;
  25063. var beginChunk = Math.floor(position / this.chunkSize);
  25064. this.bytes.set(new Uint8Array(data), position);
  25065. position += data.byteLength;
  25066. this.progressiveDataLength = position;
  25067. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25068. var curChunk;
  25069. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25070. if (!this.loadedChunks[curChunk]) {
  25071. this.loadedChunks[curChunk] = true;
  25072. ++this.numChunksLoaded;
  25073. }
  25074. }
  25075. },
  25076. ensureByte: function ChunkedStream_ensureByte(pos) {
  25077. var chunk = Math.floor(pos / this.chunkSize);
  25078. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25079. return;
  25080. }
  25081. if (!this.loadedChunks[chunk]) {
  25082. throw new MissingDataException(pos, pos + 1);
  25083. }
  25084. this.lastSuccessfulEnsureByteChunk = chunk;
  25085. },
  25086. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25087. if (begin >= end) {
  25088. return;
  25089. }
  25090. if (end <= this.progressiveDataLength) {
  25091. return;
  25092. }
  25093. var chunkSize = this.chunkSize;
  25094. var beginChunk = Math.floor(begin / chunkSize);
  25095. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25096. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25097. if (!this.loadedChunks[chunk]) {
  25098. throw new MissingDataException(begin, end);
  25099. }
  25100. }
  25101. },
  25102. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25103. var chunk, numChunks = this.numChunks;
  25104. for (var i = 0; i < numChunks; ++i) {
  25105. chunk = (beginChunk + i) % numChunks;
  25106. if (!this.loadedChunks[chunk]) {
  25107. return chunk;
  25108. }
  25109. }
  25110. return null;
  25111. },
  25112. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25113. return !!this.loadedChunks[chunk];
  25114. },
  25115. get length() {
  25116. return this.end - this.start;
  25117. },
  25118. get isEmpty() {
  25119. return this.length === 0;
  25120. },
  25121. getByte: function ChunkedStream_getByte() {
  25122. var pos = this.pos;
  25123. if (pos >= this.end) {
  25124. return -1;
  25125. }
  25126. this.ensureByte(pos);
  25127. return this.bytes[this.pos++];
  25128. },
  25129. getUint16: function ChunkedStream_getUint16() {
  25130. var b0 = this.getByte();
  25131. var b1 = this.getByte();
  25132. if (b0 === -1 || b1 === -1) {
  25133. return -1;
  25134. }
  25135. return (b0 << 8) + b1;
  25136. },
  25137. getInt32: function ChunkedStream_getInt32() {
  25138. var b0 = this.getByte();
  25139. var b1 = this.getByte();
  25140. var b2 = this.getByte();
  25141. var b3 = this.getByte();
  25142. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25143. },
  25144. getBytes: function ChunkedStream_getBytes(length) {
  25145. var bytes = this.bytes;
  25146. var pos = this.pos;
  25147. var strEnd = this.end;
  25148. if (!length) {
  25149. this.ensureRange(pos, strEnd);
  25150. return bytes.subarray(pos, strEnd);
  25151. }
  25152. var end = pos + length;
  25153. if (end > strEnd) {
  25154. end = strEnd;
  25155. }
  25156. this.ensureRange(pos, end);
  25157. this.pos = end;
  25158. return bytes.subarray(pos, end);
  25159. },
  25160. peekByte: function ChunkedStream_peekByte() {
  25161. var peekedByte = this.getByte();
  25162. this.pos--;
  25163. return peekedByte;
  25164. },
  25165. peekBytes: function ChunkedStream_peekBytes(length) {
  25166. var bytes = this.getBytes(length);
  25167. this.pos -= bytes.length;
  25168. return bytes;
  25169. },
  25170. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25171. this.ensureRange(begin, end);
  25172. return this.bytes.subarray(begin, end);
  25173. },
  25174. skip: function ChunkedStream_skip(n) {
  25175. if (!n) {
  25176. n = 1;
  25177. }
  25178. this.pos += n;
  25179. },
  25180. reset: function ChunkedStream_reset() {
  25181. this.pos = this.start;
  25182. },
  25183. moveStart: function ChunkedStream_moveStart() {
  25184. this.start = this.pos;
  25185. },
  25186. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25187. this.ensureRange(start, start + length);
  25188. function ChunkedStreamSubstream() {
  25189. }
  25190. ChunkedStreamSubstream.prototype = Object.create(this);
  25191. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25192. var chunkSize = this.chunkSize;
  25193. var beginChunk = Math.floor(this.start / chunkSize);
  25194. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25195. var missingChunks = [];
  25196. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25197. if (!this.loadedChunks[chunk]) {
  25198. missingChunks.push(chunk);
  25199. }
  25200. }
  25201. return missingChunks;
  25202. };
  25203. var subStream = new ChunkedStreamSubstream();
  25204. subStream.pos = subStream.start = start;
  25205. subStream.end = start + length || this.end;
  25206. subStream.dict = dict;
  25207. return subStream;
  25208. }
  25209. };
  25210. return ChunkedStream;
  25211. }();
  25212. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25213. function ChunkedStreamManager(pdfNetworkStream, args) {
  25214. var chunkSize = args.rangeChunkSize;
  25215. var length = args.length;
  25216. this.stream = new ChunkedStream(length, chunkSize, this);
  25217. this.length = length;
  25218. this.chunkSize = chunkSize;
  25219. this.pdfNetworkStream = pdfNetworkStream;
  25220. this.url = args.url;
  25221. this.disableAutoFetch = args.disableAutoFetch;
  25222. this.msgHandler = args.msgHandler;
  25223. this.currRequestId = 0;
  25224. this.chunksNeededByRequest = Object.create(null);
  25225. this.requestsByChunk = Object.create(null);
  25226. this.promisesByRequest = Object.create(null);
  25227. this.progressiveDataLength = 0;
  25228. this.aborted = false;
  25229. this._loadedStreamCapability = createPromiseCapability();
  25230. }
  25231. ChunkedStreamManager.prototype = {
  25232. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25233. return this._loadedStreamCapability.promise;
  25234. },
  25235. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25236. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25237. if (!rangeReader.isStreamingSupported) {
  25238. rangeReader.onProgress = this.onProgress.bind(this);
  25239. }
  25240. var chunks = [], loaded = 0;
  25241. var manager = this;
  25242. var promise = new Promise(function (resolve, reject) {
  25243. var readChunk = function (chunk) {
  25244. try {
  25245. if (!chunk.done) {
  25246. var data = chunk.value;
  25247. chunks.push(data);
  25248. loaded += arrayByteLength(data);
  25249. if (rangeReader.isStreamingSupported) {
  25250. manager.onProgress({ loaded: loaded });
  25251. }
  25252. rangeReader.read().then(readChunk, reject);
  25253. return;
  25254. }
  25255. var chunkData = arraysToBytes(chunks);
  25256. chunks = null;
  25257. resolve(chunkData);
  25258. } catch (e) {
  25259. reject(e);
  25260. }
  25261. };
  25262. rangeReader.read().then(readChunk, reject);
  25263. });
  25264. promise.then(function (data) {
  25265. if (this.aborted) {
  25266. return;
  25267. }
  25268. this.onReceiveData({
  25269. chunk: data,
  25270. begin: begin
  25271. });
  25272. }.bind(this));
  25273. },
  25274. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25275. var missingChunks = this.stream.getMissingChunks();
  25276. this._requestChunks(missingChunks);
  25277. return this._loadedStreamCapability.promise;
  25278. },
  25279. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25280. var requestId = this.currRequestId++;
  25281. var i, ii;
  25282. var chunksNeeded = Object.create(null);
  25283. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25284. for (i = 0, ii = chunks.length; i < ii; i++) {
  25285. if (!this.stream.hasChunk(chunks[i])) {
  25286. chunksNeeded[chunks[i]] = true;
  25287. }
  25288. }
  25289. if (isEmptyObj(chunksNeeded)) {
  25290. return Promise.resolve();
  25291. }
  25292. var capability = createPromiseCapability();
  25293. this.promisesByRequest[requestId] = capability;
  25294. var chunksToRequest = [];
  25295. for (var chunk in chunksNeeded) {
  25296. chunk = chunk | 0;
  25297. if (!(chunk in this.requestsByChunk)) {
  25298. this.requestsByChunk[chunk] = [];
  25299. chunksToRequest.push(chunk);
  25300. }
  25301. this.requestsByChunk[chunk].push(requestId);
  25302. }
  25303. if (!chunksToRequest.length) {
  25304. return capability.promise;
  25305. }
  25306. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25307. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25308. var groupedChunk = groupedChunksToRequest[i];
  25309. var begin = groupedChunk.beginChunk * this.chunkSize;
  25310. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25311. this.sendRequest(begin, end);
  25312. }
  25313. return capability.promise;
  25314. },
  25315. getStream: function ChunkedStreamManager_getStream() {
  25316. return this.stream;
  25317. },
  25318. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25319. end = Math.min(end, this.length);
  25320. var beginChunk = this.getBeginChunk(begin);
  25321. var endChunk = this.getEndChunk(end);
  25322. var chunks = [];
  25323. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25324. chunks.push(chunk);
  25325. }
  25326. return this._requestChunks(chunks);
  25327. },
  25328. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25329. ranges = ranges || [];
  25330. var chunksToRequest = [];
  25331. for (var i = 0; i < ranges.length; i++) {
  25332. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25333. var endChunk = this.getEndChunk(ranges[i].end);
  25334. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25335. if (chunksToRequest.indexOf(chunk) < 0) {
  25336. chunksToRequest.push(chunk);
  25337. }
  25338. }
  25339. }
  25340. chunksToRequest.sort(function (a, b) {
  25341. return a - b;
  25342. });
  25343. return this._requestChunks(chunksToRequest);
  25344. },
  25345. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25346. var groupedChunks = [];
  25347. var beginChunk = -1;
  25348. var prevChunk = -1;
  25349. for (var i = 0; i < chunks.length; ++i) {
  25350. var chunk = chunks[i];
  25351. if (beginChunk < 0) {
  25352. beginChunk = chunk;
  25353. }
  25354. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25355. groupedChunks.push({
  25356. beginChunk: beginChunk,
  25357. endChunk: prevChunk + 1
  25358. });
  25359. beginChunk = chunk;
  25360. }
  25361. if (i + 1 === chunks.length) {
  25362. groupedChunks.push({
  25363. beginChunk: beginChunk,
  25364. endChunk: chunk + 1
  25365. });
  25366. }
  25367. prevChunk = chunk;
  25368. }
  25369. return groupedChunks;
  25370. },
  25371. onProgress: function ChunkedStreamManager_onProgress(args) {
  25372. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25373. this.msgHandler.send('DocProgress', {
  25374. loaded: bytesLoaded,
  25375. total: this.length
  25376. });
  25377. },
  25378. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25379. var chunk = args.chunk;
  25380. var isProgressive = args.begin === undefined;
  25381. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25382. var end = begin + chunk.byteLength;
  25383. var beginChunk = Math.floor(begin / this.chunkSize);
  25384. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25385. if (isProgressive) {
  25386. this.stream.onReceiveProgressiveData(chunk);
  25387. this.progressiveDataLength = end;
  25388. } else {
  25389. this.stream.onReceiveData(begin, chunk);
  25390. }
  25391. if (this.stream.allChunksLoaded()) {
  25392. this._loadedStreamCapability.resolve(this.stream);
  25393. }
  25394. var loadedRequests = [];
  25395. var i, requestId;
  25396. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25397. var requestIds = this.requestsByChunk[chunk] || [];
  25398. delete this.requestsByChunk[chunk];
  25399. for (i = 0; i < requestIds.length; ++i) {
  25400. requestId = requestIds[i];
  25401. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25402. if (chunk in chunksNeeded) {
  25403. delete chunksNeeded[chunk];
  25404. }
  25405. if (!isEmptyObj(chunksNeeded)) {
  25406. continue;
  25407. }
  25408. loadedRequests.push(requestId);
  25409. }
  25410. }
  25411. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25412. var nextEmptyChunk;
  25413. if (this.stream.numChunksLoaded === 1) {
  25414. var lastChunk = this.stream.numChunks - 1;
  25415. if (!this.stream.hasChunk(lastChunk)) {
  25416. nextEmptyChunk = lastChunk;
  25417. }
  25418. } else {
  25419. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25420. }
  25421. if (isInt(nextEmptyChunk)) {
  25422. this._requestChunks([nextEmptyChunk]);
  25423. }
  25424. }
  25425. for (i = 0; i < loadedRequests.length; ++i) {
  25426. requestId = loadedRequests[i];
  25427. var capability = this.promisesByRequest[requestId];
  25428. delete this.promisesByRequest[requestId];
  25429. capability.resolve();
  25430. }
  25431. this.msgHandler.send('DocProgress', {
  25432. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25433. total: this.length
  25434. });
  25435. },
  25436. onError: function ChunkedStreamManager_onError(err) {
  25437. this._loadedStreamCapability.reject(err);
  25438. },
  25439. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25440. var chunk = Math.floor(begin / this.chunkSize);
  25441. return chunk;
  25442. },
  25443. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25444. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25445. return chunk;
  25446. },
  25447. abort: function ChunkedStreamManager_abort() {
  25448. this.aborted = true;
  25449. if (this.pdfNetworkStream) {
  25450. this.pdfNetworkStream.cancelAllRequests('abort');
  25451. }
  25452. for (var requestId in this.promisesByRequest) {
  25453. var capability = this.promisesByRequest[requestId];
  25454. capability.reject(new Error('Request was aborted'));
  25455. }
  25456. }
  25457. };
  25458. return ChunkedStreamManager;
  25459. }();
  25460. exports.ChunkedStream = ChunkedStream;
  25461. exports.ChunkedStreamManager = ChunkedStreamManager;
  25462. /***/ }),
  25463. /* 16 */
  25464. /***/ (function(module, exports, __w_pdfjs_require__) {
  25465. "use strict";
  25466. var sharedUtil = __w_pdfjs_require__(0);
  25467. var corePrimitives = __w_pdfjs_require__(1);
  25468. var coreStream = __w_pdfjs_require__(2);
  25469. var PasswordException = sharedUtil.PasswordException;
  25470. var PasswordResponses = sharedUtil.PasswordResponses;
  25471. var bytesToString = sharedUtil.bytesToString;
  25472. var warn = sharedUtil.warn;
  25473. var error = sharedUtil.error;
  25474. var assert = sharedUtil.assert;
  25475. var isInt = sharedUtil.isInt;
  25476. var stringToBytes = sharedUtil.stringToBytes;
  25477. var utf8StringToString = sharedUtil.utf8StringToString;
  25478. var Name = corePrimitives.Name;
  25479. var isName = corePrimitives.isName;
  25480. var isDict = corePrimitives.isDict;
  25481. var DecryptStream = coreStream.DecryptStream;
  25482. var ARCFourCipher = function ARCFourCipherClosure() {
  25483. function ARCFourCipher(key) {
  25484. this.a = 0;
  25485. this.b = 0;
  25486. var s = new Uint8Array(256);
  25487. var i, j = 0, tmp, keyLength = key.length;
  25488. for (i = 0; i < 256; ++i) {
  25489. s[i] = i;
  25490. }
  25491. for (i = 0; i < 256; ++i) {
  25492. tmp = s[i];
  25493. j = j + tmp + key[i % keyLength] & 0xFF;
  25494. s[i] = s[j];
  25495. s[j] = tmp;
  25496. }
  25497. this.s = s;
  25498. }
  25499. ARCFourCipher.prototype = {
  25500. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25501. var i, n = data.length, tmp, tmp2;
  25502. var a = this.a, b = this.b, s = this.s;
  25503. var output = new Uint8Array(n);
  25504. for (i = 0; i < n; ++i) {
  25505. a = a + 1 & 0xFF;
  25506. tmp = s[a];
  25507. b = b + tmp & 0xFF;
  25508. tmp2 = s[b];
  25509. s[a] = tmp2;
  25510. s[b] = tmp;
  25511. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25512. }
  25513. this.a = a;
  25514. this.b = b;
  25515. return output;
  25516. }
  25517. };
  25518. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25519. return ARCFourCipher;
  25520. }();
  25521. var calculateMD5 = function calculateMD5Closure() {
  25522. var r = new Uint8Array([
  25523. 7,
  25524. 12,
  25525. 17,
  25526. 22,
  25527. 7,
  25528. 12,
  25529. 17,
  25530. 22,
  25531. 7,
  25532. 12,
  25533. 17,
  25534. 22,
  25535. 7,
  25536. 12,
  25537. 17,
  25538. 22,
  25539. 5,
  25540. 9,
  25541. 14,
  25542. 20,
  25543. 5,
  25544. 9,
  25545. 14,
  25546. 20,
  25547. 5,
  25548. 9,
  25549. 14,
  25550. 20,
  25551. 5,
  25552. 9,
  25553. 14,
  25554. 20,
  25555. 4,
  25556. 11,
  25557. 16,
  25558. 23,
  25559. 4,
  25560. 11,
  25561. 16,
  25562. 23,
  25563. 4,
  25564. 11,
  25565. 16,
  25566. 23,
  25567. 4,
  25568. 11,
  25569. 16,
  25570. 23,
  25571. 6,
  25572. 10,
  25573. 15,
  25574. 21,
  25575. 6,
  25576. 10,
  25577. 15,
  25578. 21,
  25579. 6,
  25580. 10,
  25581. 15,
  25582. 21,
  25583. 6,
  25584. 10,
  25585. 15,
  25586. 21
  25587. ]);
  25588. var k = new Int32Array([
  25589. -680876936,
  25590. -389564586,
  25591. 606105819,
  25592. -1044525330,
  25593. -176418897,
  25594. 1200080426,
  25595. -1473231341,
  25596. -45705983,
  25597. 1770035416,
  25598. -1958414417,
  25599. -42063,
  25600. -1990404162,
  25601. 1804603682,
  25602. -40341101,
  25603. -1502002290,
  25604. 1236535329,
  25605. -165796510,
  25606. -1069501632,
  25607. 643717713,
  25608. -373897302,
  25609. -701558691,
  25610. 38016083,
  25611. -660478335,
  25612. -405537848,
  25613. 568446438,
  25614. -1019803690,
  25615. -187363961,
  25616. 1163531501,
  25617. -1444681467,
  25618. -51403784,
  25619. 1735328473,
  25620. -1926607734,
  25621. -378558,
  25622. -2022574463,
  25623. 1839030562,
  25624. -35309556,
  25625. -1530992060,
  25626. 1272893353,
  25627. -155497632,
  25628. -1094730640,
  25629. 681279174,
  25630. -358537222,
  25631. -722521979,
  25632. 76029189,
  25633. -640364487,
  25634. -421815835,
  25635. 530742520,
  25636. -995338651,
  25637. -198630844,
  25638. 1126891415,
  25639. -1416354905,
  25640. -57434055,
  25641. 1700485571,
  25642. -1894986606,
  25643. -1051523,
  25644. -2054922799,
  25645. 1873313359,
  25646. -30611744,
  25647. -1560198380,
  25648. 1309151649,
  25649. -145523070,
  25650. -1120210379,
  25651. 718787259,
  25652. -343485551
  25653. ]);
  25654. function hash(data, offset, length) {
  25655. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25656. var paddedLength = length + 72 & ~63;
  25657. var padded = new Uint8Array(paddedLength);
  25658. var i, j, n;
  25659. for (i = 0; i < length; ++i) {
  25660. padded[i] = data[offset++];
  25661. }
  25662. padded[i++] = 0x80;
  25663. n = paddedLength - 8;
  25664. while (i < n) {
  25665. padded[i++] = 0;
  25666. }
  25667. padded[i++] = length << 3 & 0xFF;
  25668. padded[i++] = length >> 5 & 0xFF;
  25669. padded[i++] = length >> 13 & 0xFF;
  25670. padded[i++] = length >> 21 & 0xFF;
  25671. padded[i++] = length >>> 29 & 0xFF;
  25672. padded[i++] = 0;
  25673. padded[i++] = 0;
  25674. padded[i++] = 0;
  25675. var w = new Int32Array(16);
  25676. for (i = 0; i < paddedLength;) {
  25677. for (j = 0; j < 16; ++j, i += 4) {
  25678. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25679. }
  25680. var a = h0, b = h1, c = h2, d = h3, f, g;
  25681. for (j = 0; j < 64; ++j) {
  25682. if (j < 16) {
  25683. f = b & c | ~b & d;
  25684. g = j;
  25685. } else if (j < 32) {
  25686. f = d & b | ~d & c;
  25687. g = 5 * j + 1 & 15;
  25688. } else if (j < 48) {
  25689. f = b ^ c ^ d;
  25690. g = 3 * j + 5 & 15;
  25691. } else {
  25692. f = c ^ (b | ~d);
  25693. g = 7 * j & 15;
  25694. }
  25695. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25696. d = c;
  25697. c = b;
  25698. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25699. a = tmp;
  25700. }
  25701. h0 = h0 + a | 0;
  25702. h1 = h1 + b | 0;
  25703. h2 = h2 + c | 0;
  25704. h3 = h3 + d | 0;
  25705. }
  25706. return new Uint8Array([
  25707. h0 & 0xFF,
  25708. h0 >> 8 & 0xFF,
  25709. h0 >> 16 & 0xFF,
  25710. h0 >>> 24 & 0xFF,
  25711. h1 & 0xFF,
  25712. h1 >> 8 & 0xFF,
  25713. h1 >> 16 & 0xFF,
  25714. h1 >>> 24 & 0xFF,
  25715. h2 & 0xFF,
  25716. h2 >> 8 & 0xFF,
  25717. h2 >> 16 & 0xFF,
  25718. h2 >>> 24 & 0xFF,
  25719. h3 & 0xFF,
  25720. h3 >> 8 & 0xFF,
  25721. h3 >> 16 & 0xFF,
  25722. h3 >>> 24 & 0xFF
  25723. ]);
  25724. }
  25725. return hash;
  25726. }();
  25727. var Word64 = function Word64Closure() {
  25728. function Word64(highInteger, lowInteger) {
  25729. this.high = highInteger | 0;
  25730. this.low = lowInteger | 0;
  25731. }
  25732. Word64.prototype = {
  25733. and: function Word64_and(word) {
  25734. this.high &= word.high;
  25735. this.low &= word.low;
  25736. },
  25737. xor: function Word64_xor(word) {
  25738. this.high ^= word.high;
  25739. this.low ^= word.low;
  25740. },
  25741. or: function Word64_or(word) {
  25742. this.high |= word.high;
  25743. this.low |= word.low;
  25744. },
  25745. shiftRight: function Word64_shiftRight(places) {
  25746. if (places >= 32) {
  25747. this.low = this.high >>> places - 32 | 0;
  25748. this.high = 0;
  25749. } else {
  25750. this.low = this.low >>> places | this.high << 32 - places;
  25751. this.high = this.high >>> places | 0;
  25752. }
  25753. },
  25754. shiftLeft: function Word64_shiftLeft(places) {
  25755. if (places >= 32) {
  25756. this.high = this.low << places - 32;
  25757. this.low = 0;
  25758. } else {
  25759. this.high = this.high << places | this.low >>> 32 - places;
  25760. this.low = this.low << places;
  25761. }
  25762. },
  25763. rotateRight: function Word64_rotateRight(places) {
  25764. var low, high;
  25765. if (places & 32) {
  25766. high = this.low;
  25767. low = this.high;
  25768. } else {
  25769. low = this.low;
  25770. high = this.high;
  25771. }
  25772. places &= 31;
  25773. this.low = low >>> places | high << 32 - places;
  25774. this.high = high >>> places | low << 32 - places;
  25775. },
  25776. not: function Word64_not() {
  25777. this.high = ~this.high;
  25778. this.low = ~this.low;
  25779. },
  25780. add: function Word64_add(word) {
  25781. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25782. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25783. if (lowAdd > 0xFFFFFFFF) {
  25784. highAdd += 1;
  25785. }
  25786. this.low = lowAdd | 0;
  25787. this.high = highAdd | 0;
  25788. },
  25789. copyTo: function Word64_copyTo(bytes, offset) {
  25790. bytes[offset] = this.high >>> 24 & 0xFF;
  25791. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25792. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25793. bytes[offset + 3] = this.high & 0xFF;
  25794. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25795. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25796. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25797. bytes[offset + 7] = this.low & 0xFF;
  25798. },
  25799. assign: function Word64_assign(word) {
  25800. this.high = word.high;
  25801. this.low = word.low;
  25802. }
  25803. };
  25804. return Word64;
  25805. }();
  25806. var calculateSHA256 = function calculateSHA256Closure() {
  25807. function rotr(x, n) {
  25808. return x >>> n | x << 32 - n;
  25809. }
  25810. function ch(x, y, z) {
  25811. return x & y ^ ~x & z;
  25812. }
  25813. function maj(x, y, z) {
  25814. return x & y ^ x & z ^ y & z;
  25815. }
  25816. function sigma(x) {
  25817. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25818. }
  25819. function sigmaPrime(x) {
  25820. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25821. }
  25822. function littleSigma(x) {
  25823. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25824. }
  25825. function littleSigmaPrime(x) {
  25826. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25827. }
  25828. var k = [
  25829. 0x428a2f98,
  25830. 0x71374491,
  25831. 0xb5c0fbcf,
  25832. 0xe9b5dba5,
  25833. 0x3956c25b,
  25834. 0x59f111f1,
  25835. 0x923f82a4,
  25836. 0xab1c5ed5,
  25837. 0xd807aa98,
  25838. 0x12835b01,
  25839. 0x243185be,
  25840. 0x550c7dc3,
  25841. 0x72be5d74,
  25842. 0x80deb1fe,
  25843. 0x9bdc06a7,
  25844. 0xc19bf174,
  25845. 0xe49b69c1,
  25846. 0xefbe4786,
  25847. 0x0fc19dc6,
  25848. 0x240ca1cc,
  25849. 0x2de92c6f,
  25850. 0x4a7484aa,
  25851. 0x5cb0a9dc,
  25852. 0x76f988da,
  25853. 0x983e5152,
  25854. 0xa831c66d,
  25855. 0xb00327c8,
  25856. 0xbf597fc7,
  25857. 0xc6e00bf3,
  25858. 0xd5a79147,
  25859. 0x06ca6351,
  25860. 0x14292967,
  25861. 0x27b70a85,
  25862. 0x2e1b2138,
  25863. 0x4d2c6dfc,
  25864. 0x53380d13,
  25865. 0x650a7354,
  25866. 0x766a0abb,
  25867. 0x81c2c92e,
  25868. 0x92722c85,
  25869. 0xa2bfe8a1,
  25870. 0xa81a664b,
  25871. 0xc24b8b70,
  25872. 0xc76c51a3,
  25873. 0xd192e819,
  25874. 0xd6990624,
  25875. 0xf40e3585,
  25876. 0x106aa070,
  25877. 0x19a4c116,
  25878. 0x1e376c08,
  25879. 0x2748774c,
  25880. 0x34b0bcb5,
  25881. 0x391c0cb3,
  25882. 0x4ed8aa4a,
  25883. 0x5b9cca4f,
  25884. 0x682e6ff3,
  25885. 0x748f82ee,
  25886. 0x78a5636f,
  25887. 0x84c87814,
  25888. 0x8cc70208,
  25889. 0x90befffa,
  25890. 0xa4506ceb,
  25891. 0xbef9a3f7,
  25892. 0xc67178f2
  25893. ];
  25894. function hash(data, offset, length) {
  25895. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25896. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25897. var padded = new Uint8Array(paddedLength);
  25898. var i, j, n;
  25899. for (i = 0; i < length; ++i) {
  25900. padded[i] = data[offset++];
  25901. }
  25902. padded[i++] = 0x80;
  25903. n = paddedLength - 8;
  25904. while (i < n) {
  25905. padded[i++] = 0;
  25906. }
  25907. padded[i++] = 0;
  25908. padded[i++] = 0;
  25909. padded[i++] = 0;
  25910. padded[i++] = length >>> 29 & 0xFF;
  25911. padded[i++] = length >> 21 & 0xFF;
  25912. padded[i++] = length >> 13 & 0xFF;
  25913. padded[i++] = length >> 5 & 0xFF;
  25914. padded[i++] = length << 3 & 0xFF;
  25915. var w = new Uint32Array(64);
  25916. for (i = 0; i < paddedLength;) {
  25917. for (j = 0; j < 16; ++j) {
  25918. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25919. i += 4;
  25920. }
  25921. for (j = 16; j < 64; ++j) {
  25922. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25923. }
  25924. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25925. for (j = 0; j < 64; ++j) {
  25926. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25927. t2 = sigma(a) + maj(a, b, c);
  25928. h = g;
  25929. g = f;
  25930. f = e;
  25931. e = d + t1 | 0;
  25932. d = c;
  25933. c = b;
  25934. b = a;
  25935. a = t1 + t2 | 0;
  25936. }
  25937. h0 = h0 + a | 0;
  25938. h1 = h1 + b | 0;
  25939. h2 = h2 + c | 0;
  25940. h3 = h3 + d | 0;
  25941. h4 = h4 + e | 0;
  25942. h5 = h5 + f | 0;
  25943. h6 = h6 + g | 0;
  25944. h7 = h7 + h | 0;
  25945. }
  25946. return new Uint8Array([
  25947. h0 >> 24 & 0xFF,
  25948. h0 >> 16 & 0xFF,
  25949. h0 >> 8 & 0xFF,
  25950. h0 & 0xFF,
  25951. h1 >> 24 & 0xFF,
  25952. h1 >> 16 & 0xFF,
  25953. h1 >> 8 & 0xFF,
  25954. h1 & 0xFF,
  25955. h2 >> 24 & 0xFF,
  25956. h2 >> 16 & 0xFF,
  25957. h2 >> 8 & 0xFF,
  25958. h2 & 0xFF,
  25959. h3 >> 24 & 0xFF,
  25960. h3 >> 16 & 0xFF,
  25961. h3 >> 8 & 0xFF,
  25962. h3 & 0xFF,
  25963. h4 >> 24 & 0xFF,
  25964. h4 >> 16 & 0xFF,
  25965. h4 >> 8 & 0xFF,
  25966. h4 & 0xFF,
  25967. h5 >> 24 & 0xFF,
  25968. h5 >> 16 & 0xFF,
  25969. h5 >> 8 & 0xFF,
  25970. h5 & 0xFF,
  25971. h6 >> 24 & 0xFF,
  25972. h6 >> 16 & 0xFF,
  25973. h6 >> 8 & 0xFF,
  25974. h6 & 0xFF,
  25975. h7 >> 24 & 0xFF,
  25976. h7 >> 16 & 0xFF,
  25977. h7 >> 8 & 0xFF,
  25978. h7 & 0xFF
  25979. ]);
  25980. }
  25981. return hash;
  25982. }();
  25983. var calculateSHA512 = function calculateSHA512Closure() {
  25984. function ch(result, x, y, z, tmp) {
  25985. result.assign(x);
  25986. result.and(y);
  25987. tmp.assign(x);
  25988. tmp.not();
  25989. tmp.and(z);
  25990. result.xor(tmp);
  25991. }
  25992. function maj(result, x, y, z, tmp) {
  25993. result.assign(x);
  25994. result.and(y);
  25995. tmp.assign(x);
  25996. tmp.and(z);
  25997. result.xor(tmp);
  25998. tmp.assign(y);
  25999. tmp.and(z);
  26000. result.xor(tmp);
  26001. }
  26002. function sigma(result, x, tmp) {
  26003. result.assign(x);
  26004. result.rotateRight(28);
  26005. tmp.assign(x);
  26006. tmp.rotateRight(34);
  26007. result.xor(tmp);
  26008. tmp.assign(x);
  26009. tmp.rotateRight(39);
  26010. result.xor(tmp);
  26011. }
  26012. function sigmaPrime(result, x, tmp) {
  26013. result.assign(x);
  26014. result.rotateRight(14);
  26015. tmp.assign(x);
  26016. tmp.rotateRight(18);
  26017. result.xor(tmp);
  26018. tmp.assign(x);
  26019. tmp.rotateRight(41);
  26020. result.xor(tmp);
  26021. }
  26022. function littleSigma(result, x, tmp) {
  26023. result.assign(x);
  26024. result.rotateRight(1);
  26025. tmp.assign(x);
  26026. tmp.rotateRight(8);
  26027. result.xor(tmp);
  26028. tmp.assign(x);
  26029. tmp.shiftRight(7);
  26030. result.xor(tmp);
  26031. }
  26032. function littleSigmaPrime(result, x, tmp) {
  26033. result.assign(x);
  26034. result.rotateRight(19);
  26035. tmp.assign(x);
  26036. tmp.rotateRight(61);
  26037. result.xor(tmp);
  26038. tmp.assign(x);
  26039. tmp.shiftRight(6);
  26040. result.xor(tmp);
  26041. }
  26042. var k = [
  26043. new Word64(0x428a2f98, 0xd728ae22),
  26044. new Word64(0x71374491, 0x23ef65cd),
  26045. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26046. new Word64(0xe9b5dba5, 0x8189dbbc),
  26047. new Word64(0x3956c25b, 0xf348b538),
  26048. new Word64(0x59f111f1, 0xb605d019),
  26049. new Word64(0x923f82a4, 0xaf194f9b),
  26050. new Word64(0xab1c5ed5, 0xda6d8118),
  26051. new Word64(0xd807aa98, 0xa3030242),
  26052. new Word64(0x12835b01, 0x45706fbe),
  26053. new Word64(0x243185be, 0x4ee4b28c),
  26054. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26055. new Word64(0x72be5d74, 0xf27b896f),
  26056. new Word64(0x80deb1fe, 0x3b1696b1),
  26057. new Word64(0x9bdc06a7, 0x25c71235),
  26058. new Word64(0xc19bf174, 0xcf692694),
  26059. new Word64(0xe49b69c1, 0x9ef14ad2),
  26060. new Word64(0xefbe4786, 0x384f25e3),
  26061. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26062. new Word64(0x240ca1cc, 0x77ac9c65),
  26063. new Word64(0x2de92c6f, 0x592b0275),
  26064. new Word64(0x4a7484aa, 0x6ea6e483),
  26065. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26066. new Word64(0x76f988da, 0x831153b5),
  26067. new Word64(0x983e5152, 0xee66dfab),
  26068. new Word64(0xa831c66d, 0x2db43210),
  26069. new Word64(0xb00327c8, 0x98fb213f),
  26070. new Word64(0xbf597fc7, 0xbeef0ee4),
  26071. new Word64(0xc6e00bf3, 0x3da88fc2),
  26072. new Word64(0xd5a79147, 0x930aa725),
  26073. new Word64(0x06ca6351, 0xe003826f),
  26074. new Word64(0x14292967, 0x0a0e6e70),
  26075. new Word64(0x27b70a85, 0x46d22ffc),
  26076. new Word64(0x2e1b2138, 0x5c26c926),
  26077. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26078. new Word64(0x53380d13, 0x9d95b3df),
  26079. new Word64(0x650a7354, 0x8baf63de),
  26080. new Word64(0x766a0abb, 0x3c77b2a8),
  26081. new Word64(0x81c2c92e, 0x47edaee6),
  26082. new Word64(0x92722c85, 0x1482353b),
  26083. new Word64(0xa2bfe8a1, 0x4cf10364),
  26084. new Word64(0xa81a664b, 0xbc423001),
  26085. new Word64(0xc24b8b70, 0xd0f89791),
  26086. new Word64(0xc76c51a3, 0x0654be30),
  26087. new Word64(0xd192e819, 0xd6ef5218),
  26088. new Word64(0xd6990624, 0x5565a910),
  26089. new Word64(0xf40e3585, 0x5771202a),
  26090. new Word64(0x106aa070, 0x32bbd1b8),
  26091. new Word64(0x19a4c116, 0xb8d2d0c8),
  26092. new Word64(0x1e376c08, 0x5141ab53),
  26093. new Word64(0x2748774c, 0xdf8eeb99),
  26094. new Word64(0x34b0bcb5, 0xe19b48a8),
  26095. new Word64(0x391c0cb3, 0xc5c95a63),
  26096. new Word64(0x4ed8aa4a, 0xe3418acb),
  26097. new Word64(0x5b9cca4f, 0x7763e373),
  26098. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26099. new Word64(0x748f82ee, 0x5defb2fc),
  26100. new Word64(0x78a5636f, 0x43172f60),
  26101. new Word64(0x84c87814, 0xa1f0ab72),
  26102. new Word64(0x8cc70208, 0x1a6439ec),
  26103. new Word64(0x90befffa, 0x23631e28),
  26104. new Word64(0xa4506ceb, 0xde82bde9),
  26105. new Word64(0xbef9a3f7, 0xb2c67915),
  26106. new Word64(0xc67178f2, 0xe372532b),
  26107. new Word64(0xca273ece, 0xea26619c),
  26108. new Word64(0xd186b8c7, 0x21c0c207),
  26109. new Word64(0xeada7dd6, 0xcde0eb1e),
  26110. new Word64(0xf57d4f7f, 0xee6ed178),
  26111. new Word64(0x06f067aa, 0x72176fba),
  26112. new Word64(0x0a637dc5, 0xa2c898a6),
  26113. new Word64(0x113f9804, 0xbef90dae),
  26114. new Word64(0x1b710b35, 0x131c471b),
  26115. new Word64(0x28db77f5, 0x23047d84),
  26116. new Word64(0x32caab7b, 0x40c72493),
  26117. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26118. new Word64(0x431d67c4, 0x9c100d4c),
  26119. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26120. new Word64(0x597f299c, 0xfc657e2a),
  26121. new Word64(0x5fcb6fab, 0x3ad6faec),
  26122. new Word64(0x6c44198c, 0x4a475817)
  26123. ];
  26124. function hash(data, offset, length, mode384) {
  26125. mode384 = !!mode384;
  26126. var h0, h1, h2, h3, h4, h5, h6, h7;
  26127. if (!mode384) {
  26128. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26129. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26130. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26131. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26132. h4 = new Word64(0x510e527f, 0xade682d1);
  26133. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26134. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26135. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26136. } else {
  26137. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26138. h1 = new Word64(0x629a292a, 0x367cd507);
  26139. h2 = new Word64(0x9159015a, 0x3070dd17);
  26140. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26141. h4 = new Word64(0x67332667, 0xffc00b31);
  26142. h5 = new Word64(0x8eb44a87, 0x68581511);
  26143. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26144. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26145. }
  26146. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26147. var padded = new Uint8Array(paddedLength);
  26148. var i, j, n;
  26149. for (i = 0; i < length; ++i) {
  26150. padded[i] = data[offset++];
  26151. }
  26152. padded[i++] = 0x80;
  26153. n = paddedLength - 16;
  26154. while (i < n) {
  26155. padded[i++] = 0;
  26156. }
  26157. padded[i++] = 0;
  26158. padded[i++] = 0;
  26159. padded[i++] = 0;
  26160. padded[i++] = 0;
  26161. padded[i++] = 0;
  26162. padded[i++] = 0;
  26163. padded[i++] = 0;
  26164. padded[i++] = 0;
  26165. padded[i++] = 0;
  26166. padded[i++] = 0;
  26167. padded[i++] = 0;
  26168. padded[i++] = length >>> 29 & 0xFF;
  26169. padded[i++] = length >> 21 & 0xFF;
  26170. padded[i++] = length >> 13 & 0xFF;
  26171. padded[i++] = length >> 5 & 0xFF;
  26172. padded[i++] = length << 3 & 0xFF;
  26173. var w = new Array(80);
  26174. for (i = 0; i < 80; i++) {
  26175. w[i] = new Word64(0, 0);
  26176. }
  26177. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26178. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26179. var g = new Word64(0, 0), h = new Word64(0, 0);
  26180. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26181. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26182. for (i = 0; i < paddedLength;) {
  26183. for (j = 0; j < 16; ++j) {
  26184. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26185. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26186. i += 8;
  26187. }
  26188. for (j = 16; j < 80; ++j) {
  26189. tmp3 = w[j];
  26190. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26191. tmp3.add(w[j - 7]);
  26192. littleSigma(tmp1, w[j - 15], tmp2);
  26193. tmp3.add(tmp1);
  26194. tmp3.add(w[j - 16]);
  26195. }
  26196. a.assign(h0);
  26197. b.assign(h1);
  26198. c.assign(h2);
  26199. d.assign(h3);
  26200. e.assign(h4);
  26201. f.assign(h5);
  26202. g.assign(h6);
  26203. h.assign(h7);
  26204. for (j = 0; j < 80; ++j) {
  26205. t1.assign(h);
  26206. sigmaPrime(tmp1, e, tmp2);
  26207. t1.add(tmp1);
  26208. ch(tmp1, e, f, g, tmp2);
  26209. t1.add(tmp1);
  26210. t1.add(k[j]);
  26211. t1.add(w[j]);
  26212. sigma(t2, a, tmp2);
  26213. maj(tmp1, a, b, c, tmp2);
  26214. t2.add(tmp1);
  26215. tmp3 = h;
  26216. h = g;
  26217. g = f;
  26218. f = e;
  26219. d.add(t1);
  26220. e = d;
  26221. d = c;
  26222. c = b;
  26223. b = a;
  26224. tmp3.assign(t1);
  26225. tmp3.add(t2);
  26226. a = tmp3;
  26227. }
  26228. h0.add(a);
  26229. h1.add(b);
  26230. h2.add(c);
  26231. h3.add(d);
  26232. h4.add(e);
  26233. h5.add(f);
  26234. h6.add(g);
  26235. h7.add(h);
  26236. }
  26237. var result;
  26238. if (!mode384) {
  26239. result = new Uint8Array(64);
  26240. h0.copyTo(result, 0);
  26241. h1.copyTo(result, 8);
  26242. h2.copyTo(result, 16);
  26243. h3.copyTo(result, 24);
  26244. h4.copyTo(result, 32);
  26245. h5.copyTo(result, 40);
  26246. h6.copyTo(result, 48);
  26247. h7.copyTo(result, 56);
  26248. } else {
  26249. result = new Uint8Array(48);
  26250. h0.copyTo(result, 0);
  26251. h1.copyTo(result, 8);
  26252. h2.copyTo(result, 16);
  26253. h3.copyTo(result, 24);
  26254. h4.copyTo(result, 32);
  26255. h5.copyTo(result, 40);
  26256. }
  26257. return result;
  26258. }
  26259. return hash;
  26260. }();
  26261. var calculateSHA384 = function calculateSHA384Closure() {
  26262. function hash(data, offset, length) {
  26263. return calculateSHA512(data, offset, length, true);
  26264. }
  26265. return hash;
  26266. }();
  26267. var NullCipher = function NullCipherClosure() {
  26268. function NullCipher() {
  26269. }
  26270. NullCipher.prototype = {
  26271. decryptBlock: function NullCipher_decryptBlock(data) {
  26272. return data;
  26273. }
  26274. };
  26275. return NullCipher;
  26276. }();
  26277. var AES128Cipher = function AES128CipherClosure() {
  26278. var rcon = new Uint8Array([
  26279. 0x8d,
  26280. 0x01,
  26281. 0x02,
  26282. 0x04,
  26283. 0x08,
  26284. 0x10,
  26285. 0x20,
  26286. 0x40,
  26287. 0x80,
  26288. 0x1b,
  26289. 0x36,
  26290. 0x6c,
  26291. 0xd8,
  26292. 0xab,
  26293. 0x4d,
  26294. 0x9a,
  26295. 0x2f,
  26296. 0x5e,
  26297. 0xbc,
  26298. 0x63,
  26299. 0xc6,
  26300. 0x97,
  26301. 0x35,
  26302. 0x6a,
  26303. 0xd4,
  26304. 0xb3,
  26305. 0x7d,
  26306. 0xfa,
  26307. 0xef,
  26308. 0xc5,
  26309. 0x91,
  26310. 0x39,
  26311. 0x72,
  26312. 0xe4,
  26313. 0xd3,
  26314. 0xbd,
  26315. 0x61,
  26316. 0xc2,
  26317. 0x9f,
  26318. 0x25,
  26319. 0x4a,
  26320. 0x94,
  26321. 0x33,
  26322. 0x66,
  26323. 0xcc,
  26324. 0x83,
  26325. 0x1d,
  26326. 0x3a,
  26327. 0x74,
  26328. 0xe8,
  26329. 0xcb,
  26330. 0x8d,
  26331. 0x01,
  26332. 0x02,
  26333. 0x04,
  26334. 0x08,
  26335. 0x10,
  26336. 0x20,
  26337. 0x40,
  26338. 0x80,
  26339. 0x1b,
  26340. 0x36,
  26341. 0x6c,
  26342. 0xd8,
  26343. 0xab,
  26344. 0x4d,
  26345. 0x9a,
  26346. 0x2f,
  26347. 0x5e,
  26348. 0xbc,
  26349. 0x63,
  26350. 0xc6,
  26351. 0x97,
  26352. 0x35,
  26353. 0x6a,
  26354. 0xd4,
  26355. 0xb3,
  26356. 0x7d,
  26357. 0xfa,
  26358. 0xef,
  26359. 0xc5,
  26360. 0x91,
  26361. 0x39,
  26362. 0x72,
  26363. 0xe4,
  26364. 0xd3,
  26365. 0xbd,
  26366. 0x61,
  26367. 0xc2,
  26368. 0x9f,
  26369. 0x25,
  26370. 0x4a,
  26371. 0x94,
  26372. 0x33,
  26373. 0x66,
  26374. 0xcc,
  26375. 0x83,
  26376. 0x1d,
  26377. 0x3a,
  26378. 0x74,
  26379. 0xe8,
  26380. 0xcb,
  26381. 0x8d,
  26382. 0x01,
  26383. 0x02,
  26384. 0x04,
  26385. 0x08,
  26386. 0x10,
  26387. 0x20,
  26388. 0x40,
  26389. 0x80,
  26390. 0x1b,
  26391. 0x36,
  26392. 0x6c,
  26393. 0xd8,
  26394. 0xab,
  26395. 0x4d,
  26396. 0x9a,
  26397. 0x2f,
  26398. 0x5e,
  26399. 0xbc,
  26400. 0x63,
  26401. 0xc6,
  26402. 0x97,
  26403. 0x35,
  26404. 0x6a,
  26405. 0xd4,
  26406. 0xb3,
  26407. 0x7d,
  26408. 0xfa,
  26409. 0xef,
  26410. 0xc5,
  26411. 0x91,
  26412. 0x39,
  26413. 0x72,
  26414. 0xe4,
  26415. 0xd3,
  26416. 0xbd,
  26417. 0x61,
  26418. 0xc2,
  26419. 0x9f,
  26420. 0x25,
  26421. 0x4a,
  26422. 0x94,
  26423. 0x33,
  26424. 0x66,
  26425. 0xcc,
  26426. 0x83,
  26427. 0x1d,
  26428. 0x3a,
  26429. 0x74,
  26430. 0xe8,
  26431. 0xcb,
  26432. 0x8d,
  26433. 0x01,
  26434. 0x02,
  26435. 0x04,
  26436. 0x08,
  26437. 0x10,
  26438. 0x20,
  26439. 0x40,
  26440. 0x80,
  26441. 0x1b,
  26442. 0x36,
  26443. 0x6c,
  26444. 0xd8,
  26445. 0xab,
  26446. 0x4d,
  26447. 0x9a,
  26448. 0x2f,
  26449. 0x5e,
  26450. 0xbc,
  26451. 0x63,
  26452. 0xc6,
  26453. 0x97,
  26454. 0x35,
  26455. 0x6a,
  26456. 0xd4,
  26457. 0xb3,
  26458. 0x7d,
  26459. 0xfa,
  26460. 0xef,
  26461. 0xc5,
  26462. 0x91,
  26463. 0x39,
  26464. 0x72,
  26465. 0xe4,
  26466. 0xd3,
  26467. 0xbd,
  26468. 0x61,
  26469. 0xc2,
  26470. 0x9f,
  26471. 0x25,
  26472. 0x4a,
  26473. 0x94,
  26474. 0x33,
  26475. 0x66,
  26476. 0xcc,
  26477. 0x83,
  26478. 0x1d,
  26479. 0x3a,
  26480. 0x74,
  26481. 0xe8,
  26482. 0xcb,
  26483. 0x8d,
  26484. 0x01,
  26485. 0x02,
  26486. 0x04,
  26487. 0x08,
  26488. 0x10,
  26489. 0x20,
  26490. 0x40,
  26491. 0x80,
  26492. 0x1b,
  26493. 0x36,
  26494. 0x6c,
  26495. 0xd8,
  26496. 0xab,
  26497. 0x4d,
  26498. 0x9a,
  26499. 0x2f,
  26500. 0x5e,
  26501. 0xbc,
  26502. 0x63,
  26503. 0xc6,
  26504. 0x97,
  26505. 0x35,
  26506. 0x6a,
  26507. 0xd4,
  26508. 0xb3,
  26509. 0x7d,
  26510. 0xfa,
  26511. 0xef,
  26512. 0xc5,
  26513. 0x91,
  26514. 0x39,
  26515. 0x72,
  26516. 0xe4,
  26517. 0xd3,
  26518. 0xbd,
  26519. 0x61,
  26520. 0xc2,
  26521. 0x9f,
  26522. 0x25,
  26523. 0x4a,
  26524. 0x94,
  26525. 0x33,
  26526. 0x66,
  26527. 0xcc,
  26528. 0x83,
  26529. 0x1d,
  26530. 0x3a,
  26531. 0x74,
  26532. 0xe8,
  26533. 0xcb,
  26534. 0x8d
  26535. ]);
  26536. var s = new Uint8Array([
  26537. 0x63,
  26538. 0x7c,
  26539. 0x77,
  26540. 0x7b,
  26541. 0xf2,
  26542. 0x6b,
  26543. 0x6f,
  26544. 0xc5,
  26545. 0x30,
  26546. 0x01,
  26547. 0x67,
  26548. 0x2b,
  26549. 0xfe,
  26550. 0xd7,
  26551. 0xab,
  26552. 0x76,
  26553. 0xca,
  26554. 0x82,
  26555. 0xc9,
  26556. 0x7d,
  26557. 0xfa,
  26558. 0x59,
  26559. 0x47,
  26560. 0xf0,
  26561. 0xad,
  26562. 0xd4,
  26563. 0xa2,
  26564. 0xaf,
  26565. 0x9c,
  26566. 0xa4,
  26567. 0x72,
  26568. 0xc0,
  26569. 0xb7,
  26570. 0xfd,
  26571. 0x93,
  26572. 0x26,
  26573. 0x36,
  26574. 0x3f,
  26575. 0xf7,
  26576. 0xcc,
  26577. 0x34,
  26578. 0xa5,
  26579. 0xe5,
  26580. 0xf1,
  26581. 0x71,
  26582. 0xd8,
  26583. 0x31,
  26584. 0x15,
  26585. 0x04,
  26586. 0xc7,
  26587. 0x23,
  26588. 0xc3,
  26589. 0x18,
  26590. 0x96,
  26591. 0x05,
  26592. 0x9a,
  26593. 0x07,
  26594. 0x12,
  26595. 0x80,
  26596. 0xe2,
  26597. 0xeb,
  26598. 0x27,
  26599. 0xb2,
  26600. 0x75,
  26601. 0x09,
  26602. 0x83,
  26603. 0x2c,
  26604. 0x1a,
  26605. 0x1b,
  26606. 0x6e,
  26607. 0x5a,
  26608. 0xa0,
  26609. 0x52,
  26610. 0x3b,
  26611. 0xd6,
  26612. 0xb3,
  26613. 0x29,
  26614. 0xe3,
  26615. 0x2f,
  26616. 0x84,
  26617. 0x53,
  26618. 0xd1,
  26619. 0x00,
  26620. 0xed,
  26621. 0x20,
  26622. 0xfc,
  26623. 0xb1,
  26624. 0x5b,
  26625. 0x6a,
  26626. 0xcb,
  26627. 0xbe,
  26628. 0x39,
  26629. 0x4a,
  26630. 0x4c,
  26631. 0x58,
  26632. 0xcf,
  26633. 0xd0,
  26634. 0xef,
  26635. 0xaa,
  26636. 0xfb,
  26637. 0x43,
  26638. 0x4d,
  26639. 0x33,
  26640. 0x85,
  26641. 0x45,
  26642. 0xf9,
  26643. 0x02,
  26644. 0x7f,
  26645. 0x50,
  26646. 0x3c,
  26647. 0x9f,
  26648. 0xa8,
  26649. 0x51,
  26650. 0xa3,
  26651. 0x40,
  26652. 0x8f,
  26653. 0x92,
  26654. 0x9d,
  26655. 0x38,
  26656. 0xf5,
  26657. 0xbc,
  26658. 0xb6,
  26659. 0xda,
  26660. 0x21,
  26661. 0x10,
  26662. 0xff,
  26663. 0xf3,
  26664. 0xd2,
  26665. 0xcd,
  26666. 0x0c,
  26667. 0x13,
  26668. 0xec,
  26669. 0x5f,
  26670. 0x97,
  26671. 0x44,
  26672. 0x17,
  26673. 0xc4,
  26674. 0xa7,
  26675. 0x7e,
  26676. 0x3d,
  26677. 0x64,
  26678. 0x5d,
  26679. 0x19,
  26680. 0x73,
  26681. 0x60,
  26682. 0x81,
  26683. 0x4f,
  26684. 0xdc,
  26685. 0x22,
  26686. 0x2a,
  26687. 0x90,
  26688. 0x88,
  26689. 0x46,
  26690. 0xee,
  26691. 0xb8,
  26692. 0x14,
  26693. 0xde,
  26694. 0x5e,
  26695. 0x0b,
  26696. 0xdb,
  26697. 0xe0,
  26698. 0x32,
  26699. 0x3a,
  26700. 0x0a,
  26701. 0x49,
  26702. 0x06,
  26703. 0x24,
  26704. 0x5c,
  26705. 0xc2,
  26706. 0xd3,
  26707. 0xac,
  26708. 0x62,
  26709. 0x91,
  26710. 0x95,
  26711. 0xe4,
  26712. 0x79,
  26713. 0xe7,
  26714. 0xc8,
  26715. 0x37,
  26716. 0x6d,
  26717. 0x8d,
  26718. 0xd5,
  26719. 0x4e,
  26720. 0xa9,
  26721. 0x6c,
  26722. 0x56,
  26723. 0xf4,
  26724. 0xea,
  26725. 0x65,
  26726. 0x7a,
  26727. 0xae,
  26728. 0x08,
  26729. 0xba,
  26730. 0x78,
  26731. 0x25,
  26732. 0x2e,
  26733. 0x1c,
  26734. 0xa6,
  26735. 0xb4,
  26736. 0xc6,
  26737. 0xe8,
  26738. 0xdd,
  26739. 0x74,
  26740. 0x1f,
  26741. 0x4b,
  26742. 0xbd,
  26743. 0x8b,
  26744. 0x8a,
  26745. 0x70,
  26746. 0x3e,
  26747. 0xb5,
  26748. 0x66,
  26749. 0x48,
  26750. 0x03,
  26751. 0xf6,
  26752. 0x0e,
  26753. 0x61,
  26754. 0x35,
  26755. 0x57,
  26756. 0xb9,
  26757. 0x86,
  26758. 0xc1,
  26759. 0x1d,
  26760. 0x9e,
  26761. 0xe1,
  26762. 0xf8,
  26763. 0x98,
  26764. 0x11,
  26765. 0x69,
  26766. 0xd9,
  26767. 0x8e,
  26768. 0x94,
  26769. 0x9b,
  26770. 0x1e,
  26771. 0x87,
  26772. 0xe9,
  26773. 0xce,
  26774. 0x55,
  26775. 0x28,
  26776. 0xdf,
  26777. 0x8c,
  26778. 0xa1,
  26779. 0x89,
  26780. 0x0d,
  26781. 0xbf,
  26782. 0xe6,
  26783. 0x42,
  26784. 0x68,
  26785. 0x41,
  26786. 0x99,
  26787. 0x2d,
  26788. 0x0f,
  26789. 0xb0,
  26790. 0x54,
  26791. 0xbb,
  26792. 0x16
  26793. ]);
  26794. var inv_s = new Uint8Array([
  26795. 0x52,
  26796. 0x09,
  26797. 0x6a,
  26798. 0xd5,
  26799. 0x30,
  26800. 0x36,
  26801. 0xa5,
  26802. 0x38,
  26803. 0xbf,
  26804. 0x40,
  26805. 0xa3,
  26806. 0x9e,
  26807. 0x81,
  26808. 0xf3,
  26809. 0xd7,
  26810. 0xfb,
  26811. 0x7c,
  26812. 0xe3,
  26813. 0x39,
  26814. 0x82,
  26815. 0x9b,
  26816. 0x2f,
  26817. 0xff,
  26818. 0x87,
  26819. 0x34,
  26820. 0x8e,
  26821. 0x43,
  26822. 0x44,
  26823. 0xc4,
  26824. 0xde,
  26825. 0xe9,
  26826. 0xcb,
  26827. 0x54,
  26828. 0x7b,
  26829. 0x94,
  26830. 0x32,
  26831. 0xa6,
  26832. 0xc2,
  26833. 0x23,
  26834. 0x3d,
  26835. 0xee,
  26836. 0x4c,
  26837. 0x95,
  26838. 0x0b,
  26839. 0x42,
  26840. 0xfa,
  26841. 0xc3,
  26842. 0x4e,
  26843. 0x08,
  26844. 0x2e,
  26845. 0xa1,
  26846. 0x66,
  26847. 0x28,
  26848. 0xd9,
  26849. 0x24,
  26850. 0xb2,
  26851. 0x76,
  26852. 0x5b,
  26853. 0xa2,
  26854. 0x49,
  26855. 0x6d,
  26856. 0x8b,
  26857. 0xd1,
  26858. 0x25,
  26859. 0x72,
  26860. 0xf8,
  26861. 0xf6,
  26862. 0x64,
  26863. 0x86,
  26864. 0x68,
  26865. 0x98,
  26866. 0x16,
  26867. 0xd4,
  26868. 0xa4,
  26869. 0x5c,
  26870. 0xcc,
  26871. 0x5d,
  26872. 0x65,
  26873. 0xb6,
  26874. 0x92,
  26875. 0x6c,
  26876. 0x70,
  26877. 0x48,
  26878. 0x50,
  26879. 0xfd,
  26880. 0xed,
  26881. 0xb9,
  26882. 0xda,
  26883. 0x5e,
  26884. 0x15,
  26885. 0x46,
  26886. 0x57,
  26887. 0xa7,
  26888. 0x8d,
  26889. 0x9d,
  26890. 0x84,
  26891. 0x90,
  26892. 0xd8,
  26893. 0xab,
  26894. 0x00,
  26895. 0x8c,
  26896. 0xbc,
  26897. 0xd3,
  26898. 0x0a,
  26899. 0xf7,
  26900. 0xe4,
  26901. 0x58,
  26902. 0x05,
  26903. 0xb8,
  26904. 0xb3,
  26905. 0x45,
  26906. 0x06,
  26907. 0xd0,
  26908. 0x2c,
  26909. 0x1e,
  26910. 0x8f,
  26911. 0xca,
  26912. 0x3f,
  26913. 0x0f,
  26914. 0x02,
  26915. 0xc1,
  26916. 0xaf,
  26917. 0xbd,
  26918. 0x03,
  26919. 0x01,
  26920. 0x13,
  26921. 0x8a,
  26922. 0x6b,
  26923. 0x3a,
  26924. 0x91,
  26925. 0x11,
  26926. 0x41,
  26927. 0x4f,
  26928. 0x67,
  26929. 0xdc,
  26930. 0xea,
  26931. 0x97,
  26932. 0xf2,
  26933. 0xcf,
  26934. 0xce,
  26935. 0xf0,
  26936. 0xb4,
  26937. 0xe6,
  26938. 0x73,
  26939. 0x96,
  26940. 0xac,
  26941. 0x74,
  26942. 0x22,
  26943. 0xe7,
  26944. 0xad,
  26945. 0x35,
  26946. 0x85,
  26947. 0xe2,
  26948. 0xf9,
  26949. 0x37,
  26950. 0xe8,
  26951. 0x1c,
  26952. 0x75,
  26953. 0xdf,
  26954. 0x6e,
  26955. 0x47,
  26956. 0xf1,
  26957. 0x1a,
  26958. 0x71,
  26959. 0x1d,
  26960. 0x29,
  26961. 0xc5,
  26962. 0x89,
  26963. 0x6f,
  26964. 0xb7,
  26965. 0x62,
  26966. 0x0e,
  26967. 0xaa,
  26968. 0x18,
  26969. 0xbe,
  26970. 0x1b,
  26971. 0xfc,
  26972. 0x56,
  26973. 0x3e,
  26974. 0x4b,
  26975. 0xc6,
  26976. 0xd2,
  26977. 0x79,
  26978. 0x20,
  26979. 0x9a,
  26980. 0xdb,
  26981. 0xc0,
  26982. 0xfe,
  26983. 0x78,
  26984. 0xcd,
  26985. 0x5a,
  26986. 0xf4,
  26987. 0x1f,
  26988. 0xdd,
  26989. 0xa8,
  26990. 0x33,
  26991. 0x88,
  26992. 0x07,
  26993. 0xc7,
  26994. 0x31,
  26995. 0xb1,
  26996. 0x12,
  26997. 0x10,
  26998. 0x59,
  26999. 0x27,
  27000. 0x80,
  27001. 0xec,
  27002. 0x5f,
  27003. 0x60,
  27004. 0x51,
  27005. 0x7f,
  27006. 0xa9,
  27007. 0x19,
  27008. 0xb5,
  27009. 0x4a,
  27010. 0x0d,
  27011. 0x2d,
  27012. 0xe5,
  27013. 0x7a,
  27014. 0x9f,
  27015. 0x93,
  27016. 0xc9,
  27017. 0x9c,
  27018. 0xef,
  27019. 0xa0,
  27020. 0xe0,
  27021. 0x3b,
  27022. 0x4d,
  27023. 0xae,
  27024. 0x2a,
  27025. 0xf5,
  27026. 0xb0,
  27027. 0xc8,
  27028. 0xeb,
  27029. 0xbb,
  27030. 0x3c,
  27031. 0x83,
  27032. 0x53,
  27033. 0x99,
  27034. 0x61,
  27035. 0x17,
  27036. 0x2b,
  27037. 0x04,
  27038. 0x7e,
  27039. 0xba,
  27040. 0x77,
  27041. 0xd6,
  27042. 0x26,
  27043. 0xe1,
  27044. 0x69,
  27045. 0x14,
  27046. 0x63,
  27047. 0x55,
  27048. 0x21,
  27049. 0x0c,
  27050. 0x7d
  27051. ]);
  27052. var mixCol = new Uint8Array(256);
  27053. for (var i = 0; i < 256; i++) {
  27054. if (i < 128) {
  27055. mixCol[i] = i << 1;
  27056. } else {
  27057. mixCol[i] = i << 1 ^ 0x1b;
  27058. }
  27059. }
  27060. var mix = new Uint32Array([
  27061. 0x00000000,
  27062. 0x0e090d0b,
  27063. 0x1c121a16,
  27064. 0x121b171d,
  27065. 0x3824342c,
  27066. 0x362d3927,
  27067. 0x24362e3a,
  27068. 0x2a3f2331,
  27069. 0x70486858,
  27070. 0x7e416553,
  27071. 0x6c5a724e,
  27072. 0x62537f45,
  27073. 0x486c5c74,
  27074. 0x4665517f,
  27075. 0x547e4662,
  27076. 0x5a774b69,
  27077. 0xe090d0b0,
  27078. 0xee99ddbb,
  27079. 0xfc82caa6,
  27080. 0xf28bc7ad,
  27081. 0xd8b4e49c,
  27082. 0xd6bde997,
  27083. 0xc4a6fe8a,
  27084. 0xcaaff381,
  27085. 0x90d8b8e8,
  27086. 0x9ed1b5e3,
  27087. 0x8ccaa2fe,
  27088. 0x82c3aff5,
  27089. 0xa8fc8cc4,
  27090. 0xa6f581cf,
  27091. 0xb4ee96d2,
  27092. 0xbae79bd9,
  27093. 0xdb3bbb7b,
  27094. 0xd532b670,
  27095. 0xc729a16d,
  27096. 0xc920ac66,
  27097. 0xe31f8f57,
  27098. 0xed16825c,
  27099. 0xff0d9541,
  27100. 0xf104984a,
  27101. 0xab73d323,
  27102. 0xa57ade28,
  27103. 0xb761c935,
  27104. 0xb968c43e,
  27105. 0x9357e70f,
  27106. 0x9d5eea04,
  27107. 0x8f45fd19,
  27108. 0x814cf012,
  27109. 0x3bab6bcb,
  27110. 0x35a266c0,
  27111. 0x27b971dd,
  27112. 0x29b07cd6,
  27113. 0x038f5fe7,
  27114. 0x0d8652ec,
  27115. 0x1f9d45f1,
  27116. 0x119448fa,
  27117. 0x4be30393,
  27118. 0x45ea0e98,
  27119. 0x57f11985,
  27120. 0x59f8148e,
  27121. 0x73c737bf,
  27122. 0x7dce3ab4,
  27123. 0x6fd52da9,
  27124. 0x61dc20a2,
  27125. 0xad766df6,
  27126. 0xa37f60fd,
  27127. 0xb16477e0,
  27128. 0xbf6d7aeb,
  27129. 0x955259da,
  27130. 0x9b5b54d1,
  27131. 0x894043cc,
  27132. 0x87494ec7,
  27133. 0xdd3e05ae,
  27134. 0xd33708a5,
  27135. 0xc12c1fb8,
  27136. 0xcf2512b3,
  27137. 0xe51a3182,
  27138. 0xeb133c89,
  27139. 0xf9082b94,
  27140. 0xf701269f,
  27141. 0x4de6bd46,
  27142. 0x43efb04d,
  27143. 0x51f4a750,
  27144. 0x5ffdaa5b,
  27145. 0x75c2896a,
  27146. 0x7bcb8461,
  27147. 0x69d0937c,
  27148. 0x67d99e77,
  27149. 0x3daed51e,
  27150. 0x33a7d815,
  27151. 0x21bccf08,
  27152. 0x2fb5c203,
  27153. 0x058ae132,
  27154. 0x0b83ec39,
  27155. 0x1998fb24,
  27156. 0x1791f62f,
  27157. 0x764dd68d,
  27158. 0x7844db86,
  27159. 0x6a5fcc9b,
  27160. 0x6456c190,
  27161. 0x4e69e2a1,
  27162. 0x4060efaa,
  27163. 0x527bf8b7,
  27164. 0x5c72f5bc,
  27165. 0x0605bed5,
  27166. 0x080cb3de,
  27167. 0x1a17a4c3,
  27168. 0x141ea9c8,
  27169. 0x3e218af9,
  27170. 0x302887f2,
  27171. 0x223390ef,
  27172. 0x2c3a9de4,
  27173. 0x96dd063d,
  27174. 0x98d40b36,
  27175. 0x8acf1c2b,
  27176. 0x84c61120,
  27177. 0xaef93211,
  27178. 0xa0f03f1a,
  27179. 0xb2eb2807,
  27180. 0xbce2250c,
  27181. 0xe6956e65,
  27182. 0xe89c636e,
  27183. 0xfa877473,
  27184. 0xf48e7978,
  27185. 0xdeb15a49,
  27186. 0xd0b85742,
  27187. 0xc2a3405f,
  27188. 0xccaa4d54,
  27189. 0x41ecdaf7,
  27190. 0x4fe5d7fc,
  27191. 0x5dfec0e1,
  27192. 0x53f7cdea,
  27193. 0x79c8eedb,
  27194. 0x77c1e3d0,
  27195. 0x65daf4cd,
  27196. 0x6bd3f9c6,
  27197. 0x31a4b2af,
  27198. 0x3fadbfa4,
  27199. 0x2db6a8b9,
  27200. 0x23bfa5b2,
  27201. 0x09808683,
  27202. 0x07898b88,
  27203. 0x15929c95,
  27204. 0x1b9b919e,
  27205. 0xa17c0a47,
  27206. 0xaf75074c,
  27207. 0xbd6e1051,
  27208. 0xb3671d5a,
  27209. 0x99583e6b,
  27210. 0x97513360,
  27211. 0x854a247d,
  27212. 0x8b432976,
  27213. 0xd134621f,
  27214. 0xdf3d6f14,
  27215. 0xcd267809,
  27216. 0xc32f7502,
  27217. 0xe9105633,
  27218. 0xe7195b38,
  27219. 0xf5024c25,
  27220. 0xfb0b412e,
  27221. 0x9ad7618c,
  27222. 0x94de6c87,
  27223. 0x86c57b9a,
  27224. 0x88cc7691,
  27225. 0xa2f355a0,
  27226. 0xacfa58ab,
  27227. 0xbee14fb6,
  27228. 0xb0e842bd,
  27229. 0xea9f09d4,
  27230. 0xe49604df,
  27231. 0xf68d13c2,
  27232. 0xf8841ec9,
  27233. 0xd2bb3df8,
  27234. 0xdcb230f3,
  27235. 0xcea927ee,
  27236. 0xc0a02ae5,
  27237. 0x7a47b13c,
  27238. 0x744ebc37,
  27239. 0x6655ab2a,
  27240. 0x685ca621,
  27241. 0x42638510,
  27242. 0x4c6a881b,
  27243. 0x5e719f06,
  27244. 0x5078920d,
  27245. 0x0a0fd964,
  27246. 0x0406d46f,
  27247. 0x161dc372,
  27248. 0x1814ce79,
  27249. 0x322bed48,
  27250. 0x3c22e043,
  27251. 0x2e39f75e,
  27252. 0x2030fa55,
  27253. 0xec9ab701,
  27254. 0xe293ba0a,
  27255. 0xf088ad17,
  27256. 0xfe81a01c,
  27257. 0xd4be832d,
  27258. 0xdab78e26,
  27259. 0xc8ac993b,
  27260. 0xc6a59430,
  27261. 0x9cd2df59,
  27262. 0x92dbd252,
  27263. 0x80c0c54f,
  27264. 0x8ec9c844,
  27265. 0xa4f6eb75,
  27266. 0xaaffe67e,
  27267. 0xb8e4f163,
  27268. 0xb6edfc68,
  27269. 0x0c0a67b1,
  27270. 0x02036aba,
  27271. 0x10187da7,
  27272. 0x1e1170ac,
  27273. 0x342e539d,
  27274. 0x3a275e96,
  27275. 0x283c498b,
  27276. 0x26354480,
  27277. 0x7c420fe9,
  27278. 0x724b02e2,
  27279. 0x605015ff,
  27280. 0x6e5918f4,
  27281. 0x44663bc5,
  27282. 0x4a6f36ce,
  27283. 0x587421d3,
  27284. 0x567d2cd8,
  27285. 0x37a10c7a,
  27286. 0x39a80171,
  27287. 0x2bb3166c,
  27288. 0x25ba1b67,
  27289. 0x0f853856,
  27290. 0x018c355d,
  27291. 0x13972240,
  27292. 0x1d9e2f4b,
  27293. 0x47e96422,
  27294. 0x49e06929,
  27295. 0x5bfb7e34,
  27296. 0x55f2733f,
  27297. 0x7fcd500e,
  27298. 0x71c45d05,
  27299. 0x63df4a18,
  27300. 0x6dd64713,
  27301. 0xd731dcca,
  27302. 0xd938d1c1,
  27303. 0xcb23c6dc,
  27304. 0xc52acbd7,
  27305. 0xef15e8e6,
  27306. 0xe11ce5ed,
  27307. 0xf307f2f0,
  27308. 0xfd0efffb,
  27309. 0xa779b492,
  27310. 0xa970b999,
  27311. 0xbb6bae84,
  27312. 0xb562a38f,
  27313. 0x9f5d80be,
  27314. 0x91548db5,
  27315. 0x834f9aa8,
  27316. 0x8d4697a3
  27317. ]);
  27318. function expandKey128(cipherKey) {
  27319. var b = 176, result = new Uint8Array(b);
  27320. result.set(cipherKey);
  27321. for (var j = 16, i = 1; j < b; ++i) {
  27322. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27323. t1 = s[t1];
  27324. t2 = s[t2];
  27325. t3 = s[t3];
  27326. t4 = s[t4];
  27327. t1 = t1 ^ rcon[i];
  27328. for (var n = 0; n < 4; ++n) {
  27329. result[j] = t1 ^= result[j - 16];
  27330. j++;
  27331. result[j] = t2 ^= result[j - 16];
  27332. j++;
  27333. result[j] = t3 ^= result[j - 16];
  27334. j++;
  27335. result[j] = t4 ^= result[j - 16];
  27336. j++;
  27337. }
  27338. }
  27339. return result;
  27340. }
  27341. function decrypt128(input, key) {
  27342. var state = new Uint8Array(16);
  27343. state.set(input);
  27344. var i, j, k;
  27345. var t, u, v;
  27346. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27347. state[j] ^= key[k];
  27348. }
  27349. for (i = 9; i >= 1; --i) {
  27350. t = state[13];
  27351. state[13] = state[9];
  27352. state[9] = state[5];
  27353. state[5] = state[1];
  27354. state[1] = t;
  27355. t = state[14];
  27356. u = state[10];
  27357. state[14] = state[6];
  27358. state[10] = state[2];
  27359. state[6] = t;
  27360. state[2] = u;
  27361. t = state[15];
  27362. u = state[11];
  27363. v = state[7];
  27364. state[15] = state[3];
  27365. state[11] = t;
  27366. state[7] = u;
  27367. state[3] = v;
  27368. for (j = 0; j < 16; ++j) {
  27369. state[j] = inv_s[state[j]];
  27370. }
  27371. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27372. state[j] ^= key[k];
  27373. }
  27374. for (j = 0; j < 16; j += 4) {
  27375. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27376. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27377. state[j] = t >>> 24 & 0xFF;
  27378. state[j + 1] = t >> 16 & 0xFF;
  27379. state[j + 2] = t >> 8 & 0xFF;
  27380. state[j + 3] = t & 0xFF;
  27381. }
  27382. }
  27383. t = state[13];
  27384. state[13] = state[9];
  27385. state[9] = state[5];
  27386. state[5] = state[1];
  27387. state[1] = t;
  27388. t = state[14];
  27389. u = state[10];
  27390. state[14] = state[6];
  27391. state[10] = state[2];
  27392. state[6] = t;
  27393. state[2] = u;
  27394. t = state[15];
  27395. u = state[11];
  27396. v = state[7];
  27397. state[15] = state[3];
  27398. state[11] = t;
  27399. state[7] = u;
  27400. state[3] = v;
  27401. for (j = 0; j < 16; ++j) {
  27402. state[j] = inv_s[state[j]];
  27403. state[j] ^= key[j];
  27404. }
  27405. return state;
  27406. }
  27407. function encrypt128(input, key) {
  27408. var t, u, v, k;
  27409. var state = new Uint8Array(16);
  27410. state.set(input);
  27411. for (j = 0; j < 16; ++j) {
  27412. state[j] ^= key[j];
  27413. }
  27414. for (i = 1; i < 10; i++) {
  27415. for (j = 0; j < 16; ++j) {
  27416. state[j] = s[state[j]];
  27417. }
  27418. v = state[1];
  27419. state[1] = state[5];
  27420. state[5] = state[9];
  27421. state[9] = state[13];
  27422. state[13] = v;
  27423. v = state[2];
  27424. u = state[6];
  27425. state[2] = state[10];
  27426. state[6] = state[14];
  27427. state[10] = v;
  27428. state[14] = u;
  27429. v = state[3];
  27430. u = state[7];
  27431. t = state[11];
  27432. state[3] = state[15];
  27433. state[7] = v;
  27434. state[11] = u;
  27435. state[15] = t;
  27436. for (var j = 0; j < 16; j += 4) {
  27437. var s0 = state[j + 0], s1 = state[j + 1];
  27438. var s2 = state[j + 2], s3 = state[j + 3];
  27439. t = s0 ^ s1 ^ s2 ^ s3;
  27440. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27441. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27442. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27443. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27444. }
  27445. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27446. state[j] ^= key[k];
  27447. }
  27448. }
  27449. for (j = 0; j < 16; ++j) {
  27450. state[j] = s[state[j]];
  27451. }
  27452. v = state[1];
  27453. state[1] = state[5];
  27454. state[5] = state[9];
  27455. state[9] = state[13];
  27456. state[13] = v;
  27457. v = state[2];
  27458. u = state[6];
  27459. state[2] = state[10];
  27460. state[6] = state[14];
  27461. state[10] = v;
  27462. state[14] = u;
  27463. v = state[3];
  27464. u = state[7];
  27465. t = state[11];
  27466. state[3] = state[15];
  27467. state[7] = v;
  27468. state[11] = u;
  27469. state[15] = t;
  27470. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27471. state[j] ^= key[k];
  27472. }
  27473. return state;
  27474. }
  27475. function AES128Cipher(key) {
  27476. this.key = expandKey128(key);
  27477. this.buffer = new Uint8Array(16);
  27478. this.bufferPosition = 0;
  27479. }
  27480. function decryptBlock2(data, finalize) {
  27481. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27482. for (i = 0; i < sourceLength; ++i) {
  27483. buffer[bufferLength] = data[i];
  27484. ++bufferLength;
  27485. if (bufferLength < 16) {
  27486. continue;
  27487. }
  27488. var plain = decrypt128(buffer, this.key);
  27489. for (j = 0; j < 16; ++j) {
  27490. plain[j] ^= iv[j];
  27491. }
  27492. iv = buffer;
  27493. result.push(plain);
  27494. buffer = new Uint8Array(16);
  27495. bufferLength = 0;
  27496. }
  27497. this.buffer = buffer;
  27498. this.bufferLength = bufferLength;
  27499. this.iv = iv;
  27500. if (result.length === 0) {
  27501. return new Uint8Array([]);
  27502. }
  27503. var outputLength = 16 * result.length;
  27504. if (finalize) {
  27505. var lastBlock = result[result.length - 1];
  27506. var psLen = lastBlock[15];
  27507. if (psLen <= 16) {
  27508. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27509. if (lastBlock[i] !== psLen) {
  27510. psLen = 0;
  27511. break;
  27512. }
  27513. }
  27514. outputLength -= psLen;
  27515. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27516. }
  27517. }
  27518. var output = new Uint8Array(outputLength);
  27519. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27520. output.set(result[i], j);
  27521. }
  27522. return output;
  27523. }
  27524. AES128Cipher.prototype = {
  27525. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27526. var i, sourceLength = data.length;
  27527. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27528. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27529. buffer[bufferLength] = data[i];
  27530. }
  27531. if (bufferLength < 16) {
  27532. this.bufferLength = bufferLength;
  27533. return new Uint8Array([]);
  27534. }
  27535. this.iv = buffer;
  27536. this.buffer = new Uint8Array(16);
  27537. this.bufferLength = 0;
  27538. this.decryptBlock = decryptBlock2;
  27539. return this.decryptBlock(data.subarray(16), finalize);
  27540. },
  27541. encrypt: function AES128Cipher_encrypt(data, iv) {
  27542. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27543. if (!iv) {
  27544. iv = new Uint8Array(16);
  27545. }
  27546. for (i = 0; i < sourceLength; ++i) {
  27547. buffer[bufferLength] = data[i];
  27548. ++bufferLength;
  27549. if (bufferLength < 16) {
  27550. continue;
  27551. }
  27552. for (j = 0; j < 16; ++j) {
  27553. buffer[j] ^= iv[j];
  27554. }
  27555. var cipher = encrypt128(buffer, this.key);
  27556. iv = cipher;
  27557. result.push(cipher);
  27558. buffer = new Uint8Array(16);
  27559. bufferLength = 0;
  27560. }
  27561. this.buffer = buffer;
  27562. this.bufferLength = bufferLength;
  27563. this.iv = iv;
  27564. if (result.length === 0) {
  27565. return new Uint8Array([]);
  27566. }
  27567. var outputLength = 16 * result.length;
  27568. var output = new Uint8Array(outputLength);
  27569. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27570. output.set(result[i], j);
  27571. }
  27572. return output;
  27573. }
  27574. };
  27575. return AES128Cipher;
  27576. }();
  27577. var AES256Cipher = function AES256CipherClosure() {
  27578. var s = new Uint8Array([
  27579. 0x63,
  27580. 0x7c,
  27581. 0x77,
  27582. 0x7b,
  27583. 0xf2,
  27584. 0x6b,
  27585. 0x6f,
  27586. 0xc5,
  27587. 0x30,
  27588. 0x01,
  27589. 0x67,
  27590. 0x2b,
  27591. 0xfe,
  27592. 0xd7,
  27593. 0xab,
  27594. 0x76,
  27595. 0xca,
  27596. 0x82,
  27597. 0xc9,
  27598. 0x7d,
  27599. 0xfa,
  27600. 0x59,
  27601. 0x47,
  27602. 0xf0,
  27603. 0xad,
  27604. 0xd4,
  27605. 0xa2,
  27606. 0xaf,
  27607. 0x9c,
  27608. 0xa4,
  27609. 0x72,
  27610. 0xc0,
  27611. 0xb7,
  27612. 0xfd,
  27613. 0x93,
  27614. 0x26,
  27615. 0x36,
  27616. 0x3f,
  27617. 0xf7,
  27618. 0xcc,
  27619. 0x34,
  27620. 0xa5,
  27621. 0xe5,
  27622. 0xf1,
  27623. 0x71,
  27624. 0xd8,
  27625. 0x31,
  27626. 0x15,
  27627. 0x04,
  27628. 0xc7,
  27629. 0x23,
  27630. 0xc3,
  27631. 0x18,
  27632. 0x96,
  27633. 0x05,
  27634. 0x9a,
  27635. 0x07,
  27636. 0x12,
  27637. 0x80,
  27638. 0xe2,
  27639. 0xeb,
  27640. 0x27,
  27641. 0xb2,
  27642. 0x75,
  27643. 0x09,
  27644. 0x83,
  27645. 0x2c,
  27646. 0x1a,
  27647. 0x1b,
  27648. 0x6e,
  27649. 0x5a,
  27650. 0xa0,
  27651. 0x52,
  27652. 0x3b,
  27653. 0xd6,
  27654. 0xb3,
  27655. 0x29,
  27656. 0xe3,
  27657. 0x2f,
  27658. 0x84,
  27659. 0x53,
  27660. 0xd1,
  27661. 0x00,
  27662. 0xed,
  27663. 0x20,
  27664. 0xfc,
  27665. 0xb1,
  27666. 0x5b,
  27667. 0x6a,
  27668. 0xcb,
  27669. 0xbe,
  27670. 0x39,
  27671. 0x4a,
  27672. 0x4c,
  27673. 0x58,
  27674. 0xcf,
  27675. 0xd0,
  27676. 0xef,
  27677. 0xaa,
  27678. 0xfb,
  27679. 0x43,
  27680. 0x4d,
  27681. 0x33,
  27682. 0x85,
  27683. 0x45,
  27684. 0xf9,
  27685. 0x02,
  27686. 0x7f,
  27687. 0x50,
  27688. 0x3c,
  27689. 0x9f,
  27690. 0xa8,
  27691. 0x51,
  27692. 0xa3,
  27693. 0x40,
  27694. 0x8f,
  27695. 0x92,
  27696. 0x9d,
  27697. 0x38,
  27698. 0xf5,
  27699. 0xbc,
  27700. 0xb6,
  27701. 0xda,
  27702. 0x21,
  27703. 0x10,
  27704. 0xff,
  27705. 0xf3,
  27706. 0xd2,
  27707. 0xcd,
  27708. 0x0c,
  27709. 0x13,
  27710. 0xec,
  27711. 0x5f,
  27712. 0x97,
  27713. 0x44,
  27714. 0x17,
  27715. 0xc4,
  27716. 0xa7,
  27717. 0x7e,
  27718. 0x3d,
  27719. 0x64,
  27720. 0x5d,
  27721. 0x19,
  27722. 0x73,
  27723. 0x60,
  27724. 0x81,
  27725. 0x4f,
  27726. 0xdc,
  27727. 0x22,
  27728. 0x2a,
  27729. 0x90,
  27730. 0x88,
  27731. 0x46,
  27732. 0xee,
  27733. 0xb8,
  27734. 0x14,
  27735. 0xde,
  27736. 0x5e,
  27737. 0x0b,
  27738. 0xdb,
  27739. 0xe0,
  27740. 0x32,
  27741. 0x3a,
  27742. 0x0a,
  27743. 0x49,
  27744. 0x06,
  27745. 0x24,
  27746. 0x5c,
  27747. 0xc2,
  27748. 0xd3,
  27749. 0xac,
  27750. 0x62,
  27751. 0x91,
  27752. 0x95,
  27753. 0xe4,
  27754. 0x79,
  27755. 0xe7,
  27756. 0xc8,
  27757. 0x37,
  27758. 0x6d,
  27759. 0x8d,
  27760. 0xd5,
  27761. 0x4e,
  27762. 0xa9,
  27763. 0x6c,
  27764. 0x56,
  27765. 0xf4,
  27766. 0xea,
  27767. 0x65,
  27768. 0x7a,
  27769. 0xae,
  27770. 0x08,
  27771. 0xba,
  27772. 0x78,
  27773. 0x25,
  27774. 0x2e,
  27775. 0x1c,
  27776. 0xa6,
  27777. 0xb4,
  27778. 0xc6,
  27779. 0xe8,
  27780. 0xdd,
  27781. 0x74,
  27782. 0x1f,
  27783. 0x4b,
  27784. 0xbd,
  27785. 0x8b,
  27786. 0x8a,
  27787. 0x70,
  27788. 0x3e,
  27789. 0xb5,
  27790. 0x66,
  27791. 0x48,
  27792. 0x03,
  27793. 0xf6,
  27794. 0x0e,
  27795. 0x61,
  27796. 0x35,
  27797. 0x57,
  27798. 0xb9,
  27799. 0x86,
  27800. 0xc1,
  27801. 0x1d,
  27802. 0x9e,
  27803. 0xe1,
  27804. 0xf8,
  27805. 0x98,
  27806. 0x11,
  27807. 0x69,
  27808. 0xd9,
  27809. 0x8e,
  27810. 0x94,
  27811. 0x9b,
  27812. 0x1e,
  27813. 0x87,
  27814. 0xe9,
  27815. 0xce,
  27816. 0x55,
  27817. 0x28,
  27818. 0xdf,
  27819. 0x8c,
  27820. 0xa1,
  27821. 0x89,
  27822. 0x0d,
  27823. 0xbf,
  27824. 0xe6,
  27825. 0x42,
  27826. 0x68,
  27827. 0x41,
  27828. 0x99,
  27829. 0x2d,
  27830. 0x0f,
  27831. 0xb0,
  27832. 0x54,
  27833. 0xbb,
  27834. 0x16
  27835. ]);
  27836. var inv_s = new Uint8Array([
  27837. 0x52,
  27838. 0x09,
  27839. 0x6a,
  27840. 0xd5,
  27841. 0x30,
  27842. 0x36,
  27843. 0xa5,
  27844. 0x38,
  27845. 0xbf,
  27846. 0x40,
  27847. 0xa3,
  27848. 0x9e,
  27849. 0x81,
  27850. 0xf3,
  27851. 0xd7,
  27852. 0xfb,
  27853. 0x7c,
  27854. 0xe3,
  27855. 0x39,
  27856. 0x82,
  27857. 0x9b,
  27858. 0x2f,
  27859. 0xff,
  27860. 0x87,
  27861. 0x34,
  27862. 0x8e,
  27863. 0x43,
  27864. 0x44,
  27865. 0xc4,
  27866. 0xde,
  27867. 0xe9,
  27868. 0xcb,
  27869. 0x54,
  27870. 0x7b,
  27871. 0x94,
  27872. 0x32,
  27873. 0xa6,
  27874. 0xc2,
  27875. 0x23,
  27876. 0x3d,
  27877. 0xee,
  27878. 0x4c,
  27879. 0x95,
  27880. 0x0b,
  27881. 0x42,
  27882. 0xfa,
  27883. 0xc3,
  27884. 0x4e,
  27885. 0x08,
  27886. 0x2e,
  27887. 0xa1,
  27888. 0x66,
  27889. 0x28,
  27890. 0xd9,
  27891. 0x24,
  27892. 0xb2,
  27893. 0x76,
  27894. 0x5b,
  27895. 0xa2,
  27896. 0x49,
  27897. 0x6d,
  27898. 0x8b,
  27899. 0xd1,
  27900. 0x25,
  27901. 0x72,
  27902. 0xf8,
  27903. 0xf6,
  27904. 0x64,
  27905. 0x86,
  27906. 0x68,
  27907. 0x98,
  27908. 0x16,
  27909. 0xd4,
  27910. 0xa4,
  27911. 0x5c,
  27912. 0xcc,
  27913. 0x5d,
  27914. 0x65,
  27915. 0xb6,
  27916. 0x92,
  27917. 0x6c,
  27918. 0x70,
  27919. 0x48,
  27920. 0x50,
  27921. 0xfd,
  27922. 0xed,
  27923. 0xb9,
  27924. 0xda,
  27925. 0x5e,
  27926. 0x15,
  27927. 0x46,
  27928. 0x57,
  27929. 0xa7,
  27930. 0x8d,
  27931. 0x9d,
  27932. 0x84,
  27933. 0x90,
  27934. 0xd8,
  27935. 0xab,
  27936. 0x00,
  27937. 0x8c,
  27938. 0xbc,
  27939. 0xd3,
  27940. 0x0a,
  27941. 0xf7,
  27942. 0xe4,
  27943. 0x58,
  27944. 0x05,
  27945. 0xb8,
  27946. 0xb3,
  27947. 0x45,
  27948. 0x06,
  27949. 0xd0,
  27950. 0x2c,
  27951. 0x1e,
  27952. 0x8f,
  27953. 0xca,
  27954. 0x3f,
  27955. 0x0f,
  27956. 0x02,
  27957. 0xc1,
  27958. 0xaf,
  27959. 0xbd,
  27960. 0x03,
  27961. 0x01,
  27962. 0x13,
  27963. 0x8a,
  27964. 0x6b,
  27965. 0x3a,
  27966. 0x91,
  27967. 0x11,
  27968. 0x41,
  27969. 0x4f,
  27970. 0x67,
  27971. 0xdc,
  27972. 0xea,
  27973. 0x97,
  27974. 0xf2,
  27975. 0xcf,
  27976. 0xce,
  27977. 0xf0,
  27978. 0xb4,
  27979. 0xe6,
  27980. 0x73,
  27981. 0x96,
  27982. 0xac,
  27983. 0x74,
  27984. 0x22,
  27985. 0xe7,
  27986. 0xad,
  27987. 0x35,
  27988. 0x85,
  27989. 0xe2,
  27990. 0xf9,
  27991. 0x37,
  27992. 0xe8,
  27993. 0x1c,
  27994. 0x75,
  27995. 0xdf,
  27996. 0x6e,
  27997. 0x47,
  27998. 0xf1,
  27999. 0x1a,
  28000. 0x71,
  28001. 0x1d,
  28002. 0x29,
  28003. 0xc5,
  28004. 0x89,
  28005. 0x6f,
  28006. 0xb7,
  28007. 0x62,
  28008. 0x0e,
  28009. 0xaa,
  28010. 0x18,
  28011. 0xbe,
  28012. 0x1b,
  28013. 0xfc,
  28014. 0x56,
  28015. 0x3e,
  28016. 0x4b,
  28017. 0xc6,
  28018. 0xd2,
  28019. 0x79,
  28020. 0x20,
  28021. 0x9a,
  28022. 0xdb,
  28023. 0xc0,
  28024. 0xfe,
  28025. 0x78,
  28026. 0xcd,
  28027. 0x5a,
  28028. 0xf4,
  28029. 0x1f,
  28030. 0xdd,
  28031. 0xa8,
  28032. 0x33,
  28033. 0x88,
  28034. 0x07,
  28035. 0xc7,
  28036. 0x31,
  28037. 0xb1,
  28038. 0x12,
  28039. 0x10,
  28040. 0x59,
  28041. 0x27,
  28042. 0x80,
  28043. 0xec,
  28044. 0x5f,
  28045. 0x60,
  28046. 0x51,
  28047. 0x7f,
  28048. 0xa9,
  28049. 0x19,
  28050. 0xb5,
  28051. 0x4a,
  28052. 0x0d,
  28053. 0x2d,
  28054. 0xe5,
  28055. 0x7a,
  28056. 0x9f,
  28057. 0x93,
  28058. 0xc9,
  28059. 0x9c,
  28060. 0xef,
  28061. 0xa0,
  28062. 0xe0,
  28063. 0x3b,
  28064. 0x4d,
  28065. 0xae,
  28066. 0x2a,
  28067. 0xf5,
  28068. 0xb0,
  28069. 0xc8,
  28070. 0xeb,
  28071. 0xbb,
  28072. 0x3c,
  28073. 0x83,
  28074. 0x53,
  28075. 0x99,
  28076. 0x61,
  28077. 0x17,
  28078. 0x2b,
  28079. 0x04,
  28080. 0x7e,
  28081. 0xba,
  28082. 0x77,
  28083. 0xd6,
  28084. 0x26,
  28085. 0xe1,
  28086. 0x69,
  28087. 0x14,
  28088. 0x63,
  28089. 0x55,
  28090. 0x21,
  28091. 0x0c,
  28092. 0x7d
  28093. ]);
  28094. var mixCol = new Uint8Array(256);
  28095. for (var i = 0; i < 256; i++) {
  28096. if (i < 128) {
  28097. mixCol[i] = i << 1;
  28098. } else {
  28099. mixCol[i] = i << 1 ^ 0x1b;
  28100. }
  28101. }
  28102. var mix = new Uint32Array([
  28103. 0x00000000,
  28104. 0x0e090d0b,
  28105. 0x1c121a16,
  28106. 0x121b171d,
  28107. 0x3824342c,
  28108. 0x362d3927,
  28109. 0x24362e3a,
  28110. 0x2a3f2331,
  28111. 0x70486858,
  28112. 0x7e416553,
  28113. 0x6c5a724e,
  28114. 0x62537f45,
  28115. 0x486c5c74,
  28116. 0x4665517f,
  28117. 0x547e4662,
  28118. 0x5a774b69,
  28119. 0xe090d0b0,
  28120. 0xee99ddbb,
  28121. 0xfc82caa6,
  28122. 0xf28bc7ad,
  28123. 0xd8b4e49c,
  28124. 0xd6bde997,
  28125. 0xc4a6fe8a,
  28126. 0xcaaff381,
  28127. 0x90d8b8e8,
  28128. 0x9ed1b5e3,
  28129. 0x8ccaa2fe,
  28130. 0x82c3aff5,
  28131. 0xa8fc8cc4,
  28132. 0xa6f581cf,
  28133. 0xb4ee96d2,
  28134. 0xbae79bd9,
  28135. 0xdb3bbb7b,
  28136. 0xd532b670,
  28137. 0xc729a16d,
  28138. 0xc920ac66,
  28139. 0xe31f8f57,
  28140. 0xed16825c,
  28141. 0xff0d9541,
  28142. 0xf104984a,
  28143. 0xab73d323,
  28144. 0xa57ade28,
  28145. 0xb761c935,
  28146. 0xb968c43e,
  28147. 0x9357e70f,
  28148. 0x9d5eea04,
  28149. 0x8f45fd19,
  28150. 0x814cf012,
  28151. 0x3bab6bcb,
  28152. 0x35a266c0,
  28153. 0x27b971dd,
  28154. 0x29b07cd6,
  28155. 0x038f5fe7,
  28156. 0x0d8652ec,
  28157. 0x1f9d45f1,
  28158. 0x119448fa,
  28159. 0x4be30393,
  28160. 0x45ea0e98,
  28161. 0x57f11985,
  28162. 0x59f8148e,
  28163. 0x73c737bf,
  28164. 0x7dce3ab4,
  28165. 0x6fd52da9,
  28166. 0x61dc20a2,
  28167. 0xad766df6,
  28168. 0xa37f60fd,
  28169. 0xb16477e0,
  28170. 0xbf6d7aeb,
  28171. 0x955259da,
  28172. 0x9b5b54d1,
  28173. 0x894043cc,
  28174. 0x87494ec7,
  28175. 0xdd3e05ae,
  28176. 0xd33708a5,
  28177. 0xc12c1fb8,
  28178. 0xcf2512b3,
  28179. 0xe51a3182,
  28180. 0xeb133c89,
  28181. 0xf9082b94,
  28182. 0xf701269f,
  28183. 0x4de6bd46,
  28184. 0x43efb04d,
  28185. 0x51f4a750,
  28186. 0x5ffdaa5b,
  28187. 0x75c2896a,
  28188. 0x7bcb8461,
  28189. 0x69d0937c,
  28190. 0x67d99e77,
  28191. 0x3daed51e,
  28192. 0x33a7d815,
  28193. 0x21bccf08,
  28194. 0x2fb5c203,
  28195. 0x058ae132,
  28196. 0x0b83ec39,
  28197. 0x1998fb24,
  28198. 0x1791f62f,
  28199. 0x764dd68d,
  28200. 0x7844db86,
  28201. 0x6a5fcc9b,
  28202. 0x6456c190,
  28203. 0x4e69e2a1,
  28204. 0x4060efaa,
  28205. 0x527bf8b7,
  28206. 0x5c72f5bc,
  28207. 0x0605bed5,
  28208. 0x080cb3de,
  28209. 0x1a17a4c3,
  28210. 0x141ea9c8,
  28211. 0x3e218af9,
  28212. 0x302887f2,
  28213. 0x223390ef,
  28214. 0x2c3a9de4,
  28215. 0x96dd063d,
  28216. 0x98d40b36,
  28217. 0x8acf1c2b,
  28218. 0x84c61120,
  28219. 0xaef93211,
  28220. 0xa0f03f1a,
  28221. 0xb2eb2807,
  28222. 0xbce2250c,
  28223. 0xe6956e65,
  28224. 0xe89c636e,
  28225. 0xfa877473,
  28226. 0xf48e7978,
  28227. 0xdeb15a49,
  28228. 0xd0b85742,
  28229. 0xc2a3405f,
  28230. 0xccaa4d54,
  28231. 0x41ecdaf7,
  28232. 0x4fe5d7fc,
  28233. 0x5dfec0e1,
  28234. 0x53f7cdea,
  28235. 0x79c8eedb,
  28236. 0x77c1e3d0,
  28237. 0x65daf4cd,
  28238. 0x6bd3f9c6,
  28239. 0x31a4b2af,
  28240. 0x3fadbfa4,
  28241. 0x2db6a8b9,
  28242. 0x23bfa5b2,
  28243. 0x09808683,
  28244. 0x07898b88,
  28245. 0x15929c95,
  28246. 0x1b9b919e,
  28247. 0xa17c0a47,
  28248. 0xaf75074c,
  28249. 0xbd6e1051,
  28250. 0xb3671d5a,
  28251. 0x99583e6b,
  28252. 0x97513360,
  28253. 0x854a247d,
  28254. 0x8b432976,
  28255. 0xd134621f,
  28256. 0xdf3d6f14,
  28257. 0xcd267809,
  28258. 0xc32f7502,
  28259. 0xe9105633,
  28260. 0xe7195b38,
  28261. 0xf5024c25,
  28262. 0xfb0b412e,
  28263. 0x9ad7618c,
  28264. 0x94de6c87,
  28265. 0x86c57b9a,
  28266. 0x88cc7691,
  28267. 0xa2f355a0,
  28268. 0xacfa58ab,
  28269. 0xbee14fb6,
  28270. 0xb0e842bd,
  28271. 0xea9f09d4,
  28272. 0xe49604df,
  28273. 0xf68d13c2,
  28274. 0xf8841ec9,
  28275. 0xd2bb3df8,
  28276. 0xdcb230f3,
  28277. 0xcea927ee,
  28278. 0xc0a02ae5,
  28279. 0x7a47b13c,
  28280. 0x744ebc37,
  28281. 0x6655ab2a,
  28282. 0x685ca621,
  28283. 0x42638510,
  28284. 0x4c6a881b,
  28285. 0x5e719f06,
  28286. 0x5078920d,
  28287. 0x0a0fd964,
  28288. 0x0406d46f,
  28289. 0x161dc372,
  28290. 0x1814ce79,
  28291. 0x322bed48,
  28292. 0x3c22e043,
  28293. 0x2e39f75e,
  28294. 0x2030fa55,
  28295. 0xec9ab701,
  28296. 0xe293ba0a,
  28297. 0xf088ad17,
  28298. 0xfe81a01c,
  28299. 0xd4be832d,
  28300. 0xdab78e26,
  28301. 0xc8ac993b,
  28302. 0xc6a59430,
  28303. 0x9cd2df59,
  28304. 0x92dbd252,
  28305. 0x80c0c54f,
  28306. 0x8ec9c844,
  28307. 0xa4f6eb75,
  28308. 0xaaffe67e,
  28309. 0xb8e4f163,
  28310. 0xb6edfc68,
  28311. 0x0c0a67b1,
  28312. 0x02036aba,
  28313. 0x10187da7,
  28314. 0x1e1170ac,
  28315. 0x342e539d,
  28316. 0x3a275e96,
  28317. 0x283c498b,
  28318. 0x26354480,
  28319. 0x7c420fe9,
  28320. 0x724b02e2,
  28321. 0x605015ff,
  28322. 0x6e5918f4,
  28323. 0x44663bc5,
  28324. 0x4a6f36ce,
  28325. 0x587421d3,
  28326. 0x567d2cd8,
  28327. 0x37a10c7a,
  28328. 0x39a80171,
  28329. 0x2bb3166c,
  28330. 0x25ba1b67,
  28331. 0x0f853856,
  28332. 0x018c355d,
  28333. 0x13972240,
  28334. 0x1d9e2f4b,
  28335. 0x47e96422,
  28336. 0x49e06929,
  28337. 0x5bfb7e34,
  28338. 0x55f2733f,
  28339. 0x7fcd500e,
  28340. 0x71c45d05,
  28341. 0x63df4a18,
  28342. 0x6dd64713,
  28343. 0xd731dcca,
  28344. 0xd938d1c1,
  28345. 0xcb23c6dc,
  28346. 0xc52acbd7,
  28347. 0xef15e8e6,
  28348. 0xe11ce5ed,
  28349. 0xf307f2f0,
  28350. 0xfd0efffb,
  28351. 0xa779b492,
  28352. 0xa970b999,
  28353. 0xbb6bae84,
  28354. 0xb562a38f,
  28355. 0x9f5d80be,
  28356. 0x91548db5,
  28357. 0x834f9aa8,
  28358. 0x8d4697a3
  28359. ]);
  28360. function expandKey256(cipherKey) {
  28361. var b = 240, result = new Uint8Array(b);
  28362. var r = 1;
  28363. result.set(cipherKey);
  28364. for (var j = 32, i = 1; j < b; ++i) {
  28365. if (j % 32 === 16) {
  28366. t1 = s[t1];
  28367. t2 = s[t2];
  28368. t3 = s[t3];
  28369. t4 = s[t4];
  28370. } else if (j % 32 === 0) {
  28371. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28372. t1 = s[t1];
  28373. t2 = s[t2];
  28374. t3 = s[t3];
  28375. t4 = s[t4];
  28376. t1 = t1 ^ r;
  28377. if ((r <<= 1) >= 256) {
  28378. r = (r ^ 0x1b) & 0xFF;
  28379. }
  28380. }
  28381. for (var n = 0; n < 4; ++n) {
  28382. result[j] = t1 ^= result[j - 32];
  28383. j++;
  28384. result[j] = t2 ^= result[j - 32];
  28385. j++;
  28386. result[j] = t3 ^= result[j - 32];
  28387. j++;
  28388. result[j] = t4 ^= result[j - 32];
  28389. j++;
  28390. }
  28391. }
  28392. return result;
  28393. }
  28394. function decrypt256(input, key) {
  28395. var state = new Uint8Array(16);
  28396. state.set(input);
  28397. var i, j, k;
  28398. var t, u, v;
  28399. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28400. state[j] ^= key[k];
  28401. }
  28402. for (i = 13; i >= 1; --i) {
  28403. t = state[13];
  28404. state[13] = state[9];
  28405. state[9] = state[5];
  28406. state[5] = state[1];
  28407. state[1] = t;
  28408. t = state[14];
  28409. u = state[10];
  28410. state[14] = state[6];
  28411. state[10] = state[2];
  28412. state[6] = t;
  28413. state[2] = u;
  28414. t = state[15];
  28415. u = state[11];
  28416. v = state[7];
  28417. state[15] = state[3];
  28418. state[11] = t;
  28419. state[7] = u;
  28420. state[3] = v;
  28421. for (j = 0; j < 16; ++j) {
  28422. state[j] = inv_s[state[j]];
  28423. }
  28424. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28425. state[j] ^= key[k];
  28426. }
  28427. for (j = 0; j < 16; j += 4) {
  28428. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28429. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28430. state[j] = t >>> 24 & 0xFF;
  28431. state[j + 1] = t >> 16 & 0xFF;
  28432. state[j + 2] = t >> 8 & 0xFF;
  28433. state[j + 3] = t & 0xFF;
  28434. }
  28435. }
  28436. t = state[13];
  28437. state[13] = state[9];
  28438. state[9] = state[5];
  28439. state[5] = state[1];
  28440. state[1] = t;
  28441. t = state[14];
  28442. u = state[10];
  28443. state[14] = state[6];
  28444. state[10] = state[2];
  28445. state[6] = t;
  28446. state[2] = u;
  28447. t = state[15];
  28448. u = state[11];
  28449. v = state[7];
  28450. state[15] = state[3];
  28451. state[11] = t;
  28452. state[7] = u;
  28453. state[3] = v;
  28454. for (j = 0; j < 16; ++j) {
  28455. state[j] = inv_s[state[j]];
  28456. state[j] ^= key[j];
  28457. }
  28458. return state;
  28459. }
  28460. function encrypt256(input, key) {
  28461. var t, u, v, k;
  28462. var state = new Uint8Array(16);
  28463. state.set(input);
  28464. for (j = 0; j < 16; ++j) {
  28465. state[j] ^= key[j];
  28466. }
  28467. for (i = 1; i < 14; i++) {
  28468. for (j = 0; j < 16; ++j) {
  28469. state[j] = s[state[j]];
  28470. }
  28471. v = state[1];
  28472. state[1] = state[5];
  28473. state[5] = state[9];
  28474. state[9] = state[13];
  28475. state[13] = v;
  28476. v = state[2];
  28477. u = state[6];
  28478. state[2] = state[10];
  28479. state[6] = state[14];
  28480. state[10] = v;
  28481. state[14] = u;
  28482. v = state[3];
  28483. u = state[7];
  28484. t = state[11];
  28485. state[3] = state[15];
  28486. state[7] = v;
  28487. state[11] = u;
  28488. state[15] = t;
  28489. for (var j = 0; j < 16; j += 4) {
  28490. var s0 = state[j + 0], s1 = state[j + 1];
  28491. var s2 = state[j + 2], s3 = state[j + 3];
  28492. t = s0 ^ s1 ^ s2 ^ s3;
  28493. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28494. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28495. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28496. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28497. }
  28498. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28499. state[j] ^= key[k];
  28500. }
  28501. }
  28502. for (j = 0; j < 16; ++j) {
  28503. state[j] = s[state[j]];
  28504. }
  28505. v = state[1];
  28506. state[1] = state[5];
  28507. state[5] = state[9];
  28508. state[9] = state[13];
  28509. state[13] = v;
  28510. v = state[2];
  28511. u = state[6];
  28512. state[2] = state[10];
  28513. state[6] = state[14];
  28514. state[10] = v;
  28515. state[14] = u;
  28516. v = state[3];
  28517. u = state[7];
  28518. t = state[11];
  28519. state[3] = state[15];
  28520. state[7] = v;
  28521. state[11] = u;
  28522. state[15] = t;
  28523. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28524. state[j] ^= key[k];
  28525. }
  28526. return state;
  28527. }
  28528. function AES256Cipher(key) {
  28529. this.key = expandKey256(key);
  28530. this.buffer = new Uint8Array(16);
  28531. this.bufferPosition = 0;
  28532. }
  28533. function decryptBlock2(data, finalize) {
  28534. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28535. for (i = 0; i < sourceLength; ++i) {
  28536. buffer[bufferLength] = data[i];
  28537. ++bufferLength;
  28538. if (bufferLength < 16) {
  28539. continue;
  28540. }
  28541. var plain = decrypt256(buffer, this.key);
  28542. for (j = 0; j < 16; ++j) {
  28543. plain[j] ^= iv[j];
  28544. }
  28545. iv = buffer;
  28546. result.push(plain);
  28547. buffer = new Uint8Array(16);
  28548. bufferLength = 0;
  28549. }
  28550. this.buffer = buffer;
  28551. this.bufferLength = bufferLength;
  28552. this.iv = iv;
  28553. if (result.length === 0) {
  28554. return new Uint8Array([]);
  28555. }
  28556. var outputLength = 16 * result.length;
  28557. if (finalize) {
  28558. var lastBlock = result[result.length - 1];
  28559. var psLen = lastBlock[15];
  28560. if (psLen <= 16) {
  28561. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28562. if (lastBlock[i] !== psLen) {
  28563. psLen = 0;
  28564. break;
  28565. }
  28566. }
  28567. outputLength -= psLen;
  28568. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28569. }
  28570. }
  28571. var output = new Uint8Array(outputLength);
  28572. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28573. output.set(result[i], j);
  28574. }
  28575. return output;
  28576. }
  28577. AES256Cipher.prototype = {
  28578. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28579. var i, sourceLength = data.length;
  28580. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28581. if (iv) {
  28582. this.iv = iv;
  28583. } else {
  28584. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28585. buffer[bufferLength] = data[i];
  28586. }
  28587. if (bufferLength < 16) {
  28588. this.bufferLength = bufferLength;
  28589. return new Uint8Array([]);
  28590. }
  28591. this.iv = buffer;
  28592. data = data.subarray(16);
  28593. }
  28594. this.buffer = new Uint8Array(16);
  28595. this.bufferLength = 0;
  28596. this.decryptBlock = decryptBlock2;
  28597. return this.decryptBlock(data, finalize);
  28598. },
  28599. encrypt: function AES256Cipher_encrypt(data, iv) {
  28600. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28601. if (!iv) {
  28602. iv = new Uint8Array(16);
  28603. }
  28604. for (i = 0; i < sourceLength; ++i) {
  28605. buffer[bufferLength] = data[i];
  28606. ++bufferLength;
  28607. if (bufferLength < 16) {
  28608. continue;
  28609. }
  28610. for (j = 0; j < 16; ++j) {
  28611. buffer[j] ^= iv[j];
  28612. }
  28613. var cipher = encrypt256(buffer, this.key);
  28614. this.iv = cipher;
  28615. result.push(cipher);
  28616. buffer = new Uint8Array(16);
  28617. bufferLength = 0;
  28618. }
  28619. this.buffer = buffer;
  28620. this.bufferLength = bufferLength;
  28621. this.iv = iv;
  28622. if (result.length === 0) {
  28623. return new Uint8Array([]);
  28624. }
  28625. var outputLength = 16 * result.length;
  28626. var output = new Uint8Array(outputLength);
  28627. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28628. output.set(result[i], j);
  28629. }
  28630. return output;
  28631. }
  28632. };
  28633. return AES256Cipher;
  28634. }();
  28635. var PDF17 = function PDF17Closure() {
  28636. function compareByteArrays(array1, array2) {
  28637. if (array1.length !== array2.length) {
  28638. return false;
  28639. }
  28640. for (var i = 0; i < array1.length; i++) {
  28641. if (array1[i] !== array2[i]) {
  28642. return false;
  28643. }
  28644. }
  28645. return true;
  28646. }
  28647. function PDF17() {
  28648. }
  28649. PDF17.prototype = {
  28650. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28651. var hashData = new Uint8Array(password.length + 56);
  28652. hashData.set(password, 0);
  28653. hashData.set(ownerValidationSalt, password.length);
  28654. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28655. var result = calculateSHA256(hashData, 0, hashData.length);
  28656. return compareByteArrays(result, ownerPassword);
  28657. },
  28658. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28659. var hashData = new Uint8Array(password.length + 8);
  28660. hashData.set(password, 0);
  28661. hashData.set(userValidationSalt, password.length);
  28662. var result = calculateSHA256(hashData, 0, hashData.length);
  28663. return compareByteArrays(result, userPassword);
  28664. },
  28665. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28666. var hashData = new Uint8Array(password.length + 56);
  28667. hashData.set(password, 0);
  28668. hashData.set(ownerKeySalt, password.length);
  28669. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28670. var key = calculateSHA256(hashData, 0, hashData.length);
  28671. var cipher = new AES256Cipher(key);
  28672. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28673. },
  28674. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28675. var hashData = new Uint8Array(password.length + 8);
  28676. hashData.set(password, 0);
  28677. hashData.set(userKeySalt, password.length);
  28678. var key = calculateSHA256(hashData, 0, hashData.length);
  28679. var cipher = new AES256Cipher(key);
  28680. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28681. }
  28682. };
  28683. return PDF17;
  28684. }();
  28685. var PDF20 = function PDF20Closure() {
  28686. function concatArrays(array1, array2) {
  28687. var t = new Uint8Array(array1.length + array2.length);
  28688. t.set(array1, 0);
  28689. t.set(array2, array1.length);
  28690. return t;
  28691. }
  28692. function calculatePDF20Hash(password, input, userBytes) {
  28693. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28694. var e = [0];
  28695. var i = 0;
  28696. while (i < 64 || e[e.length - 1] > i - 32) {
  28697. var arrayLength = password.length + k.length + userBytes.length;
  28698. var k1 = new Uint8Array(arrayLength * 64);
  28699. var array = concatArrays(password, k);
  28700. array = concatArrays(array, userBytes);
  28701. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28702. k1.set(array, pos);
  28703. }
  28704. var cipher = new AES128Cipher(k.subarray(0, 16));
  28705. e = cipher.encrypt(k1, k.subarray(16, 32));
  28706. var remainder = 0;
  28707. for (var z = 0; z < 16; z++) {
  28708. remainder *= 256 % 3;
  28709. remainder %= 3;
  28710. remainder += (e[z] >>> 0) % 3;
  28711. remainder %= 3;
  28712. }
  28713. if (remainder === 0) {
  28714. k = calculateSHA256(e, 0, e.length);
  28715. } else if (remainder === 1) {
  28716. k = calculateSHA384(e, 0, e.length);
  28717. } else if (remainder === 2) {
  28718. k = calculateSHA512(e, 0, e.length);
  28719. }
  28720. i++;
  28721. }
  28722. return k.subarray(0, 32);
  28723. }
  28724. function PDF20() {
  28725. }
  28726. function compareByteArrays(array1, array2) {
  28727. if (array1.length !== array2.length) {
  28728. return false;
  28729. }
  28730. for (var i = 0; i < array1.length; i++) {
  28731. if (array1[i] !== array2[i]) {
  28732. return false;
  28733. }
  28734. }
  28735. return true;
  28736. }
  28737. PDF20.prototype = {
  28738. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28739. return calculatePDF20Hash(password, concatBytes, userBytes);
  28740. },
  28741. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28742. var hashData = new Uint8Array(password.length + 56);
  28743. hashData.set(password, 0);
  28744. hashData.set(ownerValidationSalt, password.length);
  28745. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28746. var result = calculatePDF20Hash(password, hashData, userBytes);
  28747. return compareByteArrays(result, ownerPassword);
  28748. },
  28749. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28750. var hashData = new Uint8Array(password.length + 8);
  28751. hashData.set(password, 0);
  28752. hashData.set(userValidationSalt, password.length);
  28753. var result = calculatePDF20Hash(password, hashData, []);
  28754. return compareByteArrays(result, userPassword);
  28755. },
  28756. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28757. var hashData = new Uint8Array(password.length + 56);
  28758. hashData.set(password, 0);
  28759. hashData.set(ownerKeySalt, password.length);
  28760. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28761. var key = calculatePDF20Hash(password, hashData, userBytes);
  28762. var cipher = new AES256Cipher(key);
  28763. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28764. },
  28765. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28766. var hashData = new Uint8Array(password.length + 8);
  28767. hashData.set(password, 0);
  28768. hashData.set(userKeySalt, password.length);
  28769. var key = calculatePDF20Hash(password, hashData, []);
  28770. var cipher = new AES256Cipher(key);
  28771. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28772. }
  28773. };
  28774. return PDF20;
  28775. }();
  28776. var CipherTransform = function CipherTransformClosure() {
  28777. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28778. this.StringCipherConstructor = stringCipherConstructor;
  28779. this.StreamCipherConstructor = streamCipherConstructor;
  28780. }
  28781. CipherTransform.prototype = {
  28782. createStream: function CipherTransform_createStream(stream, length) {
  28783. var cipher = new this.StreamCipherConstructor();
  28784. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28785. return cipher.decryptBlock(data, finalize);
  28786. });
  28787. },
  28788. decryptString: function CipherTransform_decryptString(s) {
  28789. var cipher = new this.StringCipherConstructor();
  28790. var data = stringToBytes(s);
  28791. data = cipher.decryptBlock(data, true);
  28792. return bytesToString(data);
  28793. }
  28794. };
  28795. return CipherTransform;
  28796. }();
  28797. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28798. var defaultPasswordBytes = new Uint8Array([
  28799. 0x28,
  28800. 0xBF,
  28801. 0x4E,
  28802. 0x5E,
  28803. 0x4E,
  28804. 0x75,
  28805. 0x8A,
  28806. 0x41,
  28807. 0x64,
  28808. 0x00,
  28809. 0x4E,
  28810. 0x56,
  28811. 0xFF,
  28812. 0xFA,
  28813. 0x01,
  28814. 0x08,
  28815. 0x2E,
  28816. 0x2E,
  28817. 0x00,
  28818. 0xB6,
  28819. 0xD0,
  28820. 0x68,
  28821. 0x3E,
  28822. 0x80,
  28823. 0x2F,
  28824. 0x0C,
  28825. 0xA9,
  28826. 0xFE,
  28827. 0x64,
  28828. 0x53,
  28829. 0x69,
  28830. 0x7A
  28831. ]);
  28832. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28833. if (password) {
  28834. var passwordLength = Math.min(127, password.length);
  28835. password = password.subarray(0, passwordLength);
  28836. } else {
  28837. password = [];
  28838. }
  28839. var pdfAlgorithm;
  28840. if (revision === 6) {
  28841. pdfAlgorithm = new PDF20();
  28842. } else {
  28843. pdfAlgorithm = new PDF17();
  28844. }
  28845. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28846. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28847. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28848. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28849. }
  28850. return null;
  28851. }
  28852. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28853. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28854. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28855. if (password) {
  28856. n = Math.min(32, password.length);
  28857. for (; i < n; ++i) {
  28858. hashData[i] = password[i];
  28859. }
  28860. }
  28861. j = 0;
  28862. while (i < 32) {
  28863. hashData[i++] = defaultPasswordBytes[j++];
  28864. }
  28865. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28866. hashData[i++] = ownerPassword[j];
  28867. }
  28868. hashData[i++] = flags & 0xFF;
  28869. hashData[i++] = flags >> 8 & 0xFF;
  28870. hashData[i++] = flags >> 16 & 0xFF;
  28871. hashData[i++] = flags >>> 24 & 0xFF;
  28872. for (j = 0, n = fileId.length; j < n; ++j) {
  28873. hashData[i++] = fileId[j];
  28874. }
  28875. if (revision >= 4 && !encryptMetadata) {
  28876. hashData[i++] = 0xFF;
  28877. hashData[i++] = 0xFF;
  28878. hashData[i++] = 0xFF;
  28879. hashData[i++] = 0xFF;
  28880. }
  28881. var hash = calculateMD5(hashData, 0, i);
  28882. var keyLengthInBytes = keyLength >> 3;
  28883. if (revision >= 3) {
  28884. for (j = 0; j < 50; ++j) {
  28885. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28886. }
  28887. }
  28888. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28889. var cipher, checkData;
  28890. if (revision >= 3) {
  28891. for (i = 0; i < 32; ++i) {
  28892. hashData[i] = defaultPasswordBytes[i];
  28893. }
  28894. for (j = 0, n = fileId.length; j < n; ++j) {
  28895. hashData[i++] = fileId[j];
  28896. }
  28897. cipher = new ARCFourCipher(encryptionKey);
  28898. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28899. n = encryptionKey.length;
  28900. var derivedKey = new Uint8Array(n), k;
  28901. for (j = 1; j <= 19; ++j) {
  28902. for (k = 0; k < n; ++k) {
  28903. derivedKey[k] = encryptionKey[k] ^ j;
  28904. }
  28905. cipher = new ARCFourCipher(derivedKey);
  28906. checkData = cipher.encryptBlock(checkData);
  28907. }
  28908. for (j = 0, n = checkData.length; j < n; ++j) {
  28909. if (userPassword[j] !== checkData[j]) {
  28910. return null;
  28911. }
  28912. }
  28913. } else {
  28914. cipher = new ARCFourCipher(encryptionKey);
  28915. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28916. for (j = 0, n = checkData.length; j < n; ++j) {
  28917. if (userPassword[j] !== checkData[j]) {
  28918. return null;
  28919. }
  28920. }
  28921. }
  28922. return encryptionKey;
  28923. }
  28924. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28925. var hashData = new Uint8Array(32), i = 0, j, n;
  28926. n = Math.min(32, password.length);
  28927. for (; i < n; ++i) {
  28928. hashData[i] = password[i];
  28929. }
  28930. j = 0;
  28931. while (i < 32) {
  28932. hashData[i++] = defaultPasswordBytes[j++];
  28933. }
  28934. var hash = calculateMD5(hashData, 0, i);
  28935. var keyLengthInBytes = keyLength >> 3;
  28936. if (revision >= 3) {
  28937. for (j = 0; j < 50; ++j) {
  28938. hash = calculateMD5(hash, 0, hash.length);
  28939. }
  28940. }
  28941. var cipher, userPassword;
  28942. if (revision >= 3) {
  28943. userPassword = ownerPassword;
  28944. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28945. for (j = 19; j >= 0; j--) {
  28946. for (k = 0; k < keyLengthInBytes; ++k) {
  28947. derivedKey[k] = hash[k] ^ j;
  28948. }
  28949. cipher = new ARCFourCipher(derivedKey);
  28950. userPassword = cipher.encryptBlock(userPassword);
  28951. }
  28952. } else {
  28953. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28954. userPassword = cipher.encryptBlock(ownerPassword);
  28955. }
  28956. return userPassword;
  28957. }
  28958. var identityName = Name.get('Identity');
  28959. function CipherTransformFactory(dict, fileId, password) {
  28960. var filter = dict.get('Filter');
  28961. if (!isName(filter, 'Standard')) {
  28962. error('unknown encryption method');
  28963. }
  28964. this.dict = dict;
  28965. var algorithm = dict.get('V');
  28966. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28967. error('unsupported encryption algorithm');
  28968. }
  28969. this.algorithm = algorithm;
  28970. var keyLength = dict.get('Length');
  28971. if (!keyLength) {
  28972. if (algorithm <= 3) {
  28973. keyLength = 40;
  28974. } else {
  28975. var cfDict = dict.get('CF');
  28976. var streamCryptoName = dict.get('StmF');
  28977. if (isDict(cfDict) && isName(streamCryptoName)) {
  28978. cfDict.suppressEncryption = true;
  28979. var handlerDict = cfDict.get(streamCryptoName.name);
  28980. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28981. if (keyLength < 40) {
  28982. keyLength <<= 3;
  28983. }
  28984. }
  28985. }
  28986. }
  28987. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28988. error('invalid key length');
  28989. }
  28990. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28991. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28992. var flags = dict.get('P');
  28993. var revision = dict.get('R');
  28994. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28995. this.encryptMetadata = encryptMetadata;
  28996. var fileIdBytes = stringToBytes(fileId);
  28997. var passwordBytes;
  28998. if (password) {
  28999. if (revision === 6) {
  29000. try {
  29001. password = utf8StringToString(password);
  29002. } catch (ex) {
  29003. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29004. }
  29005. }
  29006. passwordBytes = stringToBytes(password);
  29007. }
  29008. var encryptionKey;
  29009. if (algorithm !== 5) {
  29010. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29011. } else {
  29012. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29013. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29014. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29015. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29016. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29017. var ownerEncryption = stringToBytes(dict.get('OE'));
  29018. var userEncryption = stringToBytes(dict.get('UE'));
  29019. var perms = stringToBytes(dict.get('Perms'));
  29020. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29021. }
  29022. if (!encryptionKey && !password) {
  29023. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29024. } else if (!encryptionKey && password) {
  29025. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29026. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29027. }
  29028. if (!encryptionKey) {
  29029. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29030. }
  29031. this.encryptionKey = encryptionKey;
  29032. if (algorithm >= 4) {
  29033. var cf = dict.get('CF');
  29034. if (isDict(cf)) {
  29035. cf.suppressEncryption = true;
  29036. }
  29037. this.cf = cf;
  29038. this.stmf = dict.get('StmF') || identityName;
  29039. this.strf = dict.get('StrF') || identityName;
  29040. this.eff = dict.get('EFF') || this.stmf;
  29041. }
  29042. }
  29043. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29044. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29045. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29046. key[i] = encryptionKey[i];
  29047. }
  29048. key[i++] = num & 0xFF;
  29049. key[i++] = num >> 8 & 0xFF;
  29050. key[i++] = num >> 16 & 0xFF;
  29051. key[i++] = gen & 0xFF;
  29052. key[i++] = gen >> 8 & 0xFF;
  29053. if (isAes) {
  29054. key[i++] = 0x73;
  29055. key[i++] = 0x41;
  29056. key[i++] = 0x6C;
  29057. key[i++] = 0x54;
  29058. }
  29059. var hash = calculateMD5(key, 0, i);
  29060. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29061. }
  29062. function buildCipherConstructor(cf, name, num, gen, key) {
  29063. assert(isName(name), 'Invalid crypt filter name.');
  29064. var cryptFilter = cf.get(name.name);
  29065. var cfm;
  29066. if (cryptFilter !== null && cryptFilter !== undefined) {
  29067. cfm = cryptFilter.get('CFM');
  29068. }
  29069. if (!cfm || cfm.name === 'None') {
  29070. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29071. return new NullCipher();
  29072. };
  29073. }
  29074. if (cfm.name === 'V2') {
  29075. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29076. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29077. };
  29078. }
  29079. if (cfm.name === 'AESV2') {
  29080. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29081. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29082. };
  29083. }
  29084. if (cfm.name === 'AESV3') {
  29085. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29086. return new AES256Cipher(key);
  29087. };
  29088. }
  29089. error('Unknown crypto method');
  29090. }
  29091. CipherTransformFactory.prototype = {
  29092. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29093. if (this.algorithm === 4 || this.algorithm === 5) {
  29094. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29095. }
  29096. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29097. var cipherConstructor = function buildCipherCipherConstructor() {
  29098. return new ARCFourCipher(key);
  29099. };
  29100. return new CipherTransform(cipherConstructor, cipherConstructor);
  29101. }
  29102. };
  29103. return CipherTransformFactory;
  29104. }();
  29105. exports.AES128Cipher = AES128Cipher;
  29106. exports.AES256Cipher = AES256Cipher;
  29107. exports.ARCFourCipher = ARCFourCipher;
  29108. exports.CipherTransformFactory = CipherTransformFactory;
  29109. exports.PDF17 = PDF17;
  29110. exports.PDF20 = PDF20;
  29111. exports.calculateMD5 = calculateMD5;
  29112. exports.calculateSHA256 = calculateSHA256;
  29113. exports.calculateSHA384 = calculateSHA384;
  29114. exports.calculateSHA512 = calculateSHA512;
  29115. /***/ }),
  29116. /* 17 */
  29117. /***/ (function(module, exports, __w_pdfjs_require__) {
  29118. "use strict";
  29119. var sharedUtil = __w_pdfjs_require__(0);
  29120. var corePrimitives = __w_pdfjs_require__(1);
  29121. var coreStream = __w_pdfjs_require__(2);
  29122. var coreParser = __w_pdfjs_require__(6);
  29123. var coreImage = __w_pdfjs_require__(35);
  29124. var coreColorSpace = __w_pdfjs_require__(4);
  29125. var coreMurmurHash3 = __w_pdfjs_require__(39);
  29126. var coreFonts = __w_pdfjs_require__(34);
  29127. var coreFunction = __w_pdfjs_require__(7);
  29128. var corePattern = __w_pdfjs_require__(41);
  29129. var coreCMap = __w_pdfjs_require__(31);
  29130. var coreMetrics = __w_pdfjs_require__(38);
  29131. var coreBidi = __w_pdfjs_require__(29);
  29132. var coreEncodings = __w_pdfjs_require__(5);
  29133. var coreStandardFonts = __w_pdfjs_require__(20);
  29134. var coreUnicode = __w_pdfjs_require__(21);
  29135. var coreGlyphList = __w_pdfjs_require__(8);
  29136. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29137. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29138. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29139. var ImageKind = sharedUtil.ImageKind;
  29140. var OPS = sharedUtil.OPS;
  29141. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29142. var Util = sharedUtil.Util;
  29143. var assert = sharedUtil.assert;
  29144. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29145. var error = sharedUtil.error;
  29146. var info = sharedUtil.info;
  29147. var isArray = sharedUtil.isArray;
  29148. var isNum = sharedUtil.isNum;
  29149. var isString = sharedUtil.isString;
  29150. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29151. var warn = sharedUtil.warn;
  29152. var Dict = corePrimitives.Dict;
  29153. var Name = corePrimitives.Name;
  29154. var isEOF = corePrimitives.isEOF;
  29155. var isCmd = corePrimitives.isCmd;
  29156. var isDict = corePrimitives.isDict;
  29157. var isName = corePrimitives.isName;
  29158. var isRef = corePrimitives.isRef;
  29159. var isStream = corePrimitives.isStream;
  29160. var DecodeStream = coreStream.DecodeStream;
  29161. var JpegStream = coreStream.JpegStream;
  29162. var Stream = coreStream.Stream;
  29163. var Lexer = coreParser.Lexer;
  29164. var Parser = coreParser.Parser;
  29165. var PDFImage = coreImage.PDFImage;
  29166. var ColorSpace = coreColorSpace.ColorSpace;
  29167. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29168. var ErrorFont = coreFonts.ErrorFont;
  29169. var FontFlags = coreFonts.FontFlags;
  29170. var Font = coreFonts.Font;
  29171. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29172. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29173. var getFontType = coreFonts.getFontType;
  29174. var isPDFFunction = coreFunction.isPDFFunction;
  29175. var PDFFunction = coreFunction.PDFFunction;
  29176. var Pattern = corePattern.Pattern;
  29177. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29178. var CMapFactory = coreCMap.CMapFactory;
  29179. var IdentityCMap = coreCMap.IdentityCMap;
  29180. var getMetrics = coreMetrics.getMetrics;
  29181. var bidi = coreBidi.bidi;
  29182. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29183. var StandardEncoding = coreEncodings.StandardEncoding;
  29184. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29185. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29186. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29187. var getEncoding = coreEncodings.getEncoding;
  29188. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29189. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29190. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29191. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29192. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29193. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29194. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29195. var PartialEvaluator = function PartialEvaluatorClosure() {
  29196. var DefaultPartialEvaluatorOptions = {
  29197. forceDataSchema: false,
  29198. maxImageSize: -1,
  29199. disableFontFace: false,
  29200. cMapOptions: {
  29201. url: null,
  29202. packed: false
  29203. },
  29204. disableNativeImageDecoder: false
  29205. };
  29206. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29207. this.xref = xref;
  29208. this.resources = resources;
  29209. this.handler = handler;
  29210. this.forceDataSchema = forceDataSchema;
  29211. }
  29212. NativeImageDecoder.prototype = {
  29213. canDecode: function (image) {
  29214. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29215. },
  29216. decode: function (image) {
  29217. var dict = image.dict;
  29218. var colorSpace = dict.get('ColorSpace', 'CS');
  29219. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29220. var numComps = colorSpace.numComps;
  29221. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29222. image.getIR(this.forceDataSchema),
  29223. numComps
  29224. ]);
  29225. return decodePromise.then(function (message) {
  29226. var data = message.data;
  29227. return new Stream(data, 0, data.length, image.dict);
  29228. });
  29229. }
  29230. };
  29231. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29232. var dict = image.dict;
  29233. if (dict.has('DecodeParms') || dict.has('DP')) {
  29234. return false;
  29235. }
  29236. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29237. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29238. };
  29239. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29240. var dict = image.dict;
  29241. if (dict.has('DecodeParms') || dict.has('DP')) {
  29242. return false;
  29243. }
  29244. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29245. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29246. };
  29247. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  29248. this.pdfManager = pdfManager;
  29249. this.xref = xref;
  29250. this.handler = handler;
  29251. this.pageIndex = pageIndex;
  29252. this.idFactory = idFactory;
  29253. this.fontCache = fontCache;
  29254. this.options = options || DefaultPartialEvaluatorOptions;
  29255. }
  29256. var TIME_SLOT_DURATION_MS = 20;
  29257. var CHECK_TIME_EVERY = 100;
  29258. function TimeSlotManager() {
  29259. this.reset();
  29260. }
  29261. TimeSlotManager.prototype = {
  29262. check: function TimeSlotManager_check() {
  29263. if (++this.checked < CHECK_TIME_EVERY) {
  29264. return false;
  29265. }
  29266. this.checked = 0;
  29267. return this.endTime <= Date.now();
  29268. },
  29269. reset: function TimeSlotManager_reset() {
  29270. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29271. this.checked = 0;
  29272. }
  29273. };
  29274. var deferred = Promise.resolve();
  29275. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29276. PartialEvaluator.prototype = {
  29277. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29278. if (!isDict(resources)) {
  29279. return false;
  29280. }
  29281. var processed = Object.create(null);
  29282. if (resources.objId) {
  29283. processed[resources.objId] = true;
  29284. }
  29285. var nodes = [resources], xref = this.xref;
  29286. while (nodes.length) {
  29287. var key, i, ii;
  29288. var node = nodes.shift();
  29289. var graphicStates = node.get('ExtGState');
  29290. if (isDict(graphicStates)) {
  29291. var graphicStatesKeys = graphicStates.getKeys();
  29292. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29293. key = graphicStatesKeys[i];
  29294. var graphicState = graphicStates.get(key);
  29295. var bm = graphicState.get('BM');
  29296. if (isName(bm) && bm.name !== 'Normal') {
  29297. return true;
  29298. }
  29299. }
  29300. }
  29301. var xObjects = node.get('XObject');
  29302. if (!isDict(xObjects)) {
  29303. continue;
  29304. }
  29305. var xObjectsKeys = xObjects.getKeys();
  29306. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29307. key = xObjectsKeys[i];
  29308. var xObject = xObjects.getRaw(key);
  29309. if (isRef(xObject)) {
  29310. if (processed[xObject.toString()]) {
  29311. continue;
  29312. }
  29313. xObject = xref.fetch(xObject);
  29314. }
  29315. if (!isStream(xObject)) {
  29316. continue;
  29317. }
  29318. if (xObject.dict.objId) {
  29319. if (processed[xObject.dict.objId]) {
  29320. continue;
  29321. }
  29322. processed[xObject.dict.objId] = true;
  29323. }
  29324. var xResources = xObject.dict.get('Resources');
  29325. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29326. nodes.push(xResources);
  29327. if (xResources.objId) {
  29328. processed[xResources.objId] = true;
  29329. }
  29330. }
  29331. }
  29332. }
  29333. return false;
  29334. },
  29335. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29336. var matrix = xobj.dict.getArray('Matrix');
  29337. var bbox = xobj.dict.getArray('BBox');
  29338. var group = xobj.dict.get('Group');
  29339. if (group) {
  29340. var groupOptions = {
  29341. matrix: matrix,
  29342. bbox: bbox,
  29343. smask: smask,
  29344. isolated: false,
  29345. knockout: false
  29346. };
  29347. var groupSubtype = group.get('S');
  29348. var colorSpace;
  29349. if (isName(groupSubtype, 'Transparency')) {
  29350. groupOptions.isolated = group.get('I') || false;
  29351. groupOptions.knockout = group.get('K') || false;
  29352. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29353. }
  29354. if (smask && smask.backdrop) {
  29355. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29356. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29357. }
  29358. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29359. }
  29360. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29361. matrix,
  29362. bbox
  29363. ]);
  29364. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29365. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29366. if (group) {
  29367. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29368. }
  29369. });
  29370. },
  29371. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29372. var self = this;
  29373. var dict = image.dict;
  29374. var w = dict.get('Width', 'W');
  29375. var h = dict.get('Height', 'H');
  29376. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29377. warn('Image dimensions are missing, or not numbers.');
  29378. return;
  29379. }
  29380. var maxImageSize = this.options.maxImageSize;
  29381. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29382. warn('Image exceeded maximum allowed size and was removed.');
  29383. return;
  29384. }
  29385. var imageMask = dict.get('ImageMask', 'IM') || false;
  29386. var imgData, args;
  29387. if (imageMask) {
  29388. var width = dict.get('Width', 'W');
  29389. var height = dict.get('Height', 'H');
  29390. var bitStrideLength = width + 7 >> 3;
  29391. var imgArray = image.getBytes(bitStrideLength * height);
  29392. var decode = dict.getArray('Decode', 'D');
  29393. var inverseDecode = !!decode && decode[0] > 0;
  29394. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29395. imgData.cached = true;
  29396. args = [imgData];
  29397. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29398. if (cacheKey) {
  29399. imageCache[cacheKey] = {
  29400. fn: OPS.paintImageMaskXObject,
  29401. args: args
  29402. };
  29403. }
  29404. return;
  29405. }
  29406. var softMask = dict.get('SMask', 'SM') || false;
  29407. var mask = dict.get('Mask') || false;
  29408. var SMALL_IMAGE_DIMENSIONS = 200;
  29409. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29410. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29411. imgData = imageObj.createImageData(true);
  29412. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29413. return;
  29414. }
  29415. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29416. var objId = 'img_' + this.idFactory.createObjId();
  29417. operatorList.addDependency(objId);
  29418. args = [
  29419. objId,
  29420. w,
  29421. h
  29422. ];
  29423. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29424. operatorList.addOp(OPS.paintJpegXObject, args);
  29425. this.handler.send('obj', [
  29426. objId,
  29427. this.pageIndex,
  29428. 'JpegStream',
  29429. image.getIR(this.options.forceDataSchema)
  29430. ]);
  29431. return;
  29432. }
  29433. var nativeImageDecoder = null;
  29434. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29435. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29436. }
  29437. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29438. var imgData = imageObj.createImageData(false);
  29439. self.handler.send('obj', [
  29440. objId,
  29441. self.pageIndex,
  29442. 'Image',
  29443. imgData
  29444. ], [imgData.data.buffer]);
  29445. }).then(undefined, function (reason) {
  29446. warn('Unable to decode image: ' + reason);
  29447. self.handler.send('obj', [
  29448. objId,
  29449. self.pageIndex,
  29450. 'Image',
  29451. null
  29452. ]);
  29453. });
  29454. operatorList.addOp(OPS.paintImageXObject, args);
  29455. if (cacheKey) {
  29456. imageCache[cacheKey] = {
  29457. fn: OPS.paintImageXObject,
  29458. args: args
  29459. };
  29460. }
  29461. },
  29462. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29463. var smaskContent = smask.get('G');
  29464. var smaskOptions = {
  29465. subtype: smask.get('S').name,
  29466. backdrop: smask.get('BC')
  29467. };
  29468. var transferObj = smask.get('TR');
  29469. if (isPDFFunction(transferObj)) {
  29470. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29471. var transferMap = new Uint8Array(256);
  29472. var tmp = new Float32Array(1);
  29473. for (var i = 0; i < 256; i++) {
  29474. tmp[0] = i / 255;
  29475. transferFn(tmp, 0, tmp, 0);
  29476. transferMap[i] = tmp[0] * 255 | 0;
  29477. }
  29478. smaskOptions.transferMap = transferMap;
  29479. }
  29480. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29481. },
  29482. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29483. var tilingOpList = new OperatorList();
  29484. var resourcesArray = [
  29485. patternDict.get('Resources'),
  29486. resources
  29487. ];
  29488. var patternResources = Dict.merge(this.xref, resourcesArray);
  29489. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29490. operatorList.addDependencies(tilingOpList.dependencies);
  29491. operatorList.addOp(fn, getTilingPatternIR({
  29492. fnArray: tilingOpList.fnArray,
  29493. argsArray: tilingOpList.argsArray
  29494. }, patternDict, args));
  29495. });
  29496. },
  29497. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29498. var fontName;
  29499. if (fontArgs) {
  29500. fontArgs = fontArgs.slice();
  29501. fontName = fontArgs[0].name;
  29502. }
  29503. var self = this;
  29504. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29505. if (!translated.font.isType3Font) {
  29506. return translated;
  29507. }
  29508. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29509. return translated;
  29510. }, function (reason) {
  29511. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29512. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29513. });
  29514. }).then(function (translated) {
  29515. state.font = translated.font;
  29516. translated.send(self.handler);
  29517. return translated.loadedName;
  29518. });
  29519. },
  29520. handleText: function PartialEvaluator_handleText(chars, state) {
  29521. var font = state.font;
  29522. var glyphs = font.charsToGlyphs(chars);
  29523. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29524. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29525. var buildPath = function (fontChar) {
  29526. if (!font.renderer.hasBuiltPath(fontChar)) {
  29527. var path = font.renderer.getPathJs(fontChar);
  29528. this.handler.send('commonobj', [
  29529. font.loadedName + '_path_' + fontChar,
  29530. 'FontPath',
  29531. path
  29532. ]);
  29533. }
  29534. }.bind(this);
  29535. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29536. var glyph = glyphs[i];
  29537. buildPath(glyph.fontChar);
  29538. var accent = glyph.accent;
  29539. if (accent && accent.fontChar) {
  29540. buildPath(accent.fontChar);
  29541. }
  29542. }
  29543. }
  29544. return glyphs;
  29545. },
  29546. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29547. var gStateObj = [];
  29548. var gStateKeys = gState.getKeys();
  29549. var self = this;
  29550. var promise = Promise.resolve();
  29551. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29552. var key = gStateKeys[i];
  29553. var value = gState.get(key);
  29554. switch (key) {
  29555. case 'Type':
  29556. break;
  29557. case 'LW':
  29558. case 'LC':
  29559. case 'LJ':
  29560. case 'ML':
  29561. case 'D':
  29562. case 'RI':
  29563. case 'FL':
  29564. case 'CA':
  29565. case 'ca':
  29566. gStateObj.push([
  29567. key,
  29568. value
  29569. ]);
  29570. break;
  29571. case 'Font':
  29572. promise = promise.then(function () {
  29573. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29574. operatorList.addDependency(loadedName);
  29575. gStateObj.push([
  29576. key,
  29577. [
  29578. loadedName,
  29579. value[1]
  29580. ]
  29581. ]);
  29582. });
  29583. });
  29584. break;
  29585. case 'BM':
  29586. gStateObj.push([
  29587. key,
  29588. value
  29589. ]);
  29590. break;
  29591. case 'SMask':
  29592. if (isName(value, 'None')) {
  29593. gStateObj.push([
  29594. key,
  29595. false
  29596. ]);
  29597. break;
  29598. }
  29599. if (isDict(value)) {
  29600. promise = promise.then(function (dict) {
  29601. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29602. }.bind(this, value));
  29603. gStateObj.push([
  29604. key,
  29605. true
  29606. ]);
  29607. } else {
  29608. warn('Unsupported SMask type');
  29609. }
  29610. break;
  29611. case 'OP':
  29612. case 'op':
  29613. case 'OPM':
  29614. case 'BG':
  29615. case 'BG2':
  29616. case 'UCR':
  29617. case 'UCR2':
  29618. case 'TR':
  29619. case 'TR2':
  29620. case 'HT':
  29621. case 'SM':
  29622. case 'SA':
  29623. case 'AIS':
  29624. case 'TK':
  29625. info('graphic state operator ' + key);
  29626. break;
  29627. default:
  29628. info('Unknown graphic state operator ' + key);
  29629. break;
  29630. }
  29631. }
  29632. return promise.then(function () {
  29633. if (gStateObj.length > 0) {
  29634. operatorList.addOp(OPS.setGState, [gStateObj]);
  29635. }
  29636. });
  29637. },
  29638. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29639. function errorFont() {
  29640. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29641. }
  29642. var fontRef;
  29643. if (font) {
  29644. assert(isRef(font));
  29645. fontRef = font;
  29646. } else {
  29647. var fontRes = resources.get('Font');
  29648. if (fontRes) {
  29649. fontRef = fontRes.getRaw(fontName);
  29650. } else {
  29651. warn('fontRes not available');
  29652. return errorFont();
  29653. }
  29654. }
  29655. if (!fontRef) {
  29656. warn('fontRef not available');
  29657. return errorFont();
  29658. }
  29659. if (this.fontCache.has(fontRef)) {
  29660. return this.fontCache.get(fontRef);
  29661. }
  29662. font = xref.fetchIfRef(fontRef);
  29663. if (!isDict(font)) {
  29664. return errorFont();
  29665. }
  29666. if (font.translated) {
  29667. return font.translated;
  29668. }
  29669. var fontCapability = createPromiseCapability();
  29670. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29671. var descriptor = preEvaluatedFont.descriptor;
  29672. var fontRefIsRef = isRef(fontRef), fontID;
  29673. if (fontRefIsRef) {
  29674. fontID = fontRef.toString();
  29675. }
  29676. if (isDict(descriptor)) {
  29677. if (!descriptor.fontAliases) {
  29678. descriptor.fontAliases = Object.create(null);
  29679. }
  29680. var fontAliases = descriptor.fontAliases;
  29681. var hash = preEvaluatedFont.hash;
  29682. if (fontAliases[hash]) {
  29683. var aliasFontRef = fontAliases[hash].aliasRef;
  29684. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29685. this.fontCache.putAlias(fontRef, aliasFontRef);
  29686. return this.fontCache.get(fontRef);
  29687. }
  29688. } else {
  29689. fontAliases[hash] = { fontID: Font.getFontID() };
  29690. }
  29691. if (fontRefIsRef) {
  29692. fontAliases[hash].aliasRef = fontRef;
  29693. }
  29694. fontID = fontAliases[hash].fontID;
  29695. }
  29696. if (fontRefIsRef) {
  29697. this.fontCache.put(fontRef, fontCapability.promise);
  29698. } else {
  29699. if (!fontID) {
  29700. fontID = this.idFactory.createObjId();
  29701. }
  29702. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29703. }
  29704. assert(fontID, 'The "fontID" must be defined.');
  29705. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29706. font.translated = fontCapability.promise;
  29707. var translatedPromise;
  29708. try {
  29709. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29710. } catch (e) {
  29711. translatedPromise = Promise.reject(e);
  29712. }
  29713. var self = this;
  29714. translatedPromise.then(function (translatedFont) {
  29715. if (translatedFont.fontType !== undefined) {
  29716. var xrefFontStats = xref.stats.fontTypes;
  29717. xrefFontStats[translatedFont.fontType] = true;
  29718. }
  29719. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29720. }, function (reason) {
  29721. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29722. try {
  29723. var descriptor = preEvaluatedFont.descriptor;
  29724. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29725. var subtype = fontFile3 && fontFile3.get('Subtype');
  29726. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29727. var xrefFontStats = xref.stats.fontTypes;
  29728. xrefFontStats[fontType] = true;
  29729. } catch (ex) {
  29730. }
  29731. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29732. });
  29733. return fontCapability.promise;
  29734. },
  29735. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29736. var lastIndex = operatorList.length - 1;
  29737. if (!args) {
  29738. args = [];
  29739. }
  29740. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29741. operatorList.addOp(OPS.constructPath, [
  29742. [fn],
  29743. args
  29744. ]);
  29745. } else {
  29746. var opArgs = operatorList.argsArray[lastIndex];
  29747. opArgs[0].push(fn);
  29748. Array.prototype.push.apply(opArgs[1], args);
  29749. }
  29750. },
  29751. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29752. var patternName = args[args.length - 1];
  29753. var pattern;
  29754. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29755. var dict = isStream(pattern) ? pattern.dict : pattern;
  29756. var typeNum = dict.get('PatternType');
  29757. if (typeNum === TILING_PATTERN) {
  29758. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29759. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29760. } else if (typeNum === SHADING_PATTERN) {
  29761. var shading = dict.get('Shading');
  29762. var matrix = dict.getArray('Matrix');
  29763. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29764. operatorList.addOp(fn, pattern.getIR());
  29765. return Promise.resolve();
  29766. }
  29767. return Promise.reject('Unknown PatternType: ' + typeNum);
  29768. }
  29769. operatorList.addOp(fn, args);
  29770. return Promise.resolve();
  29771. },
  29772. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29773. var self = this;
  29774. var xref = this.xref;
  29775. var imageCache = Object.create(null);
  29776. assert(operatorList);
  29777. resources = resources || Dict.empty;
  29778. var xobjs = resources.get('XObject') || Dict.empty;
  29779. var patterns = resources.get('Pattern') || Dict.empty;
  29780. var stateManager = new StateManager(initialState || new EvalState());
  29781. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29782. var timeSlotManager = new TimeSlotManager();
  29783. return new Promise(function promiseBody(resolve, reject) {
  29784. var next = function (promise) {
  29785. promise.then(function () {
  29786. try {
  29787. promiseBody(resolve, reject);
  29788. } catch (ex) {
  29789. reject(ex);
  29790. }
  29791. }, reject);
  29792. };
  29793. task.ensureNotTerminated();
  29794. timeSlotManager.reset();
  29795. var stop, operation = {}, i, ii, cs;
  29796. while (!(stop = timeSlotManager.check())) {
  29797. operation.args = null;
  29798. if (!preprocessor.read(operation)) {
  29799. break;
  29800. }
  29801. var args = operation.args;
  29802. var fn = operation.fn;
  29803. switch (fn | 0) {
  29804. case OPS.paintXObject:
  29805. if (args[0].code) {
  29806. break;
  29807. }
  29808. var name = args[0].name;
  29809. if (!name) {
  29810. warn('XObject must be referred to by name.');
  29811. continue;
  29812. }
  29813. if (imageCache[name] !== undefined) {
  29814. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29815. args = null;
  29816. continue;
  29817. }
  29818. var xobj = xobjs.get(name);
  29819. if (xobj) {
  29820. assert(isStream(xobj), 'XObject should be a stream');
  29821. var type = xobj.dict.get('Subtype');
  29822. assert(isName(type), 'XObject should have a Name subtype');
  29823. if (type.name === 'Form') {
  29824. stateManager.save();
  29825. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29826. stateManager.restore();
  29827. }));
  29828. return;
  29829. } else if (type.name === 'Image') {
  29830. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29831. args = null;
  29832. continue;
  29833. } else if (type.name === 'PS') {
  29834. info('Ignored XObject subtype PS');
  29835. continue;
  29836. } else {
  29837. error('Unhandled XObject subtype ' + type.name);
  29838. }
  29839. }
  29840. break;
  29841. case OPS.setFont:
  29842. var fontSize = args[1];
  29843. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29844. operatorList.addDependency(loadedName);
  29845. operatorList.addOp(OPS.setFont, [
  29846. loadedName,
  29847. fontSize
  29848. ]);
  29849. }));
  29850. return;
  29851. case OPS.endInlineImage:
  29852. var cacheKey = args[0].cacheKey;
  29853. if (cacheKey) {
  29854. var cacheEntry = imageCache[cacheKey];
  29855. if (cacheEntry !== undefined) {
  29856. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29857. args = null;
  29858. continue;
  29859. }
  29860. }
  29861. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29862. args = null;
  29863. continue;
  29864. case OPS.showText:
  29865. args[0] = self.handleText(args[0], stateManager.state);
  29866. break;
  29867. case OPS.showSpacedText:
  29868. var arr = args[0];
  29869. var combinedGlyphs = [];
  29870. var arrLength = arr.length;
  29871. var state = stateManager.state;
  29872. for (i = 0; i < arrLength; ++i) {
  29873. var arrItem = arr[i];
  29874. if (isString(arrItem)) {
  29875. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29876. } else if (isNum(arrItem)) {
  29877. combinedGlyphs.push(arrItem);
  29878. }
  29879. }
  29880. args[0] = combinedGlyphs;
  29881. fn = OPS.showText;
  29882. break;
  29883. case OPS.nextLineShowText:
  29884. operatorList.addOp(OPS.nextLine);
  29885. args[0] = self.handleText(args[0], stateManager.state);
  29886. fn = OPS.showText;
  29887. break;
  29888. case OPS.nextLineSetSpacingShowText:
  29889. operatorList.addOp(OPS.nextLine);
  29890. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29891. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29892. args[0] = self.handleText(args[0], stateManager.state);
  29893. fn = OPS.showText;
  29894. break;
  29895. case OPS.setTextRenderingMode:
  29896. stateManager.state.textRenderingMode = args[0];
  29897. break;
  29898. case OPS.setFillColorSpace:
  29899. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29900. continue;
  29901. case OPS.setStrokeColorSpace:
  29902. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29903. continue;
  29904. case OPS.setFillColor:
  29905. cs = stateManager.state.fillColorSpace;
  29906. args = cs.getRgb(args, 0);
  29907. fn = OPS.setFillRGBColor;
  29908. break;
  29909. case OPS.setStrokeColor:
  29910. cs = stateManager.state.strokeColorSpace;
  29911. args = cs.getRgb(args, 0);
  29912. fn = OPS.setStrokeRGBColor;
  29913. break;
  29914. case OPS.setFillGray:
  29915. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29916. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29917. fn = OPS.setFillRGBColor;
  29918. break;
  29919. case OPS.setStrokeGray:
  29920. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29921. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29922. fn = OPS.setStrokeRGBColor;
  29923. break;
  29924. case OPS.setFillCMYKColor:
  29925. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29926. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29927. fn = OPS.setFillRGBColor;
  29928. break;
  29929. case OPS.setStrokeCMYKColor:
  29930. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29931. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29932. fn = OPS.setStrokeRGBColor;
  29933. break;
  29934. case OPS.setFillRGBColor:
  29935. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29936. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29937. break;
  29938. case OPS.setStrokeRGBColor:
  29939. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29940. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29941. break;
  29942. case OPS.setFillColorN:
  29943. cs = stateManager.state.fillColorSpace;
  29944. if (cs.name === 'Pattern') {
  29945. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29946. return;
  29947. }
  29948. args = cs.getRgb(args, 0);
  29949. fn = OPS.setFillRGBColor;
  29950. break;
  29951. case OPS.setStrokeColorN:
  29952. cs = stateManager.state.strokeColorSpace;
  29953. if (cs.name === 'Pattern') {
  29954. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29955. return;
  29956. }
  29957. args = cs.getRgb(args, 0);
  29958. fn = OPS.setStrokeRGBColor;
  29959. break;
  29960. case OPS.shadingFill:
  29961. var shadingRes = resources.get('Shading');
  29962. if (!shadingRes) {
  29963. error('No shading resource found');
  29964. }
  29965. var shading = shadingRes.get(args[0].name);
  29966. if (!shading) {
  29967. error('No shading object found');
  29968. }
  29969. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29970. var patternIR = shadingFill.getIR();
  29971. args = [patternIR];
  29972. fn = OPS.shadingFill;
  29973. break;
  29974. case OPS.setGState:
  29975. var dictName = args[0];
  29976. var extGState = resources.get('ExtGState');
  29977. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29978. break;
  29979. }
  29980. var gState = extGState.get(dictName.name);
  29981. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29982. return;
  29983. case OPS.moveTo:
  29984. case OPS.lineTo:
  29985. case OPS.curveTo:
  29986. case OPS.curveTo2:
  29987. case OPS.curveTo3:
  29988. case OPS.closePath:
  29989. self.buildPath(operatorList, fn, args);
  29990. continue;
  29991. case OPS.rectangle:
  29992. self.buildPath(operatorList, fn, args);
  29993. continue;
  29994. case OPS.markPoint:
  29995. case OPS.markPointProps:
  29996. case OPS.beginMarkedContent:
  29997. case OPS.beginMarkedContentProps:
  29998. case OPS.endMarkedContent:
  29999. case OPS.beginCompat:
  30000. case OPS.endCompat:
  30001. continue;
  30002. default:
  30003. if (args !== null) {
  30004. for (i = 0, ii = args.length; i < ii; i++) {
  30005. if (args[i] instanceof Dict) {
  30006. break;
  30007. }
  30008. }
  30009. if (i < ii) {
  30010. warn('getOperatorList - ignoring operator: ' + fn);
  30011. continue;
  30012. }
  30013. }
  30014. }
  30015. operatorList.addOp(fn, args);
  30016. }
  30017. if (stop) {
  30018. next(deferred);
  30019. return;
  30020. }
  30021. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30022. operatorList.addOp(OPS.restore, []);
  30023. }
  30024. resolve();
  30025. });
  30026. },
  30027. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30028. stateManager = stateManager || new StateManager(new TextState());
  30029. var WhitespaceRegexp = /\s/g;
  30030. var textContent = {
  30031. items: [],
  30032. styles: Object.create(null)
  30033. };
  30034. var textContentItem = {
  30035. initialized: false,
  30036. str: [],
  30037. width: 0,
  30038. height: 0,
  30039. vertical: false,
  30040. lastAdvanceWidth: 0,
  30041. lastAdvanceHeight: 0,
  30042. textAdvanceScale: 0,
  30043. spaceWidth: 0,
  30044. fakeSpaceMin: Infinity,
  30045. fakeMultiSpaceMin: Infinity,
  30046. fakeMultiSpaceMax: -0,
  30047. textRunBreakAllowed: false,
  30048. transform: null,
  30049. fontName: null
  30050. };
  30051. var SPACE_FACTOR = 0.3;
  30052. var MULTI_SPACE_FACTOR = 1.5;
  30053. var MULTI_SPACE_FACTOR_MAX = 4;
  30054. var self = this;
  30055. var xref = this.xref;
  30056. resources = xref.fetchIfRef(resources) || Dict.empty;
  30057. var xobjs = null;
  30058. var xobjsCache = Object.create(null);
  30059. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30060. var textState;
  30061. function ensureTextContentItem() {
  30062. if (textContentItem.initialized) {
  30063. return textContentItem;
  30064. }
  30065. var font = textState.font;
  30066. if (!(font.loadedName in textContent.styles)) {
  30067. textContent.styles[font.loadedName] = {
  30068. fontFamily: font.fallbackName,
  30069. ascent: font.ascent,
  30070. descent: font.descent,
  30071. vertical: font.vertical
  30072. };
  30073. }
  30074. textContentItem.fontName = font.loadedName;
  30075. var tsm = [
  30076. textState.fontSize * textState.textHScale,
  30077. 0,
  30078. 0,
  30079. textState.fontSize,
  30080. 0,
  30081. textState.textRise
  30082. ];
  30083. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30084. var glyphHeight = font.bbox[3] - font.bbox[1];
  30085. if (glyphHeight > 0) {
  30086. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30087. tsm[3] *= glyphHeight;
  30088. }
  30089. }
  30090. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30091. textContentItem.transform = trm;
  30092. if (!font.vertical) {
  30093. textContentItem.width = 0;
  30094. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30095. textContentItem.vertical = false;
  30096. } else {
  30097. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30098. textContentItem.height = 0;
  30099. textContentItem.vertical = true;
  30100. }
  30101. var a = textState.textLineMatrix[0];
  30102. var b = textState.textLineMatrix[1];
  30103. var scaleLineX = Math.sqrt(a * a + b * b);
  30104. a = textState.ctm[0];
  30105. b = textState.ctm[1];
  30106. var scaleCtmX = Math.sqrt(a * a + b * b);
  30107. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30108. textContentItem.lastAdvanceWidth = 0;
  30109. textContentItem.lastAdvanceHeight = 0;
  30110. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30111. if (spaceWidth) {
  30112. textContentItem.spaceWidth = spaceWidth;
  30113. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30114. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30115. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30116. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30117. } else {
  30118. textContentItem.spaceWidth = 0;
  30119. textContentItem.fakeSpaceMin = Infinity;
  30120. textContentItem.fakeMultiSpaceMin = Infinity;
  30121. textContentItem.fakeMultiSpaceMax = 0;
  30122. textContentItem.textRunBreakAllowed = false;
  30123. }
  30124. textContentItem.initialized = true;
  30125. return textContentItem;
  30126. }
  30127. function replaceWhitespace(str) {
  30128. var i = 0, ii = str.length, code;
  30129. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30130. i++;
  30131. }
  30132. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30133. }
  30134. function runBidiTransform(textChunk) {
  30135. var str = textChunk.str.join('');
  30136. var bidiResult = bidi(str, -1, textChunk.vertical);
  30137. return {
  30138. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30139. dir: bidiResult.dir,
  30140. width: textChunk.width,
  30141. height: textChunk.height,
  30142. transform: textChunk.transform,
  30143. fontName: textChunk.fontName
  30144. };
  30145. }
  30146. function handleSetFont(fontName, fontRef) {
  30147. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30148. textState.font = translated.font;
  30149. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30150. });
  30151. }
  30152. function buildTextContentItem(chars) {
  30153. var font = textState.font;
  30154. var textChunk = ensureTextContentItem();
  30155. var width = 0;
  30156. var height = 0;
  30157. var glyphs = font.charsToGlyphs(chars);
  30158. for (var i = 0; i < glyphs.length; i++) {
  30159. var glyph = glyphs[i];
  30160. var glyphWidth = null;
  30161. if (font.vertical && glyph.vmetric) {
  30162. glyphWidth = glyph.vmetric[0];
  30163. } else {
  30164. glyphWidth = glyph.width;
  30165. }
  30166. var glyphUnicode = glyph.unicode;
  30167. var NormalizedUnicodes = getNormalizedUnicodes();
  30168. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30169. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30170. }
  30171. glyphUnicode = reverseIfRtl(glyphUnicode);
  30172. var charSpacing = textState.charSpacing;
  30173. if (glyph.isSpace) {
  30174. var wordSpacing = textState.wordSpacing;
  30175. charSpacing += wordSpacing;
  30176. if (wordSpacing > 0) {
  30177. addFakeSpaces(wordSpacing, textChunk.str);
  30178. }
  30179. }
  30180. var tx = 0;
  30181. var ty = 0;
  30182. if (!font.vertical) {
  30183. var w0 = glyphWidth * textState.fontMatrix[0];
  30184. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30185. width += tx;
  30186. } else {
  30187. var w1 = glyphWidth * textState.fontMatrix[0];
  30188. ty = w1 * textState.fontSize + charSpacing;
  30189. height += ty;
  30190. }
  30191. textState.translateTextMatrix(tx, ty);
  30192. textChunk.str.push(glyphUnicode);
  30193. }
  30194. if (!font.vertical) {
  30195. textChunk.lastAdvanceWidth = width;
  30196. textChunk.width += width;
  30197. } else {
  30198. textChunk.lastAdvanceHeight = height;
  30199. textChunk.height += Math.abs(height);
  30200. }
  30201. return textChunk;
  30202. }
  30203. function addFakeSpaces(width, strBuf) {
  30204. if (width < textContentItem.fakeSpaceMin) {
  30205. return;
  30206. }
  30207. if (width < textContentItem.fakeMultiSpaceMin) {
  30208. strBuf.push(' ');
  30209. return;
  30210. }
  30211. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30212. while (fakeSpaces-- > 0) {
  30213. strBuf.push(' ');
  30214. }
  30215. }
  30216. function flushTextContentItem() {
  30217. if (!textContentItem.initialized) {
  30218. return;
  30219. }
  30220. textContentItem.width *= textContentItem.textAdvanceScale;
  30221. textContentItem.height *= textContentItem.textAdvanceScale;
  30222. textContent.items.push(runBidiTransform(textContentItem));
  30223. textContentItem.initialized = false;
  30224. textContentItem.str.length = 0;
  30225. }
  30226. var timeSlotManager = new TimeSlotManager();
  30227. return new Promise(function promiseBody(resolve, reject) {
  30228. var next = function (promise) {
  30229. promise.then(function () {
  30230. try {
  30231. promiseBody(resolve, reject);
  30232. } catch (ex) {
  30233. reject(ex);
  30234. }
  30235. }, reject);
  30236. };
  30237. task.ensureNotTerminated();
  30238. timeSlotManager.reset();
  30239. var stop, operation = {}, args = [];
  30240. while (!(stop = timeSlotManager.check())) {
  30241. args.length = 0;
  30242. operation.args = args;
  30243. if (!preprocessor.read(operation)) {
  30244. break;
  30245. }
  30246. textState = stateManager.state;
  30247. var fn = operation.fn;
  30248. args = operation.args;
  30249. var advance, diff;
  30250. switch (fn | 0) {
  30251. case OPS.setFont:
  30252. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30253. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30254. break;
  30255. }
  30256. flushTextContentItem();
  30257. textState.fontName = fontNameArg;
  30258. textState.fontSize = fontSizeArg;
  30259. next(handleSetFont(fontNameArg, null));
  30260. return;
  30261. case OPS.setTextRise:
  30262. flushTextContentItem();
  30263. textState.textRise = args[0];
  30264. break;
  30265. case OPS.setHScale:
  30266. flushTextContentItem();
  30267. textState.textHScale = args[0] / 100;
  30268. break;
  30269. case OPS.setLeading:
  30270. flushTextContentItem();
  30271. textState.leading = args[0];
  30272. break;
  30273. case OPS.moveText:
  30274. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30275. advance = args[0] - args[1];
  30276. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30277. textState.translateTextLineMatrix(args[0], args[1]);
  30278. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30279. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30280. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30281. addFakeSpaces(diff, textContentItem.str);
  30282. break;
  30283. }
  30284. flushTextContentItem();
  30285. textState.translateTextLineMatrix(args[0], args[1]);
  30286. textState.textMatrix = textState.textLineMatrix.slice();
  30287. break;
  30288. case OPS.setLeadingMoveText:
  30289. flushTextContentItem();
  30290. textState.leading = -args[1];
  30291. textState.translateTextLineMatrix(args[0], args[1]);
  30292. textState.textMatrix = textState.textLineMatrix.slice();
  30293. break;
  30294. case OPS.nextLine:
  30295. flushTextContentItem();
  30296. textState.carriageReturn();
  30297. break;
  30298. case OPS.setTextMatrix:
  30299. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30300. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30301. textState.translateTextLineMatrix(advance.width, advance.height);
  30302. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30303. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30304. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30305. addFakeSpaces(diff, textContentItem.str);
  30306. break;
  30307. }
  30308. flushTextContentItem();
  30309. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30310. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30311. break;
  30312. case OPS.setCharSpacing:
  30313. textState.charSpacing = args[0];
  30314. break;
  30315. case OPS.setWordSpacing:
  30316. textState.wordSpacing = args[0];
  30317. break;
  30318. case OPS.beginText:
  30319. flushTextContentItem();
  30320. textState.textMatrix = IDENTITY_MATRIX.slice();
  30321. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30322. break;
  30323. case OPS.showSpacedText:
  30324. var items = args[0];
  30325. var offset;
  30326. for (var j = 0, jj = items.length; j < jj; j++) {
  30327. if (typeof items[j] === 'string') {
  30328. buildTextContentItem(items[j]);
  30329. } else if (isNum(items[j])) {
  30330. ensureTextContentItem();
  30331. advance = items[j] * textState.fontSize / 1000;
  30332. var breakTextRun = false;
  30333. if (textState.font.vertical) {
  30334. offset = advance;
  30335. textState.translateTextMatrix(0, offset);
  30336. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30337. if (!breakTextRun) {
  30338. textContentItem.height += offset;
  30339. }
  30340. } else {
  30341. advance = -advance;
  30342. offset = advance * textState.textHScale;
  30343. textState.translateTextMatrix(offset, 0);
  30344. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30345. if (!breakTextRun) {
  30346. textContentItem.width += offset;
  30347. }
  30348. }
  30349. if (breakTextRun) {
  30350. flushTextContentItem();
  30351. } else if (advance > 0) {
  30352. addFakeSpaces(advance, textContentItem.str);
  30353. }
  30354. }
  30355. }
  30356. break;
  30357. case OPS.showText:
  30358. buildTextContentItem(args[0]);
  30359. break;
  30360. case OPS.nextLineShowText:
  30361. flushTextContentItem();
  30362. textState.carriageReturn();
  30363. buildTextContentItem(args[0]);
  30364. break;
  30365. case OPS.nextLineSetSpacingShowText:
  30366. flushTextContentItem();
  30367. textState.wordSpacing = args[0];
  30368. textState.charSpacing = args[1];
  30369. textState.carriageReturn();
  30370. buildTextContentItem(args[2]);
  30371. break;
  30372. case OPS.paintXObject:
  30373. flushTextContentItem();
  30374. if (args[0].code) {
  30375. break;
  30376. }
  30377. if (!xobjs) {
  30378. xobjs = resources.get('XObject') || Dict.empty;
  30379. }
  30380. var name = args[0].name;
  30381. if (xobjsCache.key === name) {
  30382. if (xobjsCache.texts) {
  30383. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30384. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30385. }
  30386. break;
  30387. }
  30388. var xobj = xobjs.get(name);
  30389. if (!xobj) {
  30390. break;
  30391. }
  30392. assert(isStream(xobj), 'XObject should be a stream');
  30393. var type = xobj.dict.get('Subtype');
  30394. assert(isName(type), 'XObject should have a Name subtype');
  30395. if ('Form' !== type.name) {
  30396. xobjsCache.key = name;
  30397. xobjsCache.texts = null;
  30398. break;
  30399. }
  30400. stateManager.save();
  30401. var matrix = xobj.dict.getArray('Matrix');
  30402. if (isArray(matrix) && matrix.length === 6) {
  30403. stateManager.transform(matrix);
  30404. }
  30405. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30406. Util.appendToArray(textContent.items, formTextContent.items);
  30407. Util.extendObj(textContent.styles, formTextContent.styles);
  30408. stateManager.restore();
  30409. xobjsCache.key = name;
  30410. xobjsCache.texts = formTextContent;
  30411. }));
  30412. return;
  30413. case OPS.setGState:
  30414. flushTextContentItem();
  30415. var dictName = args[0];
  30416. var extGState = resources.get('ExtGState');
  30417. if (!isDict(extGState) || !isName(dictName)) {
  30418. break;
  30419. }
  30420. var gState = extGState.get(dictName.name);
  30421. if (!isDict(gState)) {
  30422. break;
  30423. }
  30424. var gStateFont = gState.get('Font');
  30425. if (gStateFont) {
  30426. textState.fontName = null;
  30427. textState.fontSize = gStateFont[1];
  30428. next(handleSetFont(null, gStateFont[0]));
  30429. return;
  30430. }
  30431. break;
  30432. }
  30433. }
  30434. if (stop) {
  30435. next(deferred);
  30436. return;
  30437. }
  30438. flushTextContentItem();
  30439. resolve(textContent);
  30440. });
  30441. },
  30442. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30443. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30444. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30445. if (properties.composite) {
  30446. var cidSystemInfo = dict.get('CIDSystemInfo');
  30447. if (isDict(cidSystemInfo)) {
  30448. properties.cidSystemInfo = {
  30449. registry: cidSystemInfo.get('Registry'),
  30450. ordering: cidSystemInfo.get('Ordering'),
  30451. supplement: cidSystemInfo.get('Supplement')
  30452. };
  30453. }
  30454. var cidToGidMap = dict.get('CIDToGIDMap');
  30455. if (isStream(cidToGidMap)) {
  30456. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30457. }
  30458. }
  30459. var differences = [];
  30460. var baseEncodingName = null;
  30461. var encoding;
  30462. if (dict.has('Encoding')) {
  30463. encoding = dict.get('Encoding');
  30464. if (isDict(encoding)) {
  30465. baseEncodingName = encoding.get('BaseEncoding');
  30466. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30467. if (encoding.has('Differences')) {
  30468. var diffEncoding = encoding.get('Differences');
  30469. var index = 0;
  30470. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30471. var data = xref.fetchIfRef(diffEncoding[j]);
  30472. if (isNum(data)) {
  30473. index = data;
  30474. } else if (isName(data)) {
  30475. differences[index++] = data.name;
  30476. } else {
  30477. error('Invalid entry in \'Differences\' array: ' + data);
  30478. }
  30479. }
  30480. }
  30481. } else if (isName(encoding)) {
  30482. baseEncodingName = encoding.name;
  30483. } else {
  30484. error('Encoding is not a Name nor a Dict');
  30485. }
  30486. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30487. baseEncodingName = null;
  30488. }
  30489. }
  30490. if (baseEncodingName) {
  30491. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30492. } else {
  30493. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30494. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30495. encoding = StandardEncoding;
  30496. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30497. encoding = WinAnsiEncoding;
  30498. }
  30499. if (isSymbolicFont) {
  30500. encoding = MacRomanEncoding;
  30501. if (!properties.file) {
  30502. if (/Symbol/i.test(properties.name)) {
  30503. encoding = SymbolSetEncoding;
  30504. } else if (/Dingbats/i.test(properties.name)) {
  30505. encoding = ZapfDingbatsEncoding;
  30506. }
  30507. }
  30508. }
  30509. properties.defaultEncoding = encoding;
  30510. }
  30511. properties.differences = differences;
  30512. properties.baseEncodingName = baseEncodingName;
  30513. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30514. properties.dict = dict;
  30515. return toUnicodePromise.then(function (toUnicode) {
  30516. properties.toUnicode = toUnicode;
  30517. return this.buildToUnicode(properties);
  30518. }.bind(this)).then(function (toUnicode) {
  30519. properties.toUnicode = toUnicode;
  30520. return properties;
  30521. });
  30522. },
  30523. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30524. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30525. if (properties.hasIncludedToUnicodeMap) {
  30526. return Promise.resolve(properties.toUnicode);
  30527. }
  30528. var toUnicode, charcode, glyphName;
  30529. if (!properties.composite) {
  30530. toUnicode = [];
  30531. var encoding = properties.defaultEncoding.slice();
  30532. var baseEncodingName = properties.baseEncodingName;
  30533. var differences = properties.differences;
  30534. for (charcode in differences) {
  30535. glyphName = differences[charcode];
  30536. if (glyphName === '.notdef') {
  30537. continue;
  30538. }
  30539. encoding[charcode] = glyphName;
  30540. }
  30541. var glyphsUnicodeMap = getGlyphsUnicode();
  30542. for (charcode in encoding) {
  30543. glyphName = encoding[charcode];
  30544. if (glyphName === '') {
  30545. continue;
  30546. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30547. var code = 0;
  30548. switch (glyphName[0]) {
  30549. case 'G':
  30550. if (glyphName.length === 3) {
  30551. code = parseInt(glyphName.substr(1), 16);
  30552. }
  30553. break;
  30554. case 'g':
  30555. if (glyphName.length === 5) {
  30556. code = parseInt(glyphName.substr(1), 16);
  30557. }
  30558. break;
  30559. case 'C':
  30560. case 'c':
  30561. if (glyphName.length >= 3) {
  30562. code = +glyphName.substr(1);
  30563. }
  30564. break;
  30565. default:
  30566. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30567. if (unicode !== -1) {
  30568. code = unicode;
  30569. }
  30570. }
  30571. if (code) {
  30572. if (baseEncodingName && code === +charcode) {
  30573. var baseEncoding = getEncoding(baseEncodingName);
  30574. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30575. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30576. continue;
  30577. }
  30578. }
  30579. toUnicode[charcode] = String.fromCharCode(code);
  30580. }
  30581. continue;
  30582. }
  30583. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30584. }
  30585. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30586. }
  30587. 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'))) {
  30588. var registry = properties.cidSystemInfo.registry;
  30589. var ordering = properties.cidSystemInfo.ordering;
  30590. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30591. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  30592. var cMap = properties.cMap;
  30593. toUnicode = [];
  30594. cMap.forEach(function (charcode, cid) {
  30595. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30596. var ucs2 = ucs2CMap.lookup(cid);
  30597. if (ucs2) {
  30598. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30599. }
  30600. });
  30601. return new ToUnicodeMap(toUnicode);
  30602. });
  30603. }
  30604. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30605. },
  30606. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30607. var cmapObj = toUnicode;
  30608. if (isName(cmapObj)) {
  30609. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30610. if (cmap instanceof IdentityCMap) {
  30611. return new IdentityToUnicodeMap(0, 0xFFFF);
  30612. }
  30613. return new ToUnicodeMap(cmap.getMap());
  30614. });
  30615. } else if (isStream(cmapObj)) {
  30616. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30617. if (cmap instanceof IdentityCMap) {
  30618. return new IdentityToUnicodeMap(0, 0xFFFF);
  30619. }
  30620. var map = new Array(cmap.length);
  30621. cmap.forEach(function (charCode, token) {
  30622. var str = [];
  30623. for (var k = 0; k < token.length; k += 2) {
  30624. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30625. if ((w1 & 0xF800) !== 0xD800) {
  30626. str.push(w1);
  30627. continue;
  30628. }
  30629. k += 2;
  30630. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30631. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30632. }
  30633. map[charCode] = String.fromCharCode.apply(String, str);
  30634. });
  30635. return new ToUnicodeMap(map);
  30636. });
  30637. }
  30638. return Promise.resolve(null);
  30639. },
  30640. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30641. var glyphsData = cidToGidStream.getBytes();
  30642. var result = [];
  30643. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30644. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30645. if (glyphID === 0) {
  30646. continue;
  30647. }
  30648. var code = j >> 1;
  30649. result[code] = glyphID;
  30650. }
  30651. return result;
  30652. },
  30653. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30654. var glyphsWidths = [];
  30655. var defaultWidth = 0;
  30656. var glyphsVMetrics = [];
  30657. var defaultVMetrics;
  30658. var i, ii, j, jj, start, code, widths;
  30659. if (properties.composite) {
  30660. defaultWidth = dict.get('DW') || 1000;
  30661. widths = dict.get('W');
  30662. if (widths) {
  30663. for (i = 0, ii = widths.length; i < ii; i++) {
  30664. start = xref.fetchIfRef(widths[i++]);
  30665. code = xref.fetchIfRef(widths[i]);
  30666. if (isArray(code)) {
  30667. for (j = 0, jj = code.length; j < jj; j++) {
  30668. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30669. }
  30670. } else {
  30671. var width = xref.fetchIfRef(widths[++i]);
  30672. for (j = start; j <= code; j++) {
  30673. glyphsWidths[j] = width;
  30674. }
  30675. }
  30676. }
  30677. }
  30678. if (properties.vertical) {
  30679. var vmetrics = dict.getArray('DW2') || [
  30680. 880,
  30681. -1000
  30682. ];
  30683. defaultVMetrics = [
  30684. vmetrics[1],
  30685. defaultWidth * 0.5,
  30686. vmetrics[0]
  30687. ];
  30688. vmetrics = dict.get('W2');
  30689. if (vmetrics) {
  30690. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30691. start = xref.fetchIfRef(vmetrics[i++]);
  30692. code = xref.fetchIfRef(vmetrics[i]);
  30693. if (isArray(code)) {
  30694. for (j = 0, jj = code.length; j < jj; j++) {
  30695. glyphsVMetrics[start++] = [
  30696. xref.fetchIfRef(code[j++]),
  30697. xref.fetchIfRef(code[j++]),
  30698. xref.fetchIfRef(code[j])
  30699. ];
  30700. }
  30701. } else {
  30702. var vmetric = [
  30703. xref.fetchIfRef(vmetrics[++i]),
  30704. xref.fetchIfRef(vmetrics[++i]),
  30705. xref.fetchIfRef(vmetrics[++i])
  30706. ];
  30707. for (j = start; j <= code; j++) {
  30708. glyphsVMetrics[j] = vmetric;
  30709. }
  30710. }
  30711. }
  30712. }
  30713. }
  30714. } else {
  30715. var firstChar = properties.firstChar;
  30716. widths = dict.get('Widths');
  30717. if (widths) {
  30718. j = firstChar;
  30719. for (i = 0, ii = widths.length; i < ii; i++) {
  30720. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30721. }
  30722. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30723. } else {
  30724. var baseFontName = dict.get('BaseFont');
  30725. if (isName(baseFontName)) {
  30726. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30727. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30728. defaultWidth = metrics.defaultWidth;
  30729. }
  30730. }
  30731. }
  30732. var isMonospace = true;
  30733. var firstWidth = defaultWidth;
  30734. for (var glyph in glyphsWidths) {
  30735. var glyphWidth = glyphsWidths[glyph];
  30736. if (!glyphWidth) {
  30737. continue;
  30738. }
  30739. if (!firstWidth) {
  30740. firstWidth = glyphWidth;
  30741. continue;
  30742. }
  30743. if (firstWidth !== glyphWidth) {
  30744. isMonospace = false;
  30745. break;
  30746. }
  30747. }
  30748. if (isMonospace) {
  30749. properties.flags |= FontFlags.FixedPitch;
  30750. }
  30751. properties.defaultWidth = defaultWidth;
  30752. properties.widths = glyphsWidths;
  30753. properties.defaultVMetrics = defaultVMetrics;
  30754. properties.vmetrics = glyphsVMetrics;
  30755. },
  30756. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30757. var fontNameWoStyle = baseFontName.split('-')[0];
  30758. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30759. },
  30760. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30761. var defaultWidth = 0;
  30762. var widths = [];
  30763. var monospace = false;
  30764. var stdFontMap = getStdFontMap();
  30765. var lookupName = stdFontMap[name] || name;
  30766. var Metrics = getMetrics();
  30767. if (!(lookupName in Metrics)) {
  30768. if (this.isSerifFont(name)) {
  30769. lookupName = 'Times-Roman';
  30770. } else {
  30771. lookupName = 'Helvetica';
  30772. }
  30773. }
  30774. var glyphWidths = Metrics[lookupName];
  30775. if (isNum(glyphWidths)) {
  30776. defaultWidth = glyphWidths;
  30777. monospace = true;
  30778. } else {
  30779. widths = glyphWidths();
  30780. }
  30781. return {
  30782. defaultWidth: defaultWidth,
  30783. monospace: monospace,
  30784. widths: widths
  30785. };
  30786. },
  30787. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30788. var widths = Object.create(null);
  30789. var differences = properties.differences;
  30790. var encoding = properties.defaultEncoding;
  30791. for (var charCode = 0; charCode < 256; charCode++) {
  30792. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30793. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30794. continue;
  30795. }
  30796. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30797. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30798. continue;
  30799. }
  30800. }
  30801. return widths;
  30802. },
  30803. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30804. var baseDict = dict;
  30805. var type = dict.get('Subtype');
  30806. assert(isName(type), 'invalid font Subtype');
  30807. var composite = false;
  30808. var uint8array;
  30809. if (type.name === 'Type0') {
  30810. var df = dict.get('DescendantFonts');
  30811. if (!df) {
  30812. error('Descendant fonts are not specified');
  30813. }
  30814. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30815. type = dict.get('Subtype');
  30816. assert(isName(type), 'invalid font Subtype');
  30817. composite = true;
  30818. }
  30819. var descriptor = dict.get('FontDescriptor');
  30820. if (descriptor) {
  30821. var hash = new MurmurHash3_64();
  30822. var encoding = baseDict.getRaw('Encoding');
  30823. if (isName(encoding)) {
  30824. hash.update(encoding.name);
  30825. } else if (isRef(encoding)) {
  30826. hash.update(encoding.toString());
  30827. } else if (isDict(encoding)) {
  30828. var keys = encoding.getKeys();
  30829. for (var i = 0, ii = keys.length; i < ii; i++) {
  30830. var entry = encoding.getRaw(keys[i]);
  30831. if (isName(entry)) {
  30832. hash.update(entry.name);
  30833. } else if (isRef(entry)) {
  30834. hash.update(entry.toString());
  30835. } else if (isArray(entry)) {
  30836. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30837. for (var j = 0; j < diffLength; j++) {
  30838. var diffEntry = entry[j];
  30839. if (isName(diffEntry)) {
  30840. diffBuf[j] = diffEntry.name;
  30841. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30842. diffBuf[j] = diffEntry.toString();
  30843. }
  30844. }
  30845. hash.update(diffBuf.join());
  30846. }
  30847. }
  30848. }
  30849. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30850. if (isStream(toUnicode)) {
  30851. var stream = toUnicode.str || toUnicode;
  30852. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30853. hash.update(uint8array);
  30854. } else if (isName(toUnicode)) {
  30855. hash.update(toUnicode.name);
  30856. }
  30857. var widths = dict.get('Widths') || baseDict.get('Widths');
  30858. if (widths) {
  30859. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30860. hash.update(uint8array);
  30861. }
  30862. }
  30863. return {
  30864. descriptor: descriptor,
  30865. dict: dict,
  30866. baseDict: baseDict,
  30867. composite: composite,
  30868. type: type.name,
  30869. hash: hash ? hash.hexdigest() : ''
  30870. };
  30871. },
  30872. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30873. var baseDict = preEvaluatedFont.baseDict;
  30874. var dict = preEvaluatedFont.dict;
  30875. var composite = preEvaluatedFont.composite;
  30876. var descriptor = preEvaluatedFont.descriptor;
  30877. var type = preEvaluatedFont.type;
  30878. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30879. var cMapOptions = this.options.cMapOptions;
  30880. var properties;
  30881. if (!descriptor) {
  30882. if (type === 'Type3') {
  30883. descriptor = new Dict(null);
  30884. descriptor.set('FontName', Name.get(type));
  30885. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30886. } else {
  30887. var baseFontName = dict.get('BaseFont');
  30888. if (!isName(baseFontName)) {
  30889. error('Base font is not specified');
  30890. }
  30891. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30892. var metrics = this.getBaseFontMetrics(baseFontName);
  30893. var fontNameWoStyle = baseFontName.split('-')[0];
  30894. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30895. properties = {
  30896. type: type,
  30897. name: baseFontName,
  30898. widths: metrics.widths,
  30899. defaultWidth: metrics.defaultWidth,
  30900. flags: flags,
  30901. firstChar: 0,
  30902. lastChar: maxCharIndex
  30903. };
  30904. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30905. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30906. return new Font(baseFontName, null, properties);
  30907. }.bind(this));
  30908. }
  30909. }
  30910. var firstChar = dict.get('FirstChar') || 0;
  30911. var lastChar = dict.get('LastChar') || maxCharIndex;
  30912. var fontName = descriptor.get('FontName');
  30913. var baseFont = dict.get('BaseFont');
  30914. if (isString(fontName)) {
  30915. fontName = Name.get(fontName);
  30916. }
  30917. if (isString(baseFont)) {
  30918. baseFont = Name.get(baseFont);
  30919. }
  30920. if (type !== 'Type3') {
  30921. var fontNameStr = fontName && fontName.name;
  30922. var baseFontStr = baseFont && baseFont.name;
  30923. if (fontNameStr !== baseFontStr) {
  30924. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30925. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30926. fontName = baseFont;
  30927. }
  30928. }
  30929. }
  30930. fontName = fontName || baseFont;
  30931. assert(isName(fontName), 'invalid font name');
  30932. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30933. if (fontFile) {
  30934. if (fontFile.dict) {
  30935. var subtype = fontFile.dict.get('Subtype');
  30936. if (subtype) {
  30937. subtype = subtype.name;
  30938. }
  30939. var length1 = fontFile.dict.get('Length1');
  30940. var length2 = fontFile.dict.get('Length2');
  30941. var length3 = fontFile.dict.get('Length3');
  30942. }
  30943. }
  30944. properties = {
  30945. type: type,
  30946. name: fontName.name,
  30947. subtype: subtype,
  30948. file: fontFile,
  30949. length1: length1,
  30950. length2: length2,
  30951. length3: length3,
  30952. loadedName: baseDict.loadedName,
  30953. composite: composite,
  30954. wideChars: composite,
  30955. fixedPitch: false,
  30956. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30957. firstChar: firstChar || 0,
  30958. lastChar: lastChar || maxCharIndex,
  30959. bbox: descriptor.getArray('FontBBox'),
  30960. ascent: descriptor.get('Ascent'),
  30961. descent: descriptor.get('Descent'),
  30962. xHeight: descriptor.get('XHeight'),
  30963. capHeight: descriptor.get('CapHeight'),
  30964. flags: descriptor.get('Flags'),
  30965. italicAngle: descriptor.get('ItalicAngle'),
  30966. coded: false
  30967. };
  30968. var cMapPromise;
  30969. if (composite) {
  30970. var cidEncoding = baseDict.get('Encoding');
  30971. if (isName(cidEncoding)) {
  30972. properties.cidEncoding = cidEncoding.name;
  30973. }
  30974. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  30975. properties.cMap = cMap;
  30976. properties.vertical = properties.cMap.vertical;
  30977. });
  30978. } else {
  30979. cMapPromise = Promise.resolve(undefined);
  30980. }
  30981. return cMapPromise.then(function () {
  30982. return this.extractDataStructures(dict, baseDict, xref, properties);
  30983. }.bind(this)).then(function (properties) {
  30984. this.extractWidths(dict, xref, descriptor, properties);
  30985. if (type === 'Type3') {
  30986. properties.isType3Font = true;
  30987. }
  30988. return new Font(fontName.name, fontFile, properties);
  30989. }.bind(this));
  30990. }
  30991. };
  30992. return PartialEvaluator;
  30993. }();
  30994. var TranslatedFont = function TranslatedFontClosure() {
  30995. function TranslatedFont(loadedName, font, dict) {
  30996. this.loadedName = loadedName;
  30997. this.font = font;
  30998. this.dict = dict;
  30999. this.type3Loaded = null;
  31000. this.sent = false;
  31001. }
  31002. TranslatedFont.prototype = {
  31003. send: function (handler) {
  31004. if (this.sent) {
  31005. return;
  31006. }
  31007. var fontData = this.font.exportData();
  31008. handler.send('commonobj', [
  31009. this.loadedName,
  31010. 'Font',
  31011. fontData
  31012. ]);
  31013. this.sent = true;
  31014. },
  31015. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31016. assert(this.font.isType3Font);
  31017. if (this.type3Loaded) {
  31018. return this.type3Loaded;
  31019. }
  31020. var translatedFont = this.font;
  31021. var loadCharProcsPromise = Promise.resolve();
  31022. var charProcs = this.dict.get('CharProcs');
  31023. var fontResources = this.dict.get('Resources') || resources;
  31024. var charProcKeys = charProcs.getKeys();
  31025. var charProcOperatorList = Object.create(null);
  31026. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31027. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31028. var glyphStream = charProcs.get(key);
  31029. var operatorList = new OperatorList();
  31030. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31031. charProcOperatorList[key] = operatorList.getIR();
  31032. parentOperatorList.addDependencies(operatorList.dependencies);
  31033. }, function (reason) {
  31034. warn('Type3 font resource \"' + key + '\" is not available');
  31035. var operatorList = new OperatorList();
  31036. charProcOperatorList[key] = operatorList.getIR();
  31037. });
  31038. }.bind(this, charProcKeys[i]));
  31039. }
  31040. this.type3Loaded = loadCharProcsPromise.then(function () {
  31041. translatedFont.charProcOperatorList = charProcOperatorList;
  31042. });
  31043. return this.type3Loaded;
  31044. }
  31045. };
  31046. return TranslatedFont;
  31047. }();
  31048. var OperatorList = function OperatorListClosure() {
  31049. var CHUNK_SIZE = 1000;
  31050. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31051. function getTransfers(queue) {
  31052. var transfers = [];
  31053. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31054. for (var i = 0, ii = queue.length; i < ii; i++) {
  31055. switch (fnArray[i]) {
  31056. case OPS.paintInlineImageXObject:
  31057. case OPS.paintInlineImageXObjectGroup:
  31058. case OPS.paintImageMaskXObject:
  31059. var arg = argsArray[i][0];
  31060. if (!arg.cached) {
  31061. transfers.push(arg.data.buffer);
  31062. }
  31063. break;
  31064. }
  31065. }
  31066. return transfers;
  31067. }
  31068. function OperatorList(intent, messageHandler, pageIndex) {
  31069. this.messageHandler = messageHandler;
  31070. this.fnArray = [];
  31071. this.argsArray = [];
  31072. this.dependencies = Object.create(null);
  31073. this._totalLength = 0;
  31074. this.pageIndex = pageIndex;
  31075. this.intent = intent;
  31076. }
  31077. OperatorList.prototype = {
  31078. get length() {
  31079. return this.argsArray.length;
  31080. },
  31081. get totalLength() {
  31082. return this._totalLength + this.length;
  31083. },
  31084. addOp: function (fn, args) {
  31085. this.fnArray.push(fn);
  31086. this.argsArray.push(args);
  31087. if (this.messageHandler) {
  31088. if (this.fnArray.length >= CHUNK_SIZE) {
  31089. this.flush();
  31090. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31091. this.flush();
  31092. }
  31093. }
  31094. },
  31095. addDependency: function (dependency) {
  31096. if (dependency in this.dependencies) {
  31097. return;
  31098. }
  31099. this.dependencies[dependency] = true;
  31100. this.addOp(OPS.dependency, [dependency]);
  31101. },
  31102. addDependencies: function (dependencies) {
  31103. for (var key in dependencies) {
  31104. this.addDependency(key);
  31105. }
  31106. },
  31107. addOpList: function (opList) {
  31108. Util.extendObj(this.dependencies, opList.dependencies);
  31109. for (var i = 0, ii = opList.length; i < ii; i++) {
  31110. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31111. }
  31112. },
  31113. getIR: function () {
  31114. return {
  31115. fnArray: this.fnArray,
  31116. argsArray: this.argsArray,
  31117. length: this.length
  31118. };
  31119. },
  31120. flush: function (lastChunk) {
  31121. if (this.intent !== 'oplist') {
  31122. new QueueOptimizer().optimize(this);
  31123. }
  31124. var transfers = getTransfers(this);
  31125. var length = this.length;
  31126. this._totalLength += length;
  31127. this.messageHandler.send('RenderPageChunk', {
  31128. operatorList: {
  31129. fnArray: this.fnArray,
  31130. argsArray: this.argsArray,
  31131. lastChunk: lastChunk,
  31132. length: length
  31133. },
  31134. pageIndex: this.pageIndex,
  31135. intent: this.intent
  31136. }, transfers);
  31137. this.dependencies = Object.create(null);
  31138. this.fnArray.length = 0;
  31139. this.argsArray.length = 0;
  31140. }
  31141. };
  31142. return OperatorList;
  31143. }();
  31144. var StateManager = function StateManagerClosure() {
  31145. function StateManager(initialState) {
  31146. this.state = initialState;
  31147. this.stateStack = [];
  31148. }
  31149. StateManager.prototype = {
  31150. save: function () {
  31151. var old = this.state;
  31152. this.stateStack.push(this.state);
  31153. this.state = old.clone();
  31154. },
  31155. restore: function () {
  31156. var prev = this.stateStack.pop();
  31157. if (prev) {
  31158. this.state = prev;
  31159. }
  31160. },
  31161. transform: function (args) {
  31162. this.state.ctm = Util.transform(this.state.ctm, args);
  31163. }
  31164. };
  31165. return StateManager;
  31166. }();
  31167. var TextState = function TextStateClosure() {
  31168. function TextState() {
  31169. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31170. this.fontName = null;
  31171. this.fontSize = 0;
  31172. this.font = null;
  31173. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31174. this.textMatrix = IDENTITY_MATRIX.slice();
  31175. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31176. this.charSpacing = 0;
  31177. this.wordSpacing = 0;
  31178. this.leading = 0;
  31179. this.textHScale = 1;
  31180. this.textRise = 0;
  31181. }
  31182. TextState.prototype = {
  31183. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31184. var m = this.textMatrix;
  31185. m[0] = a;
  31186. m[1] = b;
  31187. m[2] = c;
  31188. m[3] = d;
  31189. m[4] = e;
  31190. m[5] = f;
  31191. },
  31192. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31193. var m = this.textLineMatrix;
  31194. m[0] = a;
  31195. m[1] = b;
  31196. m[2] = c;
  31197. m[3] = d;
  31198. m[4] = e;
  31199. m[5] = f;
  31200. },
  31201. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31202. var m = this.textMatrix;
  31203. m[4] = m[0] * x + m[2] * y + m[4];
  31204. m[5] = m[1] * x + m[3] * y + m[5];
  31205. },
  31206. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31207. var m = this.textLineMatrix;
  31208. m[4] = m[0] * x + m[2] * y + m[4];
  31209. m[5] = m[1] * x + m[3] * y + m[5];
  31210. },
  31211. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31212. var font = this.font;
  31213. if (!font) {
  31214. return null;
  31215. }
  31216. var m = this.textLineMatrix;
  31217. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31218. return null;
  31219. }
  31220. var txDiff = e - m[4], tyDiff = f - m[5];
  31221. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31222. return null;
  31223. }
  31224. var tx, ty, denominator = a * d - b * c;
  31225. if (font.vertical) {
  31226. tx = -tyDiff * c / denominator;
  31227. ty = tyDiff * a / denominator;
  31228. } else {
  31229. tx = txDiff * d / denominator;
  31230. ty = -txDiff * b / denominator;
  31231. }
  31232. return {
  31233. width: tx,
  31234. height: ty,
  31235. value: font.vertical ? ty : tx
  31236. };
  31237. },
  31238. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31239. var tsm = [
  31240. this.fontSize * this.textHScale,
  31241. 0,
  31242. 0,
  31243. this.fontSize,
  31244. 0,
  31245. this.textRise
  31246. ];
  31247. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31248. },
  31249. carriageReturn: function TextState_carriageReturn() {
  31250. this.translateTextLineMatrix(0, -this.leading);
  31251. this.textMatrix = this.textLineMatrix.slice();
  31252. },
  31253. clone: function TextState_clone() {
  31254. var clone = Object.create(this);
  31255. clone.textMatrix = this.textMatrix.slice();
  31256. clone.textLineMatrix = this.textLineMatrix.slice();
  31257. clone.fontMatrix = this.fontMatrix.slice();
  31258. return clone;
  31259. }
  31260. };
  31261. return TextState;
  31262. }();
  31263. var EvalState = function EvalStateClosure() {
  31264. function EvalState() {
  31265. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31266. this.font = null;
  31267. this.textRenderingMode = TextRenderingMode.FILL;
  31268. this.fillColorSpace = ColorSpace.singletons.gray;
  31269. this.strokeColorSpace = ColorSpace.singletons.gray;
  31270. }
  31271. EvalState.prototype = {
  31272. clone: function CanvasExtraState_clone() {
  31273. return Object.create(this);
  31274. }
  31275. };
  31276. return EvalState;
  31277. }();
  31278. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31279. var getOPMap = getLookupTableFactory(function (t) {
  31280. t['w'] = {
  31281. id: OPS.setLineWidth,
  31282. numArgs: 1,
  31283. variableArgs: false
  31284. };
  31285. t['J'] = {
  31286. id: OPS.setLineCap,
  31287. numArgs: 1,
  31288. variableArgs: false
  31289. };
  31290. t['j'] = {
  31291. id: OPS.setLineJoin,
  31292. numArgs: 1,
  31293. variableArgs: false
  31294. };
  31295. t['M'] = {
  31296. id: OPS.setMiterLimit,
  31297. numArgs: 1,
  31298. variableArgs: false
  31299. };
  31300. t['d'] = {
  31301. id: OPS.setDash,
  31302. numArgs: 2,
  31303. variableArgs: false
  31304. };
  31305. t['ri'] = {
  31306. id: OPS.setRenderingIntent,
  31307. numArgs: 1,
  31308. variableArgs: false
  31309. };
  31310. t['i'] = {
  31311. id: OPS.setFlatness,
  31312. numArgs: 1,
  31313. variableArgs: false
  31314. };
  31315. t['gs'] = {
  31316. id: OPS.setGState,
  31317. numArgs: 1,
  31318. variableArgs: false
  31319. };
  31320. t['q'] = {
  31321. id: OPS.save,
  31322. numArgs: 0,
  31323. variableArgs: false
  31324. };
  31325. t['Q'] = {
  31326. id: OPS.restore,
  31327. numArgs: 0,
  31328. variableArgs: false
  31329. };
  31330. t['cm'] = {
  31331. id: OPS.transform,
  31332. numArgs: 6,
  31333. variableArgs: false
  31334. };
  31335. t['m'] = {
  31336. id: OPS.moveTo,
  31337. numArgs: 2,
  31338. variableArgs: false
  31339. };
  31340. t['l'] = {
  31341. id: OPS.lineTo,
  31342. numArgs: 2,
  31343. variableArgs: false
  31344. };
  31345. t['c'] = {
  31346. id: OPS.curveTo,
  31347. numArgs: 6,
  31348. variableArgs: false
  31349. };
  31350. t['v'] = {
  31351. id: OPS.curveTo2,
  31352. numArgs: 4,
  31353. variableArgs: false
  31354. };
  31355. t['y'] = {
  31356. id: OPS.curveTo3,
  31357. numArgs: 4,
  31358. variableArgs: false
  31359. };
  31360. t['h'] = {
  31361. id: OPS.closePath,
  31362. numArgs: 0,
  31363. variableArgs: false
  31364. };
  31365. t['re'] = {
  31366. id: OPS.rectangle,
  31367. numArgs: 4,
  31368. variableArgs: false
  31369. };
  31370. t['S'] = {
  31371. id: OPS.stroke,
  31372. numArgs: 0,
  31373. variableArgs: false
  31374. };
  31375. t['s'] = {
  31376. id: OPS.closeStroke,
  31377. numArgs: 0,
  31378. variableArgs: false
  31379. };
  31380. t['f'] = {
  31381. id: OPS.fill,
  31382. numArgs: 0,
  31383. variableArgs: false
  31384. };
  31385. t['F'] = {
  31386. id: OPS.fill,
  31387. numArgs: 0,
  31388. variableArgs: false
  31389. };
  31390. t['f*'] = {
  31391. id: OPS.eoFill,
  31392. numArgs: 0,
  31393. variableArgs: false
  31394. };
  31395. t['B'] = {
  31396. id: OPS.fillStroke,
  31397. numArgs: 0,
  31398. variableArgs: false
  31399. };
  31400. t['B*'] = {
  31401. id: OPS.eoFillStroke,
  31402. numArgs: 0,
  31403. variableArgs: false
  31404. };
  31405. t['b'] = {
  31406. id: OPS.closeFillStroke,
  31407. numArgs: 0,
  31408. variableArgs: false
  31409. };
  31410. t['b*'] = {
  31411. id: OPS.closeEOFillStroke,
  31412. numArgs: 0,
  31413. variableArgs: false
  31414. };
  31415. t['n'] = {
  31416. id: OPS.endPath,
  31417. numArgs: 0,
  31418. variableArgs: false
  31419. };
  31420. t['W'] = {
  31421. id: OPS.clip,
  31422. numArgs: 0,
  31423. variableArgs: false
  31424. };
  31425. t['W*'] = {
  31426. id: OPS.eoClip,
  31427. numArgs: 0,
  31428. variableArgs: false
  31429. };
  31430. t['BT'] = {
  31431. id: OPS.beginText,
  31432. numArgs: 0,
  31433. variableArgs: false
  31434. };
  31435. t['ET'] = {
  31436. id: OPS.endText,
  31437. numArgs: 0,
  31438. variableArgs: false
  31439. };
  31440. t['Tc'] = {
  31441. id: OPS.setCharSpacing,
  31442. numArgs: 1,
  31443. variableArgs: false
  31444. };
  31445. t['Tw'] = {
  31446. id: OPS.setWordSpacing,
  31447. numArgs: 1,
  31448. variableArgs: false
  31449. };
  31450. t['Tz'] = {
  31451. id: OPS.setHScale,
  31452. numArgs: 1,
  31453. variableArgs: false
  31454. };
  31455. t['TL'] = {
  31456. id: OPS.setLeading,
  31457. numArgs: 1,
  31458. variableArgs: false
  31459. };
  31460. t['Tf'] = {
  31461. id: OPS.setFont,
  31462. numArgs: 2,
  31463. variableArgs: false
  31464. };
  31465. t['Tr'] = {
  31466. id: OPS.setTextRenderingMode,
  31467. numArgs: 1,
  31468. variableArgs: false
  31469. };
  31470. t['Ts'] = {
  31471. id: OPS.setTextRise,
  31472. numArgs: 1,
  31473. variableArgs: false
  31474. };
  31475. t['Td'] = {
  31476. id: OPS.moveText,
  31477. numArgs: 2,
  31478. variableArgs: false
  31479. };
  31480. t['TD'] = {
  31481. id: OPS.setLeadingMoveText,
  31482. numArgs: 2,
  31483. variableArgs: false
  31484. };
  31485. t['Tm'] = {
  31486. id: OPS.setTextMatrix,
  31487. numArgs: 6,
  31488. variableArgs: false
  31489. };
  31490. t['T*'] = {
  31491. id: OPS.nextLine,
  31492. numArgs: 0,
  31493. variableArgs: false
  31494. };
  31495. t['Tj'] = {
  31496. id: OPS.showText,
  31497. numArgs: 1,
  31498. variableArgs: false
  31499. };
  31500. t['TJ'] = {
  31501. id: OPS.showSpacedText,
  31502. numArgs: 1,
  31503. variableArgs: false
  31504. };
  31505. t['\''] = {
  31506. id: OPS.nextLineShowText,
  31507. numArgs: 1,
  31508. variableArgs: false
  31509. };
  31510. t['"'] = {
  31511. id: OPS.nextLineSetSpacingShowText,
  31512. numArgs: 3,
  31513. variableArgs: false
  31514. };
  31515. t['d0'] = {
  31516. id: OPS.setCharWidth,
  31517. numArgs: 2,
  31518. variableArgs: false
  31519. };
  31520. t['d1'] = {
  31521. id: OPS.setCharWidthAndBounds,
  31522. numArgs: 6,
  31523. variableArgs: false
  31524. };
  31525. t['CS'] = {
  31526. id: OPS.setStrokeColorSpace,
  31527. numArgs: 1,
  31528. variableArgs: false
  31529. };
  31530. t['cs'] = {
  31531. id: OPS.setFillColorSpace,
  31532. numArgs: 1,
  31533. variableArgs: false
  31534. };
  31535. t['SC'] = {
  31536. id: OPS.setStrokeColor,
  31537. numArgs: 4,
  31538. variableArgs: true
  31539. };
  31540. t['SCN'] = {
  31541. id: OPS.setStrokeColorN,
  31542. numArgs: 33,
  31543. variableArgs: true
  31544. };
  31545. t['sc'] = {
  31546. id: OPS.setFillColor,
  31547. numArgs: 4,
  31548. variableArgs: true
  31549. };
  31550. t['scn'] = {
  31551. id: OPS.setFillColorN,
  31552. numArgs: 33,
  31553. variableArgs: true
  31554. };
  31555. t['G'] = {
  31556. id: OPS.setStrokeGray,
  31557. numArgs: 1,
  31558. variableArgs: false
  31559. };
  31560. t['g'] = {
  31561. id: OPS.setFillGray,
  31562. numArgs: 1,
  31563. variableArgs: false
  31564. };
  31565. t['RG'] = {
  31566. id: OPS.setStrokeRGBColor,
  31567. numArgs: 3,
  31568. variableArgs: false
  31569. };
  31570. t['rg'] = {
  31571. id: OPS.setFillRGBColor,
  31572. numArgs: 3,
  31573. variableArgs: false
  31574. };
  31575. t['K'] = {
  31576. id: OPS.setStrokeCMYKColor,
  31577. numArgs: 4,
  31578. variableArgs: false
  31579. };
  31580. t['k'] = {
  31581. id: OPS.setFillCMYKColor,
  31582. numArgs: 4,
  31583. variableArgs: false
  31584. };
  31585. t['sh'] = {
  31586. id: OPS.shadingFill,
  31587. numArgs: 1,
  31588. variableArgs: false
  31589. };
  31590. t['BI'] = {
  31591. id: OPS.beginInlineImage,
  31592. numArgs: 0,
  31593. variableArgs: false
  31594. };
  31595. t['ID'] = {
  31596. id: OPS.beginImageData,
  31597. numArgs: 0,
  31598. variableArgs: false
  31599. };
  31600. t['EI'] = {
  31601. id: OPS.endInlineImage,
  31602. numArgs: 1,
  31603. variableArgs: false
  31604. };
  31605. t['Do'] = {
  31606. id: OPS.paintXObject,
  31607. numArgs: 1,
  31608. variableArgs: false
  31609. };
  31610. t['MP'] = {
  31611. id: OPS.markPoint,
  31612. numArgs: 1,
  31613. variableArgs: false
  31614. };
  31615. t['DP'] = {
  31616. id: OPS.markPointProps,
  31617. numArgs: 2,
  31618. variableArgs: false
  31619. };
  31620. t['BMC'] = {
  31621. id: OPS.beginMarkedContent,
  31622. numArgs: 1,
  31623. variableArgs: false
  31624. };
  31625. t['BDC'] = {
  31626. id: OPS.beginMarkedContentProps,
  31627. numArgs: 2,
  31628. variableArgs: false
  31629. };
  31630. t['EMC'] = {
  31631. id: OPS.endMarkedContent,
  31632. numArgs: 0,
  31633. variableArgs: false
  31634. };
  31635. t['BX'] = {
  31636. id: OPS.beginCompat,
  31637. numArgs: 0,
  31638. variableArgs: false
  31639. };
  31640. t['EX'] = {
  31641. id: OPS.endCompat,
  31642. numArgs: 0,
  31643. variableArgs: false
  31644. };
  31645. t['BM'] = null;
  31646. t['BD'] = null;
  31647. t['true'] = null;
  31648. t['fa'] = null;
  31649. t['fal'] = null;
  31650. t['fals'] = null;
  31651. t['false'] = null;
  31652. t['nu'] = null;
  31653. t['nul'] = null;
  31654. t['null'] = null;
  31655. });
  31656. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31657. this.opMap = getOPMap();
  31658. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31659. this.stateManager = stateManager;
  31660. this.nonProcessedArgs = [];
  31661. }
  31662. EvaluatorPreprocessor.prototype = {
  31663. get savedStatesDepth() {
  31664. return this.stateManager.stateStack.length;
  31665. },
  31666. read: function EvaluatorPreprocessor_read(operation) {
  31667. var args = operation.args;
  31668. while (true) {
  31669. var obj = this.parser.getObj();
  31670. if (isCmd(obj)) {
  31671. var cmd = obj.cmd;
  31672. var opSpec = this.opMap[cmd];
  31673. if (!opSpec) {
  31674. warn('Unknown command "' + cmd + '"');
  31675. continue;
  31676. }
  31677. var fn = opSpec.id;
  31678. var numArgs = opSpec.numArgs;
  31679. var argsLength = args !== null ? args.length : 0;
  31680. if (!opSpec.variableArgs) {
  31681. if (argsLength !== numArgs) {
  31682. var nonProcessedArgs = this.nonProcessedArgs;
  31683. while (argsLength > numArgs) {
  31684. nonProcessedArgs.push(args.shift());
  31685. argsLength--;
  31686. }
  31687. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31688. if (args === null) {
  31689. args = [];
  31690. }
  31691. args.unshift(nonProcessedArgs.pop());
  31692. argsLength++;
  31693. }
  31694. }
  31695. if (argsLength < numArgs) {
  31696. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31697. if (args !== null) {
  31698. args.length = 0;
  31699. }
  31700. continue;
  31701. }
  31702. } else if (argsLength > numArgs) {
  31703. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31704. }
  31705. this.preprocessCommand(fn, args);
  31706. operation.fn = fn;
  31707. operation.args = args;
  31708. return true;
  31709. }
  31710. if (isEOF(obj)) {
  31711. return false;
  31712. }
  31713. if (obj !== null) {
  31714. if (args === null) {
  31715. args = [];
  31716. }
  31717. args.push(obj);
  31718. assert(args.length <= 33, 'Too many arguments');
  31719. }
  31720. }
  31721. },
  31722. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31723. switch (fn | 0) {
  31724. case OPS.save:
  31725. this.stateManager.save();
  31726. break;
  31727. case OPS.restore:
  31728. this.stateManager.restore();
  31729. break;
  31730. case OPS.transform:
  31731. this.stateManager.transform(args);
  31732. break;
  31733. }
  31734. }
  31735. };
  31736. return EvaluatorPreprocessor;
  31737. }();
  31738. var QueueOptimizer = function QueueOptimizerClosure() {
  31739. function addState(parentState, pattern, fn) {
  31740. var state = parentState;
  31741. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31742. var item = pattern[i];
  31743. state = state[item] || (state[item] = []);
  31744. }
  31745. state[pattern[pattern.length - 1]] = fn;
  31746. }
  31747. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31748. var iFirstPIMXO = iFirstSave + 2;
  31749. for (var i = 0; i < count; i++) {
  31750. var arg = argsArray[iFirstPIMXO + 4 * i];
  31751. var imageMask = arg.length === 1 && arg[0];
  31752. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31753. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31754. continue;
  31755. }
  31756. break;
  31757. }
  31758. return count - i;
  31759. }
  31760. var InitialState = [];
  31761. addState(InitialState, [
  31762. OPS.save,
  31763. OPS.transform,
  31764. OPS.paintInlineImageXObject,
  31765. OPS.restore
  31766. ], function foundInlineImageGroup(context) {
  31767. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31768. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31769. var MAX_WIDTH = 1000;
  31770. var IMAGE_PADDING = 1;
  31771. var fnArray = context.fnArray, argsArray = context.argsArray;
  31772. var curr = context.iCurr;
  31773. var iFirstSave = curr - 3;
  31774. var iFirstTransform = curr - 2;
  31775. var iFirstPIIXO = curr - 1;
  31776. var i = iFirstSave + 4;
  31777. var ii = fnArray.length;
  31778. while (i + 3 < ii) {
  31779. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31780. break;
  31781. }
  31782. i += 4;
  31783. }
  31784. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31785. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31786. return i;
  31787. }
  31788. var maxX = 0;
  31789. var map = [], maxLineHeight = 0;
  31790. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31791. var q;
  31792. for (q = 0; q < count; q++) {
  31793. var transform = argsArray[iFirstTransform + (q << 2)];
  31794. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31795. if (currentX + img.width > MAX_WIDTH) {
  31796. maxX = Math.max(maxX, currentX);
  31797. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31798. currentX = 0;
  31799. maxLineHeight = 0;
  31800. }
  31801. map.push({
  31802. transform: transform,
  31803. x: currentX,
  31804. y: currentY,
  31805. w: img.width,
  31806. h: img.height
  31807. });
  31808. currentX += img.width + 2 * IMAGE_PADDING;
  31809. maxLineHeight = Math.max(maxLineHeight, img.height);
  31810. }
  31811. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31812. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31813. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31814. var imgRowSize = imgWidth << 2;
  31815. for (q = 0; q < count; q++) {
  31816. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31817. var rowSize = map[q].w << 2;
  31818. var dataOffset = 0;
  31819. var offset = map[q].x + map[q].y * imgWidth << 2;
  31820. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31821. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31822. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31823. dataOffset += rowSize;
  31824. offset += imgRowSize;
  31825. }
  31826. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31827. while (offset >= 0) {
  31828. data[offset - 4] = data[offset];
  31829. data[offset - 3] = data[offset + 1];
  31830. data[offset - 2] = data[offset + 2];
  31831. data[offset - 1] = data[offset + 3];
  31832. data[offset + rowSize] = data[offset + rowSize - 4];
  31833. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31834. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31835. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31836. offset -= imgRowSize;
  31837. }
  31838. }
  31839. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31840. argsArray.splice(iFirstSave, count * 4, [
  31841. {
  31842. width: imgWidth,
  31843. height: imgHeight,
  31844. kind: ImageKind.RGBA_32BPP,
  31845. data: imgData
  31846. },
  31847. map
  31848. ]);
  31849. return iFirstSave + 1;
  31850. });
  31851. addState(InitialState, [
  31852. OPS.save,
  31853. OPS.transform,
  31854. OPS.paintImageMaskXObject,
  31855. OPS.restore
  31856. ], function foundImageMaskGroup(context) {
  31857. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31858. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31859. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31860. var fnArray = context.fnArray, argsArray = context.argsArray;
  31861. var curr = context.iCurr;
  31862. var iFirstSave = curr - 3;
  31863. var iFirstTransform = curr - 2;
  31864. var iFirstPIMXO = curr - 1;
  31865. var i = iFirstSave + 4;
  31866. var ii = fnArray.length;
  31867. while (i + 3 < ii) {
  31868. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31869. break;
  31870. }
  31871. i += 4;
  31872. }
  31873. var count = (i - iFirstSave) / 4;
  31874. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31875. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31876. return i;
  31877. }
  31878. var q;
  31879. var isSameImage = false;
  31880. var iTransform, transformArgs;
  31881. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31882. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31883. isSameImage = true;
  31884. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31885. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31886. iTransform = iFirstTransform + 4;
  31887. var iPIMXO = iFirstPIMXO + 4;
  31888. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31889. transformArgs = argsArray[iTransform];
  31890. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31891. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31892. isSameImage = false;
  31893. } else {
  31894. count = q;
  31895. }
  31896. break;
  31897. }
  31898. }
  31899. }
  31900. if (isSameImage) {
  31901. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31902. var positions = new Float32Array(count * 2);
  31903. iTransform = iFirstTransform;
  31904. for (q = 0; q < count; q++, iTransform += 4) {
  31905. transformArgs = argsArray[iTransform];
  31906. positions[q << 1] = transformArgs[4];
  31907. positions[(q << 1) + 1] = transformArgs[5];
  31908. }
  31909. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31910. argsArray.splice(iFirstSave, count * 4, [
  31911. firstPIMXOArg0,
  31912. firstTransformArg0,
  31913. firstTransformArg3,
  31914. positions
  31915. ]);
  31916. } else {
  31917. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31918. var images = [];
  31919. for (q = 0; q < count; q++) {
  31920. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31921. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31922. images.push({
  31923. data: maskParams.data,
  31924. width: maskParams.width,
  31925. height: maskParams.height,
  31926. transform: transformArgs
  31927. });
  31928. }
  31929. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31930. argsArray.splice(iFirstSave, count * 4, [images]);
  31931. }
  31932. return iFirstSave + 1;
  31933. });
  31934. addState(InitialState, [
  31935. OPS.save,
  31936. OPS.transform,
  31937. OPS.paintImageXObject,
  31938. OPS.restore
  31939. ], function (context) {
  31940. var MIN_IMAGES_IN_BLOCK = 3;
  31941. var MAX_IMAGES_IN_BLOCK = 1000;
  31942. var fnArray = context.fnArray, argsArray = context.argsArray;
  31943. var curr = context.iCurr;
  31944. var iFirstSave = curr - 3;
  31945. var iFirstTransform = curr - 2;
  31946. var iFirstPIXO = curr - 1;
  31947. var iFirstRestore = curr;
  31948. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31949. return iFirstRestore + 1;
  31950. }
  31951. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31952. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31953. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31954. var i = iFirstSave + 4;
  31955. var ii = fnArray.length;
  31956. while (i + 3 < ii) {
  31957. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31958. break;
  31959. }
  31960. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31961. break;
  31962. }
  31963. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31964. break;
  31965. }
  31966. i += 4;
  31967. }
  31968. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31969. if (count < MIN_IMAGES_IN_BLOCK) {
  31970. return i;
  31971. }
  31972. var positions = new Float32Array(count * 2);
  31973. var iTransform = iFirstTransform;
  31974. for (var q = 0; q < count; q++, iTransform += 4) {
  31975. var transformArgs = argsArray[iTransform];
  31976. positions[q << 1] = transformArgs[4];
  31977. positions[(q << 1) + 1] = transformArgs[5];
  31978. }
  31979. var args = [
  31980. firstPIXOArg0,
  31981. firstTransformArg0,
  31982. firstTransformArg3,
  31983. positions
  31984. ];
  31985. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31986. argsArray.splice(iFirstSave, count * 4, args);
  31987. return iFirstSave + 1;
  31988. });
  31989. addState(InitialState, [
  31990. OPS.beginText,
  31991. OPS.setFont,
  31992. OPS.setTextMatrix,
  31993. OPS.showText,
  31994. OPS.endText
  31995. ], function (context) {
  31996. var MIN_CHARS_IN_BLOCK = 3;
  31997. var MAX_CHARS_IN_BLOCK = 1000;
  31998. var fnArray = context.fnArray, argsArray = context.argsArray;
  31999. var curr = context.iCurr;
  32000. var iFirstBeginText = curr - 4;
  32001. var iFirstSetFont = curr - 3;
  32002. var iFirstSetTextMatrix = curr - 2;
  32003. var iFirstShowText = curr - 1;
  32004. var iFirstEndText = curr;
  32005. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32006. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32007. var i = iFirstBeginText + 5;
  32008. var ii = fnArray.length;
  32009. while (i + 4 < ii) {
  32010. 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) {
  32011. break;
  32012. }
  32013. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32014. break;
  32015. }
  32016. i += 5;
  32017. }
  32018. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32019. if (count < MIN_CHARS_IN_BLOCK) {
  32020. return i;
  32021. }
  32022. var iFirst = iFirstBeginText;
  32023. 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) {
  32024. count++;
  32025. iFirst -= 5;
  32026. }
  32027. var iEndText = iFirst + 4;
  32028. for (var q = 1; q < count; q++) {
  32029. fnArray.splice(iEndText, 3);
  32030. argsArray.splice(iEndText, 3);
  32031. iEndText += 2;
  32032. }
  32033. return iEndText + 1;
  32034. });
  32035. function QueueOptimizer() {
  32036. }
  32037. QueueOptimizer.prototype = {
  32038. optimize: function QueueOptimizer_optimize(queue) {
  32039. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32040. var context = {
  32041. iCurr: 0,
  32042. fnArray: fnArray,
  32043. argsArray: argsArray
  32044. };
  32045. var state;
  32046. var i = 0, ii = fnArray.length;
  32047. while (i < ii) {
  32048. state = (state || InitialState)[fnArray[i]];
  32049. if (typeof state === 'function') {
  32050. context.iCurr = i;
  32051. i = state(context);
  32052. state = undefined;
  32053. ii = context.fnArray.length;
  32054. } else {
  32055. i++;
  32056. }
  32057. }
  32058. }
  32059. };
  32060. return QueueOptimizer;
  32061. }();
  32062. exports.OperatorList = OperatorList;
  32063. exports.PartialEvaluator = PartialEvaluator;
  32064. /***/ }),
  32065. /* 18 */
  32066. /***/ (function(module, exports, __w_pdfjs_require__) {
  32067. "use strict";
  32068. var sharedUtil = __w_pdfjs_require__(0);
  32069. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32070. var info = sharedUtil.info;
  32071. var warn = sharedUtil.warn;
  32072. var error = sharedUtil.error;
  32073. var log2 = sharedUtil.log2;
  32074. var readUint16 = sharedUtil.readUint16;
  32075. var readUint32 = sharedUtil.readUint32;
  32076. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32077. var JpxImage = function JpxImageClosure() {
  32078. var SubbandsGainLog2 = {
  32079. 'LL': 0,
  32080. 'LH': 1,
  32081. 'HL': 1,
  32082. 'HH': 2
  32083. };
  32084. function JpxImage() {
  32085. this.failOnCorruptedImage = false;
  32086. }
  32087. JpxImage.prototype = {
  32088. parse: function JpxImage_parse(data) {
  32089. var head = readUint16(data, 0);
  32090. if (head === 0xFF4F) {
  32091. this.parseCodestream(data, 0, data.length);
  32092. return;
  32093. }
  32094. var position = 0, length = data.length;
  32095. while (position < length) {
  32096. var headerSize = 8;
  32097. var lbox = readUint32(data, position);
  32098. var tbox = readUint32(data, position + 4);
  32099. position += headerSize;
  32100. if (lbox === 1) {
  32101. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32102. position += 8;
  32103. headerSize += 8;
  32104. }
  32105. if (lbox === 0) {
  32106. lbox = length - position + headerSize;
  32107. }
  32108. if (lbox < headerSize) {
  32109. error('JPX Error: Invalid box field size');
  32110. }
  32111. var dataLength = lbox - headerSize;
  32112. var jumpDataLength = true;
  32113. switch (tbox) {
  32114. case 0x6A703268:
  32115. jumpDataLength = false;
  32116. break;
  32117. case 0x636F6C72:
  32118. var method = data[position];
  32119. if (method === 1) {
  32120. var colorspace = readUint32(data, position + 3);
  32121. switch (colorspace) {
  32122. case 16:
  32123. case 17:
  32124. case 18:
  32125. break;
  32126. default:
  32127. warn('Unknown colorspace ' + colorspace);
  32128. break;
  32129. }
  32130. } else if (method === 2) {
  32131. info('ICC profile not supported');
  32132. }
  32133. break;
  32134. case 0x6A703263:
  32135. this.parseCodestream(data, position, position + dataLength);
  32136. break;
  32137. case 0x6A502020:
  32138. if (0x0d0a870a !== readUint32(data, position)) {
  32139. warn('Invalid JP2 signature');
  32140. }
  32141. break;
  32142. case 0x6A501A1A:
  32143. case 0x66747970:
  32144. case 0x72726571:
  32145. case 0x72657320:
  32146. case 0x69686472:
  32147. break;
  32148. default:
  32149. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32150. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32151. break;
  32152. }
  32153. if (jumpDataLength) {
  32154. position += dataLength;
  32155. }
  32156. }
  32157. },
  32158. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32159. var newByte = stream.getByte();
  32160. while (newByte >= 0) {
  32161. var oldByte = newByte;
  32162. newByte = stream.getByte();
  32163. var code = oldByte << 8 | newByte;
  32164. if (code === 0xFF51) {
  32165. stream.skip(4);
  32166. var Xsiz = stream.getInt32() >>> 0;
  32167. var Ysiz = stream.getInt32() >>> 0;
  32168. var XOsiz = stream.getInt32() >>> 0;
  32169. var YOsiz = stream.getInt32() >>> 0;
  32170. stream.skip(16);
  32171. var Csiz = stream.getUint16();
  32172. this.width = Xsiz - XOsiz;
  32173. this.height = Ysiz - YOsiz;
  32174. this.componentsCount = Csiz;
  32175. this.bitsPerComponent = 8;
  32176. return;
  32177. }
  32178. }
  32179. error('JPX Error: No size marker found in JPX stream');
  32180. },
  32181. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32182. var context = {};
  32183. var doNotRecover = false;
  32184. try {
  32185. var position = start;
  32186. while (position + 1 < end) {
  32187. var code = readUint16(data, position);
  32188. position += 2;
  32189. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32190. switch (code) {
  32191. case 0xFF4F:
  32192. context.mainHeader = true;
  32193. break;
  32194. case 0xFFD9:
  32195. break;
  32196. case 0xFF51:
  32197. length = readUint16(data, position);
  32198. var siz = {};
  32199. siz.Xsiz = readUint32(data, position + 4);
  32200. siz.Ysiz = readUint32(data, position + 8);
  32201. siz.XOsiz = readUint32(data, position + 12);
  32202. siz.YOsiz = readUint32(data, position + 16);
  32203. siz.XTsiz = readUint32(data, position + 20);
  32204. siz.YTsiz = readUint32(data, position + 24);
  32205. siz.XTOsiz = readUint32(data, position + 28);
  32206. siz.YTOsiz = readUint32(data, position + 32);
  32207. var componentsCount = readUint16(data, position + 36);
  32208. siz.Csiz = componentsCount;
  32209. var components = [];
  32210. j = position + 38;
  32211. for (var i = 0; i < componentsCount; i++) {
  32212. var component = {
  32213. precision: (data[j] & 0x7F) + 1,
  32214. isSigned: !!(data[j] & 0x80),
  32215. XRsiz: data[j + 1],
  32216. YRsiz: data[j + 1]
  32217. };
  32218. calculateComponentDimensions(component, siz);
  32219. components.push(component);
  32220. }
  32221. context.SIZ = siz;
  32222. context.components = components;
  32223. calculateTileGrids(context, components);
  32224. context.QCC = [];
  32225. context.COC = [];
  32226. break;
  32227. case 0xFF5C:
  32228. length = readUint16(data, position);
  32229. var qcd = {};
  32230. j = position + 2;
  32231. sqcd = data[j++];
  32232. switch (sqcd & 0x1F) {
  32233. case 0:
  32234. spqcdSize = 8;
  32235. scalarExpounded = true;
  32236. break;
  32237. case 1:
  32238. spqcdSize = 16;
  32239. scalarExpounded = false;
  32240. break;
  32241. case 2:
  32242. spqcdSize = 16;
  32243. scalarExpounded = true;
  32244. break;
  32245. default:
  32246. throw new Error('Invalid SQcd value ' + sqcd);
  32247. }
  32248. qcd.noQuantization = spqcdSize === 8;
  32249. qcd.scalarExpounded = scalarExpounded;
  32250. qcd.guardBits = sqcd >> 5;
  32251. spqcds = [];
  32252. while (j < length + position) {
  32253. var spqcd = {};
  32254. if (spqcdSize === 8) {
  32255. spqcd.epsilon = data[j++] >> 3;
  32256. spqcd.mu = 0;
  32257. } else {
  32258. spqcd.epsilon = data[j] >> 3;
  32259. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32260. j += 2;
  32261. }
  32262. spqcds.push(spqcd);
  32263. }
  32264. qcd.SPqcds = spqcds;
  32265. if (context.mainHeader) {
  32266. context.QCD = qcd;
  32267. } else {
  32268. context.currentTile.QCD = qcd;
  32269. context.currentTile.QCC = [];
  32270. }
  32271. break;
  32272. case 0xFF5D:
  32273. length = readUint16(data, position);
  32274. var qcc = {};
  32275. j = position + 2;
  32276. var cqcc;
  32277. if (context.SIZ.Csiz < 257) {
  32278. cqcc = data[j++];
  32279. } else {
  32280. cqcc = readUint16(data, j);
  32281. j += 2;
  32282. }
  32283. sqcd = data[j++];
  32284. switch (sqcd & 0x1F) {
  32285. case 0:
  32286. spqcdSize = 8;
  32287. scalarExpounded = true;
  32288. break;
  32289. case 1:
  32290. spqcdSize = 16;
  32291. scalarExpounded = false;
  32292. break;
  32293. case 2:
  32294. spqcdSize = 16;
  32295. scalarExpounded = true;
  32296. break;
  32297. default:
  32298. throw new Error('Invalid SQcd value ' + sqcd);
  32299. }
  32300. qcc.noQuantization = spqcdSize === 8;
  32301. qcc.scalarExpounded = scalarExpounded;
  32302. qcc.guardBits = sqcd >> 5;
  32303. spqcds = [];
  32304. while (j < length + position) {
  32305. spqcd = {};
  32306. if (spqcdSize === 8) {
  32307. spqcd.epsilon = data[j++] >> 3;
  32308. spqcd.mu = 0;
  32309. } else {
  32310. spqcd.epsilon = data[j] >> 3;
  32311. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32312. j += 2;
  32313. }
  32314. spqcds.push(spqcd);
  32315. }
  32316. qcc.SPqcds = spqcds;
  32317. if (context.mainHeader) {
  32318. context.QCC[cqcc] = qcc;
  32319. } else {
  32320. context.currentTile.QCC[cqcc] = qcc;
  32321. }
  32322. break;
  32323. case 0xFF52:
  32324. length = readUint16(data, position);
  32325. var cod = {};
  32326. j = position + 2;
  32327. var scod = data[j++];
  32328. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32329. cod.sopMarkerUsed = !!(scod & 2);
  32330. cod.ephMarkerUsed = !!(scod & 4);
  32331. cod.progressionOrder = data[j++];
  32332. cod.layersCount = readUint16(data, j);
  32333. j += 2;
  32334. cod.multipleComponentTransform = data[j++];
  32335. cod.decompositionLevelsCount = data[j++];
  32336. cod.xcb = (data[j++] & 0xF) + 2;
  32337. cod.ycb = (data[j++] & 0xF) + 2;
  32338. var blockStyle = data[j++];
  32339. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32340. cod.resetContextProbabilities = !!(blockStyle & 2);
  32341. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32342. cod.verticalyStripe = !!(blockStyle & 8);
  32343. cod.predictableTermination = !!(blockStyle & 16);
  32344. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32345. cod.reversibleTransformation = data[j++];
  32346. if (cod.entropyCoderWithCustomPrecincts) {
  32347. var precinctsSizes = [];
  32348. while (j < length + position) {
  32349. var precinctsSize = data[j++];
  32350. precinctsSizes.push({
  32351. PPx: precinctsSize & 0xF,
  32352. PPy: precinctsSize >> 4
  32353. });
  32354. }
  32355. cod.precinctsSizes = precinctsSizes;
  32356. }
  32357. var unsupported = [];
  32358. if (cod.selectiveArithmeticCodingBypass) {
  32359. unsupported.push('selectiveArithmeticCodingBypass');
  32360. }
  32361. if (cod.resetContextProbabilities) {
  32362. unsupported.push('resetContextProbabilities');
  32363. }
  32364. if (cod.terminationOnEachCodingPass) {
  32365. unsupported.push('terminationOnEachCodingPass');
  32366. }
  32367. if (cod.verticalyStripe) {
  32368. unsupported.push('verticalyStripe');
  32369. }
  32370. if (cod.predictableTermination) {
  32371. unsupported.push('predictableTermination');
  32372. }
  32373. if (unsupported.length > 0) {
  32374. doNotRecover = true;
  32375. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32376. }
  32377. if (context.mainHeader) {
  32378. context.COD = cod;
  32379. } else {
  32380. context.currentTile.COD = cod;
  32381. context.currentTile.COC = [];
  32382. }
  32383. break;
  32384. case 0xFF90:
  32385. length = readUint16(data, position);
  32386. tile = {};
  32387. tile.index = readUint16(data, position + 2);
  32388. tile.length = readUint32(data, position + 4);
  32389. tile.dataEnd = tile.length + position - 2;
  32390. tile.partIndex = data[position + 8];
  32391. tile.partsCount = data[position + 9];
  32392. context.mainHeader = false;
  32393. if (tile.partIndex === 0) {
  32394. tile.COD = context.COD;
  32395. tile.COC = context.COC.slice(0);
  32396. tile.QCD = context.QCD;
  32397. tile.QCC = context.QCC.slice(0);
  32398. }
  32399. context.currentTile = tile;
  32400. break;
  32401. case 0xFF93:
  32402. tile = context.currentTile;
  32403. if (tile.partIndex === 0) {
  32404. initializeTile(context, tile.index);
  32405. buildPackets(context);
  32406. }
  32407. length = tile.dataEnd - position;
  32408. parseTilePackets(context, data, position, length);
  32409. break;
  32410. case 0xFF55:
  32411. case 0xFF57:
  32412. case 0xFF58:
  32413. case 0xFF64:
  32414. length = readUint16(data, position);
  32415. break;
  32416. case 0xFF53:
  32417. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32418. default:
  32419. throw new Error('Unknown codestream code: ' + code.toString(16));
  32420. }
  32421. position += length;
  32422. }
  32423. } catch (e) {
  32424. if (doNotRecover || this.failOnCorruptedImage) {
  32425. error('JPX Error: ' + e.message);
  32426. } else {
  32427. warn('JPX: Trying to recover from: ' + e.message);
  32428. }
  32429. }
  32430. this.tiles = transformComponents(context);
  32431. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32432. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32433. this.componentsCount = context.SIZ.Csiz;
  32434. }
  32435. };
  32436. function calculateComponentDimensions(component, siz) {
  32437. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32438. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32439. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32440. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32441. component.width = component.x1 - component.x0;
  32442. component.height = component.y1 - component.y0;
  32443. }
  32444. function calculateTileGrids(context, components) {
  32445. var siz = context.SIZ;
  32446. var tile, tiles = [];
  32447. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32448. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32449. for (var q = 0; q < numYtiles; q++) {
  32450. for (var p = 0; p < numXtiles; p++) {
  32451. tile = {};
  32452. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32453. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32454. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32455. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32456. tile.width = tile.tx1 - tile.tx0;
  32457. tile.height = tile.ty1 - tile.ty0;
  32458. tile.components = [];
  32459. tiles.push(tile);
  32460. }
  32461. }
  32462. context.tiles = tiles;
  32463. var componentsCount = siz.Csiz;
  32464. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32465. var component = components[i];
  32466. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32467. var tileComponent = {};
  32468. tile = tiles[j];
  32469. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32470. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32471. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32472. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32473. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32474. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32475. tile.components[i] = tileComponent;
  32476. }
  32477. }
  32478. }
  32479. function getBlocksDimensions(context, component, r) {
  32480. var codOrCoc = component.codingStyleParameters;
  32481. var result = {};
  32482. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32483. result.PPx = 15;
  32484. result.PPy = 15;
  32485. } else {
  32486. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32487. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32488. }
  32489. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32490. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32491. return result;
  32492. }
  32493. function buildPrecincts(context, resolution, dimensions) {
  32494. var precinctWidth = 1 << dimensions.PPx;
  32495. var precinctHeight = 1 << dimensions.PPy;
  32496. var isZeroRes = resolution.resLevel === 0;
  32497. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32498. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32499. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32500. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32501. var numprecincts = numprecinctswide * numprecinctshigh;
  32502. resolution.precinctParameters = {
  32503. precinctWidth: precinctWidth,
  32504. precinctHeight: precinctHeight,
  32505. numprecinctswide: numprecinctswide,
  32506. numprecinctshigh: numprecinctshigh,
  32507. numprecincts: numprecincts,
  32508. precinctWidthInSubband: precinctWidthInSubband,
  32509. precinctHeightInSubband: precinctHeightInSubband
  32510. };
  32511. }
  32512. function buildCodeblocks(context, subband, dimensions) {
  32513. var xcb_ = dimensions.xcb_;
  32514. var ycb_ = dimensions.ycb_;
  32515. var codeblockWidth = 1 << xcb_;
  32516. var codeblockHeight = 1 << ycb_;
  32517. var cbx0 = subband.tbx0 >> xcb_;
  32518. var cby0 = subband.tby0 >> ycb_;
  32519. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32520. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32521. var precinctParameters = subband.resolution.precinctParameters;
  32522. var codeblocks = [];
  32523. var precincts = [];
  32524. var i, j, codeblock, precinctNumber;
  32525. for (j = cby0; j < cby1; j++) {
  32526. for (i = cbx0; i < cbx1; i++) {
  32527. codeblock = {
  32528. cbx: i,
  32529. cby: j,
  32530. tbx0: codeblockWidth * i,
  32531. tby0: codeblockHeight * j,
  32532. tbx1: codeblockWidth * (i + 1),
  32533. tby1: codeblockHeight * (j + 1)
  32534. };
  32535. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32536. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32537. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32538. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32539. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32540. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32541. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32542. codeblock.precinctNumber = precinctNumber;
  32543. codeblock.subbandType = subband.type;
  32544. codeblock.Lblock = 3;
  32545. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32546. continue;
  32547. }
  32548. codeblocks.push(codeblock);
  32549. var precinct = precincts[precinctNumber];
  32550. if (precinct !== undefined) {
  32551. if (i < precinct.cbxMin) {
  32552. precinct.cbxMin = i;
  32553. } else if (i > precinct.cbxMax) {
  32554. precinct.cbxMax = i;
  32555. }
  32556. if (j < precinct.cbyMin) {
  32557. precinct.cbxMin = j;
  32558. } else if (j > precinct.cbyMax) {
  32559. precinct.cbyMax = j;
  32560. }
  32561. } else {
  32562. precincts[precinctNumber] = precinct = {
  32563. cbxMin: i,
  32564. cbyMin: j,
  32565. cbxMax: i,
  32566. cbyMax: j
  32567. };
  32568. }
  32569. codeblock.precinct = precinct;
  32570. }
  32571. }
  32572. subband.codeblockParameters = {
  32573. codeblockWidth: xcb_,
  32574. codeblockHeight: ycb_,
  32575. numcodeblockwide: cbx1 - cbx0 + 1,
  32576. numcodeblockhigh: cby1 - cby0 + 1
  32577. };
  32578. subband.codeblocks = codeblocks;
  32579. subband.precincts = precincts;
  32580. }
  32581. function createPacket(resolution, precinctNumber, layerNumber) {
  32582. var precinctCodeblocks = [];
  32583. var subbands = resolution.subbands;
  32584. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32585. var subband = subbands[i];
  32586. var codeblocks = subband.codeblocks;
  32587. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32588. var codeblock = codeblocks[j];
  32589. if (codeblock.precinctNumber !== precinctNumber) {
  32590. continue;
  32591. }
  32592. precinctCodeblocks.push(codeblock);
  32593. }
  32594. }
  32595. return {
  32596. layerNumber: layerNumber,
  32597. codeblocks: precinctCodeblocks
  32598. };
  32599. }
  32600. function LayerResolutionComponentPositionIterator(context) {
  32601. var siz = context.SIZ;
  32602. var tileIndex = context.currentTile.index;
  32603. var tile = context.tiles[tileIndex];
  32604. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32605. var componentsCount = siz.Csiz;
  32606. var maxDecompositionLevelsCount = 0;
  32607. for (var q = 0; q < componentsCount; q++) {
  32608. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32609. }
  32610. var l = 0, r = 0, i = 0, k = 0;
  32611. this.nextPacket = function JpxImage_nextPacket() {
  32612. for (; l < layersCount; l++) {
  32613. for (; r <= maxDecompositionLevelsCount; r++) {
  32614. for (; i < componentsCount; i++) {
  32615. var component = tile.components[i];
  32616. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32617. continue;
  32618. }
  32619. var resolution = component.resolutions[r];
  32620. var numprecincts = resolution.precinctParameters.numprecincts;
  32621. for (; k < numprecincts;) {
  32622. var packet = createPacket(resolution, k, l);
  32623. k++;
  32624. return packet;
  32625. }
  32626. k = 0;
  32627. }
  32628. i = 0;
  32629. }
  32630. r = 0;
  32631. }
  32632. error('JPX Error: Out of packets');
  32633. };
  32634. }
  32635. function ResolutionLayerComponentPositionIterator(context) {
  32636. var siz = context.SIZ;
  32637. var tileIndex = context.currentTile.index;
  32638. var tile = context.tiles[tileIndex];
  32639. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32640. var componentsCount = siz.Csiz;
  32641. var maxDecompositionLevelsCount = 0;
  32642. for (var q = 0; q < componentsCount; q++) {
  32643. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32644. }
  32645. var r = 0, l = 0, i = 0, k = 0;
  32646. this.nextPacket = function JpxImage_nextPacket() {
  32647. for (; r <= maxDecompositionLevelsCount; r++) {
  32648. for (; l < layersCount; l++) {
  32649. for (; i < componentsCount; i++) {
  32650. var component = tile.components[i];
  32651. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32652. continue;
  32653. }
  32654. var resolution = component.resolutions[r];
  32655. var numprecincts = resolution.precinctParameters.numprecincts;
  32656. for (; k < numprecincts;) {
  32657. var packet = createPacket(resolution, k, l);
  32658. k++;
  32659. return packet;
  32660. }
  32661. k = 0;
  32662. }
  32663. i = 0;
  32664. }
  32665. l = 0;
  32666. }
  32667. error('JPX Error: Out of packets');
  32668. };
  32669. }
  32670. function ResolutionPositionComponentLayerIterator(context) {
  32671. var siz = context.SIZ;
  32672. var tileIndex = context.currentTile.index;
  32673. var tile = context.tiles[tileIndex];
  32674. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32675. var componentsCount = siz.Csiz;
  32676. var l, r, c, p;
  32677. var maxDecompositionLevelsCount = 0;
  32678. for (c = 0; c < componentsCount; c++) {
  32679. var component = tile.components[c];
  32680. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32681. }
  32682. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32683. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32684. var maxNumPrecincts = 0;
  32685. for (c = 0; c < componentsCount; ++c) {
  32686. var resolutions = tile.components[c].resolutions;
  32687. if (r < resolutions.length) {
  32688. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32689. }
  32690. }
  32691. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32692. }
  32693. l = 0;
  32694. r = 0;
  32695. c = 0;
  32696. p = 0;
  32697. this.nextPacket = function JpxImage_nextPacket() {
  32698. for (; r <= maxDecompositionLevelsCount; r++) {
  32699. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32700. for (; c < componentsCount; c++) {
  32701. var component = tile.components[c];
  32702. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32703. continue;
  32704. }
  32705. var resolution = component.resolutions[r];
  32706. var numprecincts = resolution.precinctParameters.numprecincts;
  32707. if (p >= numprecincts) {
  32708. continue;
  32709. }
  32710. for (; l < layersCount;) {
  32711. var packet = createPacket(resolution, p, l);
  32712. l++;
  32713. return packet;
  32714. }
  32715. l = 0;
  32716. }
  32717. c = 0;
  32718. }
  32719. p = 0;
  32720. }
  32721. error('JPX Error: Out of packets');
  32722. };
  32723. }
  32724. function PositionComponentResolutionLayerIterator(context) {
  32725. var siz = context.SIZ;
  32726. var tileIndex = context.currentTile.index;
  32727. var tile = context.tiles[tileIndex];
  32728. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32729. var componentsCount = siz.Csiz;
  32730. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32731. var precinctsIterationSizes = precinctsSizes;
  32732. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32733. this.nextPacket = function JpxImage_nextPacket() {
  32734. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32735. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32736. for (; c < componentsCount; c++) {
  32737. var component = tile.components[c];
  32738. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32739. for (; r <= decompositionLevelsCount; r++) {
  32740. var resolution = component.resolutions[r];
  32741. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32742. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32743. if (k === null) {
  32744. continue;
  32745. }
  32746. for (; l < layersCount;) {
  32747. var packet = createPacket(resolution, k, l);
  32748. l++;
  32749. return packet;
  32750. }
  32751. l = 0;
  32752. }
  32753. r = 0;
  32754. }
  32755. c = 0;
  32756. }
  32757. px = 0;
  32758. }
  32759. error('JPX Error: Out of packets');
  32760. };
  32761. }
  32762. function ComponentPositionResolutionLayerIterator(context) {
  32763. var siz = context.SIZ;
  32764. var tileIndex = context.currentTile.index;
  32765. var tile = context.tiles[tileIndex];
  32766. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32767. var componentsCount = siz.Csiz;
  32768. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32769. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32770. this.nextPacket = function JpxImage_nextPacket() {
  32771. for (; c < componentsCount; ++c) {
  32772. var component = tile.components[c];
  32773. var precinctsIterationSizes = precinctsSizes.components[c];
  32774. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32775. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32776. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32777. for (; r <= decompositionLevelsCount; r++) {
  32778. var resolution = component.resolutions[r];
  32779. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32780. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32781. if (k === null) {
  32782. continue;
  32783. }
  32784. for (; l < layersCount;) {
  32785. var packet = createPacket(resolution, k, l);
  32786. l++;
  32787. return packet;
  32788. }
  32789. l = 0;
  32790. }
  32791. r = 0;
  32792. }
  32793. px = 0;
  32794. }
  32795. py = 0;
  32796. }
  32797. error('JPX Error: Out of packets');
  32798. };
  32799. }
  32800. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32801. var posX = pxIndex * precinctIterationSizes.minWidth;
  32802. var posY = pyIndex * precinctIterationSizes.minHeight;
  32803. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32804. return null;
  32805. }
  32806. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32807. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32808. }
  32809. function getPrecinctSizesInImageScale(tile) {
  32810. var componentsCount = tile.components.length;
  32811. var minWidth = Number.MAX_VALUE;
  32812. var minHeight = Number.MAX_VALUE;
  32813. var maxNumWide = 0;
  32814. var maxNumHigh = 0;
  32815. var sizePerComponent = new Array(componentsCount);
  32816. for (var c = 0; c < componentsCount; c++) {
  32817. var component = tile.components[c];
  32818. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32819. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32820. var minWidthCurrentComponent = Number.MAX_VALUE;
  32821. var minHeightCurrentComponent = Number.MAX_VALUE;
  32822. var maxNumWideCurrentComponent = 0;
  32823. var maxNumHighCurrentComponent = 0;
  32824. var scale = 1;
  32825. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32826. var resolution = component.resolutions[r];
  32827. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32828. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32829. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32830. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32831. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32832. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32833. sizePerResolution[r] = {
  32834. width: widthCurrentResolution,
  32835. height: heightCurrentResolution
  32836. };
  32837. scale <<= 1;
  32838. }
  32839. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32840. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32841. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32842. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32843. sizePerComponent[c] = {
  32844. resolutions: sizePerResolution,
  32845. minWidth: minWidthCurrentComponent,
  32846. minHeight: minHeightCurrentComponent,
  32847. maxNumWide: maxNumWideCurrentComponent,
  32848. maxNumHigh: maxNumHighCurrentComponent
  32849. };
  32850. }
  32851. return {
  32852. components: sizePerComponent,
  32853. minWidth: minWidth,
  32854. minHeight: minHeight,
  32855. maxNumWide: maxNumWide,
  32856. maxNumHigh: maxNumHigh
  32857. };
  32858. }
  32859. function buildPackets(context) {
  32860. var siz = context.SIZ;
  32861. var tileIndex = context.currentTile.index;
  32862. var tile = context.tiles[tileIndex];
  32863. var componentsCount = siz.Csiz;
  32864. for (var c = 0; c < componentsCount; c++) {
  32865. var component = tile.components[c];
  32866. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32867. var resolutions = [];
  32868. var subbands = [];
  32869. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32870. var blocksDimensions = getBlocksDimensions(context, component, r);
  32871. var resolution = {};
  32872. var scale = 1 << decompositionLevelsCount - r;
  32873. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32874. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32875. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32876. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32877. resolution.resLevel = r;
  32878. buildPrecincts(context, resolution, blocksDimensions);
  32879. resolutions.push(resolution);
  32880. var subband;
  32881. if (r === 0) {
  32882. subband = {};
  32883. subband.type = 'LL';
  32884. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32885. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32886. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32887. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32888. subband.resolution = resolution;
  32889. buildCodeblocks(context, subband, blocksDimensions);
  32890. subbands.push(subband);
  32891. resolution.subbands = [subband];
  32892. } else {
  32893. var bscale = 1 << decompositionLevelsCount - r + 1;
  32894. var resolutionSubbands = [];
  32895. subband = {};
  32896. subband.type = 'HL';
  32897. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32898. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32899. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32900. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32901. subband.resolution = resolution;
  32902. buildCodeblocks(context, subband, blocksDimensions);
  32903. subbands.push(subband);
  32904. resolutionSubbands.push(subband);
  32905. subband = {};
  32906. subband.type = 'LH';
  32907. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32908. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32909. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32910. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32911. subband.resolution = resolution;
  32912. buildCodeblocks(context, subband, blocksDimensions);
  32913. subbands.push(subband);
  32914. resolutionSubbands.push(subband);
  32915. subband = {};
  32916. subband.type = 'HH';
  32917. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32918. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32919. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32920. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32921. subband.resolution = resolution;
  32922. buildCodeblocks(context, subband, blocksDimensions);
  32923. subbands.push(subband);
  32924. resolutionSubbands.push(subband);
  32925. resolution.subbands = resolutionSubbands;
  32926. }
  32927. }
  32928. component.resolutions = resolutions;
  32929. component.subbands = subbands;
  32930. }
  32931. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32932. switch (progressionOrder) {
  32933. case 0:
  32934. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32935. break;
  32936. case 1:
  32937. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32938. break;
  32939. case 2:
  32940. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32941. break;
  32942. case 3:
  32943. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32944. break;
  32945. case 4:
  32946. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32947. break;
  32948. default:
  32949. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32950. }
  32951. }
  32952. function parseTilePackets(context, data, offset, dataLength) {
  32953. var position = 0;
  32954. var buffer, bufferSize = 0, skipNextBit = false;
  32955. function readBits(count) {
  32956. while (bufferSize < count) {
  32957. var b = data[offset + position];
  32958. position++;
  32959. if (skipNextBit) {
  32960. buffer = buffer << 7 | b;
  32961. bufferSize += 7;
  32962. skipNextBit = false;
  32963. } else {
  32964. buffer = buffer << 8 | b;
  32965. bufferSize += 8;
  32966. }
  32967. if (b === 0xFF) {
  32968. skipNextBit = true;
  32969. }
  32970. }
  32971. bufferSize -= count;
  32972. return buffer >>> bufferSize & (1 << count) - 1;
  32973. }
  32974. function skipMarkerIfEqual(value) {
  32975. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32976. skipBytes(1);
  32977. return true;
  32978. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32979. skipBytes(2);
  32980. return true;
  32981. }
  32982. return false;
  32983. }
  32984. function skipBytes(count) {
  32985. position += count;
  32986. }
  32987. function alignToByte() {
  32988. bufferSize = 0;
  32989. if (skipNextBit) {
  32990. position++;
  32991. skipNextBit = false;
  32992. }
  32993. }
  32994. function readCodingpasses() {
  32995. if (readBits(1) === 0) {
  32996. return 1;
  32997. }
  32998. if (readBits(1) === 0) {
  32999. return 2;
  33000. }
  33001. var value = readBits(2);
  33002. if (value < 3) {
  33003. return value + 3;
  33004. }
  33005. value = readBits(5);
  33006. if (value < 31) {
  33007. return value + 6;
  33008. }
  33009. value = readBits(7);
  33010. return value + 37;
  33011. }
  33012. var tileIndex = context.currentTile.index;
  33013. var tile = context.tiles[tileIndex];
  33014. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33015. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33016. var packetsIterator = tile.packetsIterator;
  33017. while (position < dataLength) {
  33018. alignToByte();
  33019. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33020. skipBytes(4);
  33021. }
  33022. var packet = packetsIterator.nextPacket();
  33023. if (!readBits(1)) {
  33024. continue;
  33025. }
  33026. var layerNumber = packet.layerNumber;
  33027. var queue = [], codeblock;
  33028. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33029. codeblock = packet.codeblocks[i];
  33030. var precinct = codeblock.precinct;
  33031. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33032. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33033. var codeblockIncluded = false;
  33034. var firstTimeInclusion = false;
  33035. var valueReady;
  33036. if (codeblock['included'] !== undefined) {
  33037. codeblockIncluded = !!readBits(1);
  33038. } else {
  33039. precinct = codeblock.precinct;
  33040. var inclusionTree, zeroBitPlanesTree;
  33041. if (precinct['inclusionTree'] !== undefined) {
  33042. inclusionTree = precinct.inclusionTree;
  33043. } else {
  33044. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33045. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33046. inclusionTree = new InclusionTree(width, height, layerNumber);
  33047. zeroBitPlanesTree = new TagTree(width, height);
  33048. precinct.inclusionTree = inclusionTree;
  33049. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33050. }
  33051. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33052. while (true) {
  33053. if (readBits(1)) {
  33054. valueReady = !inclusionTree.nextLevel();
  33055. if (valueReady) {
  33056. codeblock.included = true;
  33057. codeblockIncluded = firstTimeInclusion = true;
  33058. break;
  33059. }
  33060. } else {
  33061. inclusionTree.incrementValue(layerNumber);
  33062. break;
  33063. }
  33064. }
  33065. }
  33066. }
  33067. if (!codeblockIncluded) {
  33068. continue;
  33069. }
  33070. if (firstTimeInclusion) {
  33071. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33072. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33073. while (true) {
  33074. if (readBits(1)) {
  33075. valueReady = !zeroBitPlanesTree.nextLevel();
  33076. if (valueReady) {
  33077. break;
  33078. }
  33079. } else {
  33080. zeroBitPlanesTree.incrementValue();
  33081. }
  33082. }
  33083. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33084. }
  33085. var codingpasses = readCodingpasses();
  33086. while (readBits(1)) {
  33087. codeblock.Lblock++;
  33088. }
  33089. var codingpassesLog2 = log2(codingpasses);
  33090. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33091. var codedDataLength = readBits(bits);
  33092. queue.push({
  33093. codeblock: codeblock,
  33094. codingpasses: codingpasses,
  33095. dataLength: codedDataLength
  33096. });
  33097. }
  33098. alignToByte();
  33099. if (ephMarkerUsed) {
  33100. skipMarkerIfEqual(0x92);
  33101. }
  33102. while (queue.length > 0) {
  33103. var packetItem = queue.shift();
  33104. codeblock = packetItem.codeblock;
  33105. if (codeblock['data'] === undefined) {
  33106. codeblock.data = [];
  33107. }
  33108. codeblock.data.push({
  33109. data: data,
  33110. start: offset + position,
  33111. end: offset + position + packetItem.dataLength,
  33112. codingpasses: packetItem.codingpasses
  33113. });
  33114. position += packetItem.dataLength;
  33115. }
  33116. }
  33117. return position;
  33118. }
  33119. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33120. var x0 = subband.tbx0;
  33121. var y0 = subband.tby0;
  33122. var width = subband.tbx1 - subband.tbx0;
  33123. var codeblocks = subband.codeblocks;
  33124. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33125. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33126. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33127. var codeblock = codeblocks[i];
  33128. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33129. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33130. if (blockWidth === 0 || blockHeight === 0) {
  33131. continue;
  33132. }
  33133. if (codeblock['data'] === undefined) {
  33134. continue;
  33135. }
  33136. var bitModel, currentCodingpassType;
  33137. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33138. currentCodingpassType = 2;
  33139. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33140. var j, jj, dataItem;
  33141. for (j = 0, jj = data.length; j < jj; j++) {
  33142. dataItem = data[j];
  33143. totalLength += dataItem.end - dataItem.start;
  33144. codingpasses += dataItem.codingpasses;
  33145. }
  33146. var encodedData = new Uint8Array(totalLength);
  33147. var position = 0;
  33148. for (j = 0, jj = data.length; j < jj; j++) {
  33149. dataItem = data[j];
  33150. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33151. encodedData.set(chunk, position);
  33152. position += chunk.length;
  33153. }
  33154. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33155. bitModel.setDecoder(decoder);
  33156. for (j = 0; j < codingpasses; j++) {
  33157. switch (currentCodingpassType) {
  33158. case 0:
  33159. bitModel.runSignificancePropagationPass();
  33160. break;
  33161. case 1:
  33162. bitModel.runMagnitudeRefinementPass();
  33163. break;
  33164. case 2:
  33165. bitModel.runCleanupPass();
  33166. if (segmentationSymbolUsed) {
  33167. bitModel.checkSegmentationSymbol();
  33168. }
  33169. break;
  33170. }
  33171. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33172. }
  33173. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33174. var sign = bitModel.coefficentsSign;
  33175. var magnitude = bitModel.coefficentsMagnitude;
  33176. var bitsDecoded = bitModel.bitsDecoded;
  33177. var magnitudeCorrection = reversible ? 0 : 0.5;
  33178. var k, n, nb;
  33179. position = 0;
  33180. var interleave = subband.type !== 'LL';
  33181. for (j = 0; j < blockHeight; j++) {
  33182. var row = offset / width | 0;
  33183. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33184. for (k = 0; k < blockWidth; k++) {
  33185. n = magnitude[position];
  33186. if (n !== 0) {
  33187. n = (n + magnitudeCorrection) * delta;
  33188. if (sign[position] !== 0) {
  33189. n = -n;
  33190. }
  33191. nb = bitsDecoded[position];
  33192. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33193. if (reversible && nb >= mb) {
  33194. coefficients[pos] = n;
  33195. } else {
  33196. coefficients[pos] = n * (1 << mb - nb);
  33197. }
  33198. }
  33199. offset++;
  33200. position++;
  33201. }
  33202. offset += width - blockWidth;
  33203. }
  33204. }
  33205. }
  33206. function transformTile(context, tile, c) {
  33207. var component = tile.components[c];
  33208. var codingStyleParameters = component.codingStyleParameters;
  33209. var quantizationParameters = component.quantizationParameters;
  33210. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33211. var spqcds = quantizationParameters.SPqcds;
  33212. var scalarExpounded = quantizationParameters.scalarExpounded;
  33213. var guardBits = quantizationParameters.guardBits;
  33214. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33215. var precision = context.components[c].precision;
  33216. var reversible = codingStyleParameters.reversibleTransformation;
  33217. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33218. var subbandCoefficients = [];
  33219. var b = 0;
  33220. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33221. var resolution = component.resolutions[i];
  33222. var width = resolution.trx1 - resolution.trx0;
  33223. var height = resolution.try1 - resolution.try0;
  33224. var coefficients = new Float32Array(width * height);
  33225. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33226. var mu, epsilon;
  33227. if (!scalarExpounded) {
  33228. mu = spqcds[0].mu;
  33229. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33230. } else {
  33231. mu = spqcds[b].mu;
  33232. epsilon = spqcds[b].epsilon;
  33233. b++;
  33234. }
  33235. var subband = resolution.subbands[j];
  33236. var gainLog2 = SubbandsGainLog2[subband.type];
  33237. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33238. var mb = guardBits + epsilon - 1;
  33239. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33240. }
  33241. subbandCoefficients.push({
  33242. width: width,
  33243. height: height,
  33244. items: coefficients
  33245. });
  33246. }
  33247. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33248. return {
  33249. left: component.tcx0,
  33250. top: component.tcy0,
  33251. width: result.width,
  33252. height: result.height,
  33253. items: result.items
  33254. };
  33255. }
  33256. function transformComponents(context) {
  33257. var siz = context.SIZ;
  33258. var components = context.components;
  33259. var componentsCount = siz.Csiz;
  33260. var resultImages = [];
  33261. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33262. var tile = context.tiles[i];
  33263. var transformedTiles = [];
  33264. var c;
  33265. for (c = 0; c < componentsCount; c++) {
  33266. transformedTiles[c] = transformTile(context, tile, c);
  33267. }
  33268. var tile0 = transformedTiles[0];
  33269. var out = new Uint8Array(tile0.items.length * componentsCount);
  33270. var result = {
  33271. left: tile0.left,
  33272. top: tile0.top,
  33273. width: tile0.width,
  33274. height: tile0.height,
  33275. items: out
  33276. };
  33277. var shift, offset, max, min, maxK;
  33278. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33279. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33280. var fourComponents = componentsCount === 4;
  33281. var y0items = transformedTiles[0].items;
  33282. var y1items = transformedTiles[1].items;
  33283. var y2items = transformedTiles[2].items;
  33284. var y3items = fourComponents ? transformedTiles[3].items : null;
  33285. shift = components[0].precision - 8;
  33286. offset = (128 << shift) + 0.5;
  33287. max = 255 * (1 << shift);
  33288. maxK = max * 0.5;
  33289. min = -maxK;
  33290. var component0 = tile.components[0];
  33291. var alpha01 = componentsCount - 3;
  33292. jj = y0items.length;
  33293. if (!component0.codingStyleParameters.reversibleTransformation) {
  33294. for (j = 0; j < jj; j++, pos += alpha01) {
  33295. y0 = y0items[j] + offset;
  33296. y1 = y1items[j];
  33297. y2 = y2items[j];
  33298. r = y0 + 1.402 * y2;
  33299. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33300. b = y0 + 1.772 * y1;
  33301. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33302. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33303. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33304. }
  33305. } else {
  33306. for (j = 0; j < jj; j++, pos += alpha01) {
  33307. y0 = y0items[j] + offset;
  33308. y1 = y1items[j];
  33309. y2 = y2items[j];
  33310. g = y0 - (y2 + y1 >> 2);
  33311. r = g + y2;
  33312. b = g + y1;
  33313. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33314. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33315. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33316. }
  33317. }
  33318. if (fourComponents) {
  33319. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33320. k = y3items[j];
  33321. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33322. }
  33323. }
  33324. } else {
  33325. for (c = 0; c < componentsCount; c++) {
  33326. var items = transformedTiles[c].items;
  33327. shift = components[c].precision - 8;
  33328. offset = (128 << shift) + 0.5;
  33329. max = 127.5 * (1 << shift);
  33330. min = -max;
  33331. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33332. val = items[j];
  33333. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33334. pos += componentsCount;
  33335. }
  33336. }
  33337. }
  33338. resultImages.push(result);
  33339. }
  33340. return resultImages;
  33341. }
  33342. function initializeTile(context, tileIndex) {
  33343. var siz = context.SIZ;
  33344. var componentsCount = siz.Csiz;
  33345. var tile = context.tiles[tileIndex];
  33346. for (var c = 0; c < componentsCount; c++) {
  33347. var component = tile.components[c];
  33348. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33349. component.quantizationParameters = qcdOrQcc;
  33350. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33351. component.codingStyleParameters = codOrCoc;
  33352. }
  33353. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33354. }
  33355. var TagTree = function TagTreeClosure() {
  33356. function TagTree(width, height) {
  33357. var levelsLength = log2(Math.max(width, height)) + 1;
  33358. this.levels = [];
  33359. for (var i = 0; i < levelsLength; i++) {
  33360. var level = {
  33361. width: width,
  33362. height: height,
  33363. items: []
  33364. };
  33365. this.levels.push(level);
  33366. width = Math.ceil(width / 2);
  33367. height = Math.ceil(height / 2);
  33368. }
  33369. }
  33370. TagTree.prototype = {
  33371. reset: function TagTree_reset(i, j) {
  33372. var currentLevel = 0, value = 0, level;
  33373. while (currentLevel < this.levels.length) {
  33374. level = this.levels[currentLevel];
  33375. var index = i + j * level.width;
  33376. if (level.items[index] !== undefined) {
  33377. value = level.items[index];
  33378. break;
  33379. }
  33380. level.index = index;
  33381. i >>= 1;
  33382. j >>= 1;
  33383. currentLevel++;
  33384. }
  33385. currentLevel--;
  33386. level = this.levels[currentLevel];
  33387. level.items[level.index] = value;
  33388. this.currentLevel = currentLevel;
  33389. delete this.value;
  33390. },
  33391. incrementValue: function TagTree_incrementValue() {
  33392. var level = this.levels[this.currentLevel];
  33393. level.items[level.index]++;
  33394. },
  33395. nextLevel: function TagTree_nextLevel() {
  33396. var currentLevel = this.currentLevel;
  33397. var level = this.levels[currentLevel];
  33398. var value = level.items[level.index];
  33399. currentLevel--;
  33400. if (currentLevel < 0) {
  33401. this.value = value;
  33402. return false;
  33403. }
  33404. this.currentLevel = currentLevel;
  33405. level = this.levels[currentLevel];
  33406. level.items[level.index] = value;
  33407. return true;
  33408. }
  33409. };
  33410. return TagTree;
  33411. }();
  33412. var InclusionTree = function InclusionTreeClosure() {
  33413. function InclusionTree(width, height, defaultValue) {
  33414. var levelsLength = log2(Math.max(width, height)) + 1;
  33415. this.levels = [];
  33416. for (var i = 0; i < levelsLength; i++) {
  33417. var items = new Uint8Array(width * height);
  33418. for (var j = 0, jj = items.length; j < jj; j++) {
  33419. items[j] = defaultValue;
  33420. }
  33421. var level = {
  33422. width: width,
  33423. height: height,
  33424. items: items
  33425. };
  33426. this.levels.push(level);
  33427. width = Math.ceil(width / 2);
  33428. height = Math.ceil(height / 2);
  33429. }
  33430. }
  33431. InclusionTree.prototype = {
  33432. reset: function InclusionTree_reset(i, j, stopValue) {
  33433. var currentLevel = 0;
  33434. while (currentLevel < this.levels.length) {
  33435. var level = this.levels[currentLevel];
  33436. var index = i + j * level.width;
  33437. level.index = index;
  33438. var value = level.items[index];
  33439. if (value === 0xFF) {
  33440. break;
  33441. }
  33442. if (value > stopValue) {
  33443. this.currentLevel = currentLevel;
  33444. this.propagateValues();
  33445. return false;
  33446. }
  33447. i >>= 1;
  33448. j >>= 1;
  33449. currentLevel++;
  33450. }
  33451. this.currentLevel = currentLevel - 1;
  33452. return true;
  33453. },
  33454. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33455. var level = this.levels[this.currentLevel];
  33456. level.items[level.index] = stopValue + 1;
  33457. this.propagateValues();
  33458. },
  33459. propagateValues: function InclusionTree_propagateValues() {
  33460. var levelIndex = this.currentLevel;
  33461. var level = this.levels[levelIndex];
  33462. var currentValue = level.items[level.index];
  33463. while (--levelIndex >= 0) {
  33464. level = this.levels[levelIndex];
  33465. level.items[level.index] = currentValue;
  33466. }
  33467. },
  33468. nextLevel: function InclusionTree_nextLevel() {
  33469. var currentLevel = this.currentLevel;
  33470. var level = this.levels[currentLevel];
  33471. var value = level.items[level.index];
  33472. level.items[level.index] = 0xFF;
  33473. currentLevel--;
  33474. if (currentLevel < 0) {
  33475. return false;
  33476. }
  33477. this.currentLevel = currentLevel;
  33478. level = this.levels[currentLevel];
  33479. level.items[level.index] = value;
  33480. return true;
  33481. }
  33482. };
  33483. return InclusionTree;
  33484. }();
  33485. var BitModel = function BitModelClosure() {
  33486. var UNIFORM_CONTEXT = 17;
  33487. var RUNLENGTH_CONTEXT = 18;
  33488. var LLAndLHContextsLabel = new Uint8Array([
  33489. 0,
  33490. 5,
  33491. 8,
  33492. 0,
  33493. 3,
  33494. 7,
  33495. 8,
  33496. 0,
  33497. 4,
  33498. 7,
  33499. 8,
  33500. 0,
  33501. 0,
  33502. 0,
  33503. 0,
  33504. 0,
  33505. 1,
  33506. 6,
  33507. 8,
  33508. 0,
  33509. 3,
  33510. 7,
  33511. 8,
  33512. 0,
  33513. 4,
  33514. 7,
  33515. 8,
  33516. 0,
  33517. 0,
  33518. 0,
  33519. 0,
  33520. 0,
  33521. 2,
  33522. 6,
  33523. 8,
  33524. 0,
  33525. 3,
  33526. 7,
  33527. 8,
  33528. 0,
  33529. 4,
  33530. 7,
  33531. 8,
  33532. 0,
  33533. 0,
  33534. 0,
  33535. 0,
  33536. 0,
  33537. 2,
  33538. 6,
  33539. 8,
  33540. 0,
  33541. 3,
  33542. 7,
  33543. 8,
  33544. 0,
  33545. 4,
  33546. 7,
  33547. 8,
  33548. 0,
  33549. 0,
  33550. 0,
  33551. 0,
  33552. 0,
  33553. 2,
  33554. 6,
  33555. 8,
  33556. 0,
  33557. 3,
  33558. 7,
  33559. 8,
  33560. 0,
  33561. 4,
  33562. 7,
  33563. 8
  33564. ]);
  33565. var HLContextLabel = new Uint8Array([
  33566. 0,
  33567. 3,
  33568. 4,
  33569. 0,
  33570. 5,
  33571. 7,
  33572. 7,
  33573. 0,
  33574. 8,
  33575. 8,
  33576. 8,
  33577. 0,
  33578. 0,
  33579. 0,
  33580. 0,
  33581. 0,
  33582. 1,
  33583. 3,
  33584. 4,
  33585. 0,
  33586. 6,
  33587. 7,
  33588. 7,
  33589. 0,
  33590. 8,
  33591. 8,
  33592. 8,
  33593. 0,
  33594. 0,
  33595. 0,
  33596. 0,
  33597. 0,
  33598. 2,
  33599. 3,
  33600. 4,
  33601. 0,
  33602. 6,
  33603. 7,
  33604. 7,
  33605. 0,
  33606. 8,
  33607. 8,
  33608. 8,
  33609. 0,
  33610. 0,
  33611. 0,
  33612. 0,
  33613. 0,
  33614. 2,
  33615. 3,
  33616. 4,
  33617. 0,
  33618. 6,
  33619. 7,
  33620. 7,
  33621. 0,
  33622. 8,
  33623. 8,
  33624. 8,
  33625. 0,
  33626. 0,
  33627. 0,
  33628. 0,
  33629. 0,
  33630. 2,
  33631. 3,
  33632. 4,
  33633. 0,
  33634. 6,
  33635. 7,
  33636. 7,
  33637. 0,
  33638. 8,
  33639. 8,
  33640. 8
  33641. ]);
  33642. var HHContextLabel = new Uint8Array([
  33643. 0,
  33644. 1,
  33645. 2,
  33646. 0,
  33647. 1,
  33648. 2,
  33649. 2,
  33650. 0,
  33651. 2,
  33652. 2,
  33653. 2,
  33654. 0,
  33655. 0,
  33656. 0,
  33657. 0,
  33658. 0,
  33659. 3,
  33660. 4,
  33661. 5,
  33662. 0,
  33663. 4,
  33664. 5,
  33665. 5,
  33666. 0,
  33667. 5,
  33668. 5,
  33669. 5,
  33670. 0,
  33671. 0,
  33672. 0,
  33673. 0,
  33674. 0,
  33675. 6,
  33676. 7,
  33677. 7,
  33678. 0,
  33679. 7,
  33680. 7,
  33681. 7,
  33682. 0,
  33683. 7,
  33684. 7,
  33685. 7,
  33686. 0,
  33687. 0,
  33688. 0,
  33689. 0,
  33690. 0,
  33691. 8,
  33692. 8,
  33693. 8,
  33694. 0,
  33695. 8,
  33696. 8,
  33697. 8,
  33698. 0,
  33699. 8,
  33700. 8,
  33701. 8,
  33702. 0,
  33703. 0,
  33704. 0,
  33705. 0,
  33706. 0,
  33707. 8,
  33708. 8,
  33709. 8,
  33710. 0,
  33711. 8,
  33712. 8,
  33713. 8,
  33714. 0,
  33715. 8,
  33716. 8,
  33717. 8
  33718. ]);
  33719. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33720. this.width = width;
  33721. this.height = height;
  33722. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33723. var coefficientCount = width * height;
  33724. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33725. this.coefficentsSign = new Uint8Array(coefficientCount);
  33726. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33727. this.processingFlags = new Uint8Array(coefficientCount);
  33728. var bitsDecoded = new Uint8Array(coefficientCount);
  33729. if (zeroBitPlanes !== 0) {
  33730. for (var i = 0; i < coefficientCount; i++) {
  33731. bitsDecoded[i] = zeroBitPlanes;
  33732. }
  33733. }
  33734. this.bitsDecoded = bitsDecoded;
  33735. this.reset();
  33736. }
  33737. BitModel.prototype = {
  33738. setDecoder: function BitModel_setDecoder(decoder) {
  33739. this.decoder = decoder;
  33740. },
  33741. reset: function BitModel_reset() {
  33742. this.contexts = new Int8Array(19);
  33743. this.contexts[0] = 4 << 1 | 0;
  33744. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33745. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33746. },
  33747. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33748. var neighborsSignificance = this.neighborsSignificance;
  33749. var width = this.width, height = this.height;
  33750. var left = column > 0;
  33751. var right = column + 1 < width;
  33752. var i;
  33753. if (row > 0) {
  33754. i = index - width;
  33755. if (left) {
  33756. neighborsSignificance[i - 1] += 0x10;
  33757. }
  33758. if (right) {
  33759. neighborsSignificance[i + 1] += 0x10;
  33760. }
  33761. neighborsSignificance[i] += 0x04;
  33762. }
  33763. if (row + 1 < height) {
  33764. i = index + width;
  33765. if (left) {
  33766. neighborsSignificance[i - 1] += 0x10;
  33767. }
  33768. if (right) {
  33769. neighborsSignificance[i + 1] += 0x10;
  33770. }
  33771. neighborsSignificance[i] += 0x04;
  33772. }
  33773. if (left) {
  33774. neighborsSignificance[index - 1] += 0x01;
  33775. }
  33776. if (right) {
  33777. neighborsSignificance[index + 1] += 0x01;
  33778. }
  33779. neighborsSignificance[index] |= 0x80;
  33780. },
  33781. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33782. var decoder = this.decoder;
  33783. var width = this.width, height = this.height;
  33784. var coefficentsMagnitude = this.coefficentsMagnitude;
  33785. var coefficentsSign = this.coefficentsSign;
  33786. var neighborsSignificance = this.neighborsSignificance;
  33787. var processingFlags = this.processingFlags;
  33788. var contexts = this.contexts;
  33789. var labels = this.contextLabelTable;
  33790. var bitsDecoded = this.bitsDecoded;
  33791. var processedInverseMask = ~1;
  33792. var processedMask = 1;
  33793. var firstMagnitudeBitMask = 2;
  33794. for (var i0 = 0; i0 < height; i0 += 4) {
  33795. for (var j = 0; j < width; j++) {
  33796. var index = i0 * width + j;
  33797. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33798. var i = i0 + i1;
  33799. if (i >= height) {
  33800. break;
  33801. }
  33802. processingFlags[index] &= processedInverseMask;
  33803. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33804. continue;
  33805. }
  33806. var contextLabel = labels[neighborsSignificance[index]];
  33807. var decision = decoder.readBit(contexts, contextLabel);
  33808. if (decision) {
  33809. var sign = this.decodeSignBit(i, j, index);
  33810. coefficentsSign[index] = sign;
  33811. coefficentsMagnitude[index] = 1;
  33812. this.setNeighborsSignificance(i, j, index);
  33813. processingFlags[index] |= firstMagnitudeBitMask;
  33814. }
  33815. bitsDecoded[index]++;
  33816. processingFlags[index] |= processedMask;
  33817. }
  33818. }
  33819. }
  33820. },
  33821. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33822. var width = this.width, height = this.height;
  33823. var coefficentsMagnitude = this.coefficentsMagnitude;
  33824. var coefficentsSign = this.coefficentsSign;
  33825. var contribution, sign0, sign1, significance1;
  33826. var contextLabel, decoded;
  33827. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33828. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33829. sign1 = coefficentsSign[index + 1];
  33830. if (significance1) {
  33831. sign0 = coefficentsSign[index - 1];
  33832. contribution = 1 - sign1 - sign0;
  33833. } else {
  33834. contribution = 1 - sign1 - sign1;
  33835. }
  33836. } else if (significance1) {
  33837. sign0 = coefficentsSign[index - 1];
  33838. contribution = 1 - sign0 - sign0;
  33839. } else {
  33840. contribution = 0;
  33841. }
  33842. var horizontalContribution = 3 * contribution;
  33843. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33844. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33845. sign1 = coefficentsSign[index + width];
  33846. if (significance1) {
  33847. sign0 = coefficentsSign[index - width];
  33848. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33849. } else {
  33850. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33851. }
  33852. } else if (significance1) {
  33853. sign0 = coefficentsSign[index - width];
  33854. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33855. } else {
  33856. contribution = horizontalContribution;
  33857. }
  33858. if (contribution >= 0) {
  33859. contextLabel = 9 + contribution;
  33860. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33861. } else {
  33862. contextLabel = 9 - contribution;
  33863. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33864. }
  33865. return decoded;
  33866. },
  33867. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33868. var decoder = this.decoder;
  33869. var width = this.width, height = this.height;
  33870. var coefficentsMagnitude = this.coefficentsMagnitude;
  33871. var neighborsSignificance = this.neighborsSignificance;
  33872. var contexts = this.contexts;
  33873. var bitsDecoded = this.bitsDecoded;
  33874. var processingFlags = this.processingFlags;
  33875. var processedMask = 1;
  33876. var firstMagnitudeBitMask = 2;
  33877. var length = width * height;
  33878. var width4 = width * 4;
  33879. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33880. indexNext = Math.min(length, index0 + width4);
  33881. for (var j = 0; j < width; j++) {
  33882. for (var index = index0 + j; index < indexNext; index += width) {
  33883. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33884. continue;
  33885. }
  33886. var contextLabel = 16;
  33887. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33888. processingFlags[index] ^= firstMagnitudeBitMask;
  33889. var significance = neighborsSignificance[index] & 127;
  33890. contextLabel = significance === 0 ? 15 : 14;
  33891. }
  33892. var bit = decoder.readBit(contexts, contextLabel);
  33893. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33894. bitsDecoded[index]++;
  33895. processingFlags[index] |= processedMask;
  33896. }
  33897. }
  33898. }
  33899. },
  33900. runCleanupPass: function BitModel_runCleanupPass() {
  33901. var decoder = this.decoder;
  33902. var width = this.width, height = this.height;
  33903. var neighborsSignificance = this.neighborsSignificance;
  33904. var coefficentsMagnitude = this.coefficentsMagnitude;
  33905. var coefficentsSign = this.coefficentsSign;
  33906. var contexts = this.contexts;
  33907. var labels = this.contextLabelTable;
  33908. var bitsDecoded = this.bitsDecoded;
  33909. var processingFlags = this.processingFlags;
  33910. var processedMask = 1;
  33911. var firstMagnitudeBitMask = 2;
  33912. var oneRowDown = width;
  33913. var twoRowsDown = width * 2;
  33914. var threeRowsDown = width * 3;
  33915. var iNext;
  33916. for (var i0 = 0; i0 < height; i0 = iNext) {
  33917. iNext = Math.min(i0 + 4, height);
  33918. var indexBase = i0 * width;
  33919. var checkAllEmpty = i0 + 3 < height;
  33920. for (var j = 0; j < width; j++) {
  33921. var index0 = indexBase + j;
  33922. 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;
  33923. var i1 = 0, index = index0;
  33924. var i = i0, sign;
  33925. if (allEmpty) {
  33926. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33927. if (!hasSignificantCoefficent) {
  33928. bitsDecoded[index0]++;
  33929. bitsDecoded[index0 + oneRowDown]++;
  33930. bitsDecoded[index0 + twoRowsDown]++;
  33931. bitsDecoded[index0 + threeRowsDown]++;
  33932. continue;
  33933. }
  33934. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33935. if (i1 !== 0) {
  33936. i = i0 + i1;
  33937. index += i1 * width;
  33938. }
  33939. sign = this.decodeSignBit(i, j, index);
  33940. coefficentsSign[index] = sign;
  33941. coefficentsMagnitude[index] = 1;
  33942. this.setNeighborsSignificance(i, j, index);
  33943. processingFlags[index] |= firstMagnitudeBitMask;
  33944. index = index0;
  33945. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33946. bitsDecoded[index]++;
  33947. }
  33948. i1++;
  33949. }
  33950. for (i = i0 + i1; i < iNext; i++, index += width) {
  33951. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33952. continue;
  33953. }
  33954. var contextLabel = labels[neighborsSignificance[index]];
  33955. var decision = decoder.readBit(contexts, contextLabel);
  33956. if (decision === 1) {
  33957. sign = this.decodeSignBit(i, j, index);
  33958. coefficentsSign[index] = sign;
  33959. coefficentsMagnitude[index] = 1;
  33960. this.setNeighborsSignificance(i, j, index);
  33961. processingFlags[index] |= firstMagnitudeBitMask;
  33962. }
  33963. bitsDecoded[index]++;
  33964. }
  33965. }
  33966. }
  33967. },
  33968. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33969. var decoder = this.decoder;
  33970. var contexts = this.contexts;
  33971. 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);
  33972. if (symbol !== 0xA) {
  33973. error('JPX Error: Invalid segmentation symbol');
  33974. }
  33975. }
  33976. };
  33977. return BitModel;
  33978. }();
  33979. var Transform = function TransformClosure() {
  33980. function Transform() {
  33981. }
  33982. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33983. var ll = subbands[0];
  33984. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33985. ll = this.iterate(ll, subbands[i], u0, v0);
  33986. }
  33987. return ll;
  33988. };
  33989. Transform.prototype.extend = function extend(buffer, offset, size) {
  33990. var i1 = offset - 1, j1 = offset + 1;
  33991. var i2 = offset + size - 2, j2 = offset + size;
  33992. buffer[i1--] = buffer[j1++];
  33993. buffer[j2++] = buffer[i2--];
  33994. buffer[i1--] = buffer[j1++];
  33995. buffer[j2++] = buffer[i2--];
  33996. buffer[i1--] = buffer[j1++];
  33997. buffer[j2++] = buffer[i2--];
  33998. buffer[i1] = buffer[j1];
  33999. buffer[j2] = buffer[i2];
  34000. };
  34001. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34002. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34003. var width = hl_lh_hh.width;
  34004. var height = hl_lh_hh.height;
  34005. var items = hl_lh_hh.items;
  34006. var i, j, k, l, u, v;
  34007. for (k = 0, i = 0; i < llHeight; i++) {
  34008. l = i * 2 * width;
  34009. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34010. items[l] = llItems[k];
  34011. }
  34012. }
  34013. llItems = ll.items = null;
  34014. var bufferPadding = 4;
  34015. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34016. if (width === 1) {
  34017. if ((u0 & 1) !== 0) {
  34018. for (v = 0, k = 0; v < height; v++, k += width) {
  34019. items[k] *= 0.5;
  34020. }
  34021. }
  34022. } else {
  34023. for (v = 0, k = 0; v < height; v++, k += width) {
  34024. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34025. this.extend(rowBuffer, bufferPadding, width);
  34026. this.filter(rowBuffer, bufferPadding, width);
  34027. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34028. }
  34029. }
  34030. var numBuffers = 16;
  34031. var colBuffers = [];
  34032. for (i = 0; i < numBuffers; i++) {
  34033. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34034. }
  34035. var b, currentBuffer = 0;
  34036. ll = bufferPadding + height;
  34037. if (height === 1) {
  34038. if ((v0 & 1) !== 0) {
  34039. for (u = 0; u < width; u++) {
  34040. items[u] *= 0.5;
  34041. }
  34042. }
  34043. } else {
  34044. for (u = 0; u < width; u++) {
  34045. if (currentBuffer === 0) {
  34046. numBuffers = Math.min(width - u, numBuffers);
  34047. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34048. for (b = 0; b < numBuffers; b++) {
  34049. colBuffers[b][l] = items[k + b];
  34050. }
  34051. }
  34052. currentBuffer = numBuffers;
  34053. }
  34054. currentBuffer--;
  34055. var buffer = colBuffers[currentBuffer];
  34056. this.extend(buffer, bufferPadding, height);
  34057. this.filter(buffer, bufferPadding, height);
  34058. if (currentBuffer === 0) {
  34059. k = u - numBuffers + 1;
  34060. for (l = bufferPadding; l < ll; k += width, l++) {
  34061. for (b = 0; b < numBuffers; b++) {
  34062. items[k + b] = colBuffers[b][l];
  34063. }
  34064. }
  34065. }
  34066. }
  34067. }
  34068. return {
  34069. width: width,
  34070. height: height,
  34071. items: items
  34072. };
  34073. };
  34074. return Transform;
  34075. }();
  34076. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34077. function IrreversibleTransform() {
  34078. Transform.call(this);
  34079. }
  34080. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34081. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34082. var len = length >> 1;
  34083. offset = offset | 0;
  34084. var j, n, current, next;
  34085. var alpha = -1.586134342059924;
  34086. var beta = -0.052980118572961;
  34087. var gamma = 0.882911075530934;
  34088. var delta = 0.443506852043971;
  34089. var K = 1.230174104914001;
  34090. var K_ = 1 / K;
  34091. j = offset - 3;
  34092. for (n = len + 4; n--; j += 2) {
  34093. x[j] *= K_;
  34094. }
  34095. j = offset - 2;
  34096. current = delta * x[j - 1];
  34097. for (n = len + 3; n--; j += 2) {
  34098. next = delta * x[j + 1];
  34099. x[j] = K * x[j] - current - next;
  34100. if (n--) {
  34101. j += 2;
  34102. current = delta * x[j + 1];
  34103. x[j] = K * x[j] - current - next;
  34104. } else {
  34105. break;
  34106. }
  34107. }
  34108. j = offset - 1;
  34109. current = gamma * x[j - 1];
  34110. for (n = len + 2; n--; j += 2) {
  34111. next = gamma * x[j + 1];
  34112. x[j] -= current + next;
  34113. if (n--) {
  34114. j += 2;
  34115. current = gamma * x[j + 1];
  34116. x[j] -= current + next;
  34117. } else {
  34118. break;
  34119. }
  34120. }
  34121. j = offset;
  34122. current = beta * x[j - 1];
  34123. for (n = len + 1; n--; j += 2) {
  34124. next = beta * x[j + 1];
  34125. x[j] -= current + next;
  34126. if (n--) {
  34127. j += 2;
  34128. current = beta * x[j + 1];
  34129. x[j] -= current + next;
  34130. } else {
  34131. break;
  34132. }
  34133. }
  34134. if (len !== 0) {
  34135. j = offset + 1;
  34136. current = alpha * x[j - 1];
  34137. for (n = len; n--; j += 2) {
  34138. next = alpha * x[j + 1];
  34139. x[j] -= current + next;
  34140. if (n--) {
  34141. j += 2;
  34142. current = alpha * x[j + 1];
  34143. x[j] -= current + next;
  34144. } else {
  34145. break;
  34146. }
  34147. }
  34148. }
  34149. };
  34150. return IrreversibleTransform;
  34151. }();
  34152. var ReversibleTransform = function ReversibleTransformClosure() {
  34153. function ReversibleTransform() {
  34154. Transform.call(this);
  34155. }
  34156. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34157. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34158. var len = length >> 1;
  34159. offset = offset | 0;
  34160. var j, n;
  34161. for (j = offset, n = len + 1; n--; j += 2) {
  34162. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34163. }
  34164. for (j = offset + 1, n = len; n--; j += 2) {
  34165. x[j] += x[j - 1] + x[j + 1] >> 1;
  34166. }
  34167. };
  34168. return ReversibleTransform;
  34169. }();
  34170. return JpxImage;
  34171. }();
  34172. exports.JpxImage = JpxImage;
  34173. /***/ }),
  34174. /* 19 */
  34175. /***/ (function(module, exports, __w_pdfjs_require__) {
  34176. "use strict";
  34177. var sharedUtil = __w_pdfjs_require__(0);
  34178. var corePrimitives = __w_pdfjs_require__(1);
  34179. var coreCrypto = __w_pdfjs_require__(16);
  34180. var coreParser = __w_pdfjs_require__(6);
  34181. var coreChunkedStream = __w_pdfjs_require__(15);
  34182. var coreColorSpace = __w_pdfjs_require__(4);
  34183. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34184. var MissingDataException = sharedUtil.MissingDataException;
  34185. var XRefParseException = sharedUtil.XRefParseException;
  34186. var assert = sharedUtil.assert;
  34187. var bytesToString = sharedUtil.bytesToString;
  34188. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34189. var error = sharedUtil.error;
  34190. var info = sharedUtil.info;
  34191. var isArray = sharedUtil.isArray;
  34192. var isBool = sharedUtil.isBool;
  34193. var isInt = sharedUtil.isInt;
  34194. var isString = sharedUtil.isString;
  34195. var shadow = sharedUtil.shadow;
  34196. var stringToPDFString = sharedUtil.stringToPDFString;
  34197. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34198. var warn = sharedUtil.warn;
  34199. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34200. var Util = sharedUtil.Util;
  34201. var Ref = corePrimitives.Ref;
  34202. var RefSet = corePrimitives.RefSet;
  34203. var RefSetCache = corePrimitives.RefSetCache;
  34204. var isName = corePrimitives.isName;
  34205. var isCmd = corePrimitives.isCmd;
  34206. var isDict = corePrimitives.isDict;
  34207. var isRef = corePrimitives.isRef;
  34208. var isRefsEqual = corePrimitives.isRefsEqual;
  34209. var isStream = corePrimitives.isStream;
  34210. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34211. var Lexer = coreParser.Lexer;
  34212. var Parser = coreParser.Parser;
  34213. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34214. var ColorSpace = coreColorSpace.ColorSpace;
  34215. var Catalog = function CatalogClosure() {
  34216. function Catalog(pdfManager, xref, pageFactory) {
  34217. this.pdfManager = pdfManager;
  34218. this.xref = xref;
  34219. this.catDict = xref.getCatalogObj();
  34220. this.fontCache = new RefSetCache();
  34221. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34222. this.pageFactory = pageFactory;
  34223. this.pagePromises = [];
  34224. }
  34225. Catalog.prototype = {
  34226. get metadata() {
  34227. var streamRef = this.catDict.getRaw('Metadata');
  34228. if (!isRef(streamRef)) {
  34229. return shadow(this, 'metadata', null);
  34230. }
  34231. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34232. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34233. var metadata;
  34234. if (stream && isDict(stream.dict)) {
  34235. var type = stream.dict.get('Type');
  34236. var subtype = stream.dict.get('Subtype');
  34237. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34238. try {
  34239. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34240. } catch (e) {
  34241. info('Skipping invalid metadata.');
  34242. }
  34243. }
  34244. }
  34245. return shadow(this, 'metadata', metadata);
  34246. },
  34247. get toplevelPagesDict() {
  34248. var pagesObj = this.catDict.get('Pages');
  34249. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34250. return shadow(this, 'toplevelPagesDict', pagesObj);
  34251. },
  34252. get documentOutline() {
  34253. var obj = null;
  34254. try {
  34255. obj = this.readDocumentOutline();
  34256. } catch (ex) {
  34257. if (ex instanceof MissingDataException) {
  34258. throw ex;
  34259. }
  34260. warn('Unable to read document outline');
  34261. }
  34262. return shadow(this, 'documentOutline', obj);
  34263. },
  34264. readDocumentOutline: function Catalog_readDocumentOutline() {
  34265. var obj = this.catDict.get('Outlines');
  34266. if (!isDict(obj)) {
  34267. return null;
  34268. }
  34269. obj = obj.getRaw('First');
  34270. if (!isRef(obj)) {
  34271. return null;
  34272. }
  34273. var root = { items: [] };
  34274. var queue = [{
  34275. obj: obj,
  34276. parent: root
  34277. }];
  34278. var processed = new RefSet();
  34279. processed.put(obj);
  34280. var xref = this.xref, blackColor = new Uint8Array(3);
  34281. while (queue.length > 0) {
  34282. var i = queue.shift();
  34283. var outlineDict = xref.fetchIfRef(i.obj);
  34284. if (outlineDict === null) {
  34285. continue;
  34286. }
  34287. assert(outlineDict.has('Title'), 'Invalid outline item');
  34288. var data = {
  34289. url: null,
  34290. dest: null
  34291. };
  34292. Catalog.parseDestDictionary({
  34293. destDict: outlineDict,
  34294. resultObj: data,
  34295. docBaseUrl: this.pdfManager.docBaseUrl
  34296. });
  34297. var title = outlineDict.get('Title');
  34298. var flags = outlineDict.get('F') || 0;
  34299. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34300. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34301. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34302. }
  34303. var outlineItem = {
  34304. dest: data.dest,
  34305. url: data.url,
  34306. unsafeUrl: data.unsafeUrl,
  34307. newWindow: data.newWindow,
  34308. title: stringToPDFString(title),
  34309. color: rgbColor,
  34310. count: outlineDict.get('Count'),
  34311. bold: !!(flags & 2),
  34312. italic: !!(flags & 1),
  34313. items: []
  34314. };
  34315. i.parent.items.push(outlineItem);
  34316. obj = outlineDict.getRaw('First');
  34317. if (isRef(obj) && !processed.has(obj)) {
  34318. queue.push({
  34319. obj: obj,
  34320. parent: outlineItem
  34321. });
  34322. processed.put(obj);
  34323. }
  34324. obj = outlineDict.getRaw('Next');
  34325. if (isRef(obj) && !processed.has(obj)) {
  34326. queue.push({
  34327. obj: obj,
  34328. parent: i.parent
  34329. });
  34330. processed.put(obj);
  34331. }
  34332. }
  34333. return root.items.length > 0 ? root.items : null;
  34334. },
  34335. get numPages() {
  34336. var obj = this.toplevelPagesDict.get('Count');
  34337. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34338. return shadow(this, 'num', obj);
  34339. },
  34340. get destinations() {
  34341. function fetchDestination(dest) {
  34342. return isDict(dest) ? dest.get('D') : dest;
  34343. }
  34344. var xref = this.xref;
  34345. var dests = {}, nameTreeRef, nameDictionaryRef;
  34346. var obj = this.catDict.get('Names');
  34347. if (obj && obj.has('Dests')) {
  34348. nameTreeRef = obj.getRaw('Dests');
  34349. } else if (this.catDict.has('Dests')) {
  34350. nameDictionaryRef = this.catDict.get('Dests');
  34351. }
  34352. if (nameDictionaryRef) {
  34353. obj = nameDictionaryRef;
  34354. obj.forEach(function catalogForEach(key, value) {
  34355. if (!value) {
  34356. return;
  34357. }
  34358. dests[key] = fetchDestination(value);
  34359. });
  34360. }
  34361. if (nameTreeRef) {
  34362. var nameTree = new NameTree(nameTreeRef, xref);
  34363. var names = nameTree.getAll();
  34364. for (var name in names) {
  34365. dests[name] = fetchDestination(names[name]);
  34366. }
  34367. }
  34368. return shadow(this, 'destinations', dests);
  34369. },
  34370. getDestination: function Catalog_getDestination(destinationId) {
  34371. function fetchDestination(dest) {
  34372. return isDict(dest) ? dest.get('D') : dest;
  34373. }
  34374. var xref = this.xref;
  34375. var dest = null, nameTreeRef, nameDictionaryRef;
  34376. var obj = this.catDict.get('Names');
  34377. if (obj && obj.has('Dests')) {
  34378. nameTreeRef = obj.getRaw('Dests');
  34379. } else if (this.catDict.has('Dests')) {
  34380. nameDictionaryRef = this.catDict.get('Dests');
  34381. }
  34382. if (nameDictionaryRef) {
  34383. var value = nameDictionaryRef.get(destinationId);
  34384. if (value) {
  34385. dest = fetchDestination(value);
  34386. }
  34387. }
  34388. if (nameTreeRef) {
  34389. var nameTree = new NameTree(nameTreeRef, xref);
  34390. dest = fetchDestination(nameTree.get(destinationId));
  34391. }
  34392. return dest;
  34393. },
  34394. get pageLabels() {
  34395. var obj = null;
  34396. try {
  34397. obj = this.readPageLabels();
  34398. } catch (ex) {
  34399. if (ex instanceof MissingDataException) {
  34400. throw ex;
  34401. }
  34402. warn('Unable to read page labels.');
  34403. }
  34404. return shadow(this, 'pageLabels', obj);
  34405. },
  34406. readPageLabels: function Catalog_readPageLabels() {
  34407. var obj = this.catDict.getRaw('PageLabels');
  34408. if (!obj) {
  34409. return null;
  34410. }
  34411. var pageLabels = new Array(this.numPages);
  34412. var style = null;
  34413. var prefix = '';
  34414. var numberTree = new NumberTree(obj, this.xref);
  34415. var nums = numberTree.getAll();
  34416. var currentLabel = '', currentIndex = 1;
  34417. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34418. if (i in nums) {
  34419. var labelDict = nums[i];
  34420. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34421. var type = labelDict.get('Type');
  34422. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34423. var s = labelDict.get('S');
  34424. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34425. style = s ? s.name : null;
  34426. var p = labelDict.get('P');
  34427. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34428. prefix = p ? stringToPDFString(p) : '';
  34429. var st = labelDict.get('St');
  34430. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34431. currentIndex = st || 1;
  34432. }
  34433. switch (style) {
  34434. case 'D':
  34435. currentLabel = currentIndex;
  34436. break;
  34437. case 'R':
  34438. case 'r':
  34439. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34440. break;
  34441. case 'A':
  34442. case 'a':
  34443. var LIMIT = 26;
  34444. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34445. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34446. var letterIndex = currentIndex - 1;
  34447. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34448. var charBuf = [];
  34449. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34450. charBuf.push(character);
  34451. }
  34452. currentLabel = charBuf.join('');
  34453. break;
  34454. default:
  34455. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34456. }
  34457. pageLabels[i] = prefix + currentLabel;
  34458. currentLabel = '';
  34459. currentIndex++;
  34460. }
  34461. return pageLabels;
  34462. },
  34463. get attachments() {
  34464. var xref = this.xref;
  34465. var attachments = null, nameTreeRef;
  34466. var obj = this.catDict.get('Names');
  34467. if (obj) {
  34468. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34469. }
  34470. if (nameTreeRef) {
  34471. var nameTree = new NameTree(nameTreeRef, xref);
  34472. var names = nameTree.getAll();
  34473. for (var name in names) {
  34474. var fs = new FileSpec(names[name], xref);
  34475. if (!attachments) {
  34476. attachments = Object.create(null);
  34477. }
  34478. attachments[stringToPDFString(name)] = fs.serializable;
  34479. }
  34480. }
  34481. return shadow(this, 'attachments', attachments);
  34482. },
  34483. get javaScript() {
  34484. var xref = this.xref;
  34485. var obj = this.catDict.get('Names');
  34486. var javaScript = [];
  34487. function appendIfJavaScriptDict(jsDict) {
  34488. var type = jsDict.get('S');
  34489. if (!isName(type, 'JavaScript')) {
  34490. return;
  34491. }
  34492. var js = jsDict.get('JS');
  34493. if (isStream(js)) {
  34494. js = bytesToString(js.getBytes());
  34495. } else if (!isString(js)) {
  34496. return;
  34497. }
  34498. javaScript.push(stringToPDFString(js));
  34499. }
  34500. if (obj && obj.has('JavaScript')) {
  34501. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34502. var names = nameTree.getAll();
  34503. for (var name in names) {
  34504. var jsDict = names[name];
  34505. if (isDict(jsDict)) {
  34506. appendIfJavaScriptDict(jsDict);
  34507. }
  34508. }
  34509. }
  34510. var openactionDict = this.catDict.get('OpenAction');
  34511. if (isDict(openactionDict, 'Action')) {
  34512. var actionType = openactionDict.get('S');
  34513. if (isName(actionType, 'Named')) {
  34514. var action = openactionDict.get('N');
  34515. if (isName(action, 'Print')) {
  34516. javaScript.push('print({});');
  34517. }
  34518. } else {
  34519. appendIfJavaScriptDict(openactionDict);
  34520. }
  34521. }
  34522. return shadow(this, 'javaScript', javaScript);
  34523. },
  34524. cleanup: function Catalog_cleanup() {
  34525. var promises = [];
  34526. this.fontCache.forEach(function (promise) {
  34527. promises.push(promise);
  34528. });
  34529. return Promise.all(promises).then(function (translatedFonts) {
  34530. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34531. var font = translatedFonts[i].dict;
  34532. delete font.translated;
  34533. }
  34534. this.fontCache.clear();
  34535. }.bind(this));
  34536. },
  34537. getPage: function Catalog_getPage(pageIndex) {
  34538. if (!(pageIndex in this.pagePromises)) {
  34539. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34540. var dict = a[0];
  34541. var ref = a[1];
  34542. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  34543. }.bind(this));
  34544. }
  34545. return this.pagePromises[pageIndex];
  34546. },
  34547. getPageDict: function Catalog_getPageDict(pageIndex) {
  34548. var capability = createPromiseCapability();
  34549. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34550. var currentPageIndex = 0;
  34551. var xref = this.xref;
  34552. var checkAllKids = false;
  34553. function next() {
  34554. while (nodesToVisit.length) {
  34555. var currentNode = nodesToVisit.pop();
  34556. if (isRef(currentNode)) {
  34557. xref.fetchAsync(currentNode).then(function (obj) {
  34558. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34559. if (pageIndex === currentPageIndex) {
  34560. capability.resolve([
  34561. obj,
  34562. currentNode
  34563. ]);
  34564. } else {
  34565. currentPageIndex++;
  34566. next();
  34567. }
  34568. return;
  34569. }
  34570. nodesToVisit.push(obj);
  34571. next();
  34572. }, capability.reject);
  34573. return;
  34574. }
  34575. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34576. var count = currentNode.get('Count');
  34577. if (count === 0) {
  34578. checkAllKids = true;
  34579. }
  34580. if (currentPageIndex + count <= pageIndex) {
  34581. currentPageIndex += count;
  34582. continue;
  34583. }
  34584. var kids = currentNode.get('Kids');
  34585. assert(isArray(kids), 'page dictionary kids object is not an array');
  34586. if (!checkAllKids && count === kids.length) {
  34587. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  34588. currentPageIndex = pageIndex;
  34589. continue;
  34590. } else {
  34591. for (var last = kids.length - 1; last >= 0; last--) {
  34592. nodesToVisit.push(kids[last]);
  34593. }
  34594. }
  34595. }
  34596. capability.reject('Page index ' + pageIndex + ' not found.');
  34597. }
  34598. next();
  34599. return capability.promise;
  34600. },
  34601. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34602. var xref = this.xref;
  34603. function pagesBeforeRef(kidRef) {
  34604. var total = 0;
  34605. var parentRef;
  34606. return xref.fetchAsync(kidRef).then(function (node) {
  34607. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34608. throw new Error('The reference does not point to a /Page Dict.');
  34609. }
  34610. if (!node) {
  34611. return null;
  34612. }
  34613. assert(isDict(node), 'node must be a Dict.');
  34614. parentRef = node.getRaw('Parent');
  34615. return node.getAsync('Parent');
  34616. }).then(function (parent) {
  34617. if (!parent) {
  34618. return null;
  34619. }
  34620. assert(isDict(parent), 'parent must be a Dict.');
  34621. return parent.getAsync('Kids');
  34622. }).then(function (kids) {
  34623. if (!kids) {
  34624. return null;
  34625. }
  34626. var kidPromises = [];
  34627. var found = false;
  34628. for (var i = 0; i < kids.length; i++) {
  34629. var kid = kids[i];
  34630. assert(isRef(kid), 'kid must be a Ref.');
  34631. if (kid.num === kidRef.num) {
  34632. found = true;
  34633. break;
  34634. }
  34635. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34636. if (kid.has('Count')) {
  34637. var count = kid.get('Count');
  34638. total += count;
  34639. } else {
  34640. total++;
  34641. }
  34642. }));
  34643. }
  34644. if (!found) {
  34645. error('kid ref not found in parents kids');
  34646. }
  34647. return Promise.all(kidPromises).then(function () {
  34648. return [
  34649. total,
  34650. parentRef
  34651. ];
  34652. });
  34653. });
  34654. }
  34655. var total = 0;
  34656. function next(ref) {
  34657. return pagesBeforeRef(ref).then(function (args) {
  34658. if (!args) {
  34659. return total;
  34660. }
  34661. var count = args[0];
  34662. var parentRef = args[1];
  34663. total += count;
  34664. return next(parentRef);
  34665. });
  34666. }
  34667. return next(pageRef);
  34668. }
  34669. };
  34670. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34671. function addDefaultProtocolToUrl(url) {
  34672. if (url.indexOf('www.') === 0) {
  34673. return 'http://' + url;
  34674. }
  34675. return url;
  34676. }
  34677. function tryConvertUrlEncoding(url) {
  34678. try {
  34679. return stringToUTF8String(url);
  34680. } catch (e) {
  34681. return url;
  34682. }
  34683. }
  34684. var destDict = params.destDict;
  34685. if (!isDict(destDict)) {
  34686. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34687. return;
  34688. }
  34689. var resultObj = params.resultObj;
  34690. if (typeof resultObj !== 'object') {
  34691. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34692. return;
  34693. }
  34694. var docBaseUrl = params.docBaseUrl || null;
  34695. var action = destDict.get('A'), url, dest;
  34696. if (isDict(action)) {
  34697. var linkType = action.get('S').name;
  34698. switch (linkType) {
  34699. case 'URI':
  34700. url = action.get('URI');
  34701. if (isName(url)) {
  34702. url = '/' + url.name;
  34703. } else if (isString(url)) {
  34704. url = addDefaultProtocolToUrl(url);
  34705. }
  34706. break;
  34707. case 'GoTo':
  34708. dest = action.get('D');
  34709. break;
  34710. case 'Launch':
  34711. case 'GoToR':
  34712. var urlDict = action.get('F');
  34713. if (isDict(urlDict)) {
  34714. url = urlDict.get('F') || null;
  34715. } else if (isString(urlDict)) {
  34716. url = urlDict;
  34717. }
  34718. var remoteDest = action.get('D');
  34719. if (remoteDest) {
  34720. if (isName(remoteDest)) {
  34721. remoteDest = remoteDest.name;
  34722. }
  34723. if (isString(url)) {
  34724. var baseUrl = url.split('#')[0];
  34725. if (isString(remoteDest)) {
  34726. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34727. } else if (isArray(remoteDest)) {
  34728. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34729. }
  34730. }
  34731. }
  34732. var newWindow = action.get('NewWindow');
  34733. if (isBool(newWindow)) {
  34734. resultObj.newWindow = newWindow;
  34735. }
  34736. break;
  34737. case 'Named':
  34738. var namedAction = action.get('N');
  34739. if (isName(namedAction)) {
  34740. resultObj.action = namedAction.name;
  34741. }
  34742. break;
  34743. case 'JavaScript':
  34744. var jsAction = action.get('JS'), js;
  34745. if (isStream(jsAction)) {
  34746. js = bytesToString(jsAction.getBytes());
  34747. } else if (isString(jsAction)) {
  34748. js = jsAction;
  34749. }
  34750. if (js) {
  34751. var URL_OPEN_METHODS = [
  34752. 'app.launchURL',
  34753. 'window.open'
  34754. ];
  34755. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34756. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34757. if (jsUrl && jsUrl[1]) {
  34758. url = jsUrl[1];
  34759. break;
  34760. }
  34761. }
  34762. default:
  34763. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34764. break;
  34765. }
  34766. } else if (destDict.has('Dest')) {
  34767. dest = destDict.get('Dest');
  34768. }
  34769. if (isString(url)) {
  34770. url = tryConvertUrlEncoding(url);
  34771. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34772. if (absoluteUrl) {
  34773. resultObj.url = absoluteUrl.href;
  34774. }
  34775. resultObj.unsafeUrl = url;
  34776. }
  34777. if (dest) {
  34778. if (isName(dest)) {
  34779. dest = dest.name;
  34780. }
  34781. if (isString(dest) || isArray(dest)) {
  34782. resultObj.dest = dest;
  34783. }
  34784. }
  34785. };
  34786. return Catalog;
  34787. }();
  34788. var XRef = function XRefClosure() {
  34789. function XRef(stream, pdfManager) {
  34790. this.stream = stream;
  34791. this.pdfManager = pdfManager;
  34792. this.entries = [];
  34793. this.xrefstms = Object.create(null);
  34794. this.cache = [];
  34795. this.stats = {
  34796. streamTypes: [],
  34797. fontTypes: []
  34798. };
  34799. }
  34800. XRef.prototype = {
  34801. setStartXRef: function XRef_setStartXRef(startXRef) {
  34802. this.startXRefQueue = [startXRef];
  34803. },
  34804. parse: function XRef_parse(recoveryMode) {
  34805. var trailerDict;
  34806. if (!recoveryMode) {
  34807. trailerDict = this.readXRef();
  34808. } else {
  34809. warn('Indexing all PDF objects');
  34810. trailerDict = this.indexObjects();
  34811. }
  34812. trailerDict.assignXref(this);
  34813. this.trailer = trailerDict;
  34814. var encrypt = trailerDict.get('Encrypt');
  34815. if (isDict(encrypt)) {
  34816. var ids = trailerDict.get('ID');
  34817. var fileId = ids && ids.length ? ids[0] : '';
  34818. encrypt.suppressEncryption = true;
  34819. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34820. }
  34821. if (!(this.root = trailerDict.get('Root'))) {
  34822. error('Invalid root reference');
  34823. }
  34824. },
  34825. processXRefTable: function XRef_processXRefTable(parser) {
  34826. if (!('tableState' in this)) {
  34827. this.tableState = {
  34828. entryNum: 0,
  34829. streamPos: parser.lexer.stream.pos,
  34830. parserBuf1: parser.buf1,
  34831. parserBuf2: parser.buf2
  34832. };
  34833. }
  34834. var obj = this.readXRefTable(parser);
  34835. if (!isCmd(obj, 'trailer')) {
  34836. error('Invalid XRef table: could not find trailer dictionary');
  34837. }
  34838. var dict = parser.getObj();
  34839. if (!isDict(dict) && dict.dict) {
  34840. dict = dict.dict;
  34841. }
  34842. if (!isDict(dict)) {
  34843. error('Invalid XRef table: could not parse trailer dictionary');
  34844. }
  34845. delete this.tableState;
  34846. return dict;
  34847. },
  34848. readXRefTable: function XRef_readXRefTable(parser) {
  34849. var stream = parser.lexer.stream;
  34850. var tableState = this.tableState;
  34851. stream.pos = tableState.streamPos;
  34852. parser.buf1 = tableState.parserBuf1;
  34853. parser.buf2 = tableState.parserBuf2;
  34854. var obj;
  34855. while (true) {
  34856. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34857. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34858. break;
  34859. }
  34860. tableState.firstEntryNum = obj;
  34861. tableState.entryCount = parser.getObj();
  34862. }
  34863. var first = tableState.firstEntryNum;
  34864. var count = tableState.entryCount;
  34865. if (!isInt(first) || !isInt(count)) {
  34866. error('Invalid XRef table: wrong types in subsection header');
  34867. }
  34868. for (var i = tableState.entryNum; i < count; i++) {
  34869. tableState.streamPos = stream.pos;
  34870. tableState.entryNum = i;
  34871. tableState.parserBuf1 = parser.buf1;
  34872. tableState.parserBuf2 = parser.buf2;
  34873. var entry = {};
  34874. entry.offset = parser.getObj();
  34875. entry.gen = parser.getObj();
  34876. var type = parser.getObj();
  34877. if (isCmd(type, 'f')) {
  34878. entry.free = true;
  34879. } else if (isCmd(type, 'n')) {
  34880. entry.uncompressed = true;
  34881. }
  34882. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34883. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34884. }
  34885. if (i === 0 && entry.free && first === 1) {
  34886. first = 0;
  34887. }
  34888. if (!this.entries[i + first]) {
  34889. this.entries[i + first] = entry;
  34890. }
  34891. }
  34892. tableState.entryNum = 0;
  34893. tableState.streamPos = stream.pos;
  34894. tableState.parserBuf1 = parser.buf1;
  34895. tableState.parserBuf2 = parser.buf2;
  34896. delete tableState.firstEntryNum;
  34897. delete tableState.entryCount;
  34898. }
  34899. if (this.entries[0] && !this.entries[0].free) {
  34900. error('Invalid XRef table: unexpected first object');
  34901. }
  34902. return obj;
  34903. },
  34904. processXRefStream: function XRef_processXRefStream(stream) {
  34905. if (!('streamState' in this)) {
  34906. var streamParameters = stream.dict;
  34907. var byteWidths = streamParameters.get('W');
  34908. var range = streamParameters.get('Index');
  34909. if (!range) {
  34910. range = [
  34911. 0,
  34912. streamParameters.get('Size')
  34913. ];
  34914. }
  34915. this.streamState = {
  34916. entryRanges: range,
  34917. byteWidths: byteWidths,
  34918. entryNum: 0,
  34919. streamPos: stream.pos
  34920. };
  34921. }
  34922. this.readXRefStream(stream);
  34923. delete this.streamState;
  34924. return stream.dict;
  34925. },
  34926. readXRefStream: function XRef_readXRefStream(stream) {
  34927. var i, j;
  34928. var streamState = this.streamState;
  34929. stream.pos = streamState.streamPos;
  34930. var byteWidths = streamState.byteWidths;
  34931. var typeFieldWidth = byteWidths[0];
  34932. var offsetFieldWidth = byteWidths[1];
  34933. var generationFieldWidth = byteWidths[2];
  34934. var entryRanges = streamState.entryRanges;
  34935. while (entryRanges.length > 0) {
  34936. var first = entryRanges[0];
  34937. var n = entryRanges[1];
  34938. if (!isInt(first) || !isInt(n)) {
  34939. error('Invalid XRef range fields: ' + first + ', ' + n);
  34940. }
  34941. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34942. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34943. }
  34944. for (i = streamState.entryNum; i < n; ++i) {
  34945. streamState.entryNum = i;
  34946. streamState.streamPos = stream.pos;
  34947. var type = 0, offset = 0, generation = 0;
  34948. for (j = 0; j < typeFieldWidth; ++j) {
  34949. type = type << 8 | stream.getByte();
  34950. }
  34951. if (typeFieldWidth === 0) {
  34952. type = 1;
  34953. }
  34954. for (j = 0; j < offsetFieldWidth; ++j) {
  34955. offset = offset << 8 | stream.getByte();
  34956. }
  34957. for (j = 0; j < generationFieldWidth; ++j) {
  34958. generation = generation << 8 | stream.getByte();
  34959. }
  34960. var entry = {};
  34961. entry.offset = offset;
  34962. entry.gen = generation;
  34963. switch (type) {
  34964. case 0:
  34965. entry.free = true;
  34966. break;
  34967. case 1:
  34968. entry.uncompressed = true;
  34969. break;
  34970. case 2:
  34971. break;
  34972. default:
  34973. error('Invalid XRef entry type: ' + type);
  34974. }
  34975. if (!this.entries[first + i]) {
  34976. this.entries[first + i] = entry;
  34977. }
  34978. }
  34979. streamState.entryNum = 0;
  34980. streamState.streamPos = stream.pos;
  34981. entryRanges.splice(0, 2);
  34982. }
  34983. },
  34984. indexObjects: function XRef_indexObjects() {
  34985. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34986. var PERCENT = 0x25, LT = 0x3C;
  34987. function readToken(data, offset) {
  34988. var token = '', ch = data[offset];
  34989. while (ch !== LF && ch !== CR && ch !== LT) {
  34990. if (++offset >= data.length) {
  34991. break;
  34992. }
  34993. token += String.fromCharCode(ch);
  34994. ch = data[offset];
  34995. }
  34996. return token;
  34997. }
  34998. function skipUntil(data, offset, what) {
  34999. var length = what.length, dataLength = data.length;
  35000. var skipped = 0;
  35001. while (offset < dataLength) {
  35002. var i = 0;
  35003. while (i < length && data[offset + i] === what[i]) {
  35004. ++i;
  35005. }
  35006. if (i >= length) {
  35007. break;
  35008. }
  35009. offset++;
  35010. skipped++;
  35011. }
  35012. return skipped;
  35013. }
  35014. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35015. var trailerBytes = new Uint8Array([
  35016. 116,
  35017. 114,
  35018. 97,
  35019. 105,
  35020. 108,
  35021. 101,
  35022. 114
  35023. ]);
  35024. var startxrefBytes = new Uint8Array([
  35025. 115,
  35026. 116,
  35027. 97,
  35028. 114,
  35029. 116,
  35030. 120,
  35031. 114,
  35032. 101,
  35033. 102
  35034. ]);
  35035. var endobjBytes = new Uint8Array([
  35036. 101,
  35037. 110,
  35038. 100,
  35039. 111,
  35040. 98,
  35041. 106
  35042. ]);
  35043. var xrefBytes = new Uint8Array([
  35044. 47,
  35045. 88,
  35046. 82,
  35047. 101,
  35048. 102
  35049. ]);
  35050. this.entries.length = 0;
  35051. var stream = this.stream;
  35052. stream.pos = 0;
  35053. var buffer = stream.getBytes();
  35054. var position = stream.start, length = buffer.length;
  35055. var trailers = [], xrefStms = [];
  35056. while (position < length) {
  35057. var ch = buffer[position];
  35058. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35059. ++position;
  35060. continue;
  35061. }
  35062. if (ch === PERCENT) {
  35063. do {
  35064. ++position;
  35065. if (position >= length) {
  35066. break;
  35067. }
  35068. ch = buffer[position];
  35069. } while (ch !== LF && ch !== CR);
  35070. continue;
  35071. }
  35072. var token = readToken(buffer, position);
  35073. var m;
  35074. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35075. position += skipUntil(buffer, position, trailerBytes);
  35076. trailers.push(position);
  35077. position += skipUntil(buffer, position, startxrefBytes);
  35078. } else if (m = objRegExp.exec(token)) {
  35079. if (typeof this.entries[m[1]] === 'undefined') {
  35080. this.entries[m[1]] = {
  35081. offset: position - stream.start,
  35082. gen: m[2] | 0,
  35083. uncompressed: true
  35084. };
  35085. }
  35086. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35087. var content = buffer.subarray(position, position + contentLength);
  35088. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35089. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35090. xrefStms.push(position - stream.start);
  35091. this.xrefstms[position - stream.start] = 1;
  35092. }
  35093. position += contentLength;
  35094. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35095. trailers.push(position);
  35096. position += skipUntil(buffer, position, startxrefBytes);
  35097. } else {
  35098. position += token.length + 1;
  35099. }
  35100. }
  35101. var i, ii;
  35102. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35103. this.startXRefQueue.push(xrefStms[i]);
  35104. this.readXRef(true);
  35105. }
  35106. var dict;
  35107. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35108. stream.pos = trailers[i];
  35109. var parser = new Parser(new Lexer(stream), true, this, true);
  35110. var obj = parser.getObj();
  35111. if (!isCmd(obj, 'trailer')) {
  35112. continue;
  35113. }
  35114. dict = parser.getObj();
  35115. if (!isDict(dict)) {
  35116. continue;
  35117. }
  35118. if (dict.has('ID')) {
  35119. return dict;
  35120. }
  35121. }
  35122. if (dict) {
  35123. return dict;
  35124. }
  35125. throw new InvalidPDFException('Invalid PDF structure');
  35126. },
  35127. readXRef: function XRef_readXRef(recoveryMode) {
  35128. var stream = this.stream;
  35129. try {
  35130. while (this.startXRefQueue.length) {
  35131. var startXRef = this.startXRefQueue[0];
  35132. stream.pos = startXRef + stream.start;
  35133. var parser = new Parser(new Lexer(stream), true, this);
  35134. var obj = parser.getObj();
  35135. var dict;
  35136. if (isCmd(obj, 'xref')) {
  35137. dict = this.processXRefTable(parser);
  35138. if (!this.topDict) {
  35139. this.topDict = dict;
  35140. }
  35141. obj = dict.get('XRefStm');
  35142. if (isInt(obj)) {
  35143. var pos = obj;
  35144. if (!(pos in this.xrefstms)) {
  35145. this.xrefstms[pos] = 1;
  35146. this.startXRefQueue.push(pos);
  35147. }
  35148. }
  35149. } else if (isInt(obj)) {
  35150. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35151. error('Invalid XRef stream');
  35152. }
  35153. dict = this.processXRefStream(obj);
  35154. if (!this.topDict) {
  35155. this.topDict = dict;
  35156. }
  35157. if (!dict) {
  35158. error('Failed to read XRef stream');
  35159. }
  35160. } else {
  35161. error('Invalid XRef stream header');
  35162. }
  35163. obj = dict.get('Prev');
  35164. if (isInt(obj)) {
  35165. this.startXRefQueue.push(obj);
  35166. } else if (isRef(obj)) {
  35167. this.startXRefQueue.push(obj.num);
  35168. }
  35169. this.startXRefQueue.shift();
  35170. }
  35171. return this.topDict;
  35172. } catch (e) {
  35173. if (e instanceof MissingDataException) {
  35174. throw e;
  35175. }
  35176. info('(while reading XRef): ' + e);
  35177. }
  35178. if (recoveryMode) {
  35179. return;
  35180. }
  35181. throw new XRefParseException();
  35182. },
  35183. getEntry: function XRef_getEntry(i) {
  35184. var xrefEntry = this.entries[i];
  35185. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35186. return xrefEntry;
  35187. }
  35188. return null;
  35189. },
  35190. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35191. if (!isRef(obj)) {
  35192. return obj;
  35193. }
  35194. return this.fetch(obj, suppressEncryption);
  35195. },
  35196. fetch: function XRef_fetch(ref, suppressEncryption) {
  35197. assert(isRef(ref), 'ref object is not a reference');
  35198. var num = ref.num;
  35199. if (num in this.cache) {
  35200. var cacheEntry = this.cache[num];
  35201. return cacheEntry;
  35202. }
  35203. var xrefEntry = this.getEntry(num);
  35204. if (xrefEntry === null) {
  35205. return this.cache[num] = null;
  35206. }
  35207. if (xrefEntry.uncompressed) {
  35208. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35209. } else {
  35210. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35211. }
  35212. if (isDict(xrefEntry)) {
  35213. xrefEntry.objId = ref.toString();
  35214. } else if (isStream(xrefEntry)) {
  35215. xrefEntry.dict.objId = ref.toString();
  35216. }
  35217. return xrefEntry;
  35218. },
  35219. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35220. var gen = ref.gen;
  35221. var num = ref.num;
  35222. if (xrefEntry.gen !== gen) {
  35223. error('inconsistent generation in XRef');
  35224. }
  35225. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35226. var parser = new Parser(new Lexer(stream), true, this);
  35227. var obj1 = parser.getObj();
  35228. var obj2 = parser.getObj();
  35229. var obj3 = parser.getObj();
  35230. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35231. error('bad XRef entry');
  35232. }
  35233. if (!isCmd(obj3, 'obj')) {
  35234. if (obj3.cmd.indexOf('obj') === 0) {
  35235. num = parseInt(obj3.cmd.substring(3), 10);
  35236. if (!isNaN(num)) {
  35237. return num;
  35238. }
  35239. }
  35240. error('bad XRef entry');
  35241. }
  35242. if (this.encrypt && !suppressEncryption) {
  35243. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35244. } else {
  35245. xrefEntry = parser.getObj();
  35246. }
  35247. if (!isStream(xrefEntry)) {
  35248. this.cache[num] = xrefEntry;
  35249. }
  35250. return xrefEntry;
  35251. },
  35252. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35253. var tableOffset = xrefEntry.offset;
  35254. var stream = this.fetch(new Ref(tableOffset, 0));
  35255. if (!isStream(stream)) {
  35256. error('bad ObjStm stream');
  35257. }
  35258. var first = stream.dict.get('First');
  35259. var n = stream.dict.get('N');
  35260. if (!isInt(first) || !isInt(n)) {
  35261. error('invalid first and n parameters for ObjStm stream');
  35262. }
  35263. var parser = new Parser(new Lexer(stream), false, this);
  35264. parser.allowStreams = true;
  35265. var i, entries = [], num, nums = [];
  35266. for (i = 0; i < n; ++i) {
  35267. num = parser.getObj();
  35268. if (!isInt(num)) {
  35269. error('invalid object number in the ObjStm stream: ' + num);
  35270. }
  35271. nums.push(num);
  35272. var offset = parser.getObj();
  35273. if (!isInt(offset)) {
  35274. error('invalid object offset in the ObjStm stream: ' + offset);
  35275. }
  35276. }
  35277. for (i = 0; i < n; ++i) {
  35278. entries.push(parser.getObj());
  35279. if (isCmd(parser.buf1, 'endobj')) {
  35280. parser.shift();
  35281. }
  35282. num = nums[i];
  35283. var entry = this.entries[num];
  35284. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35285. this.cache[num] = entries[i];
  35286. }
  35287. }
  35288. xrefEntry = entries[xrefEntry.gen];
  35289. if (xrefEntry === undefined) {
  35290. error('bad XRef entry for compressed object');
  35291. }
  35292. return xrefEntry;
  35293. },
  35294. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35295. if (!isRef(obj)) {
  35296. return Promise.resolve(obj);
  35297. }
  35298. return this.fetchAsync(obj, suppressEncryption);
  35299. },
  35300. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35301. var streamManager = this.stream.manager;
  35302. var xref = this;
  35303. return new Promise(function tryFetch(resolve, reject) {
  35304. try {
  35305. resolve(xref.fetch(ref, suppressEncryption));
  35306. } catch (e) {
  35307. if (e instanceof MissingDataException) {
  35308. streamManager.requestRange(e.begin, e.end).then(function () {
  35309. tryFetch(resolve, reject);
  35310. }, reject);
  35311. return;
  35312. }
  35313. reject(e);
  35314. }
  35315. });
  35316. },
  35317. getCatalogObj: function XRef_getCatalogObj() {
  35318. return this.root;
  35319. }
  35320. };
  35321. return XRef;
  35322. }();
  35323. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35324. function NameOrNumberTree(root, xref) {
  35325. throw new Error('Cannot initialize NameOrNumberTree.');
  35326. }
  35327. NameOrNumberTree.prototype = {
  35328. getAll: function NameOrNumberTree_getAll() {
  35329. var dict = Object.create(null);
  35330. if (!this.root) {
  35331. return dict;
  35332. }
  35333. var xref = this.xref;
  35334. var processed = new RefSet();
  35335. processed.put(this.root);
  35336. var queue = [this.root];
  35337. while (queue.length > 0) {
  35338. var i, n;
  35339. var obj = xref.fetchIfRef(queue.shift());
  35340. if (!isDict(obj)) {
  35341. continue;
  35342. }
  35343. if (obj.has('Kids')) {
  35344. var kids = obj.get('Kids');
  35345. for (i = 0, n = kids.length; i < n; i++) {
  35346. var kid = kids[i];
  35347. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35348. queue.push(kid);
  35349. processed.put(kid);
  35350. }
  35351. continue;
  35352. }
  35353. var entries = obj.get(this._type);
  35354. if (isArray(entries)) {
  35355. for (i = 0, n = entries.length; i < n; i += 2) {
  35356. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35357. }
  35358. }
  35359. }
  35360. return dict;
  35361. },
  35362. get: function NameOrNumberTree_get(key) {
  35363. if (!this.root) {
  35364. return null;
  35365. }
  35366. var xref = this.xref;
  35367. var kidsOrEntries = xref.fetchIfRef(this.root);
  35368. var loopCount = 0;
  35369. var MAX_LEVELS = 10;
  35370. var l, r, m;
  35371. while (kidsOrEntries.has('Kids')) {
  35372. if (++loopCount > MAX_LEVELS) {
  35373. warn('Search depth limit reached for "' + this._type + '" tree.');
  35374. return null;
  35375. }
  35376. var kids = kidsOrEntries.get('Kids');
  35377. if (!isArray(kids)) {
  35378. return null;
  35379. }
  35380. l = 0;
  35381. r = kids.length - 1;
  35382. while (l <= r) {
  35383. m = l + r >> 1;
  35384. var kid = xref.fetchIfRef(kids[m]);
  35385. var limits = kid.get('Limits');
  35386. if (key < xref.fetchIfRef(limits[0])) {
  35387. r = m - 1;
  35388. } else if (key > xref.fetchIfRef(limits[1])) {
  35389. l = m + 1;
  35390. } else {
  35391. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35392. break;
  35393. }
  35394. }
  35395. if (l > r) {
  35396. return null;
  35397. }
  35398. }
  35399. var entries = kidsOrEntries.get(this._type);
  35400. if (isArray(entries)) {
  35401. l = 0;
  35402. r = entries.length - 2;
  35403. while (l <= r) {
  35404. m = l + r & ~1;
  35405. var currentKey = xref.fetchIfRef(entries[m]);
  35406. if (key < currentKey) {
  35407. r = m - 2;
  35408. } else if (key > currentKey) {
  35409. l = m + 2;
  35410. } else {
  35411. return xref.fetchIfRef(entries[m + 1]);
  35412. }
  35413. }
  35414. }
  35415. return null;
  35416. }
  35417. };
  35418. return NameOrNumberTree;
  35419. }();
  35420. var NameTree = function NameTreeClosure() {
  35421. function NameTree(root, xref) {
  35422. this.root = root;
  35423. this.xref = xref;
  35424. this._type = 'Names';
  35425. }
  35426. Util.inherit(NameTree, NameOrNumberTree, {});
  35427. return NameTree;
  35428. }();
  35429. var NumberTree = function NumberTreeClosure() {
  35430. function NumberTree(root, xref) {
  35431. this.root = root;
  35432. this.xref = xref;
  35433. this._type = 'Nums';
  35434. }
  35435. Util.inherit(NumberTree, NameOrNumberTree, {});
  35436. return NumberTree;
  35437. }();
  35438. var FileSpec = function FileSpecClosure() {
  35439. function FileSpec(root, xref) {
  35440. if (!root || !isDict(root)) {
  35441. return;
  35442. }
  35443. this.xref = xref;
  35444. this.root = root;
  35445. if (root.has('FS')) {
  35446. this.fs = root.get('FS');
  35447. }
  35448. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35449. if (root.has('RF')) {
  35450. warn('Related file specifications are not supported');
  35451. }
  35452. this.contentAvailable = true;
  35453. if (!root.has('EF')) {
  35454. this.contentAvailable = false;
  35455. warn('Non-embedded file specifications are not supported');
  35456. }
  35457. }
  35458. function pickPlatformItem(dict) {
  35459. if (dict.has('UF')) {
  35460. return dict.get('UF');
  35461. } else if (dict.has('F')) {
  35462. return dict.get('F');
  35463. } else if (dict.has('Unix')) {
  35464. return dict.get('Unix');
  35465. } else if (dict.has('Mac')) {
  35466. return dict.get('Mac');
  35467. } else if (dict.has('DOS')) {
  35468. return dict.get('DOS');
  35469. }
  35470. return null;
  35471. }
  35472. FileSpec.prototype = {
  35473. get filename() {
  35474. if (!this._filename && this.root) {
  35475. var filename = pickPlatformItem(this.root) || 'unnamed';
  35476. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35477. }
  35478. return this._filename;
  35479. },
  35480. get content() {
  35481. if (!this.contentAvailable) {
  35482. return null;
  35483. }
  35484. if (!this.contentRef && this.root) {
  35485. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35486. }
  35487. var content = null;
  35488. if (this.contentRef) {
  35489. var xref = this.xref;
  35490. var fileObj = xref.fetchIfRef(this.contentRef);
  35491. if (fileObj && isStream(fileObj)) {
  35492. content = fileObj.getBytes();
  35493. } else {
  35494. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35495. }
  35496. } else {
  35497. warn('Embedded file specification does not have a content');
  35498. }
  35499. return content;
  35500. },
  35501. get serializable() {
  35502. return {
  35503. filename: this.filename,
  35504. content: this.content
  35505. };
  35506. }
  35507. };
  35508. return FileSpec;
  35509. }();
  35510. var ObjectLoader = function () {
  35511. function mayHaveChildren(value) {
  35512. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35513. }
  35514. function addChildren(node, nodesToVisit) {
  35515. var value;
  35516. if (isDict(node) || isStream(node)) {
  35517. var map;
  35518. if (isDict(node)) {
  35519. map = node.map;
  35520. } else {
  35521. map = node.dict.map;
  35522. }
  35523. for (var key in map) {
  35524. value = map[key];
  35525. if (mayHaveChildren(value)) {
  35526. nodesToVisit.push(value);
  35527. }
  35528. }
  35529. } else if (isArray(node)) {
  35530. for (var i = 0, ii = node.length; i < ii; i++) {
  35531. value = node[i];
  35532. if (mayHaveChildren(value)) {
  35533. nodesToVisit.push(value);
  35534. }
  35535. }
  35536. }
  35537. }
  35538. function ObjectLoader(obj, keys, xref) {
  35539. this.obj = obj;
  35540. this.keys = keys;
  35541. this.xref = xref;
  35542. this.refSet = null;
  35543. this.capability = null;
  35544. }
  35545. ObjectLoader.prototype = {
  35546. load: function ObjectLoader_load() {
  35547. var keys = this.keys;
  35548. this.capability = createPromiseCapability();
  35549. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35550. this.capability.resolve();
  35551. return this.capability.promise;
  35552. }
  35553. this.refSet = new RefSet();
  35554. var nodesToVisit = [];
  35555. for (var i = 0; i < keys.length; i++) {
  35556. nodesToVisit.push(this.obj[keys[i]]);
  35557. }
  35558. this._walk(nodesToVisit);
  35559. return this.capability.promise;
  35560. },
  35561. _walk: function ObjectLoader_walk(nodesToVisit) {
  35562. var nodesToRevisit = [];
  35563. var pendingRequests = [];
  35564. while (nodesToVisit.length) {
  35565. var currentNode = nodesToVisit.pop();
  35566. if (isRef(currentNode)) {
  35567. if (this.refSet.has(currentNode)) {
  35568. continue;
  35569. }
  35570. try {
  35571. var ref = currentNode;
  35572. this.refSet.put(ref);
  35573. currentNode = this.xref.fetch(currentNode);
  35574. } catch (e) {
  35575. if (!(e instanceof MissingDataException)) {
  35576. throw e;
  35577. }
  35578. nodesToRevisit.push(currentNode);
  35579. pendingRequests.push({
  35580. begin: e.begin,
  35581. end: e.end
  35582. });
  35583. }
  35584. }
  35585. if (currentNode && currentNode.getBaseStreams) {
  35586. var baseStreams = currentNode.getBaseStreams();
  35587. var foundMissingData = false;
  35588. for (var i = 0; i < baseStreams.length; i++) {
  35589. var stream = baseStreams[i];
  35590. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35591. foundMissingData = true;
  35592. pendingRequests.push({
  35593. begin: stream.start,
  35594. end: stream.end
  35595. });
  35596. }
  35597. }
  35598. if (foundMissingData) {
  35599. nodesToRevisit.push(currentNode);
  35600. }
  35601. }
  35602. addChildren(currentNode, nodesToVisit);
  35603. }
  35604. if (pendingRequests.length) {
  35605. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35606. nodesToVisit = nodesToRevisit;
  35607. for (var i = 0; i < nodesToRevisit.length; i++) {
  35608. var node = nodesToRevisit[i];
  35609. if (isRef(node)) {
  35610. this.refSet.remove(node);
  35611. }
  35612. }
  35613. this._walk(nodesToVisit);
  35614. }.bind(this), this.capability.reject);
  35615. return;
  35616. }
  35617. this.refSet = null;
  35618. this.capability.resolve();
  35619. }
  35620. };
  35621. return ObjectLoader;
  35622. }();
  35623. exports.Catalog = Catalog;
  35624. exports.ObjectLoader = ObjectLoader;
  35625. exports.XRef = XRef;
  35626. exports.FileSpec = FileSpec;
  35627. /***/ }),
  35628. /* 20 */
  35629. /***/ (function(module, exports, __w_pdfjs_require__) {
  35630. "use strict";
  35631. var sharedUtil = __w_pdfjs_require__(0);
  35632. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35633. var getStdFontMap = getLookupTableFactory(function (t) {
  35634. t['ArialNarrow'] = 'Helvetica';
  35635. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35636. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35637. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35638. t['ArialBlack'] = 'Helvetica';
  35639. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35640. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35641. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35642. t['Arial-Black'] = 'Helvetica';
  35643. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35644. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35645. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35646. t['Arial'] = 'Helvetica';
  35647. t['Arial-Bold'] = 'Helvetica-Bold';
  35648. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35649. t['Arial-Italic'] = 'Helvetica-Oblique';
  35650. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35651. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35652. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35653. t['ArialMT'] = 'Helvetica';
  35654. t['Courier-Bold'] = 'Courier-Bold';
  35655. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35656. t['Courier-Italic'] = 'Courier-Oblique';
  35657. t['CourierNew'] = 'Courier';
  35658. t['CourierNew-Bold'] = 'Courier-Bold';
  35659. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35660. t['CourierNew-Italic'] = 'Courier-Oblique';
  35661. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35662. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35663. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35664. t['CourierNewPSMT'] = 'Courier';
  35665. t['Helvetica'] = 'Helvetica';
  35666. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35667. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35668. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35669. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35670. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35671. t['Symbol-Bold'] = 'Symbol';
  35672. t['Symbol-BoldItalic'] = 'Symbol';
  35673. t['Symbol-Italic'] = 'Symbol';
  35674. t['TimesNewRoman'] = 'Times-Roman';
  35675. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35676. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35677. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35678. t['TimesNewRomanPS'] = 'Times-Roman';
  35679. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35680. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35681. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35682. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35683. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35684. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35685. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35686. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35687. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35688. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35689. });
  35690. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35691. t['CenturyGothic'] = 'Helvetica';
  35692. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35693. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35694. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35695. t['ComicSansMS'] = 'Comic Sans MS';
  35696. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35697. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35698. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35699. t['LucidaConsole'] = 'Courier';
  35700. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35701. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35702. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35703. t['MS-Gothic'] = 'MS Gothic';
  35704. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35705. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35706. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35707. t['MS-Mincho'] = 'MS Mincho';
  35708. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35709. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35710. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35711. t['MS-PGothic'] = 'MS PGothic';
  35712. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35713. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35714. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35715. t['MS-PMincho'] = 'MS PMincho';
  35716. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35717. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35718. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35719. t['NuptialScript'] = 'Times-Italic';
  35720. t['Wingdings'] = 'ZapfDingbats';
  35721. });
  35722. var getSerifFonts = getLookupTableFactory(function (t) {
  35723. t['Adobe Jenson'] = true;
  35724. t['Adobe Text'] = true;
  35725. t['Albertus'] = true;
  35726. t['Aldus'] = true;
  35727. t['Alexandria'] = true;
  35728. t['Algerian'] = true;
  35729. t['American Typewriter'] = true;
  35730. t['Antiqua'] = true;
  35731. t['Apex'] = true;
  35732. t['Arno'] = true;
  35733. t['Aster'] = true;
  35734. t['Aurora'] = true;
  35735. t['Baskerville'] = true;
  35736. t['Bell'] = true;
  35737. t['Bembo'] = true;
  35738. t['Bembo Schoolbook'] = true;
  35739. t['Benguiat'] = true;
  35740. t['Berkeley Old Style'] = true;
  35741. t['Bernhard Modern'] = true;
  35742. t['Berthold City'] = true;
  35743. t['Bodoni'] = true;
  35744. t['Bauer Bodoni'] = true;
  35745. t['Book Antiqua'] = true;
  35746. t['Bookman'] = true;
  35747. t['Bordeaux Roman'] = true;
  35748. t['Californian FB'] = true;
  35749. t['Calisto'] = true;
  35750. t['Calvert'] = true;
  35751. t['Capitals'] = true;
  35752. t['Cambria'] = true;
  35753. t['Cartier'] = true;
  35754. t['Caslon'] = true;
  35755. t['Catull'] = true;
  35756. t['Centaur'] = true;
  35757. t['Century Old Style'] = true;
  35758. t['Century Schoolbook'] = true;
  35759. t['Chaparral'] = true;
  35760. t['Charis SIL'] = true;
  35761. t['Cheltenham'] = true;
  35762. t['Cholla Slab'] = true;
  35763. t['Clarendon'] = true;
  35764. t['Clearface'] = true;
  35765. t['Cochin'] = true;
  35766. t['Colonna'] = true;
  35767. t['Computer Modern'] = true;
  35768. t['Concrete Roman'] = true;
  35769. t['Constantia'] = true;
  35770. t['Cooper Black'] = true;
  35771. t['Corona'] = true;
  35772. t['Ecotype'] = true;
  35773. t['Egyptienne'] = true;
  35774. t['Elephant'] = true;
  35775. t['Excelsior'] = true;
  35776. t['Fairfield'] = true;
  35777. t['FF Scala'] = true;
  35778. t['Folkard'] = true;
  35779. t['Footlight'] = true;
  35780. t['FreeSerif'] = true;
  35781. t['Friz Quadrata'] = true;
  35782. t['Garamond'] = true;
  35783. t['Gentium'] = true;
  35784. t['Georgia'] = true;
  35785. t['Gloucester'] = true;
  35786. t['Goudy Old Style'] = true;
  35787. t['Goudy Schoolbook'] = true;
  35788. t['Goudy Pro Font'] = true;
  35789. t['Granjon'] = true;
  35790. t['Guardian Egyptian'] = true;
  35791. t['Heather'] = true;
  35792. t['Hercules'] = true;
  35793. t['High Tower Text'] = true;
  35794. t['Hiroshige'] = true;
  35795. t['Hoefler Text'] = true;
  35796. t['Humana Serif'] = true;
  35797. t['Imprint'] = true;
  35798. t['Ionic No. 5'] = true;
  35799. t['Janson'] = true;
  35800. t['Joanna'] = true;
  35801. t['Korinna'] = true;
  35802. t['Lexicon'] = true;
  35803. t['Liberation Serif'] = true;
  35804. t['Linux Libertine'] = true;
  35805. t['Literaturnaya'] = true;
  35806. t['Lucida'] = true;
  35807. t['Lucida Bright'] = true;
  35808. t['Melior'] = true;
  35809. t['Memphis'] = true;
  35810. t['Miller'] = true;
  35811. t['Minion'] = true;
  35812. t['Modern'] = true;
  35813. t['Mona Lisa'] = true;
  35814. t['Mrs Eaves'] = true;
  35815. t['MS Serif'] = true;
  35816. t['Museo Slab'] = true;
  35817. t['New York'] = true;
  35818. t['Nimbus Roman'] = true;
  35819. t['NPS Rawlinson Roadway'] = true;
  35820. t['NuptialScript'] = true;
  35821. t['Palatino'] = true;
  35822. t['Perpetua'] = true;
  35823. t['Plantin'] = true;
  35824. t['Plantin Schoolbook'] = true;
  35825. t['Playbill'] = true;
  35826. t['Poor Richard'] = true;
  35827. t['Rawlinson Roadway'] = true;
  35828. t['Renault'] = true;
  35829. t['Requiem'] = true;
  35830. t['Rockwell'] = true;
  35831. t['Roman'] = true;
  35832. t['Rotis Serif'] = true;
  35833. t['Sabon'] = true;
  35834. t['Scala'] = true;
  35835. t['Seagull'] = true;
  35836. t['Sistina'] = true;
  35837. t['Souvenir'] = true;
  35838. t['STIX'] = true;
  35839. t['Stone Informal'] = true;
  35840. t['Stone Serif'] = true;
  35841. t['Sylfaen'] = true;
  35842. t['Times'] = true;
  35843. t['Trajan'] = true;
  35844. t['Trinité'] = true;
  35845. t['Trump Mediaeval'] = true;
  35846. t['Utopia'] = true;
  35847. t['Vale Type'] = true;
  35848. t['Bitstream Vera'] = true;
  35849. t['Vera Serif'] = true;
  35850. t['Versailles'] = true;
  35851. t['Wanted'] = true;
  35852. t['Weiss'] = true;
  35853. t['Wide Latin'] = true;
  35854. t['Windsor'] = true;
  35855. t['XITS'] = true;
  35856. });
  35857. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35858. t['Dingbats'] = true;
  35859. t['Symbol'] = true;
  35860. t['ZapfDingbats'] = true;
  35861. });
  35862. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35863. t[2] = 10;
  35864. t[3] = 32;
  35865. t[4] = 33;
  35866. t[5] = 34;
  35867. t[6] = 35;
  35868. t[7] = 36;
  35869. t[8] = 37;
  35870. t[9] = 38;
  35871. t[10] = 39;
  35872. t[11] = 40;
  35873. t[12] = 41;
  35874. t[13] = 42;
  35875. t[14] = 43;
  35876. t[15] = 44;
  35877. t[16] = 45;
  35878. t[17] = 46;
  35879. t[18] = 47;
  35880. t[19] = 48;
  35881. t[20] = 49;
  35882. t[21] = 50;
  35883. t[22] = 51;
  35884. t[23] = 52;
  35885. t[24] = 53;
  35886. t[25] = 54;
  35887. t[26] = 55;
  35888. t[27] = 56;
  35889. t[28] = 57;
  35890. t[29] = 58;
  35891. t[30] = 894;
  35892. t[31] = 60;
  35893. t[32] = 61;
  35894. t[33] = 62;
  35895. t[34] = 63;
  35896. t[35] = 64;
  35897. t[36] = 65;
  35898. t[37] = 66;
  35899. t[38] = 67;
  35900. t[39] = 68;
  35901. t[40] = 69;
  35902. t[41] = 70;
  35903. t[42] = 71;
  35904. t[43] = 72;
  35905. t[44] = 73;
  35906. t[45] = 74;
  35907. t[46] = 75;
  35908. t[47] = 76;
  35909. t[48] = 77;
  35910. t[49] = 78;
  35911. t[50] = 79;
  35912. t[51] = 80;
  35913. t[52] = 81;
  35914. t[53] = 82;
  35915. t[54] = 83;
  35916. t[55] = 84;
  35917. t[56] = 85;
  35918. t[57] = 86;
  35919. t[58] = 87;
  35920. t[59] = 88;
  35921. t[60] = 89;
  35922. t[61] = 90;
  35923. t[62] = 91;
  35924. t[63] = 92;
  35925. t[64] = 93;
  35926. t[65] = 94;
  35927. t[66] = 95;
  35928. t[67] = 96;
  35929. t[68] = 97;
  35930. t[69] = 98;
  35931. t[70] = 99;
  35932. t[71] = 100;
  35933. t[72] = 101;
  35934. t[73] = 102;
  35935. t[74] = 103;
  35936. t[75] = 104;
  35937. t[76] = 105;
  35938. t[77] = 106;
  35939. t[78] = 107;
  35940. t[79] = 108;
  35941. t[80] = 109;
  35942. t[81] = 110;
  35943. t[82] = 111;
  35944. t[83] = 112;
  35945. t[84] = 113;
  35946. t[85] = 114;
  35947. t[86] = 115;
  35948. t[87] = 116;
  35949. t[88] = 117;
  35950. t[89] = 118;
  35951. t[90] = 119;
  35952. t[91] = 120;
  35953. t[92] = 121;
  35954. t[93] = 122;
  35955. t[94] = 123;
  35956. t[95] = 124;
  35957. t[96] = 125;
  35958. t[97] = 126;
  35959. t[98] = 196;
  35960. t[99] = 197;
  35961. t[100] = 199;
  35962. t[101] = 201;
  35963. t[102] = 209;
  35964. t[103] = 214;
  35965. t[104] = 220;
  35966. t[105] = 225;
  35967. t[106] = 224;
  35968. t[107] = 226;
  35969. t[108] = 228;
  35970. t[109] = 227;
  35971. t[110] = 229;
  35972. t[111] = 231;
  35973. t[112] = 233;
  35974. t[113] = 232;
  35975. t[114] = 234;
  35976. t[115] = 235;
  35977. t[116] = 237;
  35978. t[117] = 236;
  35979. t[118] = 238;
  35980. t[119] = 239;
  35981. t[120] = 241;
  35982. t[121] = 243;
  35983. t[122] = 242;
  35984. t[123] = 244;
  35985. t[124] = 246;
  35986. t[125] = 245;
  35987. t[126] = 250;
  35988. t[127] = 249;
  35989. t[128] = 251;
  35990. t[129] = 252;
  35991. t[130] = 8224;
  35992. t[131] = 176;
  35993. t[132] = 162;
  35994. t[133] = 163;
  35995. t[134] = 167;
  35996. t[135] = 8226;
  35997. t[136] = 182;
  35998. t[137] = 223;
  35999. t[138] = 174;
  36000. t[139] = 169;
  36001. t[140] = 8482;
  36002. t[141] = 180;
  36003. t[142] = 168;
  36004. t[143] = 8800;
  36005. t[144] = 198;
  36006. t[145] = 216;
  36007. t[146] = 8734;
  36008. t[147] = 177;
  36009. t[148] = 8804;
  36010. t[149] = 8805;
  36011. t[150] = 165;
  36012. t[151] = 181;
  36013. t[152] = 8706;
  36014. t[153] = 8721;
  36015. t[154] = 8719;
  36016. t[156] = 8747;
  36017. t[157] = 170;
  36018. t[158] = 186;
  36019. t[159] = 8486;
  36020. t[160] = 230;
  36021. t[161] = 248;
  36022. t[162] = 191;
  36023. t[163] = 161;
  36024. t[164] = 172;
  36025. t[165] = 8730;
  36026. t[166] = 402;
  36027. t[167] = 8776;
  36028. t[168] = 8710;
  36029. t[169] = 171;
  36030. t[170] = 187;
  36031. t[171] = 8230;
  36032. t[210] = 218;
  36033. t[223] = 711;
  36034. t[224] = 321;
  36035. t[225] = 322;
  36036. t[227] = 353;
  36037. t[229] = 382;
  36038. t[234] = 253;
  36039. t[252] = 263;
  36040. t[253] = 268;
  36041. t[254] = 269;
  36042. t[258] = 258;
  36043. t[260] = 260;
  36044. t[261] = 261;
  36045. t[265] = 280;
  36046. t[266] = 281;
  36047. t[268] = 283;
  36048. t[269] = 313;
  36049. t[275] = 323;
  36050. t[276] = 324;
  36051. t[278] = 328;
  36052. t[284] = 345;
  36053. t[285] = 346;
  36054. t[286] = 347;
  36055. t[292] = 367;
  36056. t[295] = 377;
  36057. t[296] = 378;
  36058. t[298] = 380;
  36059. t[305] = 963;
  36060. t[306] = 964;
  36061. t[307] = 966;
  36062. t[308] = 8215;
  36063. t[309] = 8252;
  36064. t[310] = 8319;
  36065. t[311] = 8359;
  36066. t[312] = 8592;
  36067. t[313] = 8593;
  36068. t[337] = 9552;
  36069. t[493] = 1039;
  36070. t[494] = 1040;
  36071. t[705] = 1524;
  36072. t[706] = 8362;
  36073. t[710] = 64288;
  36074. t[711] = 64298;
  36075. t[759] = 1617;
  36076. t[761] = 1776;
  36077. t[763] = 1778;
  36078. t[775] = 1652;
  36079. t[777] = 1764;
  36080. t[778] = 1780;
  36081. t[779] = 1781;
  36082. t[780] = 1782;
  36083. t[782] = 771;
  36084. t[783] = 64726;
  36085. t[786] = 8363;
  36086. t[788] = 8532;
  36087. t[790] = 768;
  36088. t[791] = 769;
  36089. t[792] = 768;
  36090. t[795] = 803;
  36091. t[797] = 64336;
  36092. t[798] = 64337;
  36093. t[799] = 64342;
  36094. t[800] = 64343;
  36095. t[801] = 64344;
  36096. t[802] = 64345;
  36097. t[803] = 64362;
  36098. t[804] = 64363;
  36099. t[805] = 64364;
  36100. t[2424] = 7821;
  36101. t[2425] = 7822;
  36102. t[2426] = 7823;
  36103. t[2427] = 7824;
  36104. t[2428] = 7825;
  36105. t[2429] = 7826;
  36106. t[2430] = 7827;
  36107. t[2433] = 7682;
  36108. t[2678] = 8045;
  36109. t[2679] = 8046;
  36110. t[2830] = 1552;
  36111. t[2838] = 686;
  36112. t[2840] = 751;
  36113. t[2842] = 753;
  36114. t[2843] = 754;
  36115. t[2844] = 755;
  36116. t[2846] = 757;
  36117. t[2856] = 767;
  36118. t[2857] = 848;
  36119. t[2858] = 849;
  36120. t[2862] = 853;
  36121. t[2863] = 854;
  36122. t[2864] = 855;
  36123. t[2865] = 861;
  36124. t[2866] = 862;
  36125. t[2906] = 7460;
  36126. t[2908] = 7462;
  36127. t[2909] = 7463;
  36128. t[2910] = 7464;
  36129. t[2912] = 7466;
  36130. t[2913] = 7467;
  36131. t[2914] = 7468;
  36132. t[2916] = 7470;
  36133. t[2917] = 7471;
  36134. t[2918] = 7472;
  36135. t[2920] = 7474;
  36136. t[2921] = 7475;
  36137. t[2922] = 7476;
  36138. t[2924] = 7478;
  36139. t[2925] = 7479;
  36140. t[2926] = 7480;
  36141. t[2928] = 7482;
  36142. t[2929] = 7483;
  36143. t[2930] = 7484;
  36144. t[2932] = 7486;
  36145. t[2933] = 7487;
  36146. t[2934] = 7488;
  36147. t[2936] = 7490;
  36148. t[2937] = 7491;
  36149. t[2938] = 7492;
  36150. t[2940] = 7494;
  36151. t[2941] = 7495;
  36152. t[2942] = 7496;
  36153. t[2944] = 7498;
  36154. t[2946] = 7500;
  36155. t[2948] = 7502;
  36156. t[2950] = 7504;
  36157. t[2951] = 7505;
  36158. t[2952] = 7506;
  36159. t[2954] = 7508;
  36160. t[2955] = 7509;
  36161. t[2956] = 7510;
  36162. t[2958] = 7512;
  36163. t[2959] = 7513;
  36164. t[2960] = 7514;
  36165. t[2962] = 7516;
  36166. t[2963] = 7517;
  36167. t[2964] = 7518;
  36168. t[2966] = 7520;
  36169. t[2967] = 7521;
  36170. t[2968] = 7522;
  36171. t[2970] = 7524;
  36172. t[2971] = 7525;
  36173. t[2972] = 7526;
  36174. t[2974] = 7528;
  36175. t[2975] = 7529;
  36176. t[2976] = 7530;
  36177. t[2978] = 1537;
  36178. t[2979] = 1538;
  36179. t[2980] = 1539;
  36180. t[2982] = 1549;
  36181. t[2983] = 1551;
  36182. t[2984] = 1552;
  36183. t[2986] = 1554;
  36184. t[2987] = 1555;
  36185. t[2988] = 1556;
  36186. t[2990] = 1623;
  36187. t[2991] = 1624;
  36188. t[2995] = 1775;
  36189. t[2999] = 1791;
  36190. t[3002] = 64290;
  36191. t[3003] = 64291;
  36192. t[3004] = 64292;
  36193. t[3006] = 64294;
  36194. t[3007] = 64295;
  36195. t[3008] = 64296;
  36196. t[3011] = 1900;
  36197. t[3014] = 8223;
  36198. t[3015] = 8244;
  36199. t[3017] = 7532;
  36200. t[3018] = 7533;
  36201. t[3019] = 7534;
  36202. t[3075] = 7590;
  36203. t[3076] = 7591;
  36204. t[3079] = 7594;
  36205. t[3080] = 7595;
  36206. t[3083] = 7598;
  36207. t[3084] = 7599;
  36208. t[3087] = 7602;
  36209. t[3088] = 7603;
  36210. t[3091] = 7606;
  36211. t[3092] = 7607;
  36212. t[3095] = 7610;
  36213. t[3096] = 7611;
  36214. t[3099] = 7614;
  36215. t[3100] = 7615;
  36216. t[3103] = 7618;
  36217. t[3104] = 7619;
  36218. t[3107] = 8337;
  36219. t[3108] = 8338;
  36220. t[3116] = 1884;
  36221. t[3119] = 1885;
  36222. t[3120] = 1885;
  36223. t[3123] = 1886;
  36224. t[3124] = 1886;
  36225. t[3127] = 1887;
  36226. t[3128] = 1887;
  36227. t[3131] = 1888;
  36228. t[3132] = 1888;
  36229. t[3135] = 1889;
  36230. t[3136] = 1889;
  36231. t[3139] = 1890;
  36232. t[3140] = 1890;
  36233. t[3143] = 1891;
  36234. t[3144] = 1891;
  36235. t[3147] = 1892;
  36236. t[3148] = 1892;
  36237. t[3153] = 580;
  36238. t[3154] = 581;
  36239. t[3157] = 584;
  36240. t[3158] = 585;
  36241. t[3161] = 588;
  36242. t[3162] = 589;
  36243. t[3165] = 891;
  36244. t[3166] = 892;
  36245. t[3169] = 1274;
  36246. t[3170] = 1275;
  36247. t[3173] = 1278;
  36248. t[3174] = 1279;
  36249. t[3181] = 7622;
  36250. t[3182] = 7623;
  36251. t[3282] = 11799;
  36252. t[3316] = 578;
  36253. t[3379] = 42785;
  36254. t[3393] = 1159;
  36255. t[3416] = 8377;
  36256. });
  36257. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36258. t[227] = 322;
  36259. t[264] = 261;
  36260. t[291] = 346;
  36261. });
  36262. exports.getStdFontMap = getStdFontMap;
  36263. exports.getNonStdFontMap = getNonStdFontMap;
  36264. exports.getSerifFonts = getSerifFonts;
  36265. exports.getSymbolsFonts = getSymbolsFonts;
  36266. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36267. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36268. /***/ }),
  36269. /* 21 */
  36270. /***/ (function(module, exports, __w_pdfjs_require__) {
  36271. "use strict";
  36272. var sharedUtil = __w_pdfjs_require__(0);
  36273. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36274. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36275. t[63721] = 0x00A9;
  36276. t[63193] = 0x00A9;
  36277. t[63720] = 0x00AE;
  36278. t[63194] = 0x00AE;
  36279. t[63722] = 0x2122;
  36280. t[63195] = 0x2122;
  36281. t[63729] = 0x23A7;
  36282. t[63730] = 0x23A8;
  36283. t[63731] = 0x23A9;
  36284. t[63740] = 0x23AB;
  36285. t[63741] = 0x23AC;
  36286. t[63742] = 0x23AD;
  36287. t[63726] = 0x23A1;
  36288. t[63727] = 0x23A2;
  36289. t[63728] = 0x23A3;
  36290. t[63737] = 0x23A4;
  36291. t[63738] = 0x23A5;
  36292. t[63739] = 0x23A6;
  36293. t[63723] = 0x239B;
  36294. t[63724] = 0x239C;
  36295. t[63725] = 0x239D;
  36296. t[63734] = 0x239E;
  36297. t[63735] = 0x239F;
  36298. t[63736] = 0x23A0;
  36299. });
  36300. function mapSpecialUnicodeValues(code) {
  36301. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36302. return 0;
  36303. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36304. return getSpecialPUASymbols()[code] || code;
  36305. }
  36306. return code;
  36307. }
  36308. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36309. var unicode = glyphsUnicodeMap[name];
  36310. if (unicode !== undefined) {
  36311. return unicode;
  36312. }
  36313. if (!name) {
  36314. return -1;
  36315. }
  36316. if (name[0] === 'u') {
  36317. var nameLen = name.length, hexStr;
  36318. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36319. hexStr = name.substr(3);
  36320. } else if (nameLen >= 5 && nameLen <= 7) {
  36321. hexStr = name.substr(1);
  36322. } else {
  36323. return -1;
  36324. }
  36325. if (hexStr === hexStr.toUpperCase()) {
  36326. unicode = parseInt(hexStr, 16);
  36327. if (unicode >= 0) {
  36328. return unicode;
  36329. }
  36330. }
  36331. }
  36332. return -1;
  36333. }
  36334. var UnicodeRanges = [
  36335. {
  36336. 'begin': 0x0000,
  36337. 'end': 0x007F
  36338. },
  36339. {
  36340. 'begin': 0x0080,
  36341. 'end': 0x00FF
  36342. },
  36343. {
  36344. 'begin': 0x0100,
  36345. 'end': 0x017F
  36346. },
  36347. {
  36348. 'begin': 0x0180,
  36349. 'end': 0x024F
  36350. },
  36351. {
  36352. 'begin': 0x0250,
  36353. 'end': 0x02AF
  36354. },
  36355. {
  36356. 'begin': 0x02B0,
  36357. 'end': 0x02FF
  36358. },
  36359. {
  36360. 'begin': 0x0300,
  36361. 'end': 0x036F
  36362. },
  36363. {
  36364. 'begin': 0x0370,
  36365. 'end': 0x03FF
  36366. },
  36367. {
  36368. 'begin': 0x2C80,
  36369. 'end': 0x2CFF
  36370. },
  36371. {
  36372. 'begin': 0x0400,
  36373. 'end': 0x04FF
  36374. },
  36375. {
  36376. 'begin': 0x0530,
  36377. 'end': 0x058F
  36378. },
  36379. {
  36380. 'begin': 0x0590,
  36381. 'end': 0x05FF
  36382. },
  36383. {
  36384. 'begin': 0xA500,
  36385. 'end': 0xA63F
  36386. },
  36387. {
  36388. 'begin': 0x0600,
  36389. 'end': 0x06FF
  36390. },
  36391. {
  36392. 'begin': 0x07C0,
  36393. 'end': 0x07FF
  36394. },
  36395. {
  36396. 'begin': 0x0900,
  36397. 'end': 0x097F
  36398. },
  36399. {
  36400. 'begin': 0x0980,
  36401. 'end': 0x09FF
  36402. },
  36403. {
  36404. 'begin': 0x0A00,
  36405. 'end': 0x0A7F
  36406. },
  36407. {
  36408. 'begin': 0x0A80,
  36409. 'end': 0x0AFF
  36410. },
  36411. {
  36412. 'begin': 0x0B00,
  36413. 'end': 0x0B7F
  36414. },
  36415. {
  36416. 'begin': 0x0B80,
  36417. 'end': 0x0BFF
  36418. },
  36419. {
  36420. 'begin': 0x0C00,
  36421. 'end': 0x0C7F
  36422. },
  36423. {
  36424. 'begin': 0x0C80,
  36425. 'end': 0x0CFF
  36426. },
  36427. {
  36428. 'begin': 0x0D00,
  36429. 'end': 0x0D7F
  36430. },
  36431. {
  36432. 'begin': 0x0E00,
  36433. 'end': 0x0E7F
  36434. },
  36435. {
  36436. 'begin': 0x0E80,
  36437. 'end': 0x0EFF
  36438. },
  36439. {
  36440. 'begin': 0x10A0,
  36441. 'end': 0x10FF
  36442. },
  36443. {
  36444. 'begin': 0x1B00,
  36445. 'end': 0x1B7F
  36446. },
  36447. {
  36448. 'begin': 0x1100,
  36449. 'end': 0x11FF
  36450. },
  36451. {
  36452. 'begin': 0x1E00,
  36453. 'end': 0x1EFF
  36454. },
  36455. {
  36456. 'begin': 0x1F00,
  36457. 'end': 0x1FFF
  36458. },
  36459. {
  36460. 'begin': 0x2000,
  36461. 'end': 0x206F
  36462. },
  36463. {
  36464. 'begin': 0x2070,
  36465. 'end': 0x209F
  36466. },
  36467. {
  36468. 'begin': 0x20A0,
  36469. 'end': 0x20CF
  36470. },
  36471. {
  36472. 'begin': 0x20D0,
  36473. 'end': 0x20FF
  36474. },
  36475. {
  36476. 'begin': 0x2100,
  36477. 'end': 0x214F
  36478. },
  36479. {
  36480. 'begin': 0x2150,
  36481. 'end': 0x218F
  36482. },
  36483. {
  36484. 'begin': 0x2190,
  36485. 'end': 0x21FF
  36486. },
  36487. {
  36488. 'begin': 0x2200,
  36489. 'end': 0x22FF
  36490. },
  36491. {
  36492. 'begin': 0x2300,
  36493. 'end': 0x23FF
  36494. },
  36495. {
  36496. 'begin': 0x2400,
  36497. 'end': 0x243F
  36498. },
  36499. {
  36500. 'begin': 0x2440,
  36501. 'end': 0x245F
  36502. },
  36503. {
  36504. 'begin': 0x2460,
  36505. 'end': 0x24FF
  36506. },
  36507. {
  36508. 'begin': 0x2500,
  36509. 'end': 0x257F
  36510. },
  36511. {
  36512. 'begin': 0x2580,
  36513. 'end': 0x259F
  36514. },
  36515. {
  36516. 'begin': 0x25A0,
  36517. 'end': 0x25FF
  36518. },
  36519. {
  36520. 'begin': 0x2600,
  36521. 'end': 0x26FF
  36522. },
  36523. {
  36524. 'begin': 0x2700,
  36525. 'end': 0x27BF
  36526. },
  36527. {
  36528. 'begin': 0x3000,
  36529. 'end': 0x303F
  36530. },
  36531. {
  36532. 'begin': 0x3040,
  36533. 'end': 0x309F
  36534. },
  36535. {
  36536. 'begin': 0x30A0,
  36537. 'end': 0x30FF
  36538. },
  36539. {
  36540. 'begin': 0x3100,
  36541. 'end': 0x312F
  36542. },
  36543. {
  36544. 'begin': 0x3130,
  36545. 'end': 0x318F
  36546. },
  36547. {
  36548. 'begin': 0xA840,
  36549. 'end': 0xA87F
  36550. },
  36551. {
  36552. 'begin': 0x3200,
  36553. 'end': 0x32FF
  36554. },
  36555. {
  36556. 'begin': 0x3300,
  36557. 'end': 0x33FF
  36558. },
  36559. {
  36560. 'begin': 0xAC00,
  36561. 'end': 0xD7AF
  36562. },
  36563. {
  36564. 'begin': 0xD800,
  36565. 'end': 0xDFFF
  36566. },
  36567. {
  36568. 'begin': 0x10900,
  36569. 'end': 0x1091F
  36570. },
  36571. {
  36572. 'begin': 0x4E00,
  36573. 'end': 0x9FFF
  36574. },
  36575. {
  36576. 'begin': 0xE000,
  36577. 'end': 0xF8FF
  36578. },
  36579. {
  36580. 'begin': 0x31C0,
  36581. 'end': 0x31EF
  36582. },
  36583. {
  36584. 'begin': 0xFB00,
  36585. 'end': 0xFB4F
  36586. },
  36587. {
  36588. 'begin': 0xFB50,
  36589. 'end': 0xFDFF
  36590. },
  36591. {
  36592. 'begin': 0xFE20,
  36593. 'end': 0xFE2F
  36594. },
  36595. {
  36596. 'begin': 0xFE10,
  36597. 'end': 0xFE1F
  36598. },
  36599. {
  36600. 'begin': 0xFE50,
  36601. 'end': 0xFE6F
  36602. },
  36603. {
  36604. 'begin': 0xFE70,
  36605. 'end': 0xFEFF
  36606. },
  36607. {
  36608. 'begin': 0xFF00,
  36609. 'end': 0xFFEF
  36610. },
  36611. {
  36612. 'begin': 0xFFF0,
  36613. 'end': 0xFFFF
  36614. },
  36615. {
  36616. 'begin': 0x0F00,
  36617. 'end': 0x0FFF
  36618. },
  36619. {
  36620. 'begin': 0x0700,
  36621. 'end': 0x074F
  36622. },
  36623. {
  36624. 'begin': 0x0780,
  36625. 'end': 0x07BF
  36626. },
  36627. {
  36628. 'begin': 0x0D80,
  36629. 'end': 0x0DFF
  36630. },
  36631. {
  36632. 'begin': 0x1000,
  36633. 'end': 0x109F
  36634. },
  36635. {
  36636. 'begin': 0x1200,
  36637. 'end': 0x137F
  36638. },
  36639. {
  36640. 'begin': 0x13A0,
  36641. 'end': 0x13FF
  36642. },
  36643. {
  36644. 'begin': 0x1400,
  36645. 'end': 0x167F
  36646. },
  36647. {
  36648. 'begin': 0x1680,
  36649. 'end': 0x169F
  36650. },
  36651. {
  36652. 'begin': 0x16A0,
  36653. 'end': 0x16FF
  36654. },
  36655. {
  36656. 'begin': 0x1780,
  36657. 'end': 0x17FF
  36658. },
  36659. {
  36660. 'begin': 0x1800,
  36661. 'end': 0x18AF
  36662. },
  36663. {
  36664. 'begin': 0x2800,
  36665. 'end': 0x28FF
  36666. },
  36667. {
  36668. 'begin': 0xA000,
  36669. 'end': 0xA48F
  36670. },
  36671. {
  36672. 'begin': 0x1700,
  36673. 'end': 0x171F
  36674. },
  36675. {
  36676. 'begin': 0x10300,
  36677. 'end': 0x1032F
  36678. },
  36679. {
  36680. 'begin': 0x10330,
  36681. 'end': 0x1034F
  36682. },
  36683. {
  36684. 'begin': 0x10400,
  36685. 'end': 0x1044F
  36686. },
  36687. {
  36688. 'begin': 0x1D000,
  36689. 'end': 0x1D0FF
  36690. },
  36691. {
  36692. 'begin': 0x1D400,
  36693. 'end': 0x1D7FF
  36694. },
  36695. {
  36696. 'begin': 0xFF000,
  36697. 'end': 0xFFFFD
  36698. },
  36699. {
  36700. 'begin': 0xFE00,
  36701. 'end': 0xFE0F
  36702. },
  36703. {
  36704. 'begin': 0xE0000,
  36705. 'end': 0xE007F
  36706. },
  36707. {
  36708. 'begin': 0x1900,
  36709. 'end': 0x194F
  36710. },
  36711. {
  36712. 'begin': 0x1950,
  36713. 'end': 0x197F
  36714. },
  36715. {
  36716. 'begin': 0x1980,
  36717. 'end': 0x19DF
  36718. },
  36719. {
  36720. 'begin': 0x1A00,
  36721. 'end': 0x1A1F
  36722. },
  36723. {
  36724. 'begin': 0x2C00,
  36725. 'end': 0x2C5F
  36726. },
  36727. {
  36728. 'begin': 0x2D30,
  36729. 'end': 0x2D7F
  36730. },
  36731. {
  36732. 'begin': 0x4DC0,
  36733. 'end': 0x4DFF
  36734. },
  36735. {
  36736. 'begin': 0xA800,
  36737. 'end': 0xA82F
  36738. },
  36739. {
  36740. 'begin': 0x10000,
  36741. 'end': 0x1007F
  36742. },
  36743. {
  36744. 'begin': 0x10140,
  36745. 'end': 0x1018F
  36746. },
  36747. {
  36748. 'begin': 0x10380,
  36749. 'end': 0x1039F
  36750. },
  36751. {
  36752. 'begin': 0x103A0,
  36753. 'end': 0x103DF
  36754. },
  36755. {
  36756. 'begin': 0x10450,
  36757. 'end': 0x1047F
  36758. },
  36759. {
  36760. 'begin': 0x10480,
  36761. 'end': 0x104AF
  36762. },
  36763. {
  36764. 'begin': 0x10800,
  36765. 'end': 0x1083F
  36766. },
  36767. {
  36768. 'begin': 0x10A00,
  36769. 'end': 0x10A5F
  36770. },
  36771. {
  36772. 'begin': 0x1D300,
  36773. 'end': 0x1D35F
  36774. },
  36775. {
  36776. 'begin': 0x12000,
  36777. 'end': 0x123FF
  36778. },
  36779. {
  36780. 'begin': 0x1D360,
  36781. 'end': 0x1D37F
  36782. },
  36783. {
  36784. 'begin': 0x1B80,
  36785. 'end': 0x1BBF
  36786. },
  36787. {
  36788. 'begin': 0x1C00,
  36789. 'end': 0x1C4F
  36790. },
  36791. {
  36792. 'begin': 0x1C50,
  36793. 'end': 0x1C7F
  36794. },
  36795. {
  36796. 'begin': 0xA880,
  36797. 'end': 0xA8DF
  36798. },
  36799. {
  36800. 'begin': 0xA900,
  36801. 'end': 0xA92F
  36802. },
  36803. {
  36804. 'begin': 0xA930,
  36805. 'end': 0xA95F
  36806. },
  36807. {
  36808. 'begin': 0xAA00,
  36809. 'end': 0xAA5F
  36810. },
  36811. {
  36812. 'begin': 0x10190,
  36813. 'end': 0x101CF
  36814. },
  36815. {
  36816. 'begin': 0x101D0,
  36817. 'end': 0x101FF
  36818. },
  36819. {
  36820. 'begin': 0x102A0,
  36821. 'end': 0x102DF
  36822. },
  36823. {
  36824. 'begin': 0x1F030,
  36825. 'end': 0x1F09F
  36826. }
  36827. ];
  36828. function getUnicodeRangeFor(value) {
  36829. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36830. var range = UnicodeRanges[i];
  36831. if (value >= range.begin && value < range.end) {
  36832. return i;
  36833. }
  36834. }
  36835. return -1;
  36836. }
  36837. function isRTLRangeFor(value) {
  36838. var range = UnicodeRanges[13];
  36839. if (value >= range.begin && value < range.end) {
  36840. return true;
  36841. }
  36842. range = UnicodeRanges[11];
  36843. if (value >= range.begin && value < range.end) {
  36844. return true;
  36845. }
  36846. return false;
  36847. }
  36848. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36849. t['\u00A8'] = '\u0020\u0308';
  36850. t['\u00AF'] = '\u0020\u0304';
  36851. t['\u00B4'] = '\u0020\u0301';
  36852. t['\u00B5'] = '\u03BC';
  36853. t['\u00B8'] = '\u0020\u0327';
  36854. t['\u0132'] = '\u0049\u004A';
  36855. t['\u0133'] = '\u0069\u006A';
  36856. t['\u013F'] = '\u004C\u00B7';
  36857. t['\u0140'] = '\u006C\u00B7';
  36858. t['\u0149'] = '\u02BC\u006E';
  36859. t['\u017F'] = '\u0073';
  36860. t['\u01C4'] = '\u0044\u017D';
  36861. t['\u01C5'] = '\u0044\u017E';
  36862. t['\u01C6'] = '\u0064\u017E';
  36863. t['\u01C7'] = '\u004C\u004A';
  36864. t['\u01C8'] = '\u004C\u006A';
  36865. t['\u01C9'] = '\u006C\u006A';
  36866. t['\u01CA'] = '\u004E\u004A';
  36867. t['\u01CB'] = '\u004E\u006A';
  36868. t['\u01CC'] = '\u006E\u006A';
  36869. t['\u01F1'] = '\u0044\u005A';
  36870. t['\u01F2'] = '\u0044\u007A';
  36871. t['\u01F3'] = '\u0064\u007A';
  36872. t['\u02D8'] = '\u0020\u0306';
  36873. t['\u02D9'] = '\u0020\u0307';
  36874. t['\u02DA'] = '\u0020\u030A';
  36875. t['\u02DB'] = '\u0020\u0328';
  36876. t['\u02DC'] = '\u0020\u0303';
  36877. t['\u02DD'] = '\u0020\u030B';
  36878. t['\u037A'] = '\u0020\u0345';
  36879. t['\u0384'] = '\u0020\u0301';
  36880. t['\u03D0'] = '\u03B2';
  36881. t['\u03D1'] = '\u03B8';
  36882. t['\u03D2'] = '\u03A5';
  36883. t['\u03D5'] = '\u03C6';
  36884. t['\u03D6'] = '\u03C0';
  36885. t['\u03F0'] = '\u03BA';
  36886. t['\u03F1'] = '\u03C1';
  36887. t['\u03F2'] = '\u03C2';
  36888. t['\u03F4'] = '\u0398';
  36889. t['\u03F5'] = '\u03B5';
  36890. t['\u03F9'] = '\u03A3';
  36891. t['\u0587'] = '\u0565\u0582';
  36892. t['\u0675'] = '\u0627\u0674';
  36893. t['\u0676'] = '\u0648\u0674';
  36894. t['\u0677'] = '\u06C7\u0674';
  36895. t['\u0678'] = '\u064A\u0674';
  36896. t['\u0E33'] = '\u0E4D\u0E32';
  36897. t['\u0EB3'] = '\u0ECD\u0EB2';
  36898. t['\u0EDC'] = '\u0EAB\u0E99';
  36899. t['\u0EDD'] = '\u0EAB\u0EA1';
  36900. t['\u0F77'] = '\u0FB2\u0F81';
  36901. t['\u0F79'] = '\u0FB3\u0F81';
  36902. t['\u1E9A'] = '\u0061\u02BE';
  36903. t['\u1FBD'] = '\u0020\u0313';
  36904. t['\u1FBF'] = '\u0020\u0313';
  36905. t['\u1FC0'] = '\u0020\u0342';
  36906. t['\u1FFE'] = '\u0020\u0314';
  36907. t['\u2002'] = '\u0020';
  36908. t['\u2003'] = '\u0020';
  36909. t['\u2004'] = '\u0020';
  36910. t['\u2005'] = '\u0020';
  36911. t['\u2006'] = '\u0020';
  36912. t['\u2008'] = '\u0020';
  36913. t['\u2009'] = '\u0020';
  36914. t['\u200A'] = '\u0020';
  36915. t['\u2017'] = '\u0020\u0333';
  36916. t['\u2024'] = '\u002E';
  36917. t['\u2025'] = '\u002E\u002E';
  36918. t['\u2026'] = '\u002E\u002E\u002E';
  36919. t['\u2033'] = '\u2032\u2032';
  36920. t['\u2034'] = '\u2032\u2032\u2032';
  36921. t['\u2036'] = '\u2035\u2035';
  36922. t['\u2037'] = '\u2035\u2035\u2035';
  36923. t['\u203C'] = '\u0021\u0021';
  36924. t['\u203E'] = '\u0020\u0305';
  36925. t['\u2047'] = '\u003F\u003F';
  36926. t['\u2048'] = '\u003F\u0021';
  36927. t['\u2049'] = '\u0021\u003F';
  36928. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36929. t['\u205F'] = '\u0020';
  36930. t['\u20A8'] = '\u0052\u0073';
  36931. t['\u2100'] = '\u0061\u002F\u0063';
  36932. t['\u2101'] = '\u0061\u002F\u0073';
  36933. t['\u2103'] = '\u00B0\u0043';
  36934. t['\u2105'] = '\u0063\u002F\u006F';
  36935. t['\u2106'] = '\u0063\u002F\u0075';
  36936. t['\u2107'] = '\u0190';
  36937. t['\u2109'] = '\u00B0\u0046';
  36938. t['\u2116'] = '\u004E\u006F';
  36939. t['\u2121'] = '\u0054\u0045\u004C';
  36940. t['\u2135'] = '\u05D0';
  36941. t['\u2136'] = '\u05D1';
  36942. t['\u2137'] = '\u05D2';
  36943. t['\u2138'] = '\u05D3';
  36944. t['\u213B'] = '\u0046\u0041\u0058';
  36945. t['\u2160'] = '\u0049';
  36946. t['\u2161'] = '\u0049\u0049';
  36947. t['\u2162'] = '\u0049\u0049\u0049';
  36948. t['\u2163'] = '\u0049\u0056';
  36949. t['\u2164'] = '\u0056';
  36950. t['\u2165'] = '\u0056\u0049';
  36951. t['\u2166'] = '\u0056\u0049\u0049';
  36952. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36953. t['\u2168'] = '\u0049\u0058';
  36954. t['\u2169'] = '\u0058';
  36955. t['\u216A'] = '\u0058\u0049';
  36956. t['\u216B'] = '\u0058\u0049\u0049';
  36957. t['\u216C'] = '\u004C';
  36958. t['\u216D'] = '\u0043';
  36959. t['\u216E'] = '\u0044';
  36960. t['\u216F'] = '\u004D';
  36961. t['\u2170'] = '\u0069';
  36962. t['\u2171'] = '\u0069\u0069';
  36963. t['\u2172'] = '\u0069\u0069\u0069';
  36964. t['\u2173'] = '\u0069\u0076';
  36965. t['\u2174'] = '\u0076';
  36966. t['\u2175'] = '\u0076\u0069';
  36967. t['\u2176'] = '\u0076\u0069\u0069';
  36968. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36969. t['\u2178'] = '\u0069\u0078';
  36970. t['\u2179'] = '\u0078';
  36971. t['\u217A'] = '\u0078\u0069';
  36972. t['\u217B'] = '\u0078\u0069\u0069';
  36973. t['\u217C'] = '\u006C';
  36974. t['\u217D'] = '\u0063';
  36975. t['\u217E'] = '\u0064';
  36976. t['\u217F'] = '\u006D';
  36977. t['\u222C'] = '\u222B\u222B';
  36978. t['\u222D'] = '\u222B\u222B\u222B';
  36979. t['\u222F'] = '\u222E\u222E';
  36980. t['\u2230'] = '\u222E\u222E\u222E';
  36981. t['\u2474'] = '\u0028\u0031\u0029';
  36982. t['\u2475'] = '\u0028\u0032\u0029';
  36983. t['\u2476'] = '\u0028\u0033\u0029';
  36984. t['\u2477'] = '\u0028\u0034\u0029';
  36985. t['\u2478'] = '\u0028\u0035\u0029';
  36986. t['\u2479'] = '\u0028\u0036\u0029';
  36987. t['\u247A'] = '\u0028\u0037\u0029';
  36988. t['\u247B'] = '\u0028\u0038\u0029';
  36989. t['\u247C'] = '\u0028\u0039\u0029';
  36990. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36991. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36992. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36993. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36994. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36995. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36996. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36997. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36998. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36999. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37000. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37001. t['\u2488'] = '\u0031\u002E';
  37002. t['\u2489'] = '\u0032\u002E';
  37003. t['\u248A'] = '\u0033\u002E';
  37004. t['\u248B'] = '\u0034\u002E';
  37005. t['\u248C'] = '\u0035\u002E';
  37006. t['\u248D'] = '\u0036\u002E';
  37007. t['\u248E'] = '\u0037\u002E';
  37008. t['\u248F'] = '\u0038\u002E';
  37009. t['\u2490'] = '\u0039\u002E';
  37010. t['\u2491'] = '\u0031\u0030\u002E';
  37011. t['\u2492'] = '\u0031\u0031\u002E';
  37012. t['\u2493'] = '\u0031\u0032\u002E';
  37013. t['\u2494'] = '\u0031\u0033\u002E';
  37014. t['\u2495'] = '\u0031\u0034\u002E';
  37015. t['\u2496'] = '\u0031\u0035\u002E';
  37016. t['\u2497'] = '\u0031\u0036\u002E';
  37017. t['\u2498'] = '\u0031\u0037\u002E';
  37018. t['\u2499'] = '\u0031\u0038\u002E';
  37019. t['\u249A'] = '\u0031\u0039\u002E';
  37020. t['\u249B'] = '\u0032\u0030\u002E';
  37021. t['\u249C'] = '\u0028\u0061\u0029';
  37022. t['\u249D'] = '\u0028\u0062\u0029';
  37023. t['\u249E'] = '\u0028\u0063\u0029';
  37024. t['\u249F'] = '\u0028\u0064\u0029';
  37025. t['\u24A0'] = '\u0028\u0065\u0029';
  37026. t['\u24A1'] = '\u0028\u0066\u0029';
  37027. t['\u24A2'] = '\u0028\u0067\u0029';
  37028. t['\u24A3'] = '\u0028\u0068\u0029';
  37029. t['\u24A4'] = '\u0028\u0069\u0029';
  37030. t['\u24A5'] = '\u0028\u006A\u0029';
  37031. t['\u24A6'] = '\u0028\u006B\u0029';
  37032. t['\u24A7'] = '\u0028\u006C\u0029';
  37033. t['\u24A8'] = '\u0028\u006D\u0029';
  37034. t['\u24A9'] = '\u0028\u006E\u0029';
  37035. t['\u24AA'] = '\u0028\u006F\u0029';
  37036. t['\u24AB'] = '\u0028\u0070\u0029';
  37037. t['\u24AC'] = '\u0028\u0071\u0029';
  37038. t['\u24AD'] = '\u0028\u0072\u0029';
  37039. t['\u24AE'] = '\u0028\u0073\u0029';
  37040. t['\u24AF'] = '\u0028\u0074\u0029';
  37041. t['\u24B0'] = '\u0028\u0075\u0029';
  37042. t['\u24B1'] = '\u0028\u0076\u0029';
  37043. t['\u24B2'] = '\u0028\u0077\u0029';
  37044. t['\u24B3'] = '\u0028\u0078\u0029';
  37045. t['\u24B4'] = '\u0028\u0079\u0029';
  37046. t['\u24B5'] = '\u0028\u007A\u0029';
  37047. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37048. t['\u2A74'] = '\u003A\u003A\u003D';
  37049. t['\u2A75'] = '\u003D\u003D';
  37050. t['\u2A76'] = '\u003D\u003D\u003D';
  37051. t['\u2E9F'] = '\u6BCD';
  37052. t['\u2EF3'] = '\u9F9F';
  37053. t['\u2F00'] = '\u4E00';
  37054. t['\u2F01'] = '\u4E28';
  37055. t['\u2F02'] = '\u4E36';
  37056. t['\u2F03'] = '\u4E3F';
  37057. t['\u2F04'] = '\u4E59';
  37058. t['\u2F05'] = '\u4E85';
  37059. t['\u2F06'] = '\u4E8C';
  37060. t['\u2F07'] = '\u4EA0';
  37061. t['\u2F08'] = '\u4EBA';
  37062. t['\u2F09'] = '\u513F';
  37063. t['\u2F0A'] = '\u5165';
  37064. t['\u2F0B'] = '\u516B';
  37065. t['\u2F0C'] = '\u5182';
  37066. t['\u2F0D'] = '\u5196';
  37067. t['\u2F0E'] = '\u51AB';
  37068. t['\u2F0F'] = '\u51E0';
  37069. t['\u2F10'] = '\u51F5';
  37070. t['\u2F11'] = '\u5200';
  37071. t['\u2F12'] = '\u529B';
  37072. t['\u2F13'] = '\u52F9';
  37073. t['\u2F14'] = '\u5315';
  37074. t['\u2F15'] = '\u531A';
  37075. t['\u2F16'] = '\u5338';
  37076. t['\u2F17'] = '\u5341';
  37077. t['\u2F18'] = '\u535C';
  37078. t['\u2F19'] = '\u5369';
  37079. t['\u2F1A'] = '\u5382';
  37080. t['\u2F1B'] = '\u53B6';
  37081. t['\u2F1C'] = '\u53C8';
  37082. t['\u2F1D'] = '\u53E3';
  37083. t['\u2F1E'] = '\u56D7';
  37084. t['\u2F1F'] = '\u571F';
  37085. t['\u2F20'] = '\u58EB';
  37086. t['\u2F21'] = '\u5902';
  37087. t['\u2F22'] = '\u590A';
  37088. t['\u2F23'] = '\u5915';
  37089. t['\u2F24'] = '\u5927';
  37090. t['\u2F25'] = '\u5973';
  37091. t['\u2F26'] = '\u5B50';
  37092. t['\u2F27'] = '\u5B80';
  37093. t['\u2F28'] = '\u5BF8';
  37094. t['\u2F29'] = '\u5C0F';
  37095. t['\u2F2A'] = '\u5C22';
  37096. t['\u2F2B'] = '\u5C38';
  37097. t['\u2F2C'] = '\u5C6E';
  37098. t['\u2F2D'] = '\u5C71';
  37099. t['\u2F2E'] = '\u5DDB';
  37100. t['\u2F2F'] = '\u5DE5';
  37101. t['\u2F30'] = '\u5DF1';
  37102. t['\u2F31'] = '\u5DFE';
  37103. t['\u2F32'] = '\u5E72';
  37104. t['\u2F33'] = '\u5E7A';
  37105. t['\u2F34'] = '\u5E7F';
  37106. t['\u2F35'] = '\u5EF4';
  37107. t['\u2F36'] = '\u5EFE';
  37108. t['\u2F37'] = '\u5F0B';
  37109. t['\u2F38'] = '\u5F13';
  37110. t['\u2F39'] = '\u5F50';
  37111. t['\u2F3A'] = '\u5F61';
  37112. t['\u2F3B'] = '\u5F73';
  37113. t['\u2F3C'] = '\u5FC3';
  37114. t['\u2F3D'] = '\u6208';
  37115. t['\u2F3E'] = '\u6236';
  37116. t['\u2F3F'] = '\u624B';
  37117. t['\u2F40'] = '\u652F';
  37118. t['\u2F41'] = '\u6534';
  37119. t['\u2F42'] = '\u6587';
  37120. t['\u2F43'] = '\u6597';
  37121. t['\u2F44'] = '\u65A4';
  37122. t['\u2F45'] = '\u65B9';
  37123. t['\u2F46'] = '\u65E0';
  37124. t['\u2F47'] = '\u65E5';
  37125. t['\u2F48'] = '\u66F0';
  37126. t['\u2F49'] = '\u6708';
  37127. t['\u2F4A'] = '\u6728';
  37128. t['\u2F4B'] = '\u6B20';
  37129. t['\u2F4C'] = '\u6B62';
  37130. t['\u2F4D'] = '\u6B79';
  37131. t['\u2F4E'] = '\u6BB3';
  37132. t['\u2F4F'] = '\u6BCB';
  37133. t['\u2F50'] = '\u6BD4';
  37134. t['\u2F51'] = '\u6BDB';
  37135. t['\u2F52'] = '\u6C0F';
  37136. t['\u2F53'] = '\u6C14';
  37137. t['\u2F54'] = '\u6C34';
  37138. t['\u2F55'] = '\u706B';
  37139. t['\u2F56'] = '\u722A';
  37140. t['\u2F57'] = '\u7236';
  37141. t['\u2F58'] = '\u723B';
  37142. t['\u2F59'] = '\u723F';
  37143. t['\u2F5A'] = '\u7247';
  37144. t['\u2F5B'] = '\u7259';
  37145. t['\u2F5C'] = '\u725B';
  37146. t['\u2F5D'] = '\u72AC';
  37147. t['\u2F5E'] = '\u7384';
  37148. t['\u2F5F'] = '\u7389';
  37149. t['\u2F60'] = '\u74DC';
  37150. t['\u2F61'] = '\u74E6';
  37151. t['\u2F62'] = '\u7518';
  37152. t['\u2F63'] = '\u751F';
  37153. t['\u2F64'] = '\u7528';
  37154. t['\u2F65'] = '\u7530';
  37155. t['\u2F66'] = '\u758B';
  37156. t['\u2F67'] = '\u7592';
  37157. t['\u2F68'] = '\u7676';
  37158. t['\u2F69'] = '\u767D';
  37159. t['\u2F6A'] = '\u76AE';
  37160. t['\u2F6B'] = '\u76BF';
  37161. t['\u2F6C'] = '\u76EE';
  37162. t['\u2F6D'] = '\u77DB';
  37163. t['\u2F6E'] = '\u77E2';
  37164. t['\u2F6F'] = '\u77F3';
  37165. t['\u2F70'] = '\u793A';
  37166. t['\u2F71'] = '\u79B8';
  37167. t['\u2F72'] = '\u79BE';
  37168. t['\u2F73'] = '\u7A74';
  37169. t['\u2F74'] = '\u7ACB';
  37170. t['\u2F75'] = '\u7AF9';
  37171. t['\u2F76'] = '\u7C73';
  37172. t['\u2F77'] = '\u7CF8';
  37173. t['\u2F78'] = '\u7F36';
  37174. t['\u2F79'] = '\u7F51';
  37175. t['\u2F7A'] = '\u7F8A';
  37176. t['\u2F7B'] = '\u7FBD';
  37177. t['\u2F7C'] = '\u8001';
  37178. t['\u2F7D'] = '\u800C';
  37179. t['\u2F7E'] = '\u8012';
  37180. t['\u2F7F'] = '\u8033';
  37181. t['\u2F80'] = '\u807F';
  37182. t['\u2F81'] = '\u8089';
  37183. t['\u2F82'] = '\u81E3';
  37184. t['\u2F83'] = '\u81EA';
  37185. t['\u2F84'] = '\u81F3';
  37186. t['\u2F85'] = '\u81FC';
  37187. t['\u2F86'] = '\u820C';
  37188. t['\u2F87'] = '\u821B';
  37189. t['\u2F88'] = '\u821F';
  37190. t['\u2F89'] = '\u826E';
  37191. t['\u2F8A'] = '\u8272';
  37192. t['\u2F8B'] = '\u8278';
  37193. t['\u2F8C'] = '\u864D';
  37194. t['\u2F8D'] = '\u866B';
  37195. t['\u2F8E'] = '\u8840';
  37196. t['\u2F8F'] = '\u884C';
  37197. t['\u2F90'] = '\u8863';
  37198. t['\u2F91'] = '\u897E';
  37199. t['\u2F92'] = '\u898B';
  37200. t['\u2F93'] = '\u89D2';
  37201. t['\u2F94'] = '\u8A00';
  37202. t['\u2F95'] = '\u8C37';
  37203. t['\u2F96'] = '\u8C46';
  37204. t['\u2F97'] = '\u8C55';
  37205. t['\u2F98'] = '\u8C78';
  37206. t['\u2F99'] = '\u8C9D';
  37207. t['\u2F9A'] = '\u8D64';
  37208. t['\u2F9B'] = '\u8D70';
  37209. t['\u2F9C'] = '\u8DB3';
  37210. t['\u2F9D'] = '\u8EAB';
  37211. t['\u2F9E'] = '\u8ECA';
  37212. t['\u2F9F'] = '\u8F9B';
  37213. t['\u2FA0'] = '\u8FB0';
  37214. t['\u2FA1'] = '\u8FB5';
  37215. t['\u2FA2'] = '\u9091';
  37216. t['\u2FA3'] = '\u9149';
  37217. t['\u2FA4'] = '\u91C6';
  37218. t['\u2FA5'] = '\u91CC';
  37219. t['\u2FA6'] = '\u91D1';
  37220. t['\u2FA7'] = '\u9577';
  37221. t['\u2FA8'] = '\u9580';
  37222. t['\u2FA9'] = '\u961C';
  37223. t['\u2FAA'] = '\u96B6';
  37224. t['\u2FAB'] = '\u96B9';
  37225. t['\u2FAC'] = '\u96E8';
  37226. t['\u2FAD'] = '\u9751';
  37227. t['\u2FAE'] = '\u975E';
  37228. t['\u2FAF'] = '\u9762';
  37229. t['\u2FB0'] = '\u9769';
  37230. t['\u2FB1'] = '\u97CB';
  37231. t['\u2FB2'] = '\u97ED';
  37232. t['\u2FB3'] = '\u97F3';
  37233. t['\u2FB4'] = '\u9801';
  37234. t['\u2FB5'] = '\u98A8';
  37235. t['\u2FB6'] = '\u98DB';
  37236. t['\u2FB7'] = '\u98DF';
  37237. t['\u2FB8'] = '\u9996';
  37238. t['\u2FB9'] = '\u9999';
  37239. t['\u2FBA'] = '\u99AC';
  37240. t['\u2FBB'] = '\u9AA8';
  37241. t['\u2FBC'] = '\u9AD8';
  37242. t['\u2FBD'] = '\u9ADF';
  37243. t['\u2FBE'] = '\u9B25';
  37244. t['\u2FBF'] = '\u9B2F';
  37245. t['\u2FC0'] = '\u9B32';
  37246. t['\u2FC1'] = '\u9B3C';
  37247. t['\u2FC2'] = '\u9B5A';
  37248. t['\u2FC3'] = '\u9CE5';
  37249. t['\u2FC4'] = '\u9E75';
  37250. t['\u2FC5'] = '\u9E7F';
  37251. t['\u2FC6'] = '\u9EA5';
  37252. t['\u2FC7'] = '\u9EBB';
  37253. t['\u2FC8'] = '\u9EC3';
  37254. t['\u2FC9'] = '\u9ECD';
  37255. t['\u2FCA'] = '\u9ED1';
  37256. t['\u2FCB'] = '\u9EF9';
  37257. t['\u2FCC'] = '\u9EFD';
  37258. t['\u2FCD'] = '\u9F0E';
  37259. t['\u2FCE'] = '\u9F13';
  37260. t['\u2FCF'] = '\u9F20';
  37261. t['\u2FD0'] = '\u9F3B';
  37262. t['\u2FD1'] = '\u9F4A';
  37263. t['\u2FD2'] = '\u9F52';
  37264. t['\u2FD3'] = '\u9F8D';
  37265. t['\u2FD4'] = '\u9F9C';
  37266. t['\u2FD5'] = '\u9FA0';
  37267. t['\u3036'] = '\u3012';
  37268. t['\u3038'] = '\u5341';
  37269. t['\u3039'] = '\u5344';
  37270. t['\u303A'] = '\u5345';
  37271. t['\u309B'] = '\u0020\u3099';
  37272. t['\u309C'] = '\u0020\u309A';
  37273. t['\u3131'] = '\u1100';
  37274. t['\u3132'] = '\u1101';
  37275. t['\u3133'] = '\u11AA';
  37276. t['\u3134'] = '\u1102';
  37277. t['\u3135'] = '\u11AC';
  37278. t['\u3136'] = '\u11AD';
  37279. t['\u3137'] = '\u1103';
  37280. t['\u3138'] = '\u1104';
  37281. t['\u3139'] = '\u1105';
  37282. t['\u313A'] = '\u11B0';
  37283. t['\u313B'] = '\u11B1';
  37284. t['\u313C'] = '\u11B2';
  37285. t['\u313D'] = '\u11B3';
  37286. t['\u313E'] = '\u11B4';
  37287. t['\u313F'] = '\u11B5';
  37288. t['\u3140'] = '\u111A';
  37289. t['\u3141'] = '\u1106';
  37290. t['\u3142'] = '\u1107';
  37291. t['\u3143'] = '\u1108';
  37292. t['\u3144'] = '\u1121';
  37293. t['\u3145'] = '\u1109';
  37294. t['\u3146'] = '\u110A';
  37295. t['\u3147'] = '\u110B';
  37296. t['\u3148'] = '\u110C';
  37297. t['\u3149'] = '\u110D';
  37298. t['\u314A'] = '\u110E';
  37299. t['\u314B'] = '\u110F';
  37300. t['\u314C'] = '\u1110';
  37301. t['\u314D'] = '\u1111';
  37302. t['\u314E'] = '\u1112';
  37303. t['\u314F'] = '\u1161';
  37304. t['\u3150'] = '\u1162';
  37305. t['\u3151'] = '\u1163';
  37306. t['\u3152'] = '\u1164';
  37307. t['\u3153'] = '\u1165';
  37308. t['\u3154'] = '\u1166';
  37309. t['\u3155'] = '\u1167';
  37310. t['\u3156'] = '\u1168';
  37311. t['\u3157'] = '\u1169';
  37312. t['\u3158'] = '\u116A';
  37313. t['\u3159'] = '\u116B';
  37314. t['\u315A'] = '\u116C';
  37315. t['\u315B'] = '\u116D';
  37316. t['\u315C'] = '\u116E';
  37317. t['\u315D'] = '\u116F';
  37318. t['\u315E'] = '\u1170';
  37319. t['\u315F'] = '\u1171';
  37320. t['\u3160'] = '\u1172';
  37321. t['\u3161'] = '\u1173';
  37322. t['\u3162'] = '\u1174';
  37323. t['\u3163'] = '\u1175';
  37324. t['\u3164'] = '\u1160';
  37325. t['\u3165'] = '\u1114';
  37326. t['\u3166'] = '\u1115';
  37327. t['\u3167'] = '\u11C7';
  37328. t['\u3168'] = '\u11C8';
  37329. t['\u3169'] = '\u11CC';
  37330. t['\u316A'] = '\u11CE';
  37331. t['\u316B'] = '\u11D3';
  37332. t['\u316C'] = '\u11D7';
  37333. t['\u316D'] = '\u11D9';
  37334. t['\u316E'] = '\u111C';
  37335. t['\u316F'] = '\u11DD';
  37336. t['\u3170'] = '\u11DF';
  37337. t['\u3171'] = '\u111D';
  37338. t['\u3172'] = '\u111E';
  37339. t['\u3173'] = '\u1120';
  37340. t['\u3174'] = '\u1122';
  37341. t['\u3175'] = '\u1123';
  37342. t['\u3176'] = '\u1127';
  37343. t['\u3177'] = '\u1129';
  37344. t['\u3178'] = '\u112B';
  37345. t['\u3179'] = '\u112C';
  37346. t['\u317A'] = '\u112D';
  37347. t['\u317B'] = '\u112E';
  37348. t['\u317C'] = '\u112F';
  37349. t['\u317D'] = '\u1132';
  37350. t['\u317E'] = '\u1136';
  37351. t['\u317F'] = '\u1140';
  37352. t['\u3180'] = '\u1147';
  37353. t['\u3181'] = '\u114C';
  37354. t['\u3182'] = '\u11F1';
  37355. t['\u3183'] = '\u11F2';
  37356. t['\u3184'] = '\u1157';
  37357. t['\u3185'] = '\u1158';
  37358. t['\u3186'] = '\u1159';
  37359. t['\u3187'] = '\u1184';
  37360. t['\u3188'] = '\u1185';
  37361. t['\u3189'] = '\u1188';
  37362. t['\u318A'] = '\u1191';
  37363. t['\u318B'] = '\u1192';
  37364. t['\u318C'] = '\u1194';
  37365. t['\u318D'] = '\u119E';
  37366. t['\u318E'] = '\u11A1';
  37367. t['\u3200'] = '\u0028\u1100\u0029';
  37368. t['\u3201'] = '\u0028\u1102\u0029';
  37369. t['\u3202'] = '\u0028\u1103\u0029';
  37370. t['\u3203'] = '\u0028\u1105\u0029';
  37371. t['\u3204'] = '\u0028\u1106\u0029';
  37372. t['\u3205'] = '\u0028\u1107\u0029';
  37373. t['\u3206'] = '\u0028\u1109\u0029';
  37374. t['\u3207'] = '\u0028\u110B\u0029';
  37375. t['\u3208'] = '\u0028\u110C\u0029';
  37376. t['\u3209'] = '\u0028\u110E\u0029';
  37377. t['\u320A'] = '\u0028\u110F\u0029';
  37378. t['\u320B'] = '\u0028\u1110\u0029';
  37379. t['\u320C'] = '\u0028\u1111\u0029';
  37380. t['\u320D'] = '\u0028\u1112\u0029';
  37381. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37382. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37383. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37384. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37385. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37386. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37387. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37388. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37389. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37390. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37391. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37392. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37393. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37394. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37395. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37396. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37397. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37398. t['\u3220'] = '\u0028\u4E00\u0029';
  37399. t['\u3221'] = '\u0028\u4E8C\u0029';
  37400. t['\u3222'] = '\u0028\u4E09\u0029';
  37401. t['\u3223'] = '\u0028\u56DB\u0029';
  37402. t['\u3224'] = '\u0028\u4E94\u0029';
  37403. t['\u3225'] = '\u0028\u516D\u0029';
  37404. t['\u3226'] = '\u0028\u4E03\u0029';
  37405. t['\u3227'] = '\u0028\u516B\u0029';
  37406. t['\u3228'] = '\u0028\u4E5D\u0029';
  37407. t['\u3229'] = '\u0028\u5341\u0029';
  37408. t['\u322A'] = '\u0028\u6708\u0029';
  37409. t['\u322B'] = '\u0028\u706B\u0029';
  37410. t['\u322C'] = '\u0028\u6C34\u0029';
  37411. t['\u322D'] = '\u0028\u6728\u0029';
  37412. t['\u322E'] = '\u0028\u91D1\u0029';
  37413. t['\u322F'] = '\u0028\u571F\u0029';
  37414. t['\u3230'] = '\u0028\u65E5\u0029';
  37415. t['\u3231'] = '\u0028\u682A\u0029';
  37416. t['\u3232'] = '\u0028\u6709\u0029';
  37417. t['\u3233'] = '\u0028\u793E\u0029';
  37418. t['\u3234'] = '\u0028\u540D\u0029';
  37419. t['\u3235'] = '\u0028\u7279\u0029';
  37420. t['\u3236'] = '\u0028\u8CA1\u0029';
  37421. t['\u3237'] = '\u0028\u795D\u0029';
  37422. t['\u3238'] = '\u0028\u52B4\u0029';
  37423. t['\u3239'] = '\u0028\u4EE3\u0029';
  37424. t['\u323A'] = '\u0028\u547C\u0029';
  37425. t['\u323B'] = '\u0028\u5B66\u0029';
  37426. t['\u323C'] = '\u0028\u76E3\u0029';
  37427. t['\u323D'] = '\u0028\u4F01\u0029';
  37428. t['\u323E'] = '\u0028\u8CC7\u0029';
  37429. t['\u323F'] = '\u0028\u5354\u0029';
  37430. t['\u3240'] = '\u0028\u796D\u0029';
  37431. t['\u3241'] = '\u0028\u4F11\u0029';
  37432. t['\u3242'] = '\u0028\u81EA\u0029';
  37433. t['\u3243'] = '\u0028\u81F3\u0029';
  37434. t['\u32C0'] = '\u0031\u6708';
  37435. t['\u32C1'] = '\u0032\u6708';
  37436. t['\u32C2'] = '\u0033\u6708';
  37437. t['\u32C3'] = '\u0034\u6708';
  37438. t['\u32C4'] = '\u0035\u6708';
  37439. t['\u32C5'] = '\u0036\u6708';
  37440. t['\u32C6'] = '\u0037\u6708';
  37441. t['\u32C7'] = '\u0038\u6708';
  37442. t['\u32C8'] = '\u0039\u6708';
  37443. t['\u32C9'] = '\u0031\u0030\u6708';
  37444. t['\u32CA'] = '\u0031\u0031\u6708';
  37445. t['\u32CB'] = '\u0031\u0032\u6708';
  37446. t['\u3358'] = '\u0030\u70B9';
  37447. t['\u3359'] = '\u0031\u70B9';
  37448. t['\u335A'] = '\u0032\u70B9';
  37449. t['\u335B'] = '\u0033\u70B9';
  37450. t['\u335C'] = '\u0034\u70B9';
  37451. t['\u335D'] = '\u0035\u70B9';
  37452. t['\u335E'] = '\u0036\u70B9';
  37453. t['\u335F'] = '\u0037\u70B9';
  37454. t['\u3360'] = '\u0038\u70B9';
  37455. t['\u3361'] = '\u0039\u70B9';
  37456. t['\u3362'] = '\u0031\u0030\u70B9';
  37457. t['\u3363'] = '\u0031\u0031\u70B9';
  37458. t['\u3364'] = '\u0031\u0032\u70B9';
  37459. t['\u3365'] = '\u0031\u0033\u70B9';
  37460. t['\u3366'] = '\u0031\u0034\u70B9';
  37461. t['\u3367'] = '\u0031\u0035\u70B9';
  37462. t['\u3368'] = '\u0031\u0036\u70B9';
  37463. t['\u3369'] = '\u0031\u0037\u70B9';
  37464. t['\u336A'] = '\u0031\u0038\u70B9';
  37465. t['\u336B'] = '\u0031\u0039\u70B9';
  37466. t['\u336C'] = '\u0032\u0030\u70B9';
  37467. t['\u336D'] = '\u0032\u0031\u70B9';
  37468. t['\u336E'] = '\u0032\u0032\u70B9';
  37469. t['\u336F'] = '\u0032\u0033\u70B9';
  37470. t['\u3370'] = '\u0032\u0034\u70B9';
  37471. t['\u33E0'] = '\u0031\u65E5';
  37472. t['\u33E1'] = '\u0032\u65E5';
  37473. t['\u33E2'] = '\u0033\u65E5';
  37474. t['\u33E3'] = '\u0034\u65E5';
  37475. t['\u33E4'] = '\u0035\u65E5';
  37476. t['\u33E5'] = '\u0036\u65E5';
  37477. t['\u33E6'] = '\u0037\u65E5';
  37478. t['\u33E7'] = '\u0038\u65E5';
  37479. t['\u33E8'] = '\u0039\u65E5';
  37480. t['\u33E9'] = '\u0031\u0030\u65E5';
  37481. t['\u33EA'] = '\u0031\u0031\u65E5';
  37482. t['\u33EB'] = '\u0031\u0032\u65E5';
  37483. t['\u33EC'] = '\u0031\u0033\u65E5';
  37484. t['\u33ED'] = '\u0031\u0034\u65E5';
  37485. t['\u33EE'] = '\u0031\u0035\u65E5';
  37486. t['\u33EF'] = '\u0031\u0036\u65E5';
  37487. t['\u33F0'] = '\u0031\u0037\u65E5';
  37488. t['\u33F1'] = '\u0031\u0038\u65E5';
  37489. t['\u33F2'] = '\u0031\u0039\u65E5';
  37490. t['\u33F3'] = '\u0032\u0030\u65E5';
  37491. t['\u33F4'] = '\u0032\u0031\u65E5';
  37492. t['\u33F5'] = '\u0032\u0032\u65E5';
  37493. t['\u33F6'] = '\u0032\u0033\u65E5';
  37494. t['\u33F7'] = '\u0032\u0034\u65E5';
  37495. t['\u33F8'] = '\u0032\u0035\u65E5';
  37496. t['\u33F9'] = '\u0032\u0036\u65E5';
  37497. t['\u33FA'] = '\u0032\u0037\u65E5';
  37498. t['\u33FB'] = '\u0032\u0038\u65E5';
  37499. t['\u33FC'] = '\u0032\u0039\u65E5';
  37500. t['\u33FD'] = '\u0033\u0030\u65E5';
  37501. t['\u33FE'] = '\u0033\u0031\u65E5';
  37502. t['\uFB00'] = '\u0066\u0066';
  37503. t['\uFB01'] = '\u0066\u0069';
  37504. t['\uFB02'] = '\u0066\u006C';
  37505. t['\uFB03'] = '\u0066\u0066\u0069';
  37506. t['\uFB04'] = '\u0066\u0066\u006C';
  37507. t['\uFB05'] = '\u017F\u0074';
  37508. t['\uFB06'] = '\u0073\u0074';
  37509. t['\uFB13'] = '\u0574\u0576';
  37510. t['\uFB14'] = '\u0574\u0565';
  37511. t['\uFB15'] = '\u0574\u056B';
  37512. t['\uFB16'] = '\u057E\u0576';
  37513. t['\uFB17'] = '\u0574\u056D';
  37514. t['\uFB4F'] = '\u05D0\u05DC';
  37515. t['\uFB50'] = '\u0671';
  37516. t['\uFB51'] = '\u0671';
  37517. t['\uFB52'] = '\u067B';
  37518. t['\uFB53'] = '\u067B';
  37519. t['\uFB54'] = '\u067B';
  37520. t['\uFB55'] = '\u067B';
  37521. t['\uFB56'] = '\u067E';
  37522. t['\uFB57'] = '\u067E';
  37523. t['\uFB58'] = '\u067E';
  37524. t['\uFB59'] = '\u067E';
  37525. t['\uFB5A'] = '\u0680';
  37526. t['\uFB5B'] = '\u0680';
  37527. t['\uFB5C'] = '\u0680';
  37528. t['\uFB5D'] = '\u0680';
  37529. t['\uFB5E'] = '\u067A';
  37530. t['\uFB5F'] = '\u067A';
  37531. t['\uFB60'] = '\u067A';
  37532. t['\uFB61'] = '\u067A';
  37533. t['\uFB62'] = '\u067F';
  37534. t['\uFB63'] = '\u067F';
  37535. t['\uFB64'] = '\u067F';
  37536. t['\uFB65'] = '\u067F';
  37537. t['\uFB66'] = '\u0679';
  37538. t['\uFB67'] = '\u0679';
  37539. t['\uFB68'] = '\u0679';
  37540. t['\uFB69'] = '\u0679';
  37541. t['\uFB6A'] = '\u06A4';
  37542. t['\uFB6B'] = '\u06A4';
  37543. t['\uFB6C'] = '\u06A4';
  37544. t['\uFB6D'] = '\u06A4';
  37545. t['\uFB6E'] = '\u06A6';
  37546. t['\uFB6F'] = '\u06A6';
  37547. t['\uFB70'] = '\u06A6';
  37548. t['\uFB71'] = '\u06A6';
  37549. t['\uFB72'] = '\u0684';
  37550. t['\uFB73'] = '\u0684';
  37551. t['\uFB74'] = '\u0684';
  37552. t['\uFB75'] = '\u0684';
  37553. t['\uFB76'] = '\u0683';
  37554. t['\uFB77'] = '\u0683';
  37555. t['\uFB78'] = '\u0683';
  37556. t['\uFB79'] = '\u0683';
  37557. t['\uFB7A'] = '\u0686';
  37558. t['\uFB7B'] = '\u0686';
  37559. t['\uFB7C'] = '\u0686';
  37560. t['\uFB7D'] = '\u0686';
  37561. t['\uFB7E'] = '\u0687';
  37562. t['\uFB7F'] = '\u0687';
  37563. t['\uFB80'] = '\u0687';
  37564. t['\uFB81'] = '\u0687';
  37565. t['\uFB82'] = '\u068D';
  37566. t['\uFB83'] = '\u068D';
  37567. t['\uFB84'] = '\u068C';
  37568. t['\uFB85'] = '\u068C';
  37569. t['\uFB86'] = '\u068E';
  37570. t['\uFB87'] = '\u068E';
  37571. t['\uFB88'] = '\u0688';
  37572. t['\uFB89'] = '\u0688';
  37573. t['\uFB8A'] = '\u0698';
  37574. t['\uFB8B'] = '\u0698';
  37575. t['\uFB8C'] = '\u0691';
  37576. t['\uFB8D'] = '\u0691';
  37577. t['\uFB8E'] = '\u06A9';
  37578. t['\uFB8F'] = '\u06A9';
  37579. t['\uFB90'] = '\u06A9';
  37580. t['\uFB91'] = '\u06A9';
  37581. t['\uFB92'] = '\u06AF';
  37582. t['\uFB93'] = '\u06AF';
  37583. t['\uFB94'] = '\u06AF';
  37584. t['\uFB95'] = '\u06AF';
  37585. t['\uFB96'] = '\u06B3';
  37586. t['\uFB97'] = '\u06B3';
  37587. t['\uFB98'] = '\u06B3';
  37588. t['\uFB99'] = '\u06B3';
  37589. t['\uFB9A'] = '\u06B1';
  37590. t['\uFB9B'] = '\u06B1';
  37591. t['\uFB9C'] = '\u06B1';
  37592. t['\uFB9D'] = '\u06B1';
  37593. t['\uFB9E'] = '\u06BA';
  37594. t['\uFB9F'] = '\u06BA';
  37595. t['\uFBA0'] = '\u06BB';
  37596. t['\uFBA1'] = '\u06BB';
  37597. t['\uFBA2'] = '\u06BB';
  37598. t['\uFBA3'] = '\u06BB';
  37599. t['\uFBA4'] = '\u06C0';
  37600. t['\uFBA5'] = '\u06C0';
  37601. t['\uFBA6'] = '\u06C1';
  37602. t['\uFBA7'] = '\u06C1';
  37603. t['\uFBA8'] = '\u06C1';
  37604. t['\uFBA9'] = '\u06C1';
  37605. t['\uFBAA'] = '\u06BE';
  37606. t['\uFBAB'] = '\u06BE';
  37607. t['\uFBAC'] = '\u06BE';
  37608. t['\uFBAD'] = '\u06BE';
  37609. t['\uFBAE'] = '\u06D2';
  37610. t['\uFBAF'] = '\u06D2';
  37611. t['\uFBB0'] = '\u06D3';
  37612. t['\uFBB1'] = '\u06D3';
  37613. t['\uFBD3'] = '\u06AD';
  37614. t['\uFBD4'] = '\u06AD';
  37615. t['\uFBD5'] = '\u06AD';
  37616. t['\uFBD6'] = '\u06AD';
  37617. t['\uFBD7'] = '\u06C7';
  37618. t['\uFBD8'] = '\u06C7';
  37619. t['\uFBD9'] = '\u06C6';
  37620. t['\uFBDA'] = '\u06C6';
  37621. t['\uFBDB'] = '\u06C8';
  37622. t['\uFBDC'] = '\u06C8';
  37623. t['\uFBDD'] = '\u0677';
  37624. t['\uFBDE'] = '\u06CB';
  37625. t['\uFBDF'] = '\u06CB';
  37626. t['\uFBE0'] = '\u06C5';
  37627. t['\uFBE1'] = '\u06C5';
  37628. t['\uFBE2'] = '\u06C9';
  37629. t['\uFBE3'] = '\u06C9';
  37630. t['\uFBE4'] = '\u06D0';
  37631. t['\uFBE5'] = '\u06D0';
  37632. t['\uFBE6'] = '\u06D0';
  37633. t['\uFBE7'] = '\u06D0';
  37634. t['\uFBE8'] = '\u0649';
  37635. t['\uFBE9'] = '\u0649';
  37636. t['\uFBEA'] = '\u0626\u0627';
  37637. t['\uFBEB'] = '\u0626\u0627';
  37638. t['\uFBEC'] = '\u0626\u06D5';
  37639. t['\uFBED'] = '\u0626\u06D5';
  37640. t['\uFBEE'] = '\u0626\u0648';
  37641. t['\uFBEF'] = '\u0626\u0648';
  37642. t['\uFBF0'] = '\u0626\u06C7';
  37643. t['\uFBF1'] = '\u0626\u06C7';
  37644. t['\uFBF2'] = '\u0626\u06C6';
  37645. t['\uFBF3'] = '\u0626\u06C6';
  37646. t['\uFBF4'] = '\u0626\u06C8';
  37647. t['\uFBF5'] = '\u0626\u06C8';
  37648. t['\uFBF6'] = '\u0626\u06D0';
  37649. t['\uFBF7'] = '\u0626\u06D0';
  37650. t['\uFBF8'] = '\u0626\u06D0';
  37651. t['\uFBF9'] = '\u0626\u0649';
  37652. t['\uFBFA'] = '\u0626\u0649';
  37653. t['\uFBFB'] = '\u0626\u0649';
  37654. t['\uFBFC'] = '\u06CC';
  37655. t['\uFBFD'] = '\u06CC';
  37656. t['\uFBFE'] = '\u06CC';
  37657. t['\uFBFF'] = '\u06CC';
  37658. t['\uFC00'] = '\u0626\u062C';
  37659. t['\uFC01'] = '\u0626\u062D';
  37660. t['\uFC02'] = '\u0626\u0645';
  37661. t['\uFC03'] = '\u0626\u0649';
  37662. t['\uFC04'] = '\u0626\u064A';
  37663. t['\uFC05'] = '\u0628\u062C';
  37664. t['\uFC06'] = '\u0628\u062D';
  37665. t['\uFC07'] = '\u0628\u062E';
  37666. t['\uFC08'] = '\u0628\u0645';
  37667. t['\uFC09'] = '\u0628\u0649';
  37668. t['\uFC0A'] = '\u0628\u064A';
  37669. t['\uFC0B'] = '\u062A\u062C';
  37670. t['\uFC0C'] = '\u062A\u062D';
  37671. t['\uFC0D'] = '\u062A\u062E';
  37672. t['\uFC0E'] = '\u062A\u0645';
  37673. t['\uFC0F'] = '\u062A\u0649';
  37674. t['\uFC10'] = '\u062A\u064A';
  37675. t['\uFC11'] = '\u062B\u062C';
  37676. t['\uFC12'] = '\u062B\u0645';
  37677. t['\uFC13'] = '\u062B\u0649';
  37678. t['\uFC14'] = '\u062B\u064A';
  37679. t['\uFC15'] = '\u062C\u062D';
  37680. t['\uFC16'] = '\u062C\u0645';
  37681. t['\uFC17'] = '\u062D\u062C';
  37682. t['\uFC18'] = '\u062D\u0645';
  37683. t['\uFC19'] = '\u062E\u062C';
  37684. t['\uFC1A'] = '\u062E\u062D';
  37685. t['\uFC1B'] = '\u062E\u0645';
  37686. t['\uFC1C'] = '\u0633\u062C';
  37687. t['\uFC1D'] = '\u0633\u062D';
  37688. t['\uFC1E'] = '\u0633\u062E';
  37689. t['\uFC1F'] = '\u0633\u0645';
  37690. t['\uFC20'] = '\u0635\u062D';
  37691. t['\uFC21'] = '\u0635\u0645';
  37692. t['\uFC22'] = '\u0636\u062C';
  37693. t['\uFC23'] = '\u0636\u062D';
  37694. t['\uFC24'] = '\u0636\u062E';
  37695. t['\uFC25'] = '\u0636\u0645';
  37696. t['\uFC26'] = '\u0637\u062D';
  37697. t['\uFC27'] = '\u0637\u0645';
  37698. t['\uFC28'] = '\u0638\u0645';
  37699. t['\uFC29'] = '\u0639\u062C';
  37700. t['\uFC2A'] = '\u0639\u0645';
  37701. t['\uFC2B'] = '\u063A\u062C';
  37702. t['\uFC2C'] = '\u063A\u0645';
  37703. t['\uFC2D'] = '\u0641\u062C';
  37704. t['\uFC2E'] = '\u0641\u062D';
  37705. t['\uFC2F'] = '\u0641\u062E';
  37706. t['\uFC30'] = '\u0641\u0645';
  37707. t['\uFC31'] = '\u0641\u0649';
  37708. t['\uFC32'] = '\u0641\u064A';
  37709. t['\uFC33'] = '\u0642\u062D';
  37710. t['\uFC34'] = '\u0642\u0645';
  37711. t['\uFC35'] = '\u0642\u0649';
  37712. t['\uFC36'] = '\u0642\u064A';
  37713. t['\uFC37'] = '\u0643\u0627';
  37714. t['\uFC38'] = '\u0643\u062C';
  37715. t['\uFC39'] = '\u0643\u062D';
  37716. t['\uFC3A'] = '\u0643\u062E';
  37717. t['\uFC3B'] = '\u0643\u0644';
  37718. t['\uFC3C'] = '\u0643\u0645';
  37719. t['\uFC3D'] = '\u0643\u0649';
  37720. t['\uFC3E'] = '\u0643\u064A';
  37721. t['\uFC3F'] = '\u0644\u062C';
  37722. t['\uFC40'] = '\u0644\u062D';
  37723. t['\uFC41'] = '\u0644\u062E';
  37724. t['\uFC42'] = '\u0644\u0645';
  37725. t['\uFC43'] = '\u0644\u0649';
  37726. t['\uFC44'] = '\u0644\u064A';
  37727. t['\uFC45'] = '\u0645\u062C';
  37728. t['\uFC46'] = '\u0645\u062D';
  37729. t['\uFC47'] = '\u0645\u062E';
  37730. t['\uFC48'] = '\u0645\u0645';
  37731. t['\uFC49'] = '\u0645\u0649';
  37732. t['\uFC4A'] = '\u0645\u064A';
  37733. t['\uFC4B'] = '\u0646\u062C';
  37734. t['\uFC4C'] = '\u0646\u062D';
  37735. t['\uFC4D'] = '\u0646\u062E';
  37736. t['\uFC4E'] = '\u0646\u0645';
  37737. t['\uFC4F'] = '\u0646\u0649';
  37738. t['\uFC50'] = '\u0646\u064A';
  37739. t['\uFC51'] = '\u0647\u062C';
  37740. t['\uFC52'] = '\u0647\u0645';
  37741. t['\uFC53'] = '\u0647\u0649';
  37742. t['\uFC54'] = '\u0647\u064A';
  37743. t['\uFC55'] = '\u064A\u062C';
  37744. t['\uFC56'] = '\u064A\u062D';
  37745. t['\uFC57'] = '\u064A\u062E';
  37746. t['\uFC58'] = '\u064A\u0645';
  37747. t['\uFC59'] = '\u064A\u0649';
  37748. t['\uFC5A'] = '\u064A\u064A';
  37749. t['\uFC5B'] = '\u0630\u0670';
  37750. t['\uFC5C'] = '\u0631\u0670';
  37751. t['\uFC5D'] = '\u0649\u0670';
  37752. t['\uFC5E'] = '\u0020\u064C\u0651';
  37753. t['\uFC5F'] = '\u0020\u064D\u0651';
  37754. t['\uFC60'] = '\u0020\u064E\u0651';
  37755. t['\uFC61'] = '\u0020\u064F\u0651';
  37756. t['\uFC62'] = '\u0020\u0650\u0651';
  37757. t['\uFC63'] = '\u0020\u0651\u0670';
  37758. t['\uFC64'] = '\u0626\u0631';
  37759. t['\uFC65'] = '\u0626\u0632';
  37760. t['\uFC66'] = '\u0626\u0645';
  37761. t['\uFC67'] = '\u0626\u0646';
  37762. t['\uFC68'] = '\u0626\u0649';
  37763. t['\uFC69'] = '\u0626\u064A';
  37764. t['\uFC6A'] = '\u0628\u0631';
  37765. t['\uFC6B'] = '\u0628\u0632';
  37766. t['\uFC6C'] = '\u0628\u0645';
  37767. t['\uFC6D'] = '\u0628\u0646';
  37768. t['\uFC6E'] = '\u0628\u0649';
  37769. t['\uFC6F'] = '\u0628\u064A';
  37770. t['\uFC70'] = '\u062A\u0631';
  37771. t['\uFC71'] = '\u062A\u0632';
  37772. t['\uFC72'] = '\u062A\u0645';
  37773. t['\uFC73'] = '\u062A\u0646';
  37774. t['\uFC74'] = '\u062A\u0649';
  37775. t['\uFC75'] = '\u062A\u064A';
  37776. t['\uFC76'] = '\u062B\u0631';
  37777. t['\uFC77'] = '\u062B\u0632';
  37778. t['\uFC78'] = '\u062B\u0645';
  37779. t['\uFC79'] = '\u062B\u0646';
  37780. t['\uFC7A'] = '\u062B\u0649';
  37781. t['\uFC7B'] = '\u062B\u064A';
  37782. t['\uFC7C'] = '\u0641\u0649';
  37783. t['\uFC7D'] = '\u0641\u064A';
  37784. t['\uFC7E'] = '\u0642\u0649';
  37785. t['\uFC7F'] = '\u0642\u064A';
  37786. t['\uFC80'] = '\u0643\u0627';
  37787. t['\uFC81'] = '\u0643\u0644';
  37788. t['\uFC82'] = '\u0643\u0645';
  37789. t['\uFC83'] = '\u0643\u0649';
  37790. t['\uFC84'] = '\u0643\u064A';
  37791. t['\uFC85'] = '\u0644\u0645';
  37792. t['\uFC86'] = '\u0644\u0649';
  37793. t['\uFC87'] = '\u0644\u064A';
  37794. t['\uFC88'] = '\u0645\u0627';
  37795. t['\uFC89'] = '\u0645\u0645';
  37796. t['\uFC8A'] = '\u0646\u0631';
  37797. t['\uFC8B'] = '\u0646\u0632';
  37798. t['\uFC8C'] = '\u0646\u0645';
  37799. t['\uFC8D'] = '\u0646\u0646';
  37800. t['\uFC8E'] = '\u0646\u0649';
  37801. t['\uFC8F'] = '\u0646\u064A';
  37802. t['\uFC90'] = '\u0649\u0670';
  37803. t['\uFC91'] = '\u064A\u0631';
  37804. t['\uFC92'] = '\u064A\u0632';
  37805. t['\uFC93'] = '\u064A\u0645';
  37806. t['\uFC94'] = '\u064A\u0646';
  37807. t['\uFC95'] = '\u064A\u0649';
  37808. t['\uFC96'] = '\u064A\u064A';
  37809. t['\uFC97'] = '\u0626\u062C';
  37810. t['\uFC98'] = '\u0626\u062D';
  37811. t['\uFC99'] = '\u0626\u062E';
  37812. t['\uFC9A'] = '\u0626\u0645';
  37813. t['\uFC9B'] = '\u0626\u0647';
  37814. t['\uFC9C'] = '\u0628\u062C';
  37815. t['\uFC9D'] = '\u0628\u062D';
  37816. t['\uFC9E'] = '\u0628\u062E';
  37817. t['\uFC9F'] = '\u0628\u0645';
  37818. t['\uFCA0'] = '\u0628\u0647';
  37819. t['\uFCA1'] = '\u062A\u062C';
  37820. t['\uFCA2'] = '\u062A\u062D';
  37821. t['\uFCA3'] = '\u062A\u062E';
  37822. t['\uFCA4'] = '\u062A\u0645';
  37823. t['\uFCA5'] = '\u062A\u0647';
  37824. t['\uFCA6'] = '\u062B\u0645';
  37825. t['\uFCA7'] = '\u062C\u062D';
  37826. t['\uFCA8'] = '\u062C\u0645';
  37827. t['\uFCA9'] = '\u062D\u062C';
  37828. t['\uFCAA'] = '\u062D\u0645';
  37829. t['\uFCAB'] = '\u062E\u062C';
  37830. t['\uFCAC'] = '\u062E\u0645';
  37831. t['\uFCAD'] = '\u0633\u062C';
  37832. t['\uFCAE'] = '\u0633\u062D';
  37833. t['\uFCAF'] = '\u0633\u062E';
  37834. t['\uFCB0'] = '\u0633\u0645';
  37835. t['\uFCB1'] = '\u0635\u062D';
  37836. t['\uFCB2'] = '\u0635\u062E';
  37837. t['\uFCB3'] = '\u0635\u0645';
  37838. t['\uFCB4'] = '\u0636\u062C';
  37839. t['\uFCB5'] = '\u0636\u062D';
  37840. t['\uFCB6'] = '\u0636\u062E';
  37841. t['\uFCB7'] = '\u0636\u0645';
  37842. t['\uFCB8'] = '\u0637\u062D';
  37843. t['\uFCB9'] = '\u0638\u0645';
  37844. t['\uFCBA'] = '\u0639\u062C';
  37845. t['\uFCBB'] = '\u0639\u0645';
  37846. t['\uFCBC'] = '\u063A\u062C';
  37847. t['\uFCBD'] = '\u063A\u0645';
  37848. t['\uFCBE'] = '\u0641\u062C';
  37849. t['\uFCBF'] = '\u0641\u062D';
  37850. t['\uFCC0'] = '\u0641\u062E';
  37851. t['\uFCC1'] = '\u0641\u0645';
  37852. t['\uFCC2'] = '\u0642\u062D';
  37853. t['\uFCC3'] = '\u0642\u0645';
  37854. t['\uFCC4'] = '\u0643\u062C';
  37855. t['\uFCC5'] = '\u0643\u062D';
  37856. t['\uFCC6'] = '\u0643\u062E';
  37857. t['\uFCC7'] = '\u0643\u0644';
  37858. t['\uFCC8'] = '\u0643\u0645';
  37859. t['\uFCC9'] = '\u0644\u062C';
  37860. t['\uFCCA'] = '\u0644\u062D';
  37861. t['\uFCCB'] = '\u0644\u062E';
  37862. t['\uFCCC'] = '\u0644\u0645';
  37863. t['\uFCCD'] = '\u0644\u0647';
  37864. t['\uFCCE'] = '\u0645\u062C';
  37865. t['\uFCCF'] = '\u0645\u062D';
  37866. t['\uFCD0'] = '\u0645\u062E';
  37867. t['\uFCD1'] = '\u0645\u0645';
  37868. t['\uFCD2'] = '\u0646\u062C';
  37869. t['\uFCD3'] = '\u0646\u062D';
  37870. t['\uFCD4'] = '\u0646\u062E';
  37871. t['\uFCD5'] = '\u0646\u0645';
  37872. t['\uFCD6'] = '\u0646\u0647';
  37873. t['\uFCD7'] = '\u0647\u062C';
  37874. t['\uFCD8'] = '\u0647\u0645';
  37875. t['\uFCD9'] = '\u0647\u0670';
  37876. t['\uFCDA'] = '\u064A\u062C';
  37877. t['\uFCDB'] = '\u064A\u062D';
  37878. t['\uFCDC'] = '\u064A\u062E';
  37879. t['\uFCDD'] = '\u064A\u0645';
  37880. t['\uFCDE'] = '\u064A\u0647';
  37881. t['\uFCDF'] = '\u0626\u0645';
  37882. t['\uFCE0'] = '\u0626\u0647';
  37883. t['\uFCE1'] = '\u0628\u0645';
  37884. t['\uFCE2'] = '\u0628\u0647';
  37885. t['\uFCE3'] = '\u062A\u0645';
  37886. t['\uFCE4'] = '\u062A\u0647';
  37887. t['\uFCE5'] = '\u062B\u0645';
  37888. t['\uFCE6'] = '\u062B\u0647';
  37889. t['\uFCE7'] = '\u0633\u0645';
  37890. t['\uFCE8'] = '\u0633\u0647';
  37891. t['\uFCE9'] = '\u0634\u0645';
  37892. t['\uFCEA'] = '\u0634\u0647';
  37893. t['\uFCEB'] = '\u0643\u0644';
  37894. t['\uFCEC'] = '\u0643\u0645';
  37895. t['\uFCED'] = '\u0644\u0645';
  37896. t['\uFCEE'] = '\u0646\u0645';
  37897. t['\uFCEF'] = '\u0646\u0647';
  37898. t['\uFCF0'] = '\u064A\u0645';
  37899. t['\uFCF1'] = '\u064A\u0647';
  37900. t['\uFCF2'] = '\u0640\u064E\u0651';
  37901. t['\uFCF3'] = '\u0640\u064F\u0651';
  37902. t['\uFCF4'] = '\u0640\u0650\u0651';
  37903. t['\uFCF5'] = '\u0637\u0649';
  37904. t['\uFCF6'] = '\u0637\u064A';
  37905. t['\uFCF7'] = '\u0639\u0649';
  37906. t['\uFCF8'] = '\u0639\u064A';
  37907. t['\uFCF9'] = '\u063A\u0649';
  37908. t['\uFCFA'] = '\u063A\u064A';
  37909. t['\uFCFB'] = '\u0633\u0649';
  37910. t['\uFCFC'] = '\u0633\u064A';
  37911. t['\uFCFD'] = '\u0634\u0649';
  37912. t['\uFCFE'] = '\u0634\u064A';
  37913. t['\uFCFF'] = '\u062D\u0649';
  37914. t['\uFD00'] = '\u062D\u064A';
  37915. t['\uFD01'] = '\u062C\u0649';
  37916. t['\uFD02'] = '\u062C\u064A';
  37917. t['\uFD03'] = '\u062E\u0649';
  37918. t['\uFD04'] = '\u062E\u064A';
  37919. t['\uFD05'] = '\u0635\u0649';
  37920. t['\uFD06'] = '\u0635\u064A';
  37921. t['\uFD07'] = '\u0636\u0649';
  37922. t['\uFD08'] = '\u0636\u064A';
  37923. t['\uFD09'] = '\u0634\u062C';
  37924. t['\uFD0A'] = '\u0634\u062D';
  37925. t['\uFD0B'] = '\u0634\u062E';
  37926. t['\uFD0C'] = '\u0634\u0645';
  37927. t['\uFD0D'] = '\u0634\u0631';
  37928. t['\uFD0E'] = '\u0633\u0631';
  37929. t['\uFD0F'] = '\u0635\u0631';
  37930. t['\uFD10'] = '\u0636\u0631';
  37931. t['\uFD11'] = '\u0637\u0649';
  37932. t['\uFD12'] = '\u0637\u064A';
  37933. t['\uFD13'] = '\u0639\u0649';
  37934. t['\uFD14'] = '\u0639\u064A';
  37935. t['\uFD15'] = '\u063A\u0649';
  37936. t['\uFD16'] = '\u063A\u064A';
  37937. t['\uFD17'] = '\u0633\u0649';
  37938. t['\uFD18'] = '\u0633\u064A';
  37939. t['\uFD19'] = '\u0634\u0649';
  37940. t['\uFD1A'] = '\u0634\u064A';
  37941. t['\uFD1B'] = '\u062D\u0649';
  37942. t['\uFD1C'] = '\u062D\u064A';
  37943. t['\uFD1D'] = '\u062C\u0649';
  37944. t['\uFD1E'] = '\u062C\u064A';
  37945. t['\uFD1F'] = '\u062E\u0649';
  37946. t['\uFD20'] = '\u062E\u064A';
  37947. t['\uFD21'] = '\u0635\u0649';
  37948. t['\uFD22'] = '\u0635\u064A';
  37949. t['\uFD23'] = '\u0636\u0649';
  37950. t['\uFD24'] = '\u0636\u064A';
  37951. t['\uFD25'] = '\u0634\u062C';
  37952. t['\uFD26'] = '\u0634\u062D';
  37953. t['\uFD27'] = '\u0634\u062E';
  37954. t['\uFD28'] = '\u0634\u0645';
  37955. t['\uFD29'] = '\u0634\u0631';
  37956. t['\uFD2A'] = '\u0633\u0631';
  37957. t['\uFD2B'] = '\u0635\u0631';
  37958. t['\uFD2C'] = '\u0636\u0631';
  37959. t['\uFD2D'] = '\u0634\u062C';
  37960. t['\uFD2E'] = '\u0634\u062D';
  37961. t['\uFD2F'] = '\u0634\u062E';
  37962. t['\uFD30'] = '\u0634\u0645';
  37963. t['\uFD31'] = '\u0633\u0647';
  37964. t['\uFD32'] = '\u0634\u0647';
  37965. t['\uFD33'] = '\u0637\u0645';
  37966. t['\uFD34'] = '\u0633\u062C';
  37967. t['\uFD35'] = '\u0633\u062D';
  37968. t['\uFD36'] = '\u0633\u062E';
  37969. t['\uFD37'] = '\u0634\u062C';
  37970. t['\uFD38'] = '\u0634\u062D';
  37971. t['\uFD39'] = '\u0634\u062E';
  37972. t['\uFD3A'] = '\u0637\u0645';
  37973. t['\uFD3B'] = '\u0638\u0645';
  37974. t['\uFD3C'] = '\u0627\u064B';
  37975. t['\uFD3D'] = '\u0627\u064B';
  37976. t['\uFD50'] = '\u062A\u062C\u0645';
  37977. t['\uFD51'] = '\u062A\u062D\u062C';
  37978. t['\uFD52'] = '\u062A\u062D\u062C';
  37979. t['\uFD53'] = '\u062A\u062D\u0645';
  37980. t['\uFD54'] = '\u062A\u062E\u0645';
  37981. t['\uFD55'] = '\u062A\u0645\u062C';
  37982. t['\uFD56'] = '\u062A\u0645\u062D';
  37983. t['\uFD57'] = '\u062A\u0645\u062E';
  37984. t['\uFD58'] = '\u062C\u0645\u062D';
  37985. t['\uFD59'] = '\u062C\u0645\u062D';
  37986. t['\uFD5A'] = '\u062D\u0645\u064A';
  37987. t['\uFD5B'] = '\u062D\u0645\u0649';
  37988. t['\uFD5C'] = '\u0633\u062D\u062C';
  37989. t['\uFD5D'] = '\u0633\u062C\u062D';
  37990. t['\uFD5E'] = '\u0633\u062C\u0649';
  37991. t['\uFD5F'] = '\u0633\u0645\u062D';
  37992. t['\uFD60'] = '\u0633\u0645\u062D';
  37993. t['\uFD61'] = '\u0633\u0645\u062C';
  37994. t['\uFD62'] = '\u0633\u0645\u0645';
  37995. t['\uFD63'] = '\u0633\u0645\u0645';
  37996. t['\uFD64'] = '\u0635\u062D\u062D';
  37997. t['\uFD65'] = '\u0635\u062D\u062D';
  37998. t['\uFD66'] = '\u0635\u0645\u0645';
  37999. t['\uFD67'] = '\u0634\u062D\u0645';
  38000. t['\uFD68'] = '\u0634\u062D\u0645';
  38001. t['\uFD69'] = '\u0634\u062C\u064A';
  38002. t['\uFD6A'] = '\u0634\u0645\u062E';
  38003. t['\uFD6B'] = '\u0634\u0645\u062E';
  38004. t['\uFD6C'] = '\u0634\u0645\u0645';
  38005. t['\uFD6D'] = '\u0634\u0645\u0645';
  38006. t['\uFD6E'] = '\u0636\u062D\u0649';
  38007. t['\uFD6F'] = '\u0636\u062E\u0645';
  38008. t['\uFD70'] = '\u0636\u062E\u0645';
  38009. t['\uFD71'] = '\u0637\u0645\u062D';
  38010. t['\uFD72'] = '\u0637\u0645\u062D';
  38011. t['\uFD73'] = '\u0637\u0645\u0645';
  38012. t['\uFD74'] = '\u0637\u0645\u064A';
  38013. t['\uFD75'] = '\u0639\u062C\u0645';
  38014. t['\uFD76'] = '\u0639\u0645\u0645';
  38015. t['\uFD77'] = '\u0639\u0645\u0645';
  38016. t['\uFD78'] = '\u0639\u0645\u0649';
  38017. t['\uFD79'] = '\u063A\u0645\u0645';
  38018. t['\uFD7A'] = '\u063A\u0645\u064A';
  38019. t['\uFD7B'] = '\u063A\u0645\u0649';
  38020. t['\uFD7C'] = '\u0641\u062E\u0645';
  38021. t['\uFD7D'] = '\u0641\u062E\u0645';
  38022. t['\uFD7E'] = '\u0642\u0645\u062D';
  38023. t['\uFD7F'] = '\u0642\u0645\u0645';
  38024. t['\uFD80'] = '\u0644\u062D\u0645';
  38025. t['\uFD81'] = '\u0644\u062D\u064A';
  38026. t['\uFD82'] = '\u0644\u062D\u0649';
  38027. t['\uFD83'] = '\u0644\u062C\u062C';
  38028. t['\uFD84'] = '\u0644\u062C\u062C';
  38029. t['\uFD85'] = '\u0644\u062E\u0645';
  38030. t['\uFD86'] = '\u0644\u062E\u0645';
  38031. t['\uFD87'] = '\u0644\u0645\u062D';
  38032. t['\uFD88'] = '\u0644\u0645\u062D';
  38033. t['\uFD89'] = '\u0645\u062D\u062C';
  38034. t['\uFD8A'] = '\u0645\u062D\u0645';
  38035. t['\uFD8B'] = '\u0645\u062D\u064A';
  38036. t['\uFD8C'] = '\u0645\u062C\u062D';
  38037. t['\uFD8D'] = '\u0645\u062C\u0645';
  38038. t['\uFD8E'] = '\u0645\u062E\u062C';
  38039. t['\uFD8F'] = '\u0645\u062E\u0645';
  38040. t['\uFD92'] = '\u0645\u062C\u062E';
  38041. t['\uFD93'] = '\u0647\u0645\u062C';
  38042. t['\uFD94'] = '\u0647\u0645\u0645';
  38043. t['\uFD95'] = '\u0646\u062D\u0645';
  38044. t['\uFD96'] = '\u0646\u062D\u0649';
  38045. t['\uFD97'] = '\u0646\u062C\u0645';
  38046. t['\uFD98'] = '\u0646\u062C\u0645';
  38047. t['\uFD99'] = '\u0646\u062C\u0649';
  38048. t['\uFD9A'] = '\u0646\u0645\u064A';
  38049. t['\uFD9B'] = '\u0646\u0645\u0649';
  38050. t['\uFD9C'] = '\u064A\u0645\u0645';
  38051. t['\uFD9D'] = '\u064A\u0645\u0645';
  38052. t['\uFD9E'] = '\u0628\u062E\u064A';
  38053. t['\uFD9F'] = '\u062A\u062C\u064A';
  38054. t['\uFDA0'] = '\u062A\u062C\u0649';
  38055. t['\uFDA1'] = '\u062A\u062E\u064A';
  38056. t['\uFDA2'] = '\u062A\u062E\u0649';
  38057. t['\uFDA3'] = '\u062A\u0645\u064A';
  38058. t['\uFDA4'] = '\u062A\u0645\u0649';
  38059. t['\uFDA5'] = '\u062C\u0645\u064A';
  38060. t['\uFDA6'] = '\u062C\u062D\u0649';
  38061. t['\uFDA7'] = '\u062C\u0645\u0649';
  38062. t['\uFDA8'] = '\u0633\u062E\u0649';
  38063. t['\uFDA9'] = '\u0635\u062D\u064A';
  38064. t['\uFDAA'] = '\u0634\u062D\u064A';
  38065. t['\uFDAB'] = '\u0636\u062D\u064A';
  38066. t['\uFDAC'] = '\u0644\u062C\u064A';
  38067. t['\uFDAD'] = '\u0644\u0645\u064A';
  38068. t['\uFDAE'] = '\u064A\u062D\u064A';
  38069. t['\uFDAF'] = '\u064A\u062C\u064A';
  38070. t['\uFDB0'] = '\u064A\u0645\u064A';
  38071. t['\uFDB1'] = '\u0645\u0645\u064A';
  38072. t['\uFDB2'] = '\u0642\u0645\u064A';
  38073. t['\uFDB3'] = '\u0646\u062D\u064A';
  38074. t['\uFDB4'] = '\u0642\u0645\u062D';
  38075. t['\uFDB5'] = '\u0644\u062D\u0645';
  38076. t['\uFDB6'] = '\u0639\u0645\u064A';
  38077. t['\uFDB7'] = '\u0643\u0645\u064A';
  38078. t['\uFDB8'] = '\u0646\u062C\u062D';
  38079. t['\uFDB9'] = '\u0645\u062E\u064A';
  38080. t['\uFDBA'] = '\u0644\u062C\u0645';
  38081. t['\uFDBB'] = '\u0643\u0645\u0645';
  38082. t['\uFDBC'] = '\u0644\u062C\u0645';
  38083. t['\uFDBD'] = '\u0646\u062C\u062D';
  38084. t['\uFDBE'] = '\u062C\u062D\u064A';
  38085. t['\uFDBF'] = '\u062D\u062C\u064A';
  38086. t['\uFDC0'] = '\u0645\u062C\u064A';
  38087. t['\uFDC1'] = '\u0641\u0645\u064A';
  38088. t['\uFDC2'] = '\u0628\u062D\u064A';
  38089. t['\uFDC3'] = '\u0643\u0645\u0645';
  38090. t['\uFDC4'] = '\u0639\u062C\u0645';
  38091. t['\uFDC5'] = '\u0635\u0645\u0645';
  38092. t['\uFDC6'] = '\u0633\u062E\u064A';
  38093. t['\uFDC7'] = '\u0646\u062C\u064A';
  38094. t['\uFE49'] = '\u203E';
  38095. t['\uFE4A'] = '\u203E';
  38096. t['\uFE4B'] = '\u203E';
  38097. t['\uFE4C'] = '\u203E';
  38098. t['\uFE4D'] = '\u005F';
  38099. t['\uFE4E'] = '\u005F';
  38100. t['\uFE4F'] = '\u005F';
  38101. t['\uFE80'] = '\u0621';
  38102. t['\uFE81'] = '\u0622';
  38103. t['\uFE82'] = '\u0622';
  38104. t['\uFE83'] = '\u0623';
  38105. t['\uFE84'] = '\u0623';
  38106. t['\uFE85'] = '\u0624';
  38107. t['\uFE86'] = '\u0624';
  38108. t['\uFE87'] = '\u0625';
  38109. t['\uFE88'] = '\u0625';
  38110. t['\uFE89'] = '\u0626';
  38111. t['\uFE8A'] = '\u0626';
  38112. t['\uFE8B'] = '\u0626';
  38113. t['\uFE8C'] = '\u0626';
  38114. t['\uFE8D'] = '\u0627';
  38115. t['\uFE8E'] = '\u0627';
  38116. t['\uFE8F'] = '\u0628';
  38117. t['\uFE90'] = '\u0628';
  38118. t['\uFE91'] = '\u0628';
  38119. t['\uFE92'] = '\u0628';
  38120. t['\uFE93'] = '\u0629';
  38121. t['\uFE94'] = '\u0629';
  38122. t['\uFE95'] = '\u062A';
  38123. t['\uFE96'] = '\u062A';
  38124. t['\uFE97'] = '\u062A';
  38125. t['\uFE98'] = '\u062A';
  38126. t['\uFE99'] = '\u062B';
  38127. t['\uFE9A'] = '\u062B';
  38128. t['\uFE9B'] = '\u062B';
  38129. t['\uFE9C'] = '\u062B';
  38130. t['\uFE9D'] = '\u062C';
  38131. t['\uFE9E'] = '\u062C';
  38132. t['\uFE9F'] = '\u062C';
  38133. t['\uFEA0'] = '\u062C';
  38134. t['\uFEA1'] = '\u062D';
  38135. t['\uFEA2'] = '\u062D';
  38136. t['\uFEA3'] = '\u062D';
  38137. t['\uFEA4'] = '\u062D';
  38138. t['\uFEA5'] = '\u062E';
  38139. t['\uFEA6'] = '\u062E';
  38140. t['\uFEA7'] = '\u062E';
  38141. t['\uFEA8'] = '\u062E';
  38142. t['\uFEA9'] = '\u062F';
  38143. t['\uFEAA'] = '\u062F';
  38144. t['\uFEAB'] = '\u0630';
  38145. t['\uFEAC'] = '\u0630';
  38146. t['\uFEAD'] = '\u0631';
  38147. t['\uFEAE'] = '\u0631';
  38148. t['\uFEAF'] = '\u0632';
  38149. t['\uFEB0'] = '\u0632';
  38150. t['\uFEB1'] = '\u0633';
  38151. t['\uFEB2'] = '\u0633';
  38152. t['\uFEB3'] = '\u0633';
  38153. t['\uFEB4'] = '\u0633';
  38154. t['\uFEB5'] = '\u0634';
  38155. t['\uFEB6'] = '\u0634';
  38156. t['\uFEB7'] = '\u0634';
  38157. t['\uFEB8'] = '\u0634';
  38158. t['\uFEB9'] = '\u0635';
  38159. t['\uFEBA'] = '\u0635';
  38160. t['\uFEBB'] = '\u0635';
  38161. t['\uFEBC'] = '\u0635';
  38162. t['\uFEBD'] = '\u0636';
  38163. t['\uFEBE'] = '\u0636';
  38164. t['\uFEBF'] = '\u0636';
  38165. t['\uFEC0'] = '\u0636';
  38166. t['\uFEC1'] = '\u0637';
  38167. t['\uFEC2'] = '\u0637';
  38168. t['\uFEC3'] = '\u0637';
  38169. t['\uFEC4'] = '\u0637';
  38170. t['\uFEC5'] = '\u0638';
  38171. t['\uFEC6'] = '\u0638';
  38172. t['\uFEC7'] = '\u0638';
  38173. t['\uFEC8'] = '\u0638';
  38174. t['\uFEC9'] = '\u0639';
  38175. t['\uFECA'] = '\u0639';
  38176. t['\uFECB'] = '\u0639';
  38177. t['\uFECC'] = '\u0639';
  38178. t['\uFECD'] = '\u063A';
  38179. t['\uFECE'] = '\u063A';
  38180. t['\uFECF'] = '\u063A';
  38181. t['\uFED0'] = '\u063A';
  38182. t['\uFED1'] = '\u0641';
  38183. t['\uFED2'] = '\u0641';
  38184. t['\uFED3'] = '\u0641';
  38185. t['\uFED4'] = '\u0641';
  38186. t['\uFED5'] = '\u0642';
  38187. t['\uFED6'] = '\u0642';
  38188. t['\uFED7'] = '\u0642';
  38189. t['\uFED8'] = '\u0642';
  38190. t['\uFED9'] = '\u0643';
  38191. t['\uFEDA'] = '\u0643';
  38192. t['\uFEDB'] = '\u0643';
  38193. t['\uFEDC'] = '\u0643';
  38194. t['\uFEDD'] = '\u0644';
  38195. t['\uFEDE'] = '\u0644';
  38196. t['\uFEDF'] = '\u0644';
  38197. t['\uFEE0'] = '\u0644';
  38198. t['\uFEE1'] = '\u0645';
  38199. t['\uFEE2'] = '\u0645';
  38200. t['\uFEE3'] = '\u0645';
  38201. t['\uFEE4'] = '\u0645';
  38202. t['\uFEE5'] = '\u0646';
  38203. t['\uFEE6'] = '\u0646';
  38204. t['\uFEE7'] = '\u0646';
  38205. t['\uFEE8'] = '\u0646';
  38206. t['\uFEE9'] = '\u0647';
  38207. t['\uFEEA'] = '\u0647';
  38208. t['\uFEEB'] = '\u0647';
  38209. t['\uFEEC'] = '\u0647';
  38210. t['\uFEED'] = '\u0648';
  38211. t['\uFEEE'] = '\u0648';
  38212. t['\uFEEF'] = '\u0649';
  38213. t['\uFEF0'] = '\u0649';
  38214. t['\uFEF1'] = '\u064A';
  38215. t['\uFEF2'] = '\u064A';
  38216. t['\uFEF3'] = '\u064A';
  38217. t['\uFEF4'] = '\u064A';
  38218. t['\uFEF5'] = '\u0644\u0622';
  38219. t['\uFEF6'] = '\u0644\u0622';
  38220. t['\uFEF7'] = '\u0644\u0623';
  38221. t['\uFEF8'] = '\u0644\u0623';
  38222. t['\uFEF9'] = '\u0644\u0625';
  38223. t['\uFEFA'] = '\u0644\u0625';
  38224. t['\uFEFB'] = '\u0644\u0627';
  38225. t['\uFEFC'] = '\u0644\u0627';
  38226. });
  38227. function reverseIfRtl(chars) {
  38228. var charsLength = chars.length;
  38229. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38230. return chars;
  38231. }
  38232. var s = '';
  38233. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38234. s += chars[ii];
  38235. }
  38236. return s;
  38237. }
  38238. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38239. exports.reverseIfRtl = reverseIfRtl;
  38240. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38241. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38242. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38243. /***/ }),
  38244. /* 22 */
  38245. /***/ (function(module, exports, __w_pdfjs_require__) {
  38246. "use strict";
  38247. /* WEBPACK VAR INJECTION */(function(module) {
  38248. var sharedUtil = __w_pdfjs_require__(0);
  38249. var corePrimitives = __w_pdfjs_require__(1);
  38250. var corePdfManager = __w_pdfjs_require__(42);
  38251. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38252. var InvalidPDFException = sharedUtil.InvalidPDFException;
  38253. var MessageHandler = sharedUtil.MessageHandler;
  38254. var MissingPDFException = sharedUtil.MissingPDFException;
  38255. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38256. var PasswordException = sharedUtil.PasswordException;
  38257. var UnknownErrorException = sharedUtil.UnknownErrorException;
  38258. var XRefParseException = sharedUtil.XRefParseException;
  38259. var arrayByteLength = sharedUtil.arrayByteLength;
  38260. var arraysToBytes = sharedUtil.arraysToBytes;
  38261. var assert = sharedUtil.assert;
  38262. var createPromiseCapability = sharedUtil.createPromiseCapability;
  38263. var error = sharedUtil.error;
  38264. var info = sharedUtil.info;
  38265. var warn = sharedUtil.warn;
  38266. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  38267. var Ref = corePrimitives.Ref;
  38268. var LocalPdfManager = corePdfManager.LocalPdfManager;
  38269. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  38270. var globalScope = sharedUtil.globalScope;
  38271. var WorkerTask = function WorkerTaskClosure() {
  38272. function WorkerTask(name) {
  38273. this.name = name;
  38274. this.terminated = false;
  38275. this._capability = createPromiseCapability();
  38276. }
  38277. WorkerTask.prototype = {
  38278. get finished() {
  38279. return this._capability.promise;
  38280. },
  38281. finish: function () {
  38282. this._capability.resolve();
  38283. },
  38284. terminate: function () {
  38285. this.terminated = true;
  38286. },
  38287. ensureNotTerminated: function () {
  38288. if (this.terminated) {
  38289. throw new Error('Worker task was terminated');
  38290. }
  38291. }
  38292. };
  38293. return WorkerTask;
  38294. }();
  38295. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  38296. function PDFWorkerStream(params, msgHandler) {
  38297. this._queuedChunks = [];
  38298. var initialData = params.initialData;
  38299. if (initialData && initialData.length > 0) {
  38300. this._queuedChunks.push(initialData);
  38301. }
  38302. this._msgHandler = msgHandler;
  38303. this._isRangeSupported = !params.disableRange;
  38304. this._isStreamingSupported = !params.disableStream;
  38305. this._contentLength = params.length;
  38306. this._fullRequestReader = null;
  38307. this._rangeReaders = [];
  38308. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  38309. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  38310. }
  38311. PDFWorkerStream.prototype = {
  38312. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  38313. if (args.begin === undefined) {
  38314. if (this._fullRequestReader) {
  38315. this._fullRequestReader._enqueue(args.chunk);
  38316. } else {
  38317. this._queuedChunks.push(args.chunk);
  38318. }
  38319. } else {
  38320. var found = this._rangeReaders.some(function (rangeReader) {
  38321. if (rangeReader._begin !== args.begin) {
  38322. return false;
  38323. }
  38324. rangeReader._enqueue(args.chunk);
  38325. return true;
  38326. });
  38327. assert(found);
  38328. }
  38329. },
  38330. _onProgress: function PDFWorkerStream_onProgress(evt) {
  38331. if (this._rangeReaders.length > 0) {
  38332. var firstReader = this._rangeReaders[0];
  38333. if (firstReader.onProgress) {
  38334. firstReader.onProgress({ loaded: evt.loaded });
  38335. }
  38336. }
  38337. },
  38338. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  38339. var i = this._rangeReaders.indexOf(reader);
  38340. if (i >= 0) {
  38341. this._rangeReaders.splice(i, 1);
  38342. }
  38343. },
  38344. getFullReader: function PDFWorkerStream_getFullReader() {
  38345. assert(!this._fullRequestReader);
  38346. var queuedChunks = this._queuedChunks;
  38347. this._queuedChunks = null;
  38348. return new PDFWorkerStreamReader(this, queuedChunks);
  38349. },
  38350. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  38351. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  38352. this._msgHandler.send('RequestDataRange', {
  38353. begin: begin,
  38354. end: end
  38355. });
  38356. this._rangeReaders.push(reader);
  38357. return reader;
  38358. },
  38359. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  38360. if (this._fullRequestReader) {
  38361. this._fullRequestReader.cancel(reason);
  38362. }
  38363. var readers = this._rangeReaders.slice(0);
  38364. readers.forEach(function (rangeReader) {
  38365. rangeReader.cancel(reason);
  38366. });
  38367. }
  38368. };
  38369. function PDFWorkerStreamReader(stream, queuedChunks) {
  38370. this._stream = stream;
  38371. this._done = false;
  38372. this._queuedChunks = queuedChunks || [];
  38373. this._requests = [];
  38374. this._headersReady = Promise.resolve();
  38375. stream._fullRequestReader = this;
  38376. this.onProgress = null;
  38377. }
  38378. PDFWorkerStreamReader.prototype = {
  38379. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  38380. if (this._done) {
  38381. return;
  38382. }
  38383. if (this._requests.length > 0) {
  38384. var requestCapability = this._requests.shift();
  38385. requestCapability.resolve({
  38386. value: chunk,
  38387. done: false
  38388. });
  38389. return;
  38390. }
  38391. this._queuedChunks.push(chunk);
  38392. },
  38393. get headersReady() {
  38394. return this._headersReady;
  38395. },
  38396. get isRangeSupported() {
  38397. return this._stream._isRangeSupported;
  38398. },
  38399. get isStreamingSupported() {
  38400. return this._stream._isStreamingSupported;
  38401. },
  38402. get contentLength() {
  38403. return this._stream._contentLength;
  38404. },
  38405. read: function PDFWorkerStreamReader_read() {
  38406. if (this._queuedChunks.length > 0) {
  38407. var chunk = this._queuedChunks.shift();
  38408. return Promise.resolve({
  38409. value: chunk,
  38410. done: false
  38411. });
  38412. }
  38413. if (this._done) {
  38414. return Promise.resolve({
  38415. value: undefined,
  38416. done: true
  38417. });
  38418. }
  38419. var requestCapability = createPromiseCapability();
  38420. this._requests.push(requestCapability);
  38421. return requestCapability.promise;
  38422. },
  38423. cancel: function PDFWorkerStreamReader_cancel(reason) {
  38424. this._done = true;
  38425. this._requests.forEach(function (requestCapability) {
  38426. requestCapability.resolve({
  38427. value: undefined,
  38428. done: true
  38429. });
  38430. });
  38431. this._requests = [];
  38432. }
  38433. };
  38434. function PDFWorkerStreamRangeReader(stream, begin, end) {
  38435. this._stream = stream;
  38436. this._begin = begin;
  38437. this._end = end;
  38438. this._queuedChunk = null;
  38439. this._requests = [];
  38440. this._done = false;
  38441. this.onProgress = null;
  38442. }
  38443. PDFWorkerStreamRangeReader.prototype = {
  38444. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  38445. if (this._done) {
  38446. return;
  38447. }
  38448. if (this._requests.length === 0) {
  38449. this._queuedChunk = chunk;
  38450. } else {
  38451. var requestsCapability = this._requests.shift();
  38452. requestsCapability.resolve({
  38453. value: chunk,
  38454. done: false
  38455. });
  38456. this._requests.forEach(function (requestCapability) {
  38457. requestCapability.resolve({
  38458. value: undefined,
  38459. done: true
  38460. });
  38461. });
  38462. this._requests = [];
  38463. }
  38464. this._done = true;
  38465. this._stream._removeRangeReader(this);
  38466. },
  38467. get isStreamingSupported() {
  38468. return false;
  38469. },
  38470. read: function PDFWorkerStreamRangeReader_read() {
  38471. if (this._queuedChunk) {
  38472. return Promise.resolve({
  38473. value: this._queuedChunk,
  38474. done: false
  38475. });
  38476. }
  38477. if (this._done) {
  38478. return Promise.resolve({
  38479. value: undefined,
  38480. done: true
  38481. });
  38482. }
  38483. var requestCapability = createPromiseCapability();
  38484. this._requests.push(requestCapability);
  38485. return requestCapability.promise;
  38486. },
  38487. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  38488. this._done = true;
  38489. this._requests.forEach(function (requestCapability) {
  38490. requestCapability.resolve({
  38491. value: undefined,
  38492. done: true
  38493. });
  38494. });
  38495. this._requests = [];
  38496. this._stream._removeRangeReader(this);
  38497. }
  38498. };
  38499. return PDFWorkerStream;
  38500. }();
  38501. var PDFNetworkStream;
  38502. function setPDFNetworkStreamClass(cls) {
  38503. PDFNetworkStream = cls;
  38504. }
  38505. var WorkerMessageHandler = {
  38506. setup: function wphSetup(handler, port) {
  38507. var testMessageProcessed = false;
  38508. handler.on('test', function wphSetupTest(data) {
  38509. if (testMessageProcessed) {
  38510. return;
  38511. }
  38512. testMessageProcessed = true;
  38513. if (!(data instanceof Uint8Array)) {
  38514. handler.send('test', 'main', false);
  38515. return;
  38516. }
  38517. var supportTransfers = data[0] === 255;
  38518. handler.postMessageTransfers = supportTransfers;
  38519. var xhr = new XMLHttpRequest();
  38520. var responseExists = 'response' in xhr;
  38521. try {
  38522. xhr.responseType;
  38523. } catch (e) {
  38524. responseExists = false;
  38525. }
  38526. if (!responseExists) {
  38527. handler.send('test', false);
  38528. return;
  38529. }
  38530. handler.send('test', {
  38531. supportTypedArray: true,
  38532. supportTransfers: supportTransfers
  38533. });
  38534. });
  38535. handler.on('configure', function wphConfigure(data) {
  38536. setVerbosityLevel(data.verbosity);
  38537. });
  38538. handler.on('GetDocRequest', function wphSetupDoc(data) {
  38539. return WorkerMessageHandler.createDocumentHandler(data, port);
  38540. });
  38541. },
  38542. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  38543. var pdfManager;
  38544. var terminated = false;
  38545. var cancelXHRs = null;
  38546. var WorkerTasks = [];
  38547. var docId = docParams.docId;
  38548. var docBaseUrl = docParams.docBaseUrl;
  38549. var workerHandlerName = docParams.docId + '_worker';
  38550. var handler = new MessageHandler(workerHandlerName, docId, port);
  38551. handler.postMessageTransfers = docParams.postMessageTransfers;
  38552. function ensureNotTerminated() {
  38553. if (terminated) {
  38554. throw new Error('Worker was terminated');
  38555. }
  38556. }
  38557. function startWorkerTask(task) {
  38558. WorkerTasks.push(task);
  38559. }
  38560. function finishWorkerTask(task) {
  38561. task.finish();
  38562. var i = WorkerTasks.indexOf(task);
  38563. WorkerTasks.splice(i, 1);
  38564. }
  38565. function loadDocument(recoveryMode) {
  38566. var loadDocumentCapability = createPromiseCapability();
  38567. var parseSuccess = function parseSuccess() {
  38568. var numPagesPromise = pdfManager.ensureDoc('numPages');
  38569. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  38570. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  38571. Promise.all([
  38572. numPagesPromise,
  38573. fingerprintPromise,
  38574. encryptedPromise
  38575. ]).then(function onDocReady(results) {
  38576. var doc = {
  38577. numPages: results[0],
  38578. fingerprint: results[1],
  38579. encrypted: !!results[2]
  38580. };
  38581. loadDocumentCapability.resolve(doc);
  38582. }, parseFailure);
  38583. };
  38584. var parseFailure = function parseFailure(e) {
  38585. loadDocumentCapability.reject(e);
  38586. };
  38587. pdfManager.ensureDoc('checkHeader', []).then(function () {
  38588. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  38589. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  38590. }, parseFailure);
  38591. }, parseFailure);
  38592. return loadDocumentCapability.promise;
  38593. }
  38594. function getPdfManager(data, evaluatorOptions) {
  38595. var pdfManagerCapability = createPromiseCapability();
  38596. var pdfManager;
  38597. var source = data.source;
  38598. if (source.data) {
  38599. try {
  38600. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  38601. pdfManagerCapability.resolve(pdfManager);
  38602. } catch (ex) {
  38603. pdfManagerCapability.reject(ex);
  38604. }
  38605. return pdfManagerCapability.promise;
  38606. }
  38607. var pdfStream;
  38608. try {
  38609. if (source.chunkedViewerLoading) {
  38610. pdfStream = new PDFWorkerStream(source, handler);
  38611. } else {
  38612. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  38613. pdfStream = new PDFNetworkStream(data);
  38614. }
  38615. } catch (ex) {
  38616. pdfManagerCapability.reject(ex);
  38617. return pdfManagerCapability.promise;
  38618. }
  38619. var fullRequest = pdfStream.getFullReader();
  38620. fullRequest.headersReady.then(function () {
  38621. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  38622. fullRequest.onProgress = function (evt) {
  38623. handler.send('DocProgress', {
  38624. loaded: evt.loaded,
  38625. total: evt.total
  38626. });
  38627. };
  38628. }
  38629. if (!fullRequest.isRangeSupported) {
  38630. return;
  38631. }
  38632. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  38633. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  38634. msgHandler: handler,
  38635. url: source.url,
  38636. password: source.password,
  38637. length: fullRequest.contentLength,
  38638. disableAutoFetch: disableAutoFetch,
  38639. rangeChunkSize: source.rangeChunkSize
  38640. }, evaluatorOptions, docBaseUrl);
  38641. pdfManagerCapability.resolve(pdfManager);
  38642. cancelXHRs = null;
  38643. }).catch(function (reason) {
  38644. pdfManagerCapability.reject(reason);
  38645. cancelXHRs = null;
  38646. });
  38647. var cachedChunks = [], loaded = 0;
  38648. var flushChunks = function () {
  38649. var pdfFile = arraysToBytes(cachedChunks);
  38650. if (source.length && pdfFile.length !== source.length) {
  38651. warn('reported HTTP length is different from actual');
  38652. }
  38653. try {
  38654. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  38655. pdfManagerCapability.resolve(pdfManager);
  38656. } catch (ex) {
  38657. pdfManagerCapability.reject(ex);
  38658. }
  38659. cachedChunks = [];
  38660. };
  38661. var readPromise = new Promise(function (resolve, reject) {
  38662. var readChunk = function (chunk) {
  38663. try {
  38664. ensureNotTerminated();
  38665. if (chunk.done) {
  38666. if (!pdfManager) {
  38667. flushChunks();
  38668. }
  38669. cancelXHRs = null;
  38670. return;
  38671. }
  38672. var data = chunk.value;
  38673. loaded += arrayByteLength(data);
  38674. if (!fullRequest.isStreamingSupported) {
  38675. handler.send('DocProgress', {
  38676. loaded: loaded,
  38677. total: Math.max(loaded, fullRequest.contentLength || 0)
  38678. });
  38679. }
  38680. if (pdfManager) {
  38681. pdfManager.sendProgressiveData(data);
  38682. } else {
  38683. cachedChunks.push(data);
  38684. }
  38685. fullRequest.read().then(readChunk, reject);
  38686. } catch (e) {
  38687. reject(e);
  38688. }
  38689. };
  38690. fullRequest.read().then(readChunk, reject);
  38691. });
  38692. readPromise.catch(function (e) {
  38693. pdfManagerCapability.reject(e);
  38694. cancelXHRs = null;
  38695. });
  38696. cancelXHRs = function () {
  38697. pdfStream.cancelAllRequests('abort');
  38698. };
  38699. return pdfManagerCapability.promise;
  38700. }
  38701. function setupDoc(data) {
  38702. function onSuccess(doc) {
  38703. ensureNotTerminated();
  38704. handler.send('GetDoc', { pdfInfo: doc });
  38705. }
  38706. function onFailure(e) {
  38707. if (e instanceof PasswordException) {
  38708. var task = new WorkerTask('PasswordException: response ' + e.code);
  38709. startWorkerTask(task);
  38710. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38711. finishWorkerTask(task);
  38712. pdfManager.updatePassword(data.password);
  38713. pdfManagerReady();
  38714. }).catch(function (ex) {
  38715. finishWorkerTask(task);
  38716. handler.send('PasswordException', ex);
  38717. }.bind(null, e));
  38718. } else if (e instanceof InvalidPDFException) {
  38719. handler.send('InvalidPDF', e);
  38720. } else if (e instanceof MissingPDFException) {
  38721. handler.send('MissingPDF', e);
  38722. } else if (e instanceof UnexpectedResponseException) {
  38723. handler.send('UnexpectedResponse', e);
  38724. } else {
  38725. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38726. }
  38727. }
  38728. function pdfManagerReady() {
  38729. ensureNotTerminated();
  38730. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38731. ensureNotTerminated();
  38732. if (!(ex instanceof XRefParseException)) {
  38733. onFailure(ex);
  38734. return;
  38735. }
  38736. pdfManager.requestLoadedStream();
  38737. pdfManager.onLoadedStream().then(function () {
  38738. ensureNotTerminated();
  38739. loadDocument(true).then(onSuccess, onFailure);
  38740. });
  38741. }, onFailure);
  38742. }
  38743. ensureNotTerminated();
  38744. var cMapOptions = {
  38745. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  38746. packed: data.cMapPacked === true
  38747. };
  38748. var evaluatorOptions = {
  38749. forceDataSchema: data.disableCreateObjectURL,
  38750. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38751. disableFontFace: data.disableFontFace,
  38752. cMapOptions: cMapOptions,
  38753. disableNativeImageDecoder: data.disableNativeImageDecoder
  38754. };
  38755. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38756. if (terminated) {
  38757. newPdfManager.terminate();
  38758. throw new Error('Worker was terminated');
  38759. }
  38760. pdfManager = newPdfManager;
  38761. handler.send('PDFManagerReady', null);
  38762. pdfManager.onLoadedStream().then(function (stream) {
  38763. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38764. });
  38765. }).then(pdfManagerReady, onFailure);
  38766. }
  38767. handler.on('GetPage', function wphSetupGetPage(data) {
  38768. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38769. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38770. var refPromise = pdfManager.ensure(page, 'ref');
  38771. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38772. var viewPromise = pdfManager.ensure(page, 'view');
  38773. return Promise.all([
  38774. rotatePromise,
  38775. refPromise,
  38776. userUnitPromise,
  38777. viewPromise
  38778. ]).then(function (results) {
  38779. return {
  38780. rotate: results[0],
  38781. ref: results[1],
  38782. userUnit: results[2],
  38783. view: results[3]
  38784. };
  38785. });
  38786. });
  38787. });
  38788. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38789. var ref = new Ref(data.ref.num, data.ref.gen);
  38790. var catalog = pdfManager.pdfDocument.catalog;
  38791. return catalog.getPageIndex(ref);
  38792. });
  38793. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38794. return pdfManager.ensureCatalog('destinations');
  38795. });
  38796. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38797. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38798. });
  38799. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38800. return pdfManager.ensureCatalog('pageLabels');
  38801. });
  38802. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38803. return pdfManager.ensureCatalog('attachments');
  38804. });
  38805. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38806. return pdfManager.ensureCatalog('javaScript');
  38807. });
  38808. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38809. return pdfManager.ensureCatalog('documentOutline');
  38810. });
  38811. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38812. return Promise.all([
  38813. pdfManager.ensureDoc('documentInfo'),
  38814. pdfManager.ensureCatalog('metadata')
  38815. ]);
  38816. });
  38817. handler.on('GetData', function wphSetupGetData(data) {
  38818. pdfManager.requestLoadedStream();
  38819. return pdfManager.onLoadedStream().then(function (stream) {
  38820. return stream.bytes;
  38821. });
  38822. });
  38823. handler.on('GetStats', function wphSetupGetStats(data) {
  38824. return pdfManager.pdfDocument.xref.stats;
  38825. });
  38826. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38827. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38828. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38829. });
  38830. });
  38831. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38832. var pageIndex = data.pageIndex;
  38833. pdfManager.getPage(pageIndex).then(function (page) {
  38834. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38835. startWorkerTask(task);
  38836. var pageNum = pageIndex + 1;
  38837. var start = Date.now();
  38838. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38839. finishWorkerTask(task);
  38840. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38841. }, function (e) {
  38842. finishWorkerTask(task);
  38843. if (task.terminated) {
  38844. return;
  38845. }
  38846. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38847. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38848. var wrappedException;
  38849. if (typeof e === 'string') {
  38850. wrappedException = {
  38851. message: e,
  38852. stack: minimumStackMessage
  38853. };
  38854. } else if (typeof e === 'object') {
  38855. wrappedException = {
  38856. message: e.message || e.toString(),
  38857. stack: e.stack || minimumStackMessage
  38858. };
  38859. } else {
  38860. wrappedException = {
  38861. message: 'Unknown exception type: ' + typeof e,
  38862. stack: minimumStackMessage
  38863. };
  38864. }
  38865. handler.send('PageError', {
  38866. pageNum: pageNum,
  38867. error: wrappedException,
  38868. intent: data.intent
  38869. });
  38870. });
  38871. });
  38872. }, this);
  38873. handler.on('GetTextContent', function wphExtractText(data) {
  38874. var pageIndex = data.pageIndex;
  38875. var normalizeWhitespace = data.normalizeWhitespace;
  38876. var combineTextItems = data.combineTextItems;
  38877. return pdfManager.getPage(pageIndex).then(function (page) {
  38878. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38879. startWorkerTask(task);
  38880. var pageNum = pageIndex + 1;
  38881. var start = Date.now();
  38882. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38883. finishWorkerTask(task);
  38884. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38885. return textContent;
  38886. }, function (reason) {
  38887. finishWorkerTask(task);
  38888. if (task.terminated) {
  38889. return;
  38890. }
  38891. throw reason;
  38892. });
  38893. });
  38894. });
  38895. handler.on('Cleanup', function wphCleanup(data) {
  38896. return pdfManager.cleanup();
  38897. });
  38898. handler.on('Terminate', function wphTerminate(data) {
  38899. terminated = true;
  38900. if (pdfManager) {
  38901. pdfManager.terminate();
  38902. pdfManager = null;
  38903. }
  38904. if (cancelXHRs) {
  38905. cancelXHRs();
  38906. }
  38907. var waitOn = [];
  38908. WorkerTasks.forEach(function (task) {
  38909. waitOn.push(task.finished);
  38910. task.terminate();
  38911. });
  38912. return Promise.all(waitOn).then(function () {
  38913. handler.destroy();
  38914. handler = null;
  38915. });
  38916. });
  38917. handler.on('Ready', function wphReady(data) {
  38918. setupDoc(docParams);
  38919. docParams = null;
  38920. });
  38921. return workerHandlerName;
  38922. }
  38923. };
  38924. function initializeWorker() {
  38925. if (!('console' in globalScope)) {
  38926. var consoleTimer = {};
  38927. var workerConsole = {
  38928. log: function log() {
  38929. var args = Array.prototype.slice.call(arguments);
  38930. globalScope.postMessage({
  38931. targetName: 'main',
  38932. action: 'console_log',
  38933. data: args
  38934. });
  38935. },
  38936. error: function error() {
  38937. var args = Array.prototype.slice.call(arguments);
  38938. globalScope.postMessage({
  38939. targetName: 'main',
  38940. action: 'console_error',
  38941. data: args
  38942. });
  38943. throw 'pdf.js execution error';
  38944. },
  38945. time: function time(name) {
  38946. consoleTimer[name] = Date.now();
  38947. },
  38948. timeEnd: function timeEnd(name) {
  38949. var time = consoleTimer[name];
  38950. if (!time) {
  38951. error('Unknown timer name ' + name);
  38952. }
  38953. this.log('Timer:', name, Date.now() - time);
  38954. }
  38955. };
  38956. globalScope.console = workerConsole;
  38957. }
  38958. var handler = new MessageHandler('worker', 'main', self);
  38959. WorkerMessageHandler.setup(handler, self);
  38960. handler.send('ready', null);
  38961. }
  38962. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  38963. initializeWorker();
  38964. }
  38965. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38966. exports.WorkerTask = WorkerTask;
  38967. exports.WorkerMessageHandler = WorkerMessageHandler;
  38968. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(27)(module)))
  38969. /***/ }),
  38970. /* 23 */
  38971. /***/ (function(module, exports, __w_pdfjs_require__) {
  38972. "use strict";
  38973. var sharedUtil = __w_pdfjs_require__(0);
  38974. var error = sharedUtil.error;
  38975. function fixMetadata(meta) {
  38976. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38977. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38978. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38979. });
  38980. var chars = '';
  38981. for (var i = 0; i < bytes.length; i += 2) {
  38982. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38983. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38984. }
  38985. return '>' + chars;
  38986. });
  38987. }
  38988. function Metadata(meta) {
  38989. if (typeof meta === 'string') {
  38990. meta = fixMetadata(meta);
  38991. var parser = new DOMParser();
  38992. meta = parser.parseFromString(meta, 'application/xml');
  38993. } else if (!(meta instanceof Document)) {
  38994. error('Metadata: Invalid metadata object');
  38995. }
  38996. this.metaDocument = meta;
  38997. this.metadata = Object.create(null);
  38998. this.parse();
  38999. }
  39000. Metadata.prototype = {
  39001. parse: function Metadata_parse() {
  39002. var doc = this.metaDocument;
  39003. var rdf = doc.documentElement;
  39004. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39005. rdf = rdf.firstChild;
  39006. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39007. rdf = rdf.nextSibling;
  39008. }
  39009. }
  39010. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39011. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39012. return;
  39013. }
  39014. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39015. for (i = 0, length = children.length; i < length; i++) {
  39016. desc = children[i];
  39017. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39018. continue;
  39019. }
  39020. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39021. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39022. entry = desc.childNodes[ii];
  39023. name = entry.nodeName.toLowerCase();
  39024. this.metadata[name] = entry.textContent.trim();
  39025. }
  39026. }
  39027. }
  39028. },
  39029. get: function Metadata_get(name) {
  39030. return this.metadata[name] || null;
  39031. },
  39032. has: function Metadata_has(name) {
  39033. return typeof this.metadata[name] !== 'undefined';
  39034. }
  39035. };
  39036. exports.Metadata = Metadata;
  39037. /***/ }),
  39038. /* 24 */
  39039. /***/ (function(module, exports, __w_pdfjs_require__) {
  39040. "use strict";
  39041. var sharedUtil = __w_pdfjs_require__(0);
  39042. var displayDOMUtils = __w_pdfjs_require__(3);
  39043. var shadow = sharedUtil.shadow;
  39044. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39045. var WebGLUtils = function WebGLUtilsClosure() {
  39046. function loadShader(gl, code, shaderType) {
  39047. var shader = gl.createShader(shaderType);
  39048. gl.shaderSource(shader, code);
  39049. gl.compileShader(shader);
  39050. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39051. if (!compiled) {
  39052. var errorMsg = gl.getShaderInfoLog(shader);
  39053. throw new Error('Error during shader compilation: ' + errorMsg);
  39054. }
  39055. return shader;
  39056. }
  39057. function createVertexShader(gl, code) {
  39058. return loadShader(gl, code, gl.VERTEX_SHADER);
  39059. }
  39060. function createFragmentShader(gl, code) {
  39061. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39062. }
  39063. function createProgram(gl, shaders) {
  39064. var program = gl.createProgram();
  39065. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39066. gl.attachShader(program, shaders[i]);
  39067. }
  39068. gl.linkProgram(program);
  39069. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39070. if (!linked) {
  39071. var errorMsg = gl.getProgramInfoLog(program);
  39072. throw new Error('Error during program linking: ' + errorMsg);
  39073. }
  39074. return program;
  39075. }
  39076. function createTexture(gl, image, textureId) {
  39077. gl.activeTexture(textureId);
  39078. var texture = gl.createTexture();
  39079. gl.bindTexture(gl.TEXTURE_2D, texture);
  39080. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39081. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39082. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39083. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39084. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39085. return texture;
  39086. }
  39087. var currentGL, currentCanvas;
  39088. function generateGL() {
  39089. if (currentGL) {
  39090. return;
  39091. }
  39092. currentCanvas = document.createElement('canvas');
  39093. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39094. }
  39095. var smaskVertexShaderCode = '\
  39096. attribute vec2 a_position; \
  39097. attribute vec2 a_texCoord; \
  39098. \
  39099. uniform vec2 u_resolution; \
  39100. \
  39101. varying vec2 v_texCoord; \
  39102. \
  39103. void main() { \
  39104. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39105. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39106. \
  39107. v_texCoord = a_texCoord; \
  39108. } ';
  39109. var smaskFragmentShaderCode = '\
  39110. precision mediump float; \
  39111. \
  39112. uniform vec4 u_backdrop; \
  39113. uniform int u_subtype; \
  39114. uniform sampler2D u_image; \
  39115. uniform sampler2D u_mask; \
  39116. \
  39117. varying vec2 v_texCoord; \
  39118. \
  39119. void main() { \
  39120. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39121. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39122. if (u_backdrop.a > 0.0) { \
  39123. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39124. u_backdrop.rgb * (1.0 - maskColor.a); \
  39125. } \
  39126. float lum; \
  39127. if (u_subtype == 0) { \
  39128. lum = maskColor.a; \
  39129. } else { \
  39130. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39131. maskColor.b * 0.11; \
  39132. } \
  39133. imageColor.a *= lum; \
  39134. imageColor.rgb *= imageColor.a; \
  39135. gl_FragColor = imageColor; \
  39136. } ';
  39137. var smaskCache = null;
  39138. function initSmaskGL() {
  39139. var canvas, gl;
  39140. generateGL();
  39141. canvas = currentCanvas;
  39142. currentCanvas = null;
  39143. gl = currentGL;
  39144. currentGL = null;
  39145. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39146. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39147. var program = createProgram(gl, [
  39148. vertexShader,
  39149. fragmentShader
  39150. ]);
  39151. gl.useProgram(program);
  39152. var cache = {};
  39153. cache.gl = gl;
  39154. cache.canvas = canvas;
  39155. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39156. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39157. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39158. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39159. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39160. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39161. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39162. var texCoordBuffer = gl.createBuffer();
  39163. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39164. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39165. 0.0,
  39166. 0.0,
  39167. 1.0,
  39168. 0.0,
  39169. 0.0,
  39170. 1.0,
  39171. 0.0,
  39172. 1.0,
  39173. 1.0,
  39174. 0.0,
  39175. 1.0,
  39176. 1.0
  39177. ]), gl.STATIC_DRAW);
  39178. gl.enableVertexAttribArray(texCoordLocation);
  39179. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39180. gl.uniform1i(texLayerLocation, 0);
  39181. gl.uniform1i(texMaskLocation, 1);
  39182. smaskCache = cache;
  39183. }
  39184. function composeSMask(layer, mask, properties) {
  39185. var width = layer.width, height = layer.height;
  39186. if (!smaskCache) {
  39187. initSmaskGL();
  39188. }
  39189. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39190. canvas.width = width;
  39191. canvas.height = height;
  39192. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39193. gl.uniform2f(cache.resolutionLocation, width, height);
  39194. if (properties.backdrop) {
  39195. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39196. } else {
  39197. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39198. }
  39199. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39200. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39201. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39202. var buffer = gl.createBuffer();
  39203. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39204. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39205. 0,
  39206. 0,
  39207. width,
  39208. 0,
  39209. 0,
  39210. height,
  39211. 0,
  39212. height,
  39213. width,
  39214. 0,
  39215. width,
  39216. height
  39217. ]), gl.STATIC_DRAW);
  39218. gl.enableVertexAttribArray(cache.positionLocation);
  39219. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39220. gl.clearColor(0, 0, 0, 0);
  39221. gl.enable(gl.BLEND);
  39222. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39223. gl.clear(gl.COLOR_BUFFER_BIT);
  39224. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39225. gl.flush();
  39226. gl.deleteTexture(texture);
  39227. gl.deleteTexture(maskTexture);
  39228. gl.deleteBuffer(buffer);
  39229. return canvas;
  39230. }
  39231. var figuresVertexShaderCode = '\
  39232. attribute vec2 a_position; \
  39233. attribute vec3 a_color; \
  39234. \
  39235. uniform vec2 u_resolution; \
  39236. uniform vec2 u_scale; \
  39237. uniform vec2 u_offset; \
  39238. \
  39239. varying vec4 v_color; \
  39240. \
  39241. void main() { \
  39242. vec2 position = (a_position + u_offset) * u_scale; \
  39243. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39244. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39245. \
  39246. v_color = vec4(a_color / 255.0, 1.0); \
  39247. } ';
  39248. var figuresFragmentShaderCode = '\
  39249. precision mediump float; \
  39250. \
  39251. varying vec4 v_color; \
  39252. \
  39253. void main() { \
  39254. gl_FragColor = v_color; \
  39255. } ';
  39256. var figuresCache = null;
  39257. function initFiguresGL() {
  39258. var canvas, gl;
  39259. generateGL();
  39260. canvas = currentCanvas;
  39261. currentCanvas = null;
  39262. gl = currentGL;
  39263. currentGL = null;
  39264. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39265. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39266. var program = createProgram(gl, [
  39267. vertexShader,
  39268. fragmentShader
  39269. ]);
  39270. gl.useProgram(program);
  39271. var cache = {};
  39272. cache.gl = gl;
  39273. cache.canvas = canvas;
  39274. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39275. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39276. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39277. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39278. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39279. figuresCache = cache;
  39280. }
  39281. function drawFigures(width, height, backgroundColor, figures, context) {
  39282. if (!figuresCache) {
  39283. initFiguresGL();
  39284. }
  39285. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39286. canvas.width = width;
  39287. canvas.height = height;
  39288. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39289. gl.uniform2f(cache.resolutionLocation, width, height);
  39290. var count = 0;
  39291. var i, ii, rows;
  39292. for (i = 0, ii = figures.length; i < ii; i++) {
  39293. switch (figures[i].type) {
  39294. case 'lattice':
  39295. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39296. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39297. break;
  39298. case 'triangles':
  39299. count += figures[i].coords.length;
  39300. break;
  39301. }
  39302. }
  39303. var coords = new Float32Array(count * 2);
  39304. var colors = new Uint8Array(count * 3);
  39305. var coordsMap = context.coords, colorsMap = context.colors;
  39306. var pIndex = 0, cIndex = 0;
  39307. for (i = 0, ii = figures.length; i < ii; i++) {
  39308. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39309. switch (figure.type) {
  39310. case 'lattice':
  39311. var cols = figure.verticesPerRow;
  39312. rows = ps.length / cols | 0;
  39313. for (var row = 1; row < rows; row++) {
  39314. var offset = row * cols + 1;
  39315. for (var col = 1; col < cols; col++, offset++) {
  39316. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39317. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39318. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39319. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39320. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39321. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39322. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39323. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39324. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39325. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39326. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39327. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39328. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39329. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39330. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39331. coords[pIndex + 6] = coords[pIndex + 2];
  39332. coords[pIndex + 7] = coords[pIndex + 3];
  39333. coords[pIndex + 8] = coords[pIndex + 4];
  39334. coords[pIndex + 9] = coords[pIndex + 5];
  39335. coords[pIndex + 10] = coordsMap[ps[offset]];
  39336. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39337. colors[cIndex + 9] = colors[cIndex + 3];
  39338. colors[cIndex + 10] = colors[cIndex + 4];
  39339. colors[cIndex + 11] = colors[cIndex + 5];
  39340. colors[cIndex + 12] = colors[cIndex + 6];
  39341. colors[cIndex + 13] = colors[cIndex + 7];
  39342. colors[cIndex + 14] = colors[cIndex + 8];
  39343. colors[cIndex + 15] = colorsMap[cs[offset]];
  39344. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39345. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39346. pIndex += 12;
  39347. cIndex += 18;
  39348. }
  39349. }
  39350. break;
  39351. case 'triangles':
  39352. for (var j = 0, jj = ps.length; j < jj; j++) {
  39353. coords[pIndex] = coordsMap[ps[j]];
  39354. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39355. colors[cIndex] = colorsMap[cs[j]];
  39356. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39357. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39358. pIndex += 2;
  39359. cIndex += 3;
  39360. }
  39361. break;
  39362. }
  39363. }
  39364. if (backgroundColor) {
  39365. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39366. } else {
  39367. gl.clearColor(0, 0, 0, 0);
  39368. }
  39369. gl.clear(gl.COLOR_BUFFER_BIT);
  39370. var coordsBuffer = gl.createBuffer();
  39371. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39372. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39373. gl.enableVertexAttribArray(cache.positionLocation);
  39374. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39375. var colorsBuffer = gl.createBuffer();
  39376. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39377. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39378. gl.enableVertexAttribArray(cache.colorLocation);
  39379. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39380. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39381. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39382. gl.drawArrays(gl.TRIANGLES, 0, count);
  39383. gl.flush();
  39384. gl.deleteBuffer(coordsBuffer);
  39385. gl.deleteBuffer(colorsBuffer);
  39386. return canvas;
  39387. }
  39388. function cleanup() {
  39389. if (smaskCache && smaskCache.canvas) {
  39390. smaskCache.canvas.width = 0;
  39391. smaskCache.canvas.height = 0;
  39392. }
  39393. if (figuresCache && figuresCache.canvas) {
  39394. figuresCache.canvas.width = 0;
  39395. figuresCache.canvas.height = 0;
  39396. }
  39397. smaskCache = null;
  39398. figuresCache = null;
  39399. }
  39400. return {
  39401. get isEnabled() {
  39402. if (getDefaultSetting('disableWebGL')) {
  39403. return false;
  39404. }
  39405. var enabled = false;
  39406. try {
  39407. generateGL();
  39408. enabled = !!currentGL;
  39409. } catch (e) {
  39410. }
  39411. return shadow(this, 'isEnabled', enabled);
  39412. },
  39413. composeSMask: composeSMask,
  39414. drawFigures: drawFigures,
  39415. clear: cleanup
  39416. };
  39417. }();
  39418. exports.WebGLUtils = WebGLUtils;
  39419. /***/ }),
  39420. /* 25 */
  39421. /***/ (function(module, exports, __w_pdfjs_require__) {
  39422. "use strict";
  39423. var sharedUtil = __w_pdfjs_require__(0);
  39424. var displayDOMUtils = __w_pdfjs_require__(3);
  39425. var displayAPI = __w_pdfjs_require__(10);
  39426. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39427. var displayTextLayer = __w_pdfjs_require__(12);
  39428. var displayMetadata = __w_pdfjs_require__(23);
  39429. var displaySVG = __w_pdfjs_require__(11);
  39430. var globalScope = sharedUtil.globalScope;
  39431. var deprecated = sharedUtil.deprecated;
  39432. var warn = sharedUtil.warn;
  39433. var LinkTarget = displayDOMUtils.LinkTarget;
  39434. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39435. var isWorker = typeof window === 'undefined';
  39436. if (!globalScope.PDFJS) {
  39437. globalScope.PDFJS = {};
  39438. }
  39439. var PDFJS = globalScope.PDFJS;
  39440. PDFJS.version = '1.7.290';
  39441. PDFJS.build = 'b509a3f8';
  39442. PDFJS.pdfBug = false;
  39443. if (PDFJS.verbosity !== undefined) {
  39444. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39445. }
  39446. delete PDFJS.verbosity;
  39447. Object.defineProperty(PDFJS, 'verbosity', {
  39448. get: function () {
  39449. return sharedUtil.getVerbosityLevel();
  39450. },
  39451. set: function (level) {
  39452. sharedUtil.setVerbosityLevel(level);
  39453. },
  39454. enumerable: true,
  39455. configurable: true
  39456. });
  39457. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39458. PDFJS.OPS = sharedUtil.OPS;
  39459. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39460. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39461. PDFJS.shadow = sharedUtil.shadow;
  39462. PDFJS.createBlob = sharedUtil.createBlob;
  39463. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39464. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39465. };
  39466. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39467. configurable: true,
  39468. get: function PDFJS_isLittleEndian() {
  39469. var value = sharedUtil.isLittleEndian();
  39470. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39471. }
  39472. });
  39473. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39474. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39475. PDFJS.PasswordException = sharedUtil.PasswordException;
  39476. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39477. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39478. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39479. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39480. PDFJS.Util = sharedUtil.Util;
  39481. PDFJS.PageViewport = sharedUtil.PageViewport;
  39482. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39483. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39484. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39485. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39486. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39487. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39488. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39489. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39490. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39491. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39492. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39493. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39494. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39495. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39496. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39497. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39498. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39499. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39500. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39501. delete PDFJS.openExternalLinksInNewWindow;
  39502. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39503. get: function () {
  39504. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39505. },
  39506. set: function (value) {
  39507. if (value) {
  39508. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39509. }
  39510. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39511. warn('PDFJS.externalLinkTarget is already initialized');
  39512. return;
  39513. }
  39514. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39515. },
  39516. enumerable: true,
  39517. configurable: true
  39518. });
  39519. if (savedOpenExternalLinksInNewWindow) {
  39520. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39521. }
  39522. PDFJS.getDocument = displayAPI.getDocument;
  39523. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39524. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39525. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39526. configurable: true,
  39527. get: function PDFJS_hasCanvasTypedArrays() {
  39528. var value = displayDOMUtils.hasCanvasTypedArrays();
  39529. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39530. }
  39531. });
  39532. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39533. PDFJS.LinkTarget = LinkTarget;
  39534. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39535. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39536. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39537. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39538. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39539. PDFJS.Metadata = displayMetadata.Metadata;
  39540. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39541. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39542. exports.globalScope = globalScope;
  39543. exports.isWorker = isWorker;
  39544. exports.PDFJS = globalScope.PDFJS;
  39545. /***/ }),
  39546. /* 26 */
  39547. /***/ (function(module, exports) {
  39548. var g;
  39549. g = function () {
  39550. return this;
  39551. }();
  39552. try {
  39553. g = g || Function("return this")() || (1, eval)("this");
  39554. } catch (e) {
  39555. if (typeof window === "object")
  39556. g = window;
  39557. }
  39558. module.exports = g;
  39559. /***/ }),
  39560. /* 27 */
  39561. /***/ (function(module, exports) {
  39562. module.exports = function (module) {
  39563. if (!module.webpackPolyfill) {
  39564. module.deprecate = function () {
  39565. };
  39566. module.paths = [];
  39567. if (!module.children)
  39568. module.children = [];
  39569. Object.defineProperty(module, "loaded", {
  39570. enumerable: true,
  39571. get: function () {
  39572. return module.l;
  39573. }
  39574. });
  39575. Object.defineProperty(module, "id", {
  39576. enumerable: true,
  39577. get: function () {
  39578. return module.i;
  39579. }
  39580. });
  39581. module.webpackPolyfill = 1;
  39582. }
  39583. return module;
  39584. };
  39585. /***/ }),
  39586. /* 28 */
  39587. /***/ (function(module, exports, __w_pdfjs_require__) {
  39588. "use strict";
  39589. var sharedUtil = __w_pdfjs_require__(0);
  39590. var corePrimitives = __w_pdfjs_require__(1);
  39591. var coreStream = __w_pdfjs_require__(2);
  39592. var coreColorSpace = __w_pdfjs_require__(4);
  39593. var coreObj = __w_pdfjs_require__(19);
  39594. var coreEvaluator = __w_pdfjs_require__(17);
  39595. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39596. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39597. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39598. var AnnotationType = sharedUtil.AnnotationType;
  39599. var OPS = sharedUtil.OPS;
  39600. var Util = sharedUtil.Util;
  39601. var isArray = sharedUtil.isArray;
  39602. var isInt = sharedUtil.isInt;
  39603. var stringToBytes = sharedUtil.stringToBytes;
  39604. var stringToPDFString = sharedUtil.stringToPDFString;
  39605. var warn = sharedUtil.warn;
  39606. var Dict = corePrimitives.Dict;
  39607. var isDict = corePrimitives.isDict;
  39608. var isName = corePrimitives.isName;
  39609. var isRef = corePrimitives.isRef;
  39610. var Stream = coreStream.Stream;
  39611. var ColorSpace = coreColorSpace.ColorSpace;
  39612. var Catalog = coreObj.Catalog;
  39613. var ObjectLoader = coreObj.ObjectLoader;
  39614. var FileSpec = coreObj.FileSpec;
  39615. var OperatorList = coreEvaluator.OperatorList;
  39616. function AnnotationFactory() {
  39617. }
  39618. AnnotationFactory.prototype = {
  39619. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39620. var dict = xref.fetchIfRef(ref);
  39621. if (!isDict(dict)) {
  39622. return;
  39623. }
  39624. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39625. var subtype = dict.get('Subtype');
  39626. subtype = isName(subtype) ? subtype.name : null;
  39627. var parameters = {
  39628. xref: xref,
  39629. dict: dict,
  39630. ref: isRef(ref) ? ref : null,
  39631. subtype: subtype,
  39632. id: id,
  39633. pdfManager: pdfManager
  39634. };
  39635. switch (subtype) {
  39636. case 'Link':
  39637. return new LinkAnnotation(parameters);
  39638. case 'Text':
  39639. return new TextAnnotation(parameters);
  39640. case 'Widget':
  39641. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39642. fieldType = isName(fieldType) ? fieldType.name : null;
  39643. switch (fieldType) {
  39644. case 'Tx':
  39645. return new TextWidgetAnnotation(parameters);
  39646. case 'Btn':
  39647. return new ButtonWidgetAnnotation(parameters);
  39648. case 'Ch':
  39649. return new ChoiceWidgetAnnotation(parameters);
  39650. }
  39651. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39652. return new WidgetAnnotation(parameters);
  39653. case 'Popup':
  39654. return new PopupAnnotation(parameters);
  39655. case 'Highlight':
  39656. return new HighlightAnnotation(parameters);
  39657. case 'Underline':
  39658. return new UnderlineAnnotation(parameters);
  39659. case 'Squiggly':
  39660. return new SquigglyAnnotation(parameters);
  39661. case 'StrikeOut':
  39662. return new StrikeOutAnnotation(parameters);
  39663. case 'FileAttachment':
  39664. return new FileAttachmentAnnotation(parameters);
  39665. default:
  39666. if (!subtype) {
  39667. warn('Annotation is missing the required /Subtype.');
  39668. } else {
  39669. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39670. }
  39671. return new Annotation(parameters);
  39672. }
  39673. }
  39674. };
  39675. var Annotation = function AnnotationClosure() {
  39676. function getTransformMatrix(rect, bbox, matrix) {
  39677. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39678. var minX = bounds[0];
  39679. var minY = bounds[1];
  39680. var maxX = bounds[2];
  39681. var maxY = bounds[3];
  39682. if (minX === maxX || minY === maxY) {
  39683. return [
  39684. 1,
  39685. 0,
  39686. 0,
  39687. 1,
  39688. rect[0],
  39689. rect[1]
  39690. ];
  39691. }
  39692. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39693. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39694. return [
  39695. xRatio,
  39696. 0,
  39697. 0,
  39698. yRatio,
  39699. rect[0] - minX * xRatio,
  39700. rect[1] - minY * yRatio
  39701. ];
  39702. }
  39703. function getDefaultAppearance(dict) {
  39704. var appearanceState = dict.get('AP');
  39705. if (!isDict(appearanceState)) {
  39706. return;
  39707. }
  39708. var appearance;
  39709. var appearances = appearanceState.get('N');
  39710. if (isDict(appearances)) {
  39711. var as = dict.get('AS');
  39712. if (as && appearances.has(as.name)) {
  39713. appearance = appearances.get(as.name);
  39714. }
  39715. } else {
  39716. appearance = appearances;
  39717. }
  39718. return appearance;
  39719. }
  39720. function Annotation(params) {
  39721. var dict = params.dict;
  39722. this.setFlags(dict.get('F'));
  39723. this.setRectangle(dict.getArray('Rect'));
  39724. this.setColor(dict.getArray('C'));
  39725. this.setBorderStyle(dict);
  39726. this.appearance = getDefaultAppearance(dict);
  39727. this.data = {};
  39728. this.data.id = params.id;
  39729. this.data.subtype = params.subtype;
  39730. this.data.annotationFlags = this.flags;
  39731. this.data.rect = this.rectangle;
  39732. this.data.color = this.color;
  39733. this.data.borderStyle = this.borderStyle;
  39734. this.data.hasAppearance = !!this.appearance;
  39735. }
  39736. Annotation.prototype = {
  39737. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39738. return !!(flags & flag);
  39739. },
  39740. _isViewable: function Annotation_isViewable(flags) {
  39741. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39742. },
  39743. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39744. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39745. },
  39746. get viewable() {
  39747. if (this.flags === 0) {
  39748. return true;
  39749. }
  39750. return this._isViewable(this.flags);
  39751. },
  39752. get printable() {
  39753. if (this.flags === 0) {
  39754. return false;
  39755. }
  39756. return this._isPrintable(this.flags);
  39757. },
  39758. setFlags: function Annotation_setFlags(flags) {
  39759. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39760. },
  39761. hasFlag: function Annotation_hasFlag(flag) {
  39762. return this._hasFlag(this.flags, flag);
  39763. },
  39764. setRectangle: function Annotation_setRectangle(rectangle) {
  39765. if (isArray(rectangle) && rectangle.length === 4) {
  39766. this.rectangle = Util.normalizeRect(rectangle);
  39767. } else {
  39768. this.rectangle = [
  39769. 0,
  39770. 0,
  39771. 0,
  39772. 0
  39773. ];
  39774. }
  39775. },
  39776. setColor: function Annotation_setColor(color) {
  39777. var rgbColor = new Uint8Array(3);
  39778. if (!isArray(color)) {
  39779. this.color = rgbColor;
  39780. return;
  39781. }
  39782. switch (color.length) {
  39783. case 0:
  39784. this.color = null;
  39785. break;
  39786. case 1:
  39787. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39788. this.color = rgbColor;
  39789. break;
  39790. case 3:
  39791. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39792. this.color = rgbColor;
  39793. break;
  39794. case 4:
  39795. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39796. this.color = rgbColor;
  39797. break;
  39798. default:
  39799. this.color = rgbColor;
  39800. break;
  39801. }
  39802. },
  39803. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39804. this.borderStyle = new AnnotationBorderStyle();
  39805. if (!isDict(borderStyle)) {
  39806. return;
  39807. }
  39808. if (borderStyle.has('BS')) {
  39809. var dict = borderStyle.get('BS');
  39810. var dictType = dict.get('Type');
  39811. if (!dictType || isName(dictType, 'Border')) {
  39812. this.borderStyle.setWidth(dict.get('W'));
  39813. this.borderStyle.setStyle(dict.get('S'));
  39814. this.borderStyle.setDashArray(dict.getArray('D'));
  39815. }
  39816. } else if (borderStyle.has('Border')) {
  39817. var array = borderStyle.getArray('Border');
  39818. if (isArray(array) && array.length >= 3) {
  39819. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39820. this.borderStyle.setVerticalCornerRadius(array[1]);
  39821. this.borderStyle.setWidth(array[2]);
  39822. if (array.length === 4) {
  39823. this.borderStyle.setDashArray(array[3]);
  39824. }
  39825. }
  39826. } else {
  39827. this.borderStyle.setWidth(0);
  39828. }
  39829. },
  39830. _preparePopup: function Annotation_preparePopup(dict) {
  39831. if (!dict.has('C')) {
  39832. this.data.color = null;
  39833. }
  39834. this.data.hasPopup = dict.has('Popup');
  39835. this.data.title = stringToPDFString(dict.get('T') || '');
  39836. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39837. },
  39838. loadResources: function Annotation_loadResources(keys) {
  39839. return new Promise(function (resolve, reject) {
  39840. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39841. if (!resources) {
  39842. resolve();
  39843. return;
  39844. }
  39845. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39846. objectLoader.load().then(function () {
  39847. resolve(resources);
  39848. }, reject);
  39849. }, reject);
  39850. }.bind(this));
  39851. },
  39852. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39853. if (!this.appearance) {
  39854. return Promise.resolve(new OperatorList());
  39855. }
  39856. var data = this.data;
  39857. var appearanceDict = this.appearance.dict;
  39858. var resourcesPromise = this.loadResources([
  39859. 'ExtGState',
  39860. 'ColorSpace',
  39861. 'Pattern',
  39862. 'Shading',
  39863. 'XObject',
  39864. 'Font'
  39865. ]);
  39866. var bbox = appearanceDict.getArray('BBox') || [
  39867. 0,
  39868. 0,
  39869. 1,
  39870. 1
  39871. ];
  39872. var matrix = appearanceDict.getArray('Matrix') || [
  39873. 1,
  39874. 0,
  39875. 0,
  39876. 1,
  39877. 0,
  39878. 0
  39879. ];
  39880. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39881. var self = this;
  39882. return resourcesPromise.then(function (resources) {
  39883. var opList = new OperatorList();
  39884. opList.addOp(OPS.beginAnnotation, [
  39885. data.rect,
  39886. transform,
  39887. matrix
  39888. ]);
  39889. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39890. opList.addOp(OPS.endAnnotation, []);
  39891. self.appearance.reset();
  39892. return opList;
  39893. });
  39894. });
  39895. }
  39896. };
  39897. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39898. var annotationPromises = [];
  39899. for (var i = 0, n = annotations.length; i < n; ++i) {
  39900. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39901. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39902. }
  39903. }
  39904. return Promise.all(annotationPromises).then(function (operatorLists) {
  39905. opList.addOp(OPS.beginAnnotations, []);
  39906. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39907. opList.addOpList(operatorLists[i]);
  39908. }
  39909. opList.addOp(OPS.endAnnotations, []);
  39910. });
  39911. };
  39912. return Annotation;
  39913. }();
  39914. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39915. function AnnotationBorderStyle() {
  39916. this.width = 1;
  39917. this.style = AnnotationBorderStyleType.SOLID;
  39918. this.dashArray = [3];
  39919. this.horizontalCornerRadius = 0;
  39920. this.verticalCornerRadius = 0;
  39921. }
  39922. AnnotationBorderStyle.prototype = {
  39923. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39924. if (width === (width | 0)) {
  39925. this.width = width;
  39926. }
  39927. },
  39928. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39929. if (!style) {
  39930. return;
  39931. }
  39932. switch (style.name) {
  39933. case 'S':
  39934. this.style = AnnotationBorderStyleType.SOLID;
  39935. break;
  39936. case 'D':
  39937. this.style = AnnotationBorderStyleType.DASHED;
  39938. break;
  39939. case 'B':
  39940. this.style = AnnotationBorderStyleType.BEVELED;
  39941. break;
  39942. case 'I':
  39943. this.style = AnnotationBorderStyleType.INSET;
  39944. break;
  39945. case 'U':
  39946. this.style = AnnotationBorderStyleType.UNDERLINE;
  39947. break;
  39948. default:
  39949. break;
  39950. }
  39951. },
  39952. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39953. if (isArray(dashArray) && dashArray.length > 0) {
  39954. var isValid = true;
  39955. var allZeros = true;
  39956. for (var i = 0, len = dashArray.length; i < len; i++) {
  39957. var element = dashArray[i];
  39958. var validNumber = +element >= 0;
  39959. if (!validNumber) {
  39960. isValid = false;
  39961. break;
  39962. } else if (element > 0) {
  39963. allZeros = false;
  39964. }
  39965. }
  39966. if (isValid && !allZeros) {
  39967. this.dashArray = dashArray;
  39968. } else {
  39969. this.width = 0;
  39970. }
  39971. } else if (dashArray) {
  39972. this.width = 0;
  39973. }
  39974. },
  39975. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39976. if (radius === (radius | 0)) {
  39977. this.horizontalCornerRadius = radius;
  39978. }
  39979. },
  39980. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39981. if (radius === (radius | 0)) {
  39982. this.verticalCornerRadius = radius;
  39983. }
  39984. }
  39985. };
  39986. return AnnotationBorderStyle;
  39987. }();
  39988. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39989. function WidgetAnnotation(params) {
  39990. Annotation.call(this, params);
  39991. var dict = params.dict;
  39992. var data = this.data;
  39993. data.annotationType = AnnotationType.WIDGET;
  39994. data.fieldName = this._constructFieldName(dict);
  39995. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39996. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39997. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39998. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39999. data.fieldType = isName(fieldType) ? fieldType.name : null;
  40000. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40001. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40002. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40003. data.fieldFlags = 0;
  40004. }
  40005. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40006. if (data.fieldType === 'Sig') {
  40007. this.setFlags(AnnotationFlag.HIDDEN);
  40008. }
  40009. }
  40010. Util.inherit(WidgetAnnotation, Annotation, {
  40011. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40012. if (!dict.has('T') && !dict.has('Parent')) {
  40013. warn('Unknown field name, falling back to empty field name.');
  40014. return '';
  40015. }
  40016. if (!dict.has('Parent')) {
  40017. return stringToPDFString(dict.get('T'));
  40018. }
  40019. var fieldName = [];
  40020. if (dict.has('T')) {
  40021. fieldName.unshift(stringToPDFString(dict.get('T')));
  40022. }
  40023. var loopDict = dict;
  40024. while (loopDict.has('Parent')) {
  40025. loopDict = loopDict.get('Parent');
  40026. if (loopDict.has('T')) {
  40027. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40028. }
  40029. }
  40030. return fieldName.join('.');
  40031. },
  40032. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40033. return !!(this.data.fieldFlags & flag);
  40034. }
  40035. });
  40036. return WidgetAnnotation;
  40037. }();
  40038. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40039. function TextWidgetAnnotation(params) {
  40040. WidgetAnnotation.call(this, params);
  40041. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40042. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40043. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40044. alignment = null;
  40045. }
  40046. this.data.textAlignment = alignment;
  40047. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40048. if (!isInt(maximumLength) || maximumLength < 0) {
  40049. maximumLength = null;
  40050. }
  40051. this.data.maxLen = maximumLength;
  40052. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40053. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40054. }
  40055. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40056. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40057. var operatorList = new OperatorList();
  40058. if (renderForms) {
  40059. return Promise.resolve(operatorList);
  40060. }
  40061. if (this.appearance) {
  40062. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40063. }
  40064. if (!this.data.defaultAppearance) {
  40065. return Promise.resolve(operatorList);
  40066. }
  40067. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40068. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40069. return operatorList;
  40070. });
  40071. }
  40072. });
  40073. return TextWidgetAnnotation;
  40074. }();
  40075. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40076. function ButtonWidgetAnnotation(params) {
  40077. WidgetAnnotation.call(this, params);
  40078. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40079. if (this.data.checkBox) {
  40080. if (!isName(this.data.fieldValue)) {
  40081. return;
  40082. }
  40083. this.data.fieldValue = this.data.fieldValue.name;
  40084. }
  40085. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40086. if (this.data.radioButton) {
  40087. this.data.fieldValue = this.data.buttonValue = null;
  40088. var fieldParent = params.dict.get('Parent');
  40089. if (isDict(fieldParent) && fieldParent.has('V')) {
  40090. var fieldParentValue = fieldParent.get('V');
  40091. if (isName(fieldParentValue)) {
  40092. this.data.fieldValue = fieldParentValue.name;
  40093. }
  40094. }
  40095. var appearanceStates = params.dict.get('AP');
  40096. if (!isDict(appearanceStates)) {
  40097. return;
  40098. }
  40099. var normalAppearanceState = appearanceStates.get('N');
  40100. if (!isDict(normalAppearanceState)) {
  40101. return;
  40102. }
  40103. var keys = normalAppearanceState.getKeys();
  40104. for (var i = 0, ii = keys.length; i < ii; i++) {
  40105. if (keys[i] !== 'Off') {
  40106. this.data.buttonValue = keys[i];
  40107. break;
  40108. }
  40109. }
  40110. }
  40111. }
  40112. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40113. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40114. var operatorList = new OperatorList();
  40115. if (renderForms) {
  40116. return Promise.resolve(operatorList);
  40117. }
  40118. if (this.appearance) {
  40119. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40120. }
  40121. return Promise.resolve(operatorList);
  40122. }
  40123. });
  40124. return ButtonWidgetAnnotation;
  40125. }();
  40126. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40127. function ChoiceWidgetAnnotation(params) {
  40128. WidgetAnnotation.call(this, params);
  40129. this.data.options = [];
  40130. var options = params.dict.get('Opt');
  40131. if (isArray(options)) {
  40132. var xref = params.xref;
  40133. for (var i = 0, ii = options.length; i < ii; i++) {
  40134. var option = xref.fetchIfRef(options[i]);
  40135. var isOptionArray = isArray(option);
  40136. this.data.options[i] = {
  40137. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40138. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40139. };
  40140. }
  40141. }
  40142. if (!isArray(this.data.fieldValue)) {
  40143. this.data.fieldValue = [this.data.fieldValue];
  40144. }
  40145. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40146. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40147. }
  40148. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40149. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40150. var operatorList = new OperatorList();
  40151. if (renderForms) {
  40152. return Promise.resolve(operatorList);
  40153. }
  40154. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40155. }
  40156. });
  40157. return ChoiceWidgetAnnotation;
  40158. }();
  40159. var TextAnnotation = function TextAnnotationClosure() {
  40160. var DEFAULT_ICON_SIZE = 22;
  40161. function TextAnnotation(parameters) {
  40162. Annotation.call(this, parameters);
  40163. this.data.annotationType = AnnotationType.TEXT;
  40164. if (this.data.hasAppearance) {
  40165. this.data.name = 'NoIcon';
  40166. } else {
  40167. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40168. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40169. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40170. }
  40171. this._preparePopup(parameters.dict);
  40172. }
  40173. Util.inherit(TextAnnotation, Annotation, {});
  40174. return TextAnnotation;
  40175. }();
  40176. var LinkAnnotation = function LinkAnnotationClosure() {
  40177. function LinkAnnotation(params) {
  40178. Annotation.call(this, params);
  40179. var data = this.data;
  40180. data.annotationType = AnnotationType.LINK;
  40181. Catalog.parseDestDictionary({
  40182. destDict: params.dict,
  40183. resultObj: data,
  40184. docBaseUrl: params.pdfManager.docBaseUrl
  40185. });
  40186. }
  40187. Util.inherit(LinkAnnotation, Annotation, {});
  40188. return LinkAnnotation;
  40189. }();
  40190. var PopupAnnotation = function PopupAnnotationClosure() {
  40191. function PopupAnnotation(parameters) {
  40192. Annotation.call(this, parameters);
  40193. this.data.annotationType = AnnotationType.POPUP;
  40194. var dict = parameters.dict;
  40195. var parentItem = dict.get('Parent');
  40196. if (!parentItem) {
  40197. warn('Popup annotation has a missing or invalid parent annotation.');
  40198. return;
  40199. }
  40200. this.data.parentId = dict.getRaw('Parent').toString();
  40201. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40202. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40203. if (!parentItem.has('C')) {
  40204. this.data.color = null;
  40205. } else {
  40206. this.setColor(parentItem.getArray('C'));
  40207. this.data.color = this.color;
  40208. }
  40209. if (!this.viewable) {
  40210. var parentFlags = parentItem.get('F');
  40211. if (this._isViewable(parentFlags)) {
  40212. this.setFlags(parentFlags);
  40213. }
  40214. }
  40215. }
  40216. Util.inherit(PopupAnnotation, Annotation, {});
  40217. return PopupAnnotation;
  40218. }();
  40219. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40220. function HighlightAnnotation(parameters) {
  40221. Annotation.call(this, parameters);
  40222. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40223. this._preparePopup(parameters.dict);
  40224. this.data.borderStyle.setWidth(0);
  40225. }
  40226. Util.inherit(HighlightAnnotation, Annotation, {});
  40227. return HighlightAnnotation;
  40228. }();
  40229. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40230. function UnderlineAnnotation(parameters) {
  40231. Annotation.call(this, parameters);
  40232. this.data.annotationType = AnnotationType.UNDERLINE;
  40233. this._preparePopup(parameters.dict);
  40234. this.data.borderStyle.setWidth(0);
  40235. }
  40236. Util.inherit(UnderlineAnnotation, Annotation, {});
  40237. return UnderlineAnnotation;
  40238. }();
  40239. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40240. function SquigglyAnnotation(parameters) {
  40241. Annotation.call(this, parameters);
  40242. this.data.annotationType = AnnotationType.SQUIGGLY;
  40243. this._preparePopup(parameters.dict);
  40244. this.data.borderStyle.setWidth(0);
  40245. }
  40246. Util.inherit(SquigglyAnnotation, Annotation, {});
  40247. return SquigglyAnnotation;
  40248. }();
  40249. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40250. function StrikeOutAnnotation(parameters) {
  40251. Annotation.call(this, parameters);
  40252. this.data.annotationType = AnnotationType.STRIKEOUT;
  40253. this._preparePopup(parameters.dict);
  40254. this.data.borderStyle.setWidth(0);
  40255. }
  40256. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40257. return StrikeOutAnnotation;
  40258. }();
  40259. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40260. function FileAttachmentAnnotation(parameters) {
  40261. Annotation.call(this, parameters);
  40262. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40263. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40264. this.data.file = file.serializable;
  40265. this._preparePopup(parameters.dict);
  40266. }
  40267. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40268. return FileAttachmentAnnotation;
  40269. }();
  40270. exports.Annotation = Annotation;
  40271. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40272. exports.AnnotationFactory = AnnotationFactory;
  40273. /***/ }),
  40274. /* 29 */
  40275. /***/ (function(module, exports, __w_pdfjs_require__) {
  40276. "use strict";
  40277. var sharedUtil = __w_pdfjs_require__(0);
  40278. var warn = sharedUtil.warn;
  40279. var baseTypes = [
  40280. 'BN',
  40281. 'BN',
  40282. 'BN',
  40283. 'BN',
  40284. 'BN',
  40285. 'BN',
  40286. 'BN',
  40287. 'BN',
  40288. 'BN',
  40289. 'S',
  40290. 'B',
  40291. 'S',
  40292. 'WS',
  40293. 'B',
  40294. 'BN',
  40295. 'BN',
  40296. 'BN',
  40297. 'BN',
  40298. 'BN',
  40299. 'BN',
  40300. 'BN',
  40301. 'BN',
  40302. 'BN',
  40303. 'BN',
  40304. 'BN',
  40305. 'BN',
  40306. 'BN',
  40307. 'BN',
  40308. 'B',
  40309. 'B',
  40310. 'B',
  40311. 'S',
  40312. 'WS',
  40313. 'ON',
  40314. 'ON',
  40315. 'ET',
  40316. 'ET',
  40317. 'ET',
  40318. 'ON',
  40319. 'ON',
  40320. 'ON',
  40321. 'ON',
  40322. 'ON',
  40323. 'ES',
  40324. 'CS',
  40325. 'ES',
  40326. 'CS',
  40327. 'CS',
  40328. 'EN',
  40329. 'EN',
  40330. 'EN',
  40331. 'EN',
  40332. 'EN',
  40333. 'EN',
  40334. 'EN',
  40335. 'EN',
  40336. 'EN',
  40337. 'EN',
  40338. 'CS',
  40339. 'ON',
  40340. 'ON',
  40341. 'ON',
  40342. 'ON',
  40343. 'ON',
  40344. 'ON',
  40345. 'L',
  40346. 'L',
  40347. 'L',
  40348. 'L',
  40349. 'L',
  40350. 'L',
  40351. 'L',
  40352. 'L',
  40353. 'L',
  40354. 'L',
  40355. 'L',
  40356. 'L',
  40357. 'L',
  40358. 'L',
  40359. 'L',
  40360. 'L',
  40361. 'L',
  40362. 'L',
  40363. 'L',
  40364. 'L',
  40365. 'L',
  40366. 'L',
  40367. 'L',
  40368. 'L',
  40369. 'L',
  40370. 'L',
  40371. 'ON',
  40372. 'ON',
  40373. 'ON',
  40374. 'ON',
  40375. 'ON',
  40376. 'ON',
  40377. 'L',
  40378. 'L',
  40379. 'L',
  40380. 'L',
  40381. 'L',
  40382. 'L',
  40383. 'L',
  40384. 'L',
  40385. 'L',
  40386. 'L',
  40387. 'L',
  40388. 'L',
  40389. 'L',
  40390. 'L',
  40391. 'L',
  40392. 'L',
  40393. 'L',
  40394. 'L',
  40395. 'L',
  40396. 'L',
  40397. 'L',
  40398. 'L',
  40399. 'L',
  40400. 'L',
  40401. 'L',
  40402. 'L',
  40403. 'ON',
  40404. 'ON',
  40405. 'ON',
  40406. 'ON',
  40407. 'BN',
  40408. 'BN',
  40409. 'BN',
  40410. 'BN',
  40411. 'BN',
  40412. 'BN',
  40413. 'B',
  40414. 'BN',
  40415. 'BN',
  40416. 'BN',
  40417. 'BN',
  40418. 'BN',
  40419. 'BN',
  40420. 'BN',
  40421. 'BN',
  40422. 'BN',
  40423. 'BN',
  40424. 'BN',
  40425. 'BN',
  40426. 'BN',
  40427. 'BN',
  40428. 'BN',
  40429. 'BN',
  40430. 'BN',
  40431. 'BN',
  40432. 'BN',
  40433. 'BN',
  40434. 'BN',
  40435. 'BN',
  40436. 'BN',
  40437. 'BN',
  40438. 'BN',
  40439. 'BN',
  40440. 'CS',
  40441. 'ON',
  40442. 'ET',
  40443. 'ET',
  40444. 'ET',
  40445. 'ET',
  40446. 'ON',
  40447. 'ON',
  40448. 'ON',
  40449. 'ON',
  40450. 'L',
  40451. 'ON',
  40452. 'ON',
  40453. 'BN',
  40454. 'ON',
  40455. 'ON',
  40456. 'ET',
  40457. 'ET',
  40458. 'EN',
  40459. 'EN',
  40460. 'ON',
  40461. 'L',
  40462. 'ON',
  40463. 'ON',
  40464. 'ON',
  40465. 'EN',
  40466. 'L',
  40467. 'ON',
  40468. 'ON',
  40469. 'ON',
  40470. 'ON',
  40471. 'ON',
  40472. 'L',
  40473. 'L',
  40474. 'L',
  40475. 'L',
  40476. 'L',
  40477. 'L',
  40478. 'L',
  40479. 'L',
  40480. 'L',
  40481. 'L',
  40482. 'L',
  40483. 'L',
  40484. 'L',
  40485. 'L',
  40486. 'L',
  40487. 'L',
  40488. 'L',
  40489. 'L',
  40490. 'L',
  40491. 'L',
  40492. 'L',
  40493. 'L',
  40494. 'L',
  40495. 'ON',
  40496. 'L',
  40497. 'L',
  40498. 'L',
  40499. 'L',
  40500. 'L',
  40501. 'L',
  40502. 'L',
  40503. 'L',
  40504. 'L',
  40505. 'L',
  40506. 'L',
  40507. 'L',
  40508. 'L',
  40509. 'L',
  40510. 'L',
  40511. 'L',
  40512. 'L',
  40513. 'L',
  40514. 'L',
  40515. 'L',
  40516. 'L',
  40517. 'L',
  40518. 'L',
  40519. 'L',
  40520. 'L',
  40521. 'L',
  40522. 'L',
  40523. 'L',
  40524. 'L',
  40525. 'L',
  40526. 'L',
  40527. 'ON',
  40528. 'L',
  40529. 'L',
  40530. 'L',
  40531. 'L',
  40532. 'L',
  40533. 'L',
  40534. 'L',
  40535. 'L'
  40536. ];
  40537. var arabicTypes = [
  40538. 'AN',
  40539. 'AN',
  40540. 'AN',
  40541. 'AN',
  40542. 'AN',
  40543. 'AN',
  40544. 'ON',
  40545. 'ON',
  40546. 'AL',
  40547. 'ET',
  40548. 'ET',
  40549. 'AL',
  40550. 'CS',
  40551. 'AL',
  40552. 'ON',
  40553. 'ON',
  40554. 'NSM',
  40555. 'NSM',
  40556. 'NSM',
  40557. 'NSM',
  40558. 'NSM',
  40559. 'NSM',
  40560. 'NSM',
  40561. 'NSM',
  40562. 'NSM',
  40563. 'NSM',
  40564. 'NSM',
  40565. 'AL',
  40566. 'AL',
  40567. '',
  40568. 'AL',
  40569. 'AL',
  40570. 'AL',
  40571. 'AL',
  40572. 'AL',
  40573. 'AL',
  40574. 'AL',
  40575. 'AL',
  40576. 'AL',
  40577. 'AL',
  40578. 'AL',
  40579. 'AL',
  40580. 'AL',
  40581. 'AL',
  40582. 'AL',
  40583. 'AL',
  40584. 'AL',
  40585. 'AL',
  40586. 'AL',
  40587. 'AL',
  40588. 'AL',
  40589. 'AL',
  40590. 'AL',
  40591. 'AL',
  40592. 'AL',
  40593. 'AL',
  40594. 'AL',
  40595. 'AL',
  40596. 'AL',
  40597. 'AL',
  40598. 'AL',
  40599. 'AL',
  40600. 'AL',
  40601. 'AL',
  40602. 'AL',
  40603. 'AL',
  40604. 'AL',
  40605. 'AL',
  40606. 'AL',
  40607. 'AL',
  40608. 'AL',
  40609. 'AL',
  40610. 'AL',
  40611. 'AL',
  40612. 'AL',
  40613. 'NSM',
  40614. 'NSM',
  40615. 'NSM',
  40616. 'NSM',
  40617. 'NSM',
  40618. 'NSM',
  40619. 'NSM',
  40620. 'NSM',
  40621. 'NSM',
  40622. 'NSM',
  40623. 'NSM',
  40624. 'NSM',
  40625. 'NSM',
  40626. 'NSM',
  40627. 'NSM',
  40628. 'NSM',
  40629. 'NSM',
  40630. 'NSM',
  40631. 'NSM',
  40632. 'NSM',
  40633. 'NSM',
  40634. 'AN',
  40635. 'AN',
  40636. 'AN',
  40637. 'AN',
  40638. 'AN',
  40639. 'AN',
  40640. 'AN',
  40641. 'AN',
  40642. 'AN',
  40643. 'AN',
  40644. 'ET',
  40645. 'AN',
  40646. 'AN',
  40647. 'AL',
  40648. 'AL',
  40649. 'AL',
  40650. 'NSM',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'AL',
  40671. 'AL',
  40672. 'AL',
  40673. 'AL',
  40674. 'AL',
  40675. 'AL',
  40676. 'AL',
  40677. 'AL',
  40678. 'AL',
  40679. 'AL',
  40680. 'AL',
  40681. 'AL',
  40682. 'AL',
  40683. 'AL',
  40684. 'AL',
  40685. 'AL',
  40686. 'AL',
  40687. 'AL',
  40688. 'AL',
  40689. 'AL',
  40690. 'AL',
  40691. 'AL',
  40692. 'AL',
  40693. 'AL',
  40694. 'AL',
  40695. 'AL',
  40696. 'AL',
  40697. 'AL',
  40698. 'AL',
  40699. 'AL',
  40700. 'AL',
  40701. 'AL',
  40702. 'AL',
  40703. 'AL',
  40704. 'AL',
  40705. 'AL',
  40706. 'AL',
  40707. 'AL',
  40708. 'AL',
  40709. 'AL',
  40710. 'AL',
  40711. 'AL',
  40712. 'AL',
  40713. 'AL',
  40714. 'AL',
  40715. 'AL',
  40716. 'AL',
  40717. 'AL',
  40718. 'AL',
  40719. 'AL',
  40720. 'AL',
  40721. 'AL',
  40722. 'AL',
  40723. 'AL',
  40724. 'AL',
  40725. 'AL',
  40726. 'AL',
  40727. 'AL',
  40728. 'AL',
  40729. 'AL',
  40730. 'AL',
  40731. 'AL',
  40732. 'AL',
  40733. 'AL',
  40734. 'AL',
  40735. 'AL',
  40736. 'AL',
  40737. 'AL',
  40738. 'AL',
  40739. 'AL',
  40740. 'AL',
  40741. 'AL',
  40742. 'AL',
  40743. 'AL',
  40744. 'AL',
  40745. 'AL',
  40746. 'AL',
  40747. 'AL',
  40748. 'AL',
  40749. 'AL',
  40750. 'AL',
  40751. 'AL',
  40752. 'NSM',
  40753. 'NSM',
  40754. 'NSM',
  40755. 'NSM',
  40756. 'NSM',
  40757. 'NSM',
  40758. 'NSM',
  40759. 'AN',
  40760. 'ON',
  40761. 'NSM',
  40762. 'NSM',
  40763. 'NSM',
  40764. 'NSM',
  40765. 'NSM',
  40766. 'NSM',
  40767. 'AL',
  40768. 'AL',
  40769. 'NSM',
  40770. 'NSM',
  40771. 'ON',
  40772. 'NSM',
  40773. 'NSM',
  40774. 'NSM',
  40775. 'NSM',
  40776. 'AL',
  40777. 'AL',
  40778. 'EN',
  40779. 'EN',
  40780. 'EN',
  40781. 'EN',
  40782. 'EN',
  40783. 'EN',
  40784. 'EN',
  40785. 'EN',
  40786. 'EN',
  40787. 'EN',
  40788. 'AL',
  40789. 'AL',
  40790. 'AL',
  40791. 'AL',
  40792. 'AL',
  40793. 'AL'
  40794. ];
  40795. function isOdd(i) {
  40796. return (i & 1) !== 0;
  40797. }
  40798. function isEven(i) {
  40799. return (i & 1) === 0;
  40800. }
  40801. function findUnequal(arr, start, value) {
  40802. for (var j = start, jj = arr.length; j < jj; ++j) {
  40803. if (arr[j] !== value) {
  40804. return j;
  40805. }
  40806. }
  40807. return j;
  40808. }
  40809. function setValues(arr, start, end, value) {
  40810. for (var j = start; j < end; ++j) {
  40811. arr[j] = value;
  40812. }
  40813. }
  40814. function reverseValues(arr, start, end) {
  40815. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40816. var temp = arr[i];
  40817. arr[i] = arr[j];
  40818. arr[j] = temp;
  40819. }
  40820. }
  40821. function createBidiText(str, isLTR, vertical) {
  40822. return {
  40823. str: str,
  40824. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40825. };
  40826. }
  40827. var chars = [];
  40828. var types = [];
  40829. function bidi(str, startLevel, vertical) {
  40830. var isLTR = true;
  40831. var strLength = str.length;
  40832. if (strLength === 0 || vertical) {
  40833. return createBidiText(str, isLTR, vertical);
  40834. }
  40835. chars.length = strLength;
  40836. types.length = strLength;
  40837. var numBidi = 0;
  40838. var i, ii;
  40839. for (i = 0; i < strLength; ++i) {
  40840. chars[i] = str.charAt(i);
  40841. var charCode = str.charCodeAt(i);
  40842. var charType = 'L';
  40843. if (charCode <= 0x00ff) {
  40844. charType = baseTypes[charCode];
  40845. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40846. charType = 'R';
  40847. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40848. charType = arabicTypes[charCode & 0xff];
  40849. if (!charType) {
  40850. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40851. }
  40852. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40853. charType = 'AL';
  40854. }
  40855. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40856. numBidi++;
  40857. }
  40858. types[i] = charType;
  40859. }
  40860. if (numBidi === 0) {
  40861. isLTR = true;
  40862. return createBidiText(str, isLTR);
  40863. }
  40864. if (startLevel === -1) {
  40865. if (numBidi / strLength < 0.3) {
  40866. isLTR = true;
  40867. startLevel = 0;
  40868. } else {
  40869. isLTR = false;
  40870. startLevel = 1;
  40871. }
  40872. }
  40873. var levels = [];
  40874. for (i = 0; i < strLength; ++i) {
  40875. levels[i] = startLevel;
  40876. }
  40877. var e = isOdd(startLevel) ? 'R' : 'L';
  40878. var sor = e;
  40879. var eor = sor;
  40880. var lastType = sor;
  40881. for (i = 0; i < strLength; ++i) {
  40882. if (types[i] === 'NSM') {
  40883. types[i] = lastType;
  40884. } else {
  40885. lastType = types[i];
  40886. }
  40887. }
  40888. lastType = sor;
  40889. var t;
  40890. for (i = 0; i < strLength; ++i) {
  40891. t = types[i];
  40892. if (t === 'EN') {
  40893. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40894. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40895. lastType = t;
  40896. }
  40897. }
  40898. for (i = 0; i < strLength; ++i) {
  40899. t = types[i];
  40900. if (t === 'AL') {
  40901. types[i] = 'R';
  40902. }
  40903. }
  40904. for (i = 1; i < strLength - 1; ++i) {
  40905. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40906. types[i] = 'EN';
  40907. }
  40908. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40909. types[i] = types[i - 1];
  40910. }
  40911. }
  40912. for (i = 0; i < strLength; ++i) {
  40913. if (types[i] === 'EN') {
  40914. var j;
  40915. for (j = i - 1; j >= 0; --j) {
  40916. if (types[j] !== 'ET') {
  40917. break;
  40918. }
  40919. types[j] = 'EN';
  40920. }
  40921. for (j = i + 1; j < strLength; ++j) {
  40922. if (types[j] !== 'ET') {
  40923. break;
  40924. }
  40925. types[j] = 'EN';
  40926. }
  40927. }
  40928. }
  40929. for (i = 0; i < strLength; ++i) {
  40930. t = types[i];
  40931. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40932. types[i] = 'ON';
  40933. }
  40934. }
  40935. lastType = sor;
  40936. for (i = 0; i < strLength; ++i) {
  40937. t = types[i];
  40938. if (t === 'EN') {
  40939. types[i] = lastType === 'L' ? 'L' : 'EN';
  40940. } else if (t === 'R' || t === 'L') {
  40941. lastType = t;
  40942. }
  40943. }
  40944. for (i = 0; i < strLength; ++i) {
  40945. if (types[i] === 'ON') {
  40946. var end = findUnequal(types, i + 1, 'ON');
  40947. var before = sor;
  40948. if (i > 0) {
  40949. before = types[i - 1];
  40950. }
  40951. var after = eor;
  40952. if (end + 1 < strLength) {
  40953. after = types[end + 1];
  40954. }
  40955. if (before !== 'L') {
  40956. before = 'R';
  40957. }
  40958. if (after !== 'L') {
  40959. after = 'R';
  40960. }
  40961. if (before === after) {
  40962. setValues(types, i, end, before);
  40963. }
  40964. i = end - 1;
  40965. }
  40966. }
  40967. for (i = 0; i < strLength; ++i) {
  40968. if (types[i] === 'ON') {
  40969. types[i] = e;
  40970. }
  40971. }
  40972. for (i = 0; i < strLength; ++i) {
  40973. t = types[i];
  40974. if (isEven(levels[i])) {
  40975. if (t === 'R') {
  40976. levels[i] += 1;
  40977. } else if (t === 'AN' || t === 'EN') {
  40978. levels[i] += 2;
  40979. }
  40980. } else {
  40981. if (t === 'L' || t === 'AN' || t === 'EN') {
  40982. levels[i] += 1;
  40983. }
  40984. }
  40985. }
  40986. var highestLevel = -1;
  40987. var lowestOddLevel = 99;
  40988. var level;
  40989. for (i = 0, ii = levels.length; i < ii; ++i) {
  40990. level = levels[i];
  40991. if (highestLevel < level) {
  40992. highestLevel = level;
  40993. }
  40994. if (lowestOddLevel > level && isOdd(level)) {
  40995. lowestOddLevel = level;
  40996. }
  40997. }
  40998. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40999. var start = -1;
  41000. for (i = 0, ii = levels.length; i < ii; ++i) {
  41001. if (levels[i] < level) {
  41002. if (start >= 0) {
  41003. reverseValues(chars, start, i);
  41004. start = -1;
  41005. }
  41006. } else if (start < 0) {
  41007. start = i;
  41008. }
  41009. }
  41010. if (start >= 0) {
  41011. reverseValues(chars, start, levels.length);
  41012. }
  41013. }
  41014. for (i = 0, ii = chars.length; i < ii; ++i) {
  41015. var ch = chars[i];
  41016. if (ch === '<' || ch === '>') {
  41017. chars[i] = '';
  41018. }
  41019. }
  41020. return createBidiText(chars.join(''), isLTR);
  41021. }
  41022. exports.bidi = bidi;
  41023. /***/ }),
  41024. /* 30 */
  41025. /***/ (function(module, exports, __w_pdfjs_require__) {
  41026. "use strict";
  41027. var ISOAdobeCharset = [
  41028. '.notdef',
  41029. 'space',
  41030. 'exclam',
  41031. 'quotedbl',
  41032. 'numbersign',
  41033. 'dollar',
  41034. 'percent',
  41035. 'ampersand',
  41036. 'quoteright',
  41037. 'parenleft',
  41038. 'parenright',
  41039. 'asterisk',
  41040. 'plus',
  41041. 'comma',
  41042. 'hyphen',
  41043. 'period',
  41044. 'slash',
  41045. 'zero',
  41046. 'one',
  41047. 'two',
  41048. 'three',
  41049. 'four',
  41050. 'five',
  41051. 'six',
  41052. 'seven',
  41053. 'eight',
  41054. 'nine',
  41055. 'colon',
  41056. 'semicolon',
  41057. 'less',
  41058. 'equal',
  41059. 'greater',
  41060. 'question',
  41061. 'at',
  41062. 'A',
  41063. 'B',
  41064. 'C',
  41065. 'D',
  41066. 'E',
  41067. 'F',
  41068. 'G',
  41069. 'H',
  41070. 'I',
  41071. 'J',
  41072. 'K',
  41073. 'L',
  41074. 'M',
  41075. 'N',
  41076. 'O',
  41077. 'P',
  41078. 'Q',
  41079. 'R',
  41080. 'S',
  41081. 'T',
  41082. 'U',
  41083. 'V',
  41084. 'W',
  41085. 'X',
  41086. 'Y',
  41087. 'Z',
  41088. 'bracketleft',
  41089. 'backslash',
  41090. 'bracketright',
  41091. 'asciicircum',
  41092. 'underscore',
  41093. 'quoteleft',
  41094. 'a',
  41095. 'b',
  41096. 'c',
  41097. 'd',
  41098. 'e',
  41099. 'f',
  41100. 'g',
  41101. 'h',
  41102. 'i',
  41103. 'j',
  41104. 'k',
  41105. 'l',
  41106. 'm',
  41107. 'n',
  41108. 'o',
  41109. 'p',
  41110. 'q',
  41111. 'r',
  41112. 's',
  41113. 't',
  41114. 'u',
  41115. 'v',
  41116. 'w',
  41117. 'x',
  41118. 'y',
  41119. 'z',
  41120. 'braceleft',
  41121. 'bar',
  41122. 'braceright',
  41123. 'asciitilde',
  41124. 'exclamdown',
  41125. 'cent',
  41126. 'sterling',
  41127. 'fraction',
  41128. 'yen',
  41129. 'florin',
  41130. 'section',
  41131. 'currency',
  41132. 'quotesingle',
  41133. 'quotedblleft',
  41134. 'guillemotleft',
  41135. 'guilsinglleft',
  41136. 'guilsinglright',
  41137. 'fi',
  41138. 'fl',
  41139. 'endash',
  41140. 'dagger',
  41141. 'daggerdbl',
  41142. 'periodcentered',
  41143. 'paragraph',
  41144. 'bullet',
  41145. 'quotesinglbase',
  41146. 'quotedblbase',
  41147. 'quotedblright',
  41148. 'guillemotright',
  41149. 'ellipsis',
  41150. 'perthousand',
  41151. 'questiondown',
  41152. 'grave',
  41153. 'acute',
  41154. 'circumflex',
  41155. 'tilde',
  41156. 'macron',
  41157. 'breve',
  41158. 'dotaccent',
  41159. 'dieresis',
  41160. 'ring',
  41161. 'cedilla',
  41162. 'hungarumlaut',
  41163. 'ogonek',
  41164. 'caron',
  41165. 'emdash',
  41166. 'AE',
  41167. 'ordfeminine',
  41168. 'Lslash',
  41169. 'Oslash',
  41170. 'OE',
  41171. 'ordmasculine',
  41172. 'ae',
  41173. 'dotlessi',
  41174. 'lslash',
  41175. 'oslash',
  41176. 'oe',
  41177. 'germandbls',
  41178. 'onesuperior',
  41179. 'logicalnot',
  41180. 'mu',
  41181. 'trademark',
  41182. 'Eth',
  41183. 'onehalf',
  41184. 'plusminus',
  41185. 'Thorn',
  41186. 'onequarter',
  41187. 'divide',
  41188. 'brokenbar',
  41189. 'degree',
  41190. 'thorn',
  41191. 'threequarters',
  41192. 'twosuperior',
  41193. 'registered',
  41194. 'minus',
  41195. 'eth',
  41196. 'multiply',
  41197. 'threesuperior',
  41198. 'copyright',
  41199. 'Aacute',
  41200. 'Acircumflex',
  41201. 'Adieresis',
  41202. 'Agrave',
  41203. 'Aring',
  41204. 'Atilde',
  41205. 'Ccedilla',
  41206. 'Eacute',
  41207. 'Ecircumflex',
  41208. 'Edieresis',
  41209. 'Egrave',
  41210. 'Iacute',
  41211. 'Icircumflex',
  41212. 'Idieresis',
  41213. 'Igrave',
  41214. 'Ntilde',
  41215. 'Oacute',
  41216. 'Ocircumflex',
  41217. 'Odieresis',
  41218. 'Ograve',
  41219. 'Otilde',
  41220. 'Scaron',
  41221. 'Uacute',
  41222. 'Ucircumflex',
  41223. 'Udieresis',
  41224. 'Ugrave',
  41225. 'Yacute',
  41226. 'Ydieresis',
  41227. 'Zcaron',
  41228. 'aacute',
  41229. 'acircumflex',
  41230. 'adieresis',
  41231. 'agrave',
  41232. 'aring',
  41233. 'atilde',
  41234. 'ccedilla',
  41235. 'eacute',
  41236. 'ecircumflex',
  41237. 'edieresis',
  41238. 'egrave',
  41239. 'iacute',
  41240. 'icircumflex',
  41241. 'idieresis',
  41242. 'igrave',
  41243. 'ntilde',
  41244. 'oacute',
  41245. 'ocircumflex',
  41246. 'odieresis',
  41247. 'ograve',
  41248. 'otilde',
  41249. 'scaron',
  41250. 'uacute',
  41251. 'ucircumflex',
  41252. 'udieresis',
  41253. 'ugrave',
  41254. 'yacute',
  41255. 'ydieresis',
  41256. 'zcaron'
  41257. ];
  41258. var ExpertCharset = [
  41259. '.notdef',
  41260. 'space',
  41261. 'exclamsmall',
  41262. 'Hungarumlautsmall',
  41263. 'dollaroldstyle',
  41264. 'dollarsuperior',
  41265. 'ampersandsmall',
  41266. 'Acutesmall',
  41267. 'parenleftsuperior',
  41268. 'parenrightsuperior',
  41269. 'twodotenleader',
  41270. 'onedotenleader',
  41271. 'comma',
  41272. 'hyphen',
  41273. 'period',
  41274. 'fraction',
  41275. 'zerooldstyle',
  41276. 'oneoldstyle',
  41277. 'twooldstyle',
  41278. 'threeoldstyle',
  41279. 'fouroldstyle',
  41280. 'fiveoldstyle',
  41281. 'sixoldstyle',
  41282. 'sevenoldstyle',
  41283. 'eightoldstyle',
  41284. 'nineoldstyle',
  41285. 'colon',
  41286. 'semicolon',
  41287. 'commasuperior',
  41288. 'threequartersemdash',
  41289. 'periodsuperior',
  41290. 'questionsmall',
  41291. 'asuperior',
  41292. 'bsuperior',
  41293. 'centsuperior',
  41294. 'dsuperior',
  41295. 'esuperior',
  41296. 'isuperior',
  41297. 'lsuperior',
  41298. 'msuperior',
  41299. 'nsuperior',
  41300. 'osuperior',
  41301. 'rsuperior',
  41302. 'ssuperior',
  41303. 'tsuperior',
  41304. 'ff',
  41305. 'fi',
  41306. 'fl',
  41307. 'ffi',
  41308. 'ffl',
  41309. 'parenleftinferior',
  41310. 'parenrightinferior',
  41311. 'Circumflexsmall',
  41312. 'hyphensuperior',
  41313. 'Gravesmall',
  41314. 'Asmall',
  41315. 'Bsmall',
  41316. 'Csmall',
  41317. 'Dsmall',
  41318. 'Esmall',
  41319. 'Fsmall',
  41320. 'Gsmall',
  41321. 'Hsmall',
  41322. 'Ismall',
  41323. 'Jsmall',
  41324. 'Ksmall',
  41325. 'Lsmall',
  41326. 'Msmall',
  41327. 'Nsmall',
  41328. 'Osmall',
  41329. 'Psmall',
  41330. 'Qsmall',
  41331. 'Rsmall',
  41332. 'Ssmall',
  41333. 'Tsmall',
  41334. 'Usmall',
  41335. 'Vsmall',
  41336. 'Wsmall',
  41337. 'Xsmall',
  41338. 'Ysmall',
  41339. 'Zsmall',
  41340. 'colonmonetary',
  41341. 'onefitted',
  41342. 'rupiah',
  41343. 'Tildesmall',
  41344. 'exclamdownsmall',
  41345. 'centoldstyle',
  41346. 'Lslashsmall',
  41347. 'Scaronsmall',
  41348. 'Zcaronsmall',
  41349. 'Dieresissmall',
  41350. 'Brevesmall',
  41351. 'Caronsmall',
  41352. 'Dotaccentsmall',
  41353. 'Macronsmall',
  41354. 'figuredash',
  41355. 'hypheninferior',
  41356. 'Ogoneksmall',
  41357. 'Ringsmall',
  41358. 'Cedillasmall',
  41359. 'onequarter',
  41360. 'onehalf',
  41361. 'threequarters',
  41362. 'questiondownsmall',
  41363. 'oneeighth',
  41364. 'threeeighths',
  41365. 'fiveeighths',
  41366. 'seveneighths',
  41367. 'onethird',
  41368. 'twothirds',
  41369. 'zerosuperior',
  41370. 'onesuperior',
  41371. 'twosuperior',
  41372. 'threesuperior',
  41373. 'foursuperior',
  41374. 'fivesuperior',
  41375. 'sixsuperior',
  41376. 'sevensuperior',
  41377. 'eightsuperior',
  41378. 'ninesuperior',
  41379. 'zeroinferior',
  41380. 'oneinferior',
  41381. 'twoinferior',
  41382. 'threeinferior',
  41383. 'fourinferior',
  41384. 'fiveinferior',
  41385. 'sixinferior',
  41386. 'seveninferior',
  41387. 'eightinferior',
  41388. 'nineinferior',
  41389. 'centinferior',
  41390. 'dollarinferior',
  41391. 'periodinferior',
  41392. 'commainferior',
  41393. 'Agravesmall',
  41394. 'Aacutesmall',
  41395. 'Acircumflexsmall',
  41396. 'Atildesmall',
  41397. 'Adieresissmall',
  41398. 'Aringsmall',
  41399. 'AEsmall',
  41400. 'Ccedillasmall',
  41401. 'Egravesmall',
  41402. 'Eacutesmall',
  41403. 'Ecircumflexsmall',
  41404. 'Edieresissmall',
  41405. 'Igravesmall',
  41406. 'Iacutesmall',
  41407. 'Icircumflexsmall',
  41408. 'Idieresissmall',
  41409. 'Ethsmall',
  41410. 'Ntildesmall',
  41411. 'Ogravesmall',
  41412. 'Oacutesmall',
  41413. 'Ocircumflexsmall',
  41414. 'Otildesmall',
  41415. 'Odieresissmall',
  41416. 'OEsmall',
  41417. 'Oslashsmall',
  41418. 'Ugravesmall',
  41419. 'Uacutesmall',
  41420. 'Ucircumflexsmall',
  41421. 'Udieresissmall',
  41422. 'Yacutesmall',
  41423. 'Thornsmall',
  41424. 'Ydieresissmall'
  41425. ];
  41426. var ExpertSubsetCharset = [
  41427. '.notdef',
  41428. 'space',
  41429. 'dollaroldstyle',
  41430. 'dollarsuperior',
  41431. 'parenleftsuperior',
  41432. 'parenrightsuperior',
  41433. 'twodotenleader',
  41434. 'onedotenleader',
  41435. 'comma',
  41436. 'hyphen',
  41437. 'period',
  41438. 'fraction',
  41439. 'zerooldstyle',
  41440. 'oneoldstyle',
  41441. 'twooldstyle',
  41442. 'threeoldstyle',
  41443. 'fouroldstyle',
  41444. 'fiveoldstyle',
  41445. 'sixoldstyle',
  41446. 'sevenoldstyle',
  41447. 'eightoldstyle',
  41448. 'nineoldstyle',
  41449. 'colon',
  41450. 'semicolon',
  41451. 'commasuperior',
  41452. 'threequartersemdash',
  41453. 'periodsuperior',
  41454. 'asuperior',
  41455. 'bsuperior',
  41456. 'centsuperior',
  41457. 'dsuperior',
  41458. 'esuperior',
  41459. 'isuperior',
  41460. 'lsuperior',
  41461. 'msuperior',
  41462. 'nsuperior',
  41463. 'osuperior',
  41464. 'rsuperior',
  41465. 'ssuperior',
  41466. 'tsuperior',
  41467. 'ff',
  41468. 'fi',
  41469. 'fl',
  41470. 'ffi',
  41471. 'ffl',
  41472. 'parenleftinferior',
  41473. 'parenrightinferior',
  41474. 'hyphensuperior',
  41475. 'colonmonetary',
  41476. 'onefitted',
  41477. 'rupiah',
  41478. 'centoldstyle',
  41479. 'figuredash',
  41480. 'hypheninferior',
  41481. 'onequarter',
  41482. 'onehalf',
  41483. 'threequarters',
  41484. 'oneeighth',
  41485. 'threeeighths',
  41486. 'fiveeighths',
  41487. 'seveneighths',
  41488. 'onethird',
  41489. 'twothirds',
  41490. 'zerosuperior',
  41491. 'onesuperior',
  41492. 'twosuperior',
  41493. 'threesuperior',
  41494. 'foursuperior',
  41495. 'fivesuperior',
  41496. 'sixsuperior',
  41497. 'sevensuperior',
  41498. 'eightsuperior',
  41499. 'ninesuperior',
  41500. 'zeroinferior',
  41501. 'oneinferior',
  41502. 'twoinferior',
  41503. 'threeinferior',
  41504. 'fourinferior',
  41505. 'fiveinferior',
  41506. 'sixinferior',
  41507. 'seveninferior',
  41508. 'eightinferior',
  41509. 'nineinferior',
  41510. 'centinferior',
  41511. 'dollarinferior',
  41512. 'periodinferior',
  41513. 'commainferior'
  41514. ];
  41515. exports.ISOAdobeCharset = ISOAdobeCharset;
  41516. exports.ExpertCharset = ExpertCharset;
  41517. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41518. /***/ }),
  41519. /* 31 */
  41520. /***/ (function(module, exports, __w_pdfjs_require__) {
  41521. "use strict";
  41522. var sharedUtil = __w_pdfjs_require__(0);
  41523. var corePrimitives = __w_pdfjs_require__(1);
  41524. var coreStream = __w_pdfjs_require__(2);
  41525. var coreParser = __w_pdfjs_require__(6);
  41526. var Util = sharedUtil.Util;
  41527. var assert = sharedUtil.assert;
  41528. var warn = sharedUtil.warn;
  41529. var error = sharedUtil.error;
  41530. var isInt = sharedUtil.isInt;
  41531. var isString = sharedUtil.isString;
  41532. var MissingDataException = sharedUtil.MissingDataException;
  41533. var isEOF = corePrimitives.isEOF;
  41534. var isName = corePrimitives.isName;
  41535. var isCmd = corePrimitives.isCmd;
  41536. var isStream = corePrimitives.isStream;
  41537. var StringStream = coreStream.StringStream;
  41538. var Lexer = coreParser.Lexer;
  41539. var BUILT_IN_CMAPS = [
  41540. 'Adobe-GB1-UCS2',
  41541. 'Adobe-CNS1-UCS2',
  41542. 'Adobe-Japan1-UCS2',
  41543. 'Adobe-Korea1-UCS2',
  41544. '78-EUC-H',
  41545. '78-EUC-V',
  41546. '78-H',
  41547. '78-RKSJ-H',
  41548. '78-RKSJ-V',
  41549. '78-V',
  41550. '78ms-RKSJ-H',
  41551. '78ms-RKSJ-V',
  41552. '83pv-RKSJ-H',
  41553. '90ms-RKSJ-H',
  41554. '90ms-RKSJ-V',
  41555. '90msp-RKSJ-H',
  41556. '90msp-RKSJ-V',
  41557. '90pv-RKSJ-H',
  41558. '90pv-RKSJ-V',
  41559. 'Add-H',
  41560. 'Add-RKSJ-H',
  41561. 'Add-RKSJ-V',
  41562. 'Add-V',
  41563. 'Adobe-CNS1-0',
  41564. 'Adobe-CNS1-1',
  41565. 'Adobe-CNS1-2',
  41566. 'Adobe-CNS1-3',
  41567. 'Adobe-CNS1-4',
  41568. 'Adobe-CNS1-5',
  41569. 'Adobe-CNS1-6',
  41570. 'Adobe-GB1-0',
  41571. 'Adobe-GB1-1',
  41572. 'Adobe-GB1-2',
  41573. 'Adobe-GB1-3',
  41574. 'Adobe-GB1-4',
  41575. 'Adobe-GB1-5',
  41576. 'Adobe-Japan1-0',
  41577. 'Adobe-Japan1-1',
  41578. 'Adobe-Japan1-2',
  41579. 'Adobe-Japan1-3',
  41580. 'Adobe-Japan1-4',
  41581. 'Adobe-Japan1-5',
  41582. 'Adobe-Japan1-6',
  41583. 'Adobe-Korea1-0',
  41584. 'Adobe-Korea1-1',
  41585. 'Adobe-Korea1-2',
  41586. 'B5-H',
  41587. 'B5-V',
  41588. 'B5pc-H',
  41589. 'B5pc-V',
  41590. 'CNS-EUC-H',
  41591. 'CNS-EUC-V',
  41592. 'CNS1-H',
  41593. 'CNS1-V',
  41594. 'CNS2-H',
  41595. 'CNS2-V',
  41596. 'ETHK-B5-H',
  41597. 'ETHK-B5-V',
  41598. 'ETen-B5-H',
  41599. 'ETen-B5-V',
  41600. 'ETenms-B5-H',
  41601. 'ETenms-B5-V',
  41602. 'EUC-H',
  41603. 'EUC-V',
  41604. 'Ext-H',
  41605. 'Ext-RKSJ-H',
  41606. 'Ext-RKSJ-V',
  41607. 'Ext-V',
  41608. 'GB-EUC-H',
  41609. 'GB-EUC-V',
  41610. 'GB-H',
  41611. 'GB-V',
  41612. 'GBK-EUC-H',
  41613. 'GBK-EUC-V',
  41614. 'GBK2K-H',
  41615. 'GBK2K-V',
  41616. 'GBKp-EUC-H',
  41617. 'GBKp-EUC-V',
  41618. 'GBT-EUC-H',
  41619. 'GBT-EUC-V',
  41620. 'GBT-H',
  41621. 'GBT-V',
  41622. 'GBTpc-EUC-H',
  41623. 'GBTpc-EUC-V',
  41624. 'GBpc-EUC-H',
  41625. 'GBpc-EUC-V',
  41626. 'H',
  41627. 'HKdla-B5-H',
  41628. 'HKdla-B5-V',
  41629. 'HKdlb-B5-H',
  41630. 'HKdlb-B5-V',
  41631. 'HKgccs-B5-H',
  41632. 'HKgccs-B5-V',
  41633. 'HKm314-B5-H',
  41634. 'HKm314-B5-V',
  41635. 'HKm471-B5-H',
  41636. 'HKm471-B5-V',
  41637. 'HKscs-B5-H',
  41638. 'HKscs-B5-V',
  41639. 'Hankaku',
  41640. 'Hiragana',
  41641. 'KSC-EUC-H',
  41642. 'KSC-EUC-V',
  41643. 'KSC-H',
  41644. 'KSC-Johab-H',
  41645. 'KSC-Johab-V',
  41646. 'KSC-V',
  41647. 'KSCms-UHC-H',
  41648. 'KSCms-UHC-HW-H',
  41649. 'KSCms-UHC-HW-V',
  41650. 'KSCms-UHC-V',
  41651. 'KSCpc-EUC-H',
  41652. 'KSCpc-EUC-V',
  41653. 'Katakana',
  41654. 'NWP-H',
  41655. 'NWP-V',
  41656. 'RKSJ-H',
  41657. 'RKSJ-V',
  41658. 'Roman',
  41659. 'UniCNS-UCS2-H',
  41660. 'UniCNS-UCS2-V',
  41661. 'UniCNS-UTF16-H',
  41662. 'UniCNS-UTF16-V',
  41663. 'UniCNS-UTF32-H',
  41664. 'UniCNS-UTF32-V',
  41665. 'UniCNS-UTF8-H',
  41666. 'UniCNS-UTF8-V',
  41667. 'UniGB-UCS2-H',
  41668. 'UniGB-UCS2-V',
  41669. 'UniGB-UTF16-H',
  41670. 'UniGB-UTF16-V',
  41671. 'UniGB-UTF32-H',
  41672. 'UniGB-UTF32-V',
  41673. 'UniGB-UTF8-H',
  41674. 'UniGB-UTF8-V',
  41675. 'UniJIS-UCS2-H',
  41676. 'UniJIS-UCS2-HW-H',
  41677. 'UniJIS-UCS2-HW-V',
  41678. 'UniJIS-UCS2-V',
  41679. 'UniJIS-UTF16-H',
  41680. 'UniJIS-UTF16-V',
  41681. 'UniJIS-UTF32-H',
  41682. 'UniJIS-UTF32-V',
  41683. 'UniJIS-UTF8-H',
  41684. 'UniJIS-UTF8-V',
  41685. 'UniJIS2004-UTF16-H',
  41686. 'UniJIS2004-UTF16-V',
  41687. 'UniJIS2004-UTF32-H',
  41688. 'UniJIS2004-UTF32-V',
  41689. 'UniJIS2004-UTF8-H',
  41690. 'UniJIS2004-UTF8-V',
  41691. 'UniJISPro-UCS2-HW-V',
  41692. 'UniJISPro-UCS2-V',
  41693. 'UniJISPro-UTF8-V',
  41694. 'UniJISX0213-UTF32-H',
  41695. 'UniJISX0213-UTF32-V',
  41696. 'UniJISX02132004-UTF32-H',
  41697. 'UniJISX02132004-UTF32-V',
  41698. 'UniKS-UCS2-H',
  41699. 'UniKS-UCS2-V',
  41700. 'UniKS-UTF16-H',
  41701. 'UniKS-UTF16-V',
  41702. 'UniKS-UTF32-H',
  41703. 'UniKS-UTF32-V',
  41704. 'UniKS-UTF8-H',
  41705. 'UniKS-UTF8-V',
  41706. 'V',
  41707. 'WP-Symbol'
  41708. ];
  41709. var CMap = function CMapClosure() {
  41710. function CMap(builtInCMap) {
  41711. this.codespaceRanges = [
  41712. [],
  41713. [],
  41714. [],
  41715. []
  41716. ];
  41717. this.numCodespaceRanges = 0;
  41718. this._map = [];
  41719. this.name = '';
  41720. this.vertical = false;
  41721. this.useCMap = null;
  41722. this.builtInCMap = builtInCMap;
  41723. }
  41724. CMap.prototype = {
  41725. addCodespaceRange: function (n, low, high) {
  41726. this.codespaceRanges[n - 1].push(low, high);
  41727. this.numCodespaceRanges++;
  41728. },
  41729. mapCidRange: function (low, high, dstLow) {
  41730. while (low <= high) {
  41731. this._map[low++] = dstLow++;
  41732. }
  41733. },
  41734. mapBfRange: function (low, high, dstLow) {
  41735. var lastByte = dstLow.length - 1;
  41736. while (low <= high) {
  41737. this._map[low++] = dstLow;
  41738. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41739. }
  41740. },
  41741. mapBfRangeToArray: function (low, high, array) {
  41742. var i = 0, ii = array.length;
  41743. while (low <= high && i < ii) {
  41744. this._map[low] = array[i++];
  41745. ++low;
  41746. }
  41747. },
  41748. mapOne: function (src, dst) {
  41749. this._map[src] = dst;
  41750. },
  41751. lookup: function (code) {
  41752. return this._map[code];
  41753. },
  41754. contains: function (code) {
  41755. return this._map[code] !== undefined;
  41756. },
  41757. forEach: function (callback) {
  41758. var map = this._map;
  41759. var length = map.length;
  41760. var i;
  41761. if (length <= 0x10000) {
  41762. for (i = 0; i < length; i++) {
  41763. if (map[i] !== undefined) {
  41764. callback(i, map[i]);
  41765. }
  41766. }
  41767. } else {
  41768. for (i in this._map) {
  41769. callback(i, map[i]);
  41770. }
  41771. }
  41772. },
  41773. charCodeOf: function (value) {
  41774. return this._map.indexOf(value);
  41775. },
  41776. getMap: function () {
  41777. return this._map;
  41778. },
  41779. readCharCode: function (str, offset, out) {
  41780. var c = 0;
  41781. var codespaceRanges = this.codespaceRanges;
  41782. var codespaceRangesLen = this.codespaceRanges.length;
  41783. for (var n = 0; n < codespaceRangesLen; n++) {
  41784. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41785. var codespaceRange = codespaceRanges[n];
  41786. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41787. var low = codespaceRange[k++];
  41788. var high = codespaceRange[k++];
  41789. if (c >= low && c <= high) {
  41790. out.charcode = c;
  41791. out.length = n + 1;
  41792. return;
  41793. }
  41794. }
  41795. }
  41796. out.charcode = 0;
  41797. out.length = 1;
  41798. },
  41799. get length() {
  41800. return this._map.length;
  41801. },
  41802. get isIdentityCMap() {
  41803. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41804. return false;
  41805. }
  41806. if (this._map.length !== 0x10000) {
  41807. return false;
  41808. }
  41809. for (var i = 0; i < 0x10000; i++) {
  41810. if (this._map[i] !== i) {
  41811. return false;
  41812. }
  41813. }
  41814. return true;
  41815. }
  41816. };
  41817. return CMap;
  41818. }();
  41819. var IdentityCMap = function IdentityCMapClosure() {
  41820. function IdentityCMap(vertical, n) {
  41821. CMap.call(this);
  41822. this.vertical = vertical;
  41823. this.addCodespaceRange(n, 0, 0xffff);
  41824. }
  41825. Util.inherit(IdentityCMap, CMap, {});
  41826. IdentityCMap.prototype = {
  41827. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41828. mapCidRange: function (low, high, dstLow) {
  41829. error('should not call mapCidRange');
  41830. },
  41831. mapBfRange: function (low, high, dstLow) {
  41832. error('should not call mapBfRange');
  41833. },
  41834. mapBfRangeToArray: function (low, high, array) {
  41835. error('should not call mapBfRangeToArray');
  41836. },
  41837. mapOne: function (src, dst) {
  41838. error('should not call mapCidOne');
  41839. },
  41840. lookup: function (code) {
  41841. return isInt(code) && code <= 0xffff ? code : undefined;
  41842. },
  41843. contains: function (code) {
  41844. return isInt(code) && code <= 0xffff;
  41845. },
  41846. forEach: function (callback) {
  41847. for (var i = 0; i <= 0xffff; i++) {
  41848. callback(i, i);
  41849. }
  41850. },
  41851. charCodeOf: function (value) {
  41852. return isInt(value) && value <= 0xffff ? value : -1;
  41853. },
  41854. getMap: function () {
  41855. var map = new Array(0x10000);
  41856. for (var i = 0; i <= 0xffff; i++) {
  41857. map[i] = i;
  41858. }
  41859. return map;
  41860. },
  41861. readCharCode: CMap.prototype.readCharCode,
  41862. get length() {
  41863. return 0x10000;
  41864. },
  41865. get isIdentityCMap() {
  41866. error('should not access .isIdentityCMap');
  41867. }
  41868. };
  41869. return IdentityCMap;
  41870. }();
  41871. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41872. function fetchBinaryData(url) {
  41873. return new Promise(function (resolve, reject) {
  41874. var request = new XMLHttpRequest();
  41875. request.open('GET', url, true);
  41876. request.responseType = 'arraybuffer';
  41877. request.onreadystatechange = function () {
  41878. if (request.readyState === XMLHttpRequest.DONE) {
  41879. if (!request.response || request.status !== 200 && request.status !== 0) {
  41880. reject(new Error('Unable to get binary cMap at: ' + url));
  41881. } else {
  41882. resolve(new Uint8Array(request.response));
  41883. }
  41884. }
  41885. };
  41886. request.send(null);
  41887. });
  41888. }
  41889. function hexToInt(a, size) {
  41890. var n = 0;
  41891. for (var i = 0; i <= size; i++) {
  41892. n = n << 8 | a[i];
  41893. }
  41894. return n >>> 0;
  41895. }
  41896. function hexToStr(a, size) {
  41897. if (size === 1) {
  41898. return String.fromCharCode(a[0], a[1]);
  41899. }
  41900. if (size === 3) {
  41901. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41902. }
  41903. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41904. }
  41905. function addHex(a, b, size) {
  41906. var c = 0;
  41907. for (var i = size; i >= 0; i--) {
  41908. c += a[i] + b[i];
  41909. a[i] = c & 255;
  41910. c >>= 8;
  41911. }
  41912. }
  41913. function incHex(a, size) {
  41914. var c = 1;
  41915. for (var i = size; i >= 0 && c > 0; i--) {
  41916. c += a[i];
  41917. a[i] = c & 255;
  41918. c >>= 8;
  41919. }
  41920. }
  41921. var MAX_NUM_SIZE = 16;
  41922. var MAX_ENCODED_NUM_SIZE = 19;
  41923. function BinaryCMapStream(data) {
  41924. this.buffer = data;
  41925. this.pos = 0;
  41926. this.end = data.length;
  41927. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41928. }
  41929. BinaryCMapStream.prototype = {
  41930. readByte: function () {
  41931. if (this.pos >= this.end) {
  41932. return -1;
  41933. }
  41934. return this.buffer[this.pos++];
  41935. },
  41936. readNumber: function () {
  41937. var n = 0;
  41938. var last;
  41939. do {
  41940. var b = this.readByte();
  41941. if (b < 0) {
  41942. error('unexpected EOF in bcmap');
  41943. }
  41944. last = !(b & 0x80);
  41945. n = n << 7 | b & 0x7F;
  41946. } while (!last);
  41947. return n;
  41948. },
  41949. readSigned: function () {
  41950. var n = this.readNumber();
  41951. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41952. },
  41953. readHex: function (num, size) {
  41954. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41955. this.pos += size + 1;
  41956. },
  41957. readHexNumber: function (num, size) {
  41958. var last;
  41959. var stack = this.tmpBuf, sp = 0;
  41960. do {
  41961. var b = this.readByte();
  41962. if (b < 0) {
  41963. error('unexpected EOF in bcmap');
  41964. }
  41965. last = !(b & 0x80);
  41966. stack[sp++] = b & 0x7F;
  41967. } while (!last);
  41968. var i = size, buffer = 0, bufferSize = 0;
  41969. while (i >= 0) {
  41970. while (bufferSize < 8 && stack.length > 0) {
  41971. buffer = stack[--sp] << bufferSize | buffer;
  41972. bufferSize += 7;
  41973. }
  41974. num[i] = buffer & 255;
  41975. i--;
  41976. buffer >>= 8;
  41977. bufferSize -= 8;
  41978. }
  41979. },
  41980. readHexSigned: function (num, size) {
  41981. this.readHexNumber(num, size);
  41982. var sign = num[size] & 1 ? 255 : 0;
  41983. var c = 0;
  41984. for (var i = 0; i <= size; i++) {
  41985. c = (c & 1) << 8 | num[i];
  41986. num[i] = c >> 1 ^ sign;
  41987. }
  41988. },
  41989. readString: function () {
  41990. var len = this.readNumber();
  41991. var s = '';
  41992. for (var i = 0; i < len; i++) {
  41993. s += String.fromCharCode(this.readNumber());
  41994. }
  41995. return s;
  41996. }
  41997. };
  41998. function processBinaryCMap(url, cMap, extend) {
  41999. return fetchBinaryData(url).then(function (data) {
  42000. var stream = new BinaryCMapStream(data);
  42001. var header = stream.readByte();
  42002. cMap.vertical = !!(header & 1);
  42003. var useCMap = null;
  42004. var start = new Uint8Array(MAX_NUM_SIZE);
  42005. var end = new Uint8Array(MAX_NUM_SIZE);
  42006. var char = new Uint8Array(MAX_NUM_SIZE);
  42007. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42008. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42009. var code;
  42010. var b;
  42011. while ((b = stream.readByte()) >= 0) {
  42012. var type = b >> 5;
  42013. if (type === 7) {
  42014. switch (b & 0x1F) {
  42015. case 0:
  42016. stream.readString();
  42017. break;
  42018. case 1:
  42019. useCMap = stream.readString();
  42020. break;
  42021. }
  42022. continue;
  42023. }
  42024. var sequence = !!(b & 0x10);
  42025. var dataSize = b & 15;
  42026. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42027. var ucs2DataSize = 1;
  42028. var subitemsCount = stream.readNumber();
  42029. var i;
  42030. switch (type) {
  42031. case 0:
  42032. stream.readHex(start, dataSize);
  42033. stream.readHexNumber(end, dataSize);
  42034. addHex(end, start, dataSize);
  42035. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42036. for (i = 1; i < subitemsCount; i++) {
  42037. incHex(end, dataSize);
  42038. stream.readHexNumber(start, dataSize);
  42039. addHex(start, end, dataSize);
  42040. stream.readHexNumber(end, dataSize);
  42041. addHex(end, start, dataSize);
  42042. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42043. }
  42044. break;
  42045. case 1:
  42046. stream.readHex(start, dataSize);
  42047. stream.readHexNumber(end, dataSize);
  42048. addHex(end, start, dataSize);
  42049. code = stream.readNumber();
  42050. for (i = 1; i < subitemsCount; i++) {
  42051. incHex(end, dataSize);
  42052. stream.readHexNumber(start, dataSize);
  42053. addHex(start, end, dataSize);
  42054. stream.readHexNumber(end, dataSize);
  42055. addHex(end, start, dataSize);
  42056. code = stream.readNumber();
  42057. }
  42058. break;
  42059. case 2:
  42060. stream.readHex(char, dataSize);
  42061. code = stream.readNumber();
  42062. cMap.mapOne(hexToInt(char, dataSize), code);
  42063. for (i = 1; i < subitemsCount; i++) {
  42064. incHex(char, dataSize);
  42065. if (!sequence) {
  42066. stream.readHexNumber(tmp, dataSize);
  42067. addHex(char, tmp, dataSize);
  42068. }
  42069. code = stream.readSigned() + (code + 1);
  42070. cMap.mapOne(hexToInt(char, dataSize), code);
  42071. }
  42072. break;
  42073. case 3:
  42074. stream.readHex(start, dataSize);
  42075. stream.readHexNumber(end, dataSize);
  42076. addHex(end, start, dataSize);
  42077. code = stream.readNumber();
  42078. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42079. for (i = 1; i < subitemsCount; i++) {
  42080. incHex(end, dataSize);
  42081. if (!sequence) {
  42082. stream.readHexNumber(start, dataSize);
  42083. addHex(start, end, dataSize);
  42084. } else {
  42085. start.set(end);
  42086. }
  42087. stream.readHexNumber(end, dataSize);
  42088. addHex(end, start, dataSize);
  42089. code = stream.readNumber();
  42090. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42091. }
  42092. break;
  42093. case 4:
  42094. stream.readHex(char, ucs2DataSize);
  42095. stream.readHex(charCode, dataSize);
  42096. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42097. for (i = 1; i < subitemsCount; i++) {
  42098. incHex(char, ucs2DataSize);
  42099. if (!sequence) {
  42100. stream.readHexNumber(tmp, ucs2DataSize);
  42101. addHex(char, tmp, ucs2DataSize);
  42102. }
  42103. incHex(charCode, dataSize);
  42104. stream.readHexSigned(tmp, dataSize);
  42105. addHex(charCode, tmp, dataSize);
  42106. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42107. }
  42108. break;
  42109. case 5:
  42110. stream.readHex(start, ucs2DataSize);
  42111. stream.readHexNumber(end, ucs2DataSize);
  42112. addHex(end, start, ucs2DataSize);
  42113. stream.readHex(charCode, dataSize);
  42114. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42115. for (i = 1; i < subitemsCount; i++) {
  42116. incHex(end, ucs2DataSize);
  42117. if (!sequence) {
  42118. stream.readHexNumber(start, ucs2DataSize);
  42119. addHex(start, end, ucs2DataSize);
  42120. } else {
  42121. start.set(end);
  42122. }
  42123. stream.readHexNumber(end, ucs2DataSize);
  42124. addHex(end, start, ucs2DataSize);
  42125. stream.readHex(charCode, dataSize);
  42126. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42127. }
  42128. break;
  42129. default:
  42130. error('Unknown type: ' + type);
  42131. break;
  42132. }
  42133. }
  42134. if (useCMap) {
  42135. return extend(useCMap);
  42136. }
  42137. return cMap;
  42138. });
  42139. }
  42140. function BinaryCMapReader() {
  42141. }
  42142. BinaryCMapReader.prototype = { read: processBinaryCMap };
  42143. return BinaryCMapReader;
  42144. }();
  42145. var CMapFactory = function CMapFactoryClosure() {
  42146. function strToInt(str) {
  42147. var a = 0;
  42148. for (var i = 0; i < str.length; i++) {
  42149. a = a << 8 | str.charCodeAt(i);
  42150. }
  42151. return a >>> 0;
  42152. }
  42153. function expectString(obj) {
  42154. if (!isString(obj)) {
  42155. error('Malformed CMap: expected string.');
  42156. }
  42157. }
  42158. function expectInt(obj) {
  42159. if (!isInt(obj)) {
  42160. error('Malformed CMap: expected int.');
  42161. }
  42162. }
  42163. function parseBfChar(cMap, lexer) {
  42164. while (true) {
  42165. var obj = lexer.getObj();
  42166. if (isEOF(obj)) {
  42167. break;
  42168. }
  42169. if (isCmd(obj, 'endbfchar')) {
  42170. return;
  42171. }
  42172. expectString(obj);
  42173. var src = strToInt(obj);
  42174. obj = lexer.getObj();
  42175. expectString(obj);
  42176. var dst = obj;
  42177. cMap.mapOne(src, dst);
  42178. }
  42179. }
  42180. function parseBfRange(cMap, lexer) {
  42181. while (true) {
  42182. var obj = lexer.getObj();
  42183. if (isEOF(obj)) {
  42184. break;
  42185. }
  42186. if (isCmd(obj, 'endbfrange')) {
  42187. return;
  42188. }
  42189. expectString(obj);
  42190. var low = strToInt(obj);
  42191. obj = lexer.getObj();
  42192. expectString(obj);
  42193. var high = strToInt(obj);
  42194. obj = lexer.getObj();
  42195. if (isInt(obj) || isString(obj)) {
  42196. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42197. cMap.mapBfRange(low, high, dstLow);
  42198. } else if (isCmd(obj, '[')) {
  42199. obj = lexer.getObj();
  42200. var array = [];
  42201. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42202. array.push(obj);
  42203. obj = lexer.getObj();
  42204. }
  42205. cMap.mapBfRangeToArray(low, high, array);
  42206. } else {
  42207. break;
  42208. }
  42209. }
  42210. error('Invalid bf range.');
  42211. }
  42212. function parseCidChar(cMap, lexer) {
  42213. while (true) {
  42214. var obj = lexer.getObj();
  42215. if (isEOF(obj)) {
  42216. break;
  42217. }
  42218. if (isCmd(obj, 'endcidchar')) {
  42219. return;
  42220. }
  42221. expectString(obj);
  42222. var src = strToInt(obj);
  42223. obj = lexer.getObj();
  42224. expectInt(obj);
  42225. var dst = obj;
  42226. cMap.mapOne(src, dst);
  42227. }
  42228. }
  42229. function parseCidRange(cMap, lexer) {
  42230. while (true) {
  42231. var obj = lexer.getObj();
  42232. if (isEOF(obj)) {
  42233. break;
  42234. }
  42235. if (isCmd(obj, 'endcidrange')) {
  42236. return;
  42237. }
  42238. expectString(obj);
  42239. var low = strToInt(obj);
  42240. obj = lexer.getObj();
  42241. expectString(obj);
  42242. var high = strToInt(obj);
  42243. obj = lexer.getObj();
  42244. expectInt(obj);
  42245. var dstLow = obj;
  42246. cMap.mapCidRange(low, high, dstLow);
  42247. }
  42248. }
  42249. function parseCodespaceRange(cMap, lexer) {
  42250. while (true) {
  42251. var obj = lexer.getObj();
  42252. if (isEOF(obj)) {
  42253. break;
  42254. }
  42255. if (isCmd(obj, 'endcodespacerange')) {
  42256. return;
  42257. }
  42258. if (!isString(obj)) {
  42259. break;
  42260. }
  42261. var low = strToInt(obj);
  42262. obj = lexer.getObj();
  42263. if (!isString(obj)) {
  42264. break;
  42265. }
  42266. var high = strToInt(obj);
  42267. cMap.addCodespaceRange(obj.length, low, high);
  42268. }
  42269. error('Invalid codespace range.');
  42270. }
  42271. function parseWMode(cMap, lexer) {
  42272. var obj = lexer.getObj();
  42273. if (isInt(obj)) {
  42274. cMap.vertical = !!obj;
  42275. }
  42276. }
  42277. function parseCMapName(cMap, lexer) {
  42278. var obj = lexer.getObj();
  42279. if (isName(obj) && isString(obj.name)) {
  42280. cMap.name = obj.name;
  42281. }
  42282. }
  42283. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  42284. var previous;
  42285. var embededUseCMap;
  42286. objLoop:
  42287. while (true) {
  42288. try {
  42289. var obj = lexer.getObj();
  42290. if (isEOF(obj)) {
  42291. break;
  42292. } else if (isName(obj)) {
  42293. if (obj.name === 'WMode') {
  42294. parseWMode(cMap, lexer);
  42295. } else if (obj.name === 'CMapName') {
  42296. parseCMapName(cMap, lexer);
  42297. }
  42298. previous = obj;
  42299. } else if (isCmd(obj)) {
  42300. switch (obj.cmd) {
  42301. case 'endcmap':
  42302. break objLoop;
  42303. case 'usecmap':
  42304. if (isName(previous)) {
  42305. embededUseCMap = previous.name;
  42306. }
  42307. break;
  42308. case 'begincodespacerange':
  42309. parseCodespaceRange(cMap, lexer);
  42310. break;
  42311. case 'beginbfchar':
  42312. parseBfChar(cMap, lexer);
  42313. break;
  42314. case 'begincidchar':
  42315. parseCidChar(cMap, lexer);
  42316. break;
  42317. case 'beginbfrange':
  42318. parseBfRange(cMap, lexer);
  42319. break;
  42320. case 'begincidrange':
  42321. parseCidRange(cMap, lexer);
  42322. break;
  42323. }
  42324. }
  42325. } catch (ex) {
  42326. if (ex instanceof MissingDataException) {
  42327. throw ex;
  42328. }
  42329. warn('Invalid cMap data: ' + ex);
  42330. continue;
  42331. }
  42332. }
  42333. if (!useCMap && embededUseCMap) {
  42334. useCMap = embededUseCMap;
  42335. }
  42336. if (useCMap) {
  42337. return extendCMap(cMap, builtInCMapParams, useCMap);
  42338. }
  42339. return Promise.resolve(cMap);
  42340. }
  42341. function extendCMap(cMap, builtInCMapParams, useCMap) {
  42342. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  42343. cMap.useCMap = newCMap;
  42344. if (cMap.numCodespaceRanges === 0) {
  42345. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42346. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42347. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42348. }
  42349. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42350. }
  42351. cMap.useCMap.forEach(function (key, value) {
  42352. if (!cMap.contains(key)) {
  42353. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42354. }
  42355. });
  42356. return cMap;
  42357. });
  42358. }
  42359. function parseBinaryCMap(name, builtInCMapParams) {
  42360. var url = builtInCMapParams.url + name + '.bcmap';
  42361. var cMap = new CMap(true);
  42362. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  42363. return extendCMap(cMap, builtInCMapParams, useCMap);
  42364. });
  42365. }
  42366. function createBuiltInCMap(name, builtInCMapParams) {
  42367. if (name === 'Identity-H') {
  42368. return Promise.resolve(new IdentityCMap(false, 2));
  42369. } else if (name === 'Identity-V') {
  42370. return Promise.resolve(new IdentityCMap(true, 2));
  42371. }
  42372. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42373. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42374. }
  42375. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  42376. if (builtInCMapParams.packed) {
  42377. return parseBinaryCMap(name, builtInCMapParams);
  42378. }
  42379. return new Promise(function (resolve, reject) {
  42380. var url = builtInCMapParams.url + name;
  42381. var request = new XMLHttpRequest();
  42382. request.onreadystatechange = function () {
  42383. if (request.readyState === XMLHttpRequest.DONE) {
  42384. if (request.status === 200 || request.status === 0) {
  42385. var cMap = new CMap(true);
  42386. var lexer = new Lexer(new StringStream(request.responseText));
  42387. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  42388. resolve(parsedCMap);
  42389. });
  42390. } else {
  42391. reject(new Error('Unable to get cMap at: ' + url));
  42392. }
  42393. }
  42394. };
  42395. request.open('GET', url, true);
  42396. request.send(null);
  42397. });
  42398. }
  42399. return {
  42400. create: function (encoding, builtInCMapParams, useCMap) {
  42401. if (isName(encoding)) {
  42402. return createBuiltInCMap(encoding.name, builtInCMapParams);
  42403. } else if (isStream(encoding)) {
  42404. var cMap = new CMap();
  42405. var lexer = new Lexer(encoding);
  42406. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  42407. if (parsedCMap.isIdentityCMap) {
  42408. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  42409. }
  42410. return parsedCMap;
  42411. });
  42412. }
  42413. return Promise.reject(new Error('Encoding required.'));
  42414. }
  42415. };
  42416. }();
  42417. exports.CMap = CMap;
  42418. exports.CMapFactory = CMapFactory;
  42419. exports.IdentityCMap = IdentityCMap;
  42420. /***/ }),
  42421. /* 32 */
  42422. /***/ (function(module, exports, __w_pdfjs_require__) {
  42423. "use strict";
  42424. var sharedUtil = __w_pdfjs_require__(0);
  42425. var corePrimitives = __w_pdfjs_require__(1);
  42426. var coreStream = __w_pdfjs_require__(2);
  42427. var coreObj = __w_pdfjs_require__(19);
  42428. var coreParser = __w_pdfjs_require__(6);
  42429. var coreCrypto = __w_pdfjs_require__(16);
  42430. var coreEvaluator = __w_pdfjs_require__(17);
  42431. var coreAnnotation = __w_pdfjs_require__(28);
  42432. var MissingDataException = sharedUtil.MissingDataException;
  42433. var Util = sharedUtil.Util;
  42434. var assert = sharedUtil.assert;
  42435. var error = sharedUtil.error;
  42436. var info = sharedUtil.info;
  42437. var isArray = sharedUtil.isArray;
  42438. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42439. var isNum = sharedUtil.isNum;
  42440. var isString = sharedUtil.isString;
  42441. var shadow = sharedUtil.shadow;
  42442. var stringToBytes = sharedUtil.stringToBytes;
  42443. var stringToPDFString = sharedUtil.stringToPDFString;
  42444. var warn = sharedUtil.warn;
  42445. var isSpace = sharedUtil.isSpace;
  42446. var Dict = corePrimitives.Dict;
  42447. var isDict = corePrimitives.isDict;
  42448. var isName = corePrimitives.isName;
  42449. var isStream = corePrimitives.isStream;
  42450. var NullStream = coreStream.NullStream;
  42451. var Stream = coreStream.Stream;
  42452. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42453. var Catalog = coreObj.Catalog;
  42454. var ObjectLoader = coreObj.ObjectLoader;
  42455. var XRef = coreObj.XRef;
  42456. var Linearization = coreParser.Linearization;
  42457. var calculateMD5 = coreCrypto.calculateMD5;
  42458. var OperatorList = coreEvaluator.OperatorList;
  42459. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42460. var Annotation = coreAnnotation.Annotation;
  42461. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42462. var Page = function PageClosure() {
  42463. var DEFAULT_USER_UNIT = 1.0;
  42464. var LETTER_SIZE_MEDIABOX = [
  42465. 0,
  42466. 0,
  42467. 612,
  42468. 792
  42469. ];
  42470. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  42471. this.pdfManager = pdfManager;
  42472. this.pageIndex = pageIndex;
  42473. this.pageDict = pageDict;
  42474. this.xref = xref;
  42475. this.ref = ref;
  42476. this.fontCache = fontCache;
  42477. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42478. this.resourcesPromise = null;
  42479. var uniquePrefix = 'p' + this.pageIndex + '_';
  42480. var idCounters = { obj: 0 };
  42481. this.idFactory = {
  42482. createObjId: function () {
  42483. return uniquePrefix + ++idCounters.obj;
  42484. }
  42485. };
  42486. }
  42487. Page.prototype = {
  42488. getPageProp: function Page_getPageProp(key) {
  42489. return this.pageDict.get(key);
  42490. },
  42491. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42492. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42493. var MAX_LOOP_COUNT = 100;
  42494. getArray = getArray || false;
  42495. while (dict) {
  42496. var value = getArray ? dict.getArray(key) : dict.get(key);
  42497. if (value) {
  42498. if (!valueArray) {
  42499. valueArray = [];
  42500. }
  42501. valueArray.push(value);
  42502. }
  42503. if (++loopCount > MAX_LOOP_COUNT) {
  42504. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42505. break;
  42506. }
  42507. dict = dict.get('Parent');
  42508. }
  42509. if (!valueArray) {
  42510. return Dict.empty;
  42511. }
  42512. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42513. return valueArray[0];
  42514. }
  42515. return Dict.merge(this.xref, valueArray);
  42516. },
  42517. get content() {
  42518. return this.getPageProp('Contents');
  42519. },
  42520. get resources() {
  42521. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42522. },
  42523. get mediaBox() {
  42524. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42525. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42526. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42527. }
  42528. return shadow(this, 'mediaBox', mediaBox);
  42529. },
  42530. get cropBox() {
  42531. var cropBox = this.getInheritedPageProp('CropBox', true);
  42532. if (!isArray(cropBox) || cropBox.length !== 4) {
  42533. return shadow(this, 'cropBox', this.mediaBox);
  42534. }
  42535. return shadow(this, 'cropBox', cropBox);
  42536. },
  42537. get userUnit() {
  42538. var obj = this.getPageProp('UserUnit');
  42539. if (!isNum(obj) || obj <= 0) {
  42540. obj = DEFAULT_USER_UNIT;
  42541. }
  42542. return shadow(this, 'userUnit', obj);
  42543. },
  42544. get view() {
  42545. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42546. if (mediaBox === cropBox) {
  42547. return shadow(this, 'view', mediaBox);
  42548. }
  42549. var intersection = Util.intersect(cropBox, mediaBox);
  42550. return shadow(this, 'view', intersection || mediaBox);
  42551. },
  42552. get rotate() {
  42553. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42554. if (rotate % 90 !== 0) {
  42555. rotate = 0;
  42556. } else if (rotate >= 360) {
  42557. rotate = rotate % 360;
  42558. } else if (rotate < 0) {
  42559. rotate = (rotate % 360 + 360) % 360;
  42560. }
  42561. return shadow(this, 'rotate', rotate);
  42562. },
  42563. getContentStream: function Page_getContentStream() {
  42564. var content = this.content;
  42565. var stream;
  42566. if (isArray(content)) {
  42567. var xref = this.xref;
  42568. var i, n = content.length;
  42569. var streams = [];
  42570. for (i = 0; i < n; ++i) {
  42571. streams.push(xref.fetchIfRef(content[i]));
  42572. }
  42573. stream = new StreamsSequenceStream(streams);
  42574. } else if (isStream(content)) {
  42575. stream = content;
  42576. } else {
  42577. stream = new NullStream();
  42578. }
  42579. return stream;
  42580. },
  42581. loadResources: function Page_loadResources(keys) {
  42582. if (!this.resourcesPromise) {
  42583. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42584. }
  42585. return this.resourcesPromise.then(function resourceSuccess() {
  42586. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42587. return objectLoader.load();
  42588. }.bind(this));
  42589. },
  42590. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42591. var self = this;
  42592. var pdfManager = this.pdfManager;
  42593. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42594. var resourcesPromise = this.loadResources([
  42595. 'ExtGState',
  42596. 'ColorSpace',
  42597. 'Pattern',
  42598. 'Shading',
  42599. 'XObject',
  42600. 'Font'
  42601. ]);
  42602. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  42603. var dataPromises = Promise.all([
  42604. contentStreamPromise,
  42605. resourcesPromise
  42606. ]);
  42607. var pageListPromise = dataPromises.then(function (data) {
  42608. var contentStream = data[0];
  42609. var opList = new OperatorList(intent, handler, self.pageIndex);
  42610. handler.send('StartRenderPage', {
  42611. transparency: partialEvaluator.hasBlendModes(self.resources),
  42612. pageIndex: self.pageIndex,
  42613. intent: intent
  42614. });
  42615. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42616. return opList;
  42617. });
  42618. });
  42619. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42620. return Promise.all([
  42621. pageListPromise,
  42622. annotationsPromise
  42623. ]).then(function (datas) {
  42624. var pageOpList = datas[0];
  42625. var annotations = datas[1];
  42626. if (annotations.length === 0) {
  42627. pageOpList.flush(true);
  42628. return pageOpList;
  42629. }
  42630. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42631. return annotationsReadyPromise.then(function () {
  42632. pageOpList.flush(true);
  42633. return pageOpList;
  42634. });
  42635. });
  42636. },
  42637. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42638. var handler = {
  42639. on: function nullHandlerOn() {
  42640. },
  42641. send: function nullHandlerSend() {
  42642. }
  42643. };
  42644. var self = this;
  42645. var pdfManager = this.pdfManager;
  42646. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42647. var resourcesPromise = this.loadResources([
  42648. 'ExtGState',
  42649. 'XObject',
  42650. 'Font'
  42651. ]);
  42652. var dataPromises = Promise.all([
  42653. contentStreamPromise,
  42654. resourcesPromise
  42655. ]);
  42656. return dataPromises.then(function (data) {
  42657. var contentStream = data[0];
  42658. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  42659. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42660. });
  42661. },
  42662. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42663. var annotations = this.annotations;
  42664. var annotationsData = [];
  42665. for (var i = 0, n = annotations.length; i < n; ++i) {
  42666. if (intent) {
  42667. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42668. continue;
  42669. }
  42670. }
  42671. annotationsData.push(annotations[i].data);
  42672. }
  42673. return annotationsData;
  42674. },
  42675. get annotations() {
  42676. var annotations = [];
  42677. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42678. var annotationFactory = new AnnotationFactory();
  42679. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42680. var annotationRef = annotationRefs[i];
  42681. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42682. if (annotation) {
  42683. annotations.push(annotation);
  42684. }
  42685. }
  42686. return shadow(this, 'annotations', annotations);
  42687. }
  42688. };
  42689. return Page;
  42690. }();
  42691. var PDFDocument = function PDFDocumentClosure() {
  42692. var FINGERPRINT_FIRST_BYTES = 1024;
  42693. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42694. function PDFDocument(pdfManager, arg) {
  42695. var stream;
  42696. if (isStream(arg)) {
  42697. stream = arg;
  42698. } else if (isArrayBuffer(arg)) {
  42699. stream = new Stream(arg);
  42700. } else {
  42701. error('PDFDocument: Unknown argument type');
  42702. }
  42703. assert(stream.length > 0, 'stream must have data');
  42704. this.pdfManager = pdfManager;
  42705. this.stream = stream;
  42706. this.xref = new XRef(stream, pdfManager);
  42707. }
  42708. function find(stream, needle, limit, backwards) {
  42709. var pos = stream.pos;
  42710. var end = stream.end;
  42711. var strBuf = [];
  42712. if (pos + limit > end) {
  42713. limit = end - pos;
  42714. }
  42715. for (var n = 0; n < limit; ++n) {
  42716. strBuf.push(String.fromCharCode(stream.getByte()));
  42717. }
  42718. var str = strBuf.join('');
  42719. stream.pos = pos;
  42720. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42721. if (index === -1) {
  42722. return false;
  42723. }
  42724. stream.pos += index;
  42725. return true;
  42726. }
  42727. var DocumentInfoValidators = {
  42728. get entries() {
  42729. return shadow(this, 'entries', {
  42730. Title: isString,
  42731. Author: isString,
  42732. Subject: isString,
  42733. Keywords: isString,
  42734. Creator: isString,
  42735. Producer: isString,
  42736. CreationDate: isString,
  42737. ModDate: isString,
  42738. Trapped: isName
  42739. });
  42740. }
  42741. };
  42742. PDFDocument.prototype = {
  42743. parse: function PDFDocument_parse(recoveryMode) {
  42744. this.setup(recoveryMode);
  42745. var version = this.catalog.catDict.get('Version');
  42746. if (isName(version)) {
  42747. this.pdfFormatVersion = version.name;
  42748. }
  42749. try {
  42750. this.acroForm = this.catalog.catDict.get('AcroForm');
  42751. if (this.acroForm) {
  42752. this.xfa = this.acroForm.get('XFA');
  42753. var fields = this.acroForm.get('Fields');
  42754. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42755. this.acroForm = null;
  42756. }
  42757. }
  42758. } catch (ex) {
  42759. info('Something wrong with AcroForm entry');
  42760. this.acroForm = null;
  42761. }
  42762. },
  42763. get linearization() {
  42764. var linearization = null;
  42765. if (this.stream.length) {
  42766. try {
  42767. linearization = Linearization.create(this.stream);
  42768. } catch (err) {
  42769. if (err instanceof MissingDataException) {
  42770. throw err;
  42771. }
  42772. info(err);
  42773. }
  42774. }
  42775. return shadow(this, 'linearization', linearization);
  42776. },
  42777. get startXRef() {
  42778. var stream = this.stream;
  42779. var startXRef = 0;
  42780. var linearization = this.linearization;
  42781. if (linearization) {
  42782. stream.reset();
  42783. if (find(stream, 'endobj', 1024)) {
  42784. startXRef = stream.pos + 6;
  42785. }
  42786. } else {
  42787. var step = 1024;
  42788. var found = false, pos = stream.end;
  42789. while (!found && pos > 0) {
  42790. pos -= step - 'startxref'.length;
  42791. if (pos < 0) {
  42792. pos = 0;
  42793. }
  42794. stream.pos = pos;
  42795. found = find(stream, 'startxref', step, true);
  42796. }
  42797. if (found) {
  42798. stream.skip(9);
  42799. var ch;
  42800. do {
  42801. ch = stream.getByte();
  42802. } while (isSpace(ch));
  42803. var str = '';
  42804. while (ch >= 0x20 && ch <= 0x39) {
  42805. str += String.fromCharCode(ch);
  42806. ch = stream.getByte();
  42807. }
  42808. startXRef = parseInt(str, 10);
  42809. if (isNaN(startXRef)) {
  42810. startXRef = 0;
  42811. }
  42812. }
  42813. }
  42814. return shadow(this, 'startXRef', startXRef);
  42815. },
  42816. get mainXRefEntriesOffset() {
  42817. var mainXRefEntriesOffset = 0;
  42818. var linearization = this.linearization;
  42819. if (linearization) {
  42820. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42821. }
  42822. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42823. },
  42824. checkHeader: function PDFDocument_checkHeader() {
  42825. var stream = this.stream;
  42826. stream.reset();
  42827. if (find(stream, '%PDF-', 1024)) {
  42828. stream.moveStart();
  42829. var MAX_VERSION_LENGTH = 12;
  42830. var version = '', ch;
  42831. while ((ch = stream.getByte()) > 0x20) {
  42832. if (version.length >= MAX_VERSION_LENGTH) {
  42833. break;
  42834. }
  42835. version += String.fromCharCode(ch);
  42836. }
  42837. if (!this.pdfFormatVersion) {
  42838. this.pdfFormatVersion = version.substring(5);
  42839. }
  42840. return;
  42841. }
  42842. },
  42843. parseStartXRef: function PDFDocument_parseStartXRef() {
  42844. var startXRef = this.startXRef;
  42845. this.xref.setStartXRef(startXRef);
  42846. },
  42847. setup: function PDFDocument_setup(recoveryMode) {
  42848. this.xref.parse(recoveryMode);
  42849. var self = this;
  42850. var pageFactory = {
  42851. createPage: function (pageIndex, dict, ref, fontCache) {
  42852. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  42853. }
  42854. };
  42855. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42856. },
  42857. get numPages() {
  42858. var linearization = this.linearization;
  42859. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42860. return shadow(this, 'numPages', num);
  42861. },
  42862. get documentInfo() {
  42863. var docInfo = {
  42864. PDFFormatVersion: this.pdfFormatVersion,
  42865. IsAcroFormPresent: !!this.acroForm,
  42866. IsXFAPresent: !!this.xfa
  42867. };
  42868. var infoDict;
  42869. try {
  42870. infoDict = this.xref.trailer.get('Info');
  42871. } catch (err) {
  42872. info('The document information dictionary is invalid.');
  42873. }
  42874. if (infoDict) {
  42875. var validEntries = DocumentInfoValidators.entries;
  42876. for (var key in validEntries) {
  42877. if (infoDict.has(key)) {
  42878. var value = infoDict.get(key);
  42879. if (validEntries[key](value)) {
  42880. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42881. } else {
  42882. info('Bad value in document info for "' + key + '"');
  42883. }
  42884. }
  42885. }
  42886. }
  42887. return shadow(this, 'documentInfo', docInfo);
  42888. },
  42889. get fingerprint() {
  42890. var xref = this.xref, hash, fileID = '';
  42891. var idArray = xref.trailer.get('ID');
  42892. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42893. hash = stringToBytes(idArray[0]);
  42894. } else {
  42895. if (this.stream.ensureRange) {
  42896. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42897. }
  42898. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42899. }
  42900. for (var i = 0, n = hash.length; i < n; i++) {
  42901. var hex = hash[i].toString(16);
  42902. fileID += hex.length === 1 ? '0' + hex : hex;
  42903. }
  42904. return shadow(this, 'fingerprint', fileID);
  42905. },
  42906. getPage: function PDFDocument_getPage(pageIndex) {
  42907. return this.catalog.getPage(pageIndex);
  42908. },
  42909. cleanup: function PDFDocument_cleanup() {
  42910. return this.catalog.cleanup();
  42911. }
  42912. };
  42913. return PDFDocument;
  42914. }();
  42915. exports.Page = Page;
  42916. exports.PDFDocument = PDFDocument;
  42917. /***/ }),
  42918. /* 33 */
  42919. /***/ (function(module, exports, __w_pdfjs_require__) {
  42920. "use strict";
  42921. var sharedUtil = __w_pdfjs_require__(0);
  42922. var coreStream = __w_pdfjs_require__(2);
  42923. var coreGlyphList = __w_pdfjs_require__(8);
  42924. var coreEncodings = __w_pdfjs_require__(5);
  42925. var coreCFFParser = __w_pdfjs_require__(14);
  42926. var Util = sharedUtil.Util;
  42927. var bytesToString = sharedUtil.bytesToString;
  42928. var error = sharedUtil.error;
  42929. var Stream = coreStream.Stream;
  42930. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42931. var StandardEncoding = coreEncodings.StandardEncoding;
  42932. var CFFParser = coreCFFParser.CFFParser;
  42933. var FontRendererFactory = function FontRendererFactoryClosure() {
  42934. function getLong(data, offset) {
  42935. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42936. }
  42937. function getUshort(data, offset) {
  42938. return data[offset] << 8 | data[offset + 1];
  42939. }
  42940. function parseCmap(data, start, end) {
  42941. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42942. var format = getUshort(data, start + offset);
  42943. var ranges, p, i;
  42944. if (format === 4) {
  42945. getUshort(data, start + offset + 2);
  42946. var segCount = getUshort(data, start + offset + 6) >> 1;
  42947. p = start + offset + 14;
  42948. ranges = [];
  42949. for (i = 0; i < segCount; i++, p += 2) {
  42950. ranges[i] = { end: getUshort(data, p) };
  42951. }
  42952. p += 2;
  42953. for (i = 0; i < segCount; i++, p += 2) {
  42954. ranges[i].start = getUshort(data, p);
  42955. }
  42956. for (i = 0; i < segCount; i++, p += 2) {
  42957. ranges[i].idDelta = getUshort(data, p);
  42958. }
  42959. for (i = 0; i < segCount; i++, p += 2) {
  42960. var idOffset = getUshort(data, p);
  42961. if (idOffset === 0) {
  42962. continue;
  42963. }
  42964. ranges[i].ids = [];
  42965. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42966. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42967. idOffset += 2;
  42968. }
  42969. }
  42970. return ranges;
  42971. } else if (format === 12) {
  42972. getLong(data, start + offset + 4);
  42973. var groups = getLong(data, start + offset + 12);
  42974. p = start + offset + 16;
  42975. ranges = [];
  42976. for (i = 0; i < groups; i++) {
  42977. ranges.push({
  42978. start: getLong(data, p),
  42979. end: getLong(data, p + 4),
  42980. idDelta: getLong(data, p + 8) - getLong(data, p)
  42981. });
  42982. p += 12;
  42983. }
  42984. return ranges;
  42985. }
  42986. error('not supported cmap: ' + format);
  42987. }
  42988. function parseCff(data, start, end, seacAnalysisEnabled) {
  42989. var properties = {};
  42990. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42991. var cff = parser.parse();
  42992. return {
  42993. glyphs: cff.charStrings.objects,
  42994. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42995. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42996. };
  42997. }
  42998. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42999. var itemSize, itemDecode;
  43000. if (isGlyphLocationsLong) {
  43001. itemSize = 4;
  43002. itemDecode = function fontItemDecodeLong(data, offset) {
  43003. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43004. };
  43005. } else {
  43006. itemSize = 2;
  43007. itemDecode = function fontItemDecode(data, offset) {
  43008. return data[offset] << 9 | data[offset + 1] << 1;
  43009. };
  43010. }
  43011. var glyphs = [];
  43012. var startOffset = itemDecode(loca, 0);
  43013. for (var j = itemSize; j < loca.length; j += itemSize) {
  43014. var endOffset = itemDecode(loca, j);
  43015. glyphs.push(glyf.subarray(startOffset, endOffset));
  43016. startOffset = endOffset;
  43017. }
  43018. return glyphs;
  43019. }
  43020. function lookupCmap(ranges, unicode) {
  43021. var code = unicode.charCodeAt(0), gid = 0;
  43022. var l = 0, r = ranges.length - 1;
  43023. while (l < r) {
  43024. var c = l + r + 1 >> 1;
  43025. if (code < ranges[c].start) {
  43026. r = c - 1;
  43027. } else {
  43028. l = c;
  43029. }
  43030. }
  43031. if (ranges[l].start <= code && code <= ranges[l].end) {
  43032. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43033. }
  43034. return {
  43035. charCode: code,
  43036. glyphId: gid
  43037. };
  43038. }
  43039. function compileGlyf(code, cmds, font) {
  43040. function moveTo(x, y) {
  43041. cmds.push({
  43042. cmd: 'moveTo',
  43043. args: [
  43044. x,
  43045. y
  43046. ]
  43047. });
  43048. }
  43049. function lineTo(x, y) {
  43050. cmds.push({
  43051. cmd: 'lineTo',
  43052. args: [
  43053. x,
  43054. y
  43055. ]
  43056. });
  43057. }
  43058. function quadraticCurveTo(xa, ya, x, y) {
  43059. cmds.push({
  43060. cmd: 'quadraticCurveTo',
  43061. args: [
  43062. xa,
  43063. ya,
  43064. x,
  43065. y
  43066. ]
  43067. });
  43068. }
  43069. var i = 0;
  43070. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43071. var flags;
  43072. var x = 0, y = 0;
  43073. i += 10;
  43074. if (numberOfContours < 0) {
  43075. do {
  43076. flags = code[i] << 8 | code[i + 1];
  43077. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43078. i += 4;
  43079. var arg1, arg2;
  43080. if (flags & 0x01) {
  43081. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43082. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43083. i += 4;
  43084. } else {
  43085. arg1 = code[i++];
  43086. arg2 = code[i++];
  43087. }
  43088. if (flags & 0x02) {
  43089. x = arg1;
  43090. y = arg2;
  43091. } else {
  43092. x = 0;
  43093. y = 0;
  43094. }
  43095. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43096. if (flags & 0x08) {
  43097. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43098. i += 2;
  43099. } else if (flags & 0x40) {
  43100. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43101. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43102. i += 4;
  43103. } else if (flags & 0x80) {
  43104. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43105. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43106. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43107. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43108. i += 8;
  43109. }
  43110. var subglyph = font.glyphs[glyphIndex];
  43111. if (subglyph) {
  43112. cmds.push({ cmd: 'save' });
  43113. cmds.push({
  43114. cmd: 'transform',
  43115. args: [
  43116. scaleX,
  43117. scale01,
  43118. scale10,
  43119. scaleY,
  43120. x,
  43121. y
  43122. ]
  43123. });
  43124. compileGlyf(subglyph, cmds, font);
  43125. cmds.push({ cmd: 'restore' });
  43126. }
  43127. } while (flags & 0x20);
  43128. } else {
  43129. var endPtsOfContours = [];
  43130. var j, jj;
  43131. for (j = 0; j < numberOfContours; j++) {
  43132. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43133. i += 2;
  43134. }
  43135. var instructionLength = code[i] << 8 | code[i + 1];
  43136. i += 2 + instructionLength;
  43137. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43138. var points = [];
  43139. while (points.length < numberOfPoints) {
  43140. flags = code[i++];
  43141. var repeat = 1;
  43142. if (flags & 0x08) {
  43143. repeat += code[i++];
  43144. }
  43145. while (repeat-- > 0) {
  43146. points.push({ flags: flags });
  43147. }
  43148. }
  43149. for (j = 0; j < numberOfPoints; j++) {
  43150. switch (points[j].flags & 0x12) {
  43151. case 0x00:
  43152. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43153. i += 2;
  43154. break;
  43155. case 0x02:
  43156. x -= code[i++];
  43157. break;
  43158. case 0x12:
  43159. x += code[i++];
  43160. break;
  43161. }
  43162. points[j].x = x;
  43163. }
  43164. for (j = 0; j < numberOfPoints; j++) {
  43165. switch (points[j].flags & 0x24) {
  43166. case 0x00:
  43167. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43168. i += 2;
  43169. break;
  43170. case 0x04:
  43171. y -= code[i++];
  43172. break;
  43173. case 0x24:
  43174. y += code[i++];
  43175. break;
  43176. }
  43177. points[j].y = y;
  43178. }
  43179. var startPoint = 0;
  43180. for (i = 0; i < numberOfContours; i++) {
  43181. var endPoint = endPtsOfContours[i];
  43182. var contour = points.slice(startPoint, endPoint + 1);
  43183. if (contour[0].flags & 1) {
  43184. contour.push(contour[0]);
  43185. } else if (contour[contour.length - 1].flags & 1) {
  43186. contour.unshift(contour[contour.length - 1]);
  43187. } else {
  43188. var p = {
  43189. flags: 1,
  43190. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43191. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43192. };
  43193. contour.unshift(p);
  43194. contour.push(p);
  43195. }
  43196. moveTo(contour[0].x, contour[0].y);
  43197. for (j = 1, jj = contour.length; j < jj; j++) {
  43198. if (contour[j].flags & 1) {
  43199. lineTo(contour[j].x, contour[j].y);
  43200. } else if (contour[j + 1].flags & 1) {
  43201. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43202. j++;
  43203. } else {
  43204. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43205. }
  43206. }
  43207. startPoint = endPoint + 1;
  43208. }
  43209. }
  43210. }
  43211. function compileCharString(code, cmds, font) {
  43212. var stack = [];
  43213. var x = 0, y = 0;
  43214. var stems = 0;
  43215. function moveTo(x, y) {
  43216. cmds.push({
  43217. cmd: 'moveTo',
  43218. args: [
  43219. x,
  43220. y
  43221. ]
  43222. });
  43223. }
  43224. function lineTo(x, y) {
  43225. cmds.push({
  43226. cmd: 'lineTo',
  43227. args: [
  43228. x,
  43229. y
  43230. ]
  43231. });
  43232. }
  43233. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43234. cmds.push({
  43235. cmd: 'bezierCurveTo',
  43236. args: [
  43237. x1,
  43238. y1,
  43239. x2,
  43240. y2,
  43241. x,
  43242. y
  43243. ]
  43244. });
  43245. }
  43246. function parse(code) {
  43247. var i = 0;
  43248. while (i < code.length) {
  43249. var stackClean = false;
  43250. var v = code[i++];
  43251. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43252. switch (v) {
  43253. case 1:
  43254. stems += stack.length >> 1;
  43255. stackClean = true;
  43256. break;
  43257. case 3:
  43258. stems += stack.length >> 1;
  43259. stackClean = true;
  43260. break;
  43261. case 4:
  43262. y += stack.pop();
  43263. moveTo(x, y);
  43264. stackClean = true;
  43265. break;
  43266. case 5:
  43267. while (stack.length > 0) {
  43268. x += stack.shift();
  43269. y += stack.shift();
  43270. lineTo(x, y);
  43271. }
  43272. break;
  43273. case 6:
  43274. while (stack.length > 0) {
  43275. x += stack.shift();
  43276. lineTo(x, y);
  43277. if (stack.length === 0) {
  43278. break;
  43279. }
  43280. y += stack.shift();
  43281. lineTo(x, y);
  43282. }
  43283. break;
  43284. case 7:
  43285. while (stack.length > 0) {
  43286. y += stack.shift();
  43287. lineTo(x, y);
  43288. if (stack.length === 0) {
  43289. break;
  43290. }
  43291. x += stack.shift();
  43292. lineTo(x, y);
  43293. }
  43294. break;
  43295. case 8:
  43296. while (stack.length > 0) {
  43297. xa = x + stack.shift();
  43298. ya = y + stack.shift();
  43299. xb = xa + stack.shift();
  43300. yb = ya + stack.shift();
  43301. x = xb + stack.shift();
  43302. y = yb + stack.shift();
  43303. bezierCurveTo(xa, ya, xb, yb, x, y);
  43304. }
  43305. break;
  43306. case 10:
  43307. n = stack.pop() + font.subrsBias;
  43308. subrCode = font.subrs[n];
  43309. if (subrCode) {
  43310. parse(subrCode);
  43311. }
  43312. break;
  43313. case 11:
  43314. return;
  43315. case 12:
  43316. v = code[i++];
  43317. switch (v) {
  43318. case 34:
  43319. xa = x + stack.shift();
  43320. xb = xa + stack.shift();
  43321. y1 = y + stack.shift();
  43322. x = xb + stack.shift();
  43323. bezierCurveTo(xa, y, xb, y1, x, y1);
  43324. xa = x + stack.shift();
  43325. xb = xa + stack.shift();
  43326. x = xb + stack.shift();
  43327. bezierCurveTo(xa, y1, xb, y, x, y);
  43328. break;
  43329. case 35:
  43330. xa = x + stack.shift();
  43331. ya = y + stack.shift();
  43332. xb = xa + stack.shift();
  43333. yb = ya + stack.shift();
  43334. x = xb + stack.shift();
  43335. y = yb + stack.shift();
  43336. bezierCurveTo(xa, ya, xb, yb, x, y);
  43337. xa = x + stack.shift();
  43338. ya = y + stack.shift();
  43339. xb = xa + stack.shift();
  43340. yb = ya + stack.shift();
  43341. x = xb + stack.shift();
  43342. y = yb + stack.shift();
  43343. bezierCurveTo(xa, ya, xb, yb, x, y);
  43344. stack.pop();
  43345. break;
  43346. case 36:
  43347. xa = x + stack.shift();
  43348. y1 = y + stack.shift();
  43349. xb = xa + stack.shift();
  43350. y2 = y1 + stack.shift();
  43351. x = xb + stack.shift();
  43352. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43353. xa = x + stack.shift();
  43354. xb = xa + stack.shift();
  43355. y3 = y2 + stack.shift();
  43356. x = xb + stack.shift();
  43357. bezierCurveTo(xa, y2, xb, y3, x, y);
  43358. break;
  43359. case 37:
  43360. var x0 = x, y0 = y;
  43361. xa = x + stack.shift();
  43362. ya = y + stack.shift();
  43363. xb = xa + stack.shift();
  43364. yb = ya + stack.shift();
  43365. x = xb + stack.shift();
  43366. y = yb + stack.shift();
  43367. bezierCurveTo(xa, ya, xb, yb, x, y);
  43368. xa = x + stack.shift();
  43369. ya = y + stack.shift();
  43370. xb = xa + stack.shift();
  43371. yb = ya + stack.shift();
  43372. x = xb;
  43373. y = yb;
  43374. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43375. x += stack.shift();
  43376. } else {
  43377. y += stack.shift();
  43378. }
  43379. bezierCurveTo(xa, ya, xb, yb, x, y);
  43380. break;
  43381. default:
  43382. error('unknown operator: 12 ' + v);
  43383. }
  43384. break;
  43385. case 14:
  43386. if (stack.length >= 4) {
  43387. var achar = stack.pop();
  43388. var bchar = stack.pop();
  43389. y = stack.pop();
  43390. x = stack.pop();
  43391. cmds.push({ cmd: 'save' });
  43392. cmds.push({
  43393. cmd: 'translate',
  43394. args: [
  43395. x,
  43396. y
  43397. ]
  43398. });
  43399. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43400. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43401. cmds.push({ cmd: 'restore' });
  43402. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43403. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43404. }
  43405. return;
  43406. case 18:
  43407. stems += stack.length >> 1;
  43408. stackClean = true;
  43409. break;
  43410. case 19:
  43411. stems += stack.length >> 1;
  43412. i += stems + 7 >> 3;
  43413. stackClean = true;
  43414. break;
  43415. case 20:
  43416. stems += stack.length >> 1;
  43417. i += stems + 7 >> 3;
  43418. stackClean = true;
  43419. break;
  43420. case 21:
  43421. y += stack.pop();
  43422. x += stack.pop();
  43423. moveTo(x, y);
  43424. stackClean = true;
  43425. break;
  43426. case 22:
  43427. x += stack.pop();
  43428. moveTo(x, y);
  43429. stackClean = true;
  43430. break;
  43431. case 23:
  43432. stems += stack.length >> 1;
  43433. stackClean = true;
  43434. break;
  43435. case 24:
  43436. while (stack.length > 2) {
  43437. xa = x + stack.shift();
  43438. ya = y + stack.shift();
  43439. xb = xa + stack.shift();
  43440. yb = ya + stack.shift();
  43441. x = xb + stack.shift();
  43442. y = yb + stack.shift();
  43443. bezierCurveTo(xa, ya, xb, yb, x, y);
  43444. }
  43445. x += stack.shift();
  43446. y += stack.shift();
  43447. lineTo(x, y);
  43448. break;
  43449. case 25:
  43450. while (stack.length > 6) {
  43451. x += stack.shift();
  43452. y += stack.shift();
  43453. lineTo(x, y);
  43454. }
  43455. xa = x + stack.shift();
  43456. ya = y + stack.shift();
  43457. xb = xa + stack.shift();
  43458. yb = ya + stack.shift();
  43459. x = xb + stack.shift();
  43460. y = yb + stack.shift();
  43461. bezierCurveTo(xa, ya, xb, yb, x, y);
  43462. break;
  43463. case 26:
  43464. if (stack.length % 2) {
  43465. x += stack.shift();
  43466. }
  43467. while (stack.length > 0) {
  43468. xa = x;
  43469. ya = y + stack.shift();
  43470. xb = xa + stack.shift();
  43471. yb = ya + stack.shift();
  43472. x = xb;
  43473. y = yb + stack.shift();
  43474. bezierCurveTo(xa, ya, xb, yb, x, y);
  43475. }
  43476. break;
  43477. case 27:
  43478. if (stack.length % 2) {
  43479. y += stack.shift();
  43480. }
  43481. while (stack.length > 0) {
  43482. xa = x + stack.shift();
  43483. ya = y;
  43484. xb = xa + stack.shift();
  43485. yb = ya + stack.shift();
  43486. x = xb + stack.shift();
  43487. y = yb;
  43488. bezierCurveTo(xa, ya, xb, yb, x, y);
  43489. }
  43490. break;
  43491. case 28:
  43492. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43493. i += 2;
  43494. break;
  43495. case 29:
  43496. n = stack.pop() + font.gsubrsBias;
  43497. subrCode = font.gsubrs[n];
  43498. if (subrCode) {
  43499. parse(subrCode);
  43500. }
  43501. break;
  43502. case 30:
  43503. while (stack.length > 0) {
  43504. xa = x;
  43505. ya = y + stack.shift();
  43506. xb = xa + stack.shift();
  43507. yb = ya + stack.shift();
  43508. x = xb + stack.shift();
  43509. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43510. bezierCurveTo(xa, ya, xb, yb, x, y);
  43511. if (stack.length === 0) {
  43512. break;
  43513. }
  43514. xa = x + stack.shift();
  43515. ya = y;
  43516. xb = xa + stack.shift();
  43517. yb = ya + stack.shift();
  43518. y = yb + stack.shift();
  43519. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43520. bezierCurveTo(xa, ya, xb, yb, x, y);
  43521. }
  43522. break;
  43523. case 31:
  43524. while (stack.length > 0) {
  43525. xa = x + stack.shift();
  43526. ya = y;
  43527. xb = xa + stack.shift();
  43528. yb = ya + stack.shift();
  43529. y = yb + stack.shift();
  43530. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43531. bezierCurveTo(xa, ya, xb, yb, x, y);
  43532. if (stack.length === 0) {
  43533. break;
  43534. }
  43535. xa = x;
  43536. ya = y + stack.shift();
  43537. xb = xa + stack.shift();
  43538. yb = ya + stack.shift();
  43539. x = xb + stack.shift();
  43540. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43541. bezierCurveTo(xa, ya, xb, yb, x, y);
  43542. }
  43543. break;
  43544. default:
  43545. if (v < 32) {
  43546. error('unknown operator: ' + v);
  43547. }
  43548. if (v < 247) {
  43549. stack.push(v - 139);
  43550. } else if (v < 251) {
  43551. stack.push((v - 247) * 256 + code[i++] + 108);
  43552. } else if (v < 255) {
  43553. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43554. } else {
  43555. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43556. i += 4;
  43557. }
  43558. break;
  43559. }
  43560. if (stackClean) {
  43561. stack.length = 0;
  43562. }
  43563. }
  43564. }
  43565. parse(code);
  43566. }
  43567. var noop = '';
  43568. function CompiledFont(fontMatrix) {
  43569. this.compiledGlyphs = Object.create(null);
  43570. this.compiledCharCodeToGlyphId = Object.create(null);
  43571. this.fontMatrix = fontMatrix;
  43572. }
  43573. CompiledFont.prototype = {
  43574. getPathJs: function (unicode) {
  43575. var cmap = lookupCmap(this.cmap, unicode);
  43576. var fn = this.compiledGlyphs[cmap.glyphId];
  43577. if (!fn) {
  43578. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43579. this.compiledGlyphs[cmap.glyphId] = fn;
  43580. }
  43581. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43582. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43583. }
  43584. return fn;
  43585. },
  43586. compileGlyph: function (code) {
  43587. if (!code || code.length === 0 || code[0] === 14) {
  43588. return noop;
  43589. }
  43590. var cmds = [];
  43591. cmds.push({ cmd: 'save' });
  43592. cmds.push({
  43593. cmd: 'transform',
  43594. args: this.fontMatrix.slice()
  43595. });
  43596. cmds.push({
  43597. cmd: 'scale',
  43598. args: [
  43599. 'size',
  43600. '-size'
  43601. ]
  43602. });
  43603. this.compileGlyphImpl(code, cmds);
  43604. cmds.push({ cmd: 'restore' });
  43605. return cmds;
  43606. },
  43607. compileGlyphImpl: function () {
  43608. error('Children classes should implement this.');
  43609. },
  43610. hasBuiltPath: function (unicode) {
  43611. var cmap = lookupCmap(this.cmap, unicode);
  43612. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43613. }
  43614. };
  43615. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43616. fontMatrix = fontMatrix || [
  43617. 0.000488,
  43618. 0,
  43619. 0,
  43620. 0.000488,
  43621. 0,
  43622. 0
  43623. ];
  43624. CompiledFont.call(this, fontMatrix);
  43625. this.glyphs = glyphs;
  43626. this.cmap = cmap;
  43627. }
  43628. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43629. compileGlyphImpl: function (code, cmds) {
  43630. compileGlyf(code, cmds, this);
  43631. }
  43632. });
  43633. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43634. fontMatrix = fontMatrix || [
  43635. 0.001,
  43636. 0,
  43637. 0,
  43638. 0.001,
  43639. 0,
  43640. 0
  43641. ];
  43642. CompiledFont.call(this, fontMatrix);
  43643. this.glyphs = cffInfo.glyphs;
  43644. this.gsubrs = cffInfo.gsubrs || [];
  43645. this.subrs = cffInfo.subrs || [];
  43646. this.cmap = cmap;
  43647. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43648. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43649. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43650. }
  43651. Util.inherit(Type2Compiled, CompiledFont, {
  43652. compileGlyphImpl: function (code, cmds) {
  43653. compileCharString(code, cmds, this);
  43654. }
  43655. });
  43656. return {
  43657. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43658. var data = new Uint8Array(font.data);
  43659. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43660. var numTables = getUshort(data, 4);
  43661. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43662. var tag = bytesToString(data.subarray(p, p + 4));
  43663. var offset = getLong(data, p + 8);
  43664. var length = getLong(data, p + 12);
  43665. switch (tag) {
  43666. case 'cmap':
  43667. cmap = parseCmap(data, offset, offset + length);
  43668. break;
  43669. case 'glyf':
  43670. glyf = data.subarray(offset, offset + length);
  43671. break;
  43672. case 'loca':
  43673. loca = data.subarray(offset, offset + length);
  43674. break;
  43675. case 'head':
  43676. unitsPerEm = getUshort(data, offset + 18);
  43677. indexToLocFormat = getUshort(data, offset + 50);
  43678. break;
  43679. case 'CFF ':
  43680. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43681. break;
  43682. }
  43683. }
  43684. if (glyf) {
  43685. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43686. 1 / unitsPerEm,
  43687. 0,
  43688. 0,
  43689. 1 / unitsPerEm,
  43690. 0,
  43691. 0
  43692. ];
  43693. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43694. }
  43695. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43696. }
  43697. };
  43698. }();
  43699. exports.FontRendererFactory = FontRendererFactory;
  43700. /***/ }),
  43701. /* 34 */
  43702. /***/ (function(module, exports, __w_pdfjs_require__) {
  43703. "use strict";
  43704. var sharedUtil = __w_pdfjs_require__(0);
  43705. var corePrimitives = __w_pdfjs_require__(1);
  43706. var coreStream = __w_pdfjs_require__(2);
  43707. var coreGlyphList = __w_pdfjs_require__(8);
  43708. var coreFontRenderer = __w_pdfjs_require__(33);
  43709. var coreEncodings = __w_pdfjs_require__(5);
  43710. var coreStandardFonts = __w_pdfjs_require__(20);
  43711. var coreUnicode = __w_pdfjs_require__(21);
  43712. var coreType1Parser = __w_pdfjs_require__(44);
  43713. var coreCFFParser = __w_pdfjs_require__(14);
  43714. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43715. var FontType = sharedUtil.FontType;
  43716. var assert = sharedUtil.assert;
  43717. var bytesToString = sharedUtil.bytesToString;
  43718. var error = sharedUtil.error;
  43719. var info = sharedUtil.info;
  43720. var isArray = sharedUtil.isArray;
  43721. var isInt = sharedUtil.isInt;
  43722. var isNum = sharedUtil.isNum;
  43723. var readUint32 = sharedUtil.readUint32;
  43724. var shadow = sharedUtil.shadow;
  43725. var string32 = sharedUtil.string32;
  43726. var warn = sharedUtil.warn;
  43727. var MissingDataException = sharedUtil.MissingDataException;
  43728. var isSpace = sharedUtil.isSpace;
  43729. var Stream = coreStream.Stream;
  43730. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43731. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43732. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43733. var StandardEncoding = coreEncodings.StandardEncoding;
  43734. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43735. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43736. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43737. var getEncoding = coreEncodings.getEncoding;
  43738. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43739. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43740. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43741. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43742. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43743. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43744. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43745. var Type1Parser = coreType1Parser.Type1Parser;
  43746. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43747. var CFFParser = coreCFFParser.CFFParser;
  43748. var CFFCompiler = coreCFFParser.CFFCompiler;
  43749. var CFF = coreCFFParser.CFF;
  43750. var CFFHeader = coreCFFParser.CFFHeader;
  43751. var CFFTopDict = coreCFFParser.CFFTopDict;
  43752. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43753. var CFFStrings = coreCFFParser.CFFStrings;
  43754. var CFFIndex = coreCFFParser.CFFIndex;
  43755. var CFFCharset = coreCFFParser.CFFCharset;
  43756. var PRIVATE_USE_OFFSET_START = 0xE000;
  43757. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43758. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43759. var PDF_GLYPH_SPACE_UNITS = 1000;
  43760. var SEAC_ANALYSIS_ENABLED = false;
  43761. var FontFlags = {
  43762. FixedPitch: 1,
  43763. Serif: 2,
  43764. Symbolic: 4,
  43765. Script: 8,
  43766. Nonsymbolic: 32,
  43767. Italic: 64,
  43768. AllCap: 65536,
  43769. SmallCap: 131072,
  43770. ForceBold: 262144
  43771. };
  43772. var MacStandardGlyphOrdering = [
  43773. '.notdef',
  43774. '.null',
  43775. 'nonmarkingreturn',
  43776. 'space',
  43777. 'exclam',
  43778. 'quotedbl',
  43779. 'numbersign',
  43780. 'dollar',
  43781. 'percent',
  43782. 'ampersand',
  43783. 'quotesingle',
  43784. 'parenleft',
  43785. 'parenright',
  43786. 'asterisk',
  43787. 'plus',
  43788. 'comma',
  43789. 'hyphen',
  43790. 'period',
  43791. 'slash',
  43792. 'zero',
  43793. 'one',
  43794. 'two',
  43795. 'three',
  43796. 'four',
  43797. 'five',
  43798. 'six',
  43799. 'seven',
  43800. 'eight',
  43801. 'nine',
  43802. 'colon',
  43803. 'semicolon',
  43804. 'less',
  43805. 'equal',
  43806. 'greater',
  43807. 'question',
  43808. 'at',
  43809. 'A',
  43810. 'B',
  43811. 'C',
  43812. 'D',
  43813. 'E',
  43814. 'F',
  43815. 'G',
  43816. 'H',
  43817. 'I',
  43818. 'J',
  43819. 'K',
  43820. 'L',
  43821. 'M',
  43822. 'N',
  43823. 'O',
  43824. 'P',
  43825. 'Q',
  43826. 'R',
  43827. 'S',
  43828. 'T',
  43829. 'U',
  43830. 'V',
  43831. 'W',
  43832. 'X',
  43833. 'Y',
  43834. 'Z',
  43835. 'bracketleft',
  43836. 'backslash',
  43837. 'bracketright',
  43838. 'asciicircum',
  43839. 'underscore',
  43840. 'grave',
  43841. 'a',
  43842. 'b',
  43843. 'c',
  43844. 'd',
  43845. 'e',
  43846. 'f',
  43847. 'g',
  43848. 'h',
  43849. 'i',
  43850. 'j',
  43851. 'k',
  43852. 'l',
  43853. 'm',
  43854. 'n',
  43855. 'o',
  43856. 'p',
  43857. 'q',
  43858. 'r',
  43859. 's',
  43860. 't',
  43861. 'u',
  43862. 'v',
  43863. 'w',
  43864. 'x',
  43865. 'y',
  43866. 'z',
  43867. 'braceleft',
  43868. 'bar',
  43869. 'braceright',
  43870. 'asciitilde',
  43871. 'Adieresis',
  43872. 'Aring',
  43873. 'Ccedilla',
  43874. 'Eacute',
  43875. 'Ntilde',
  43876. 'Odieresis',
  43877. 'Udieresis',
  43878. 'aacute',
  43879. 'agrave',
  43880. 'acircumflex',
  43881. 'adieresis',
  43882. 'atilde',
  43883. 'aring',
  43884. 'ccedilla',
  43885. 'eacute',
  43886. 'egrave',
  43887. 'ecircumflex',
  43888. 'edieresis',
  43889. 'iacute',
  43890. 'igrave',
  43891. 'icircumflex',
  43892. 'idieresis',
  43893. 'ntilde',
  43894. 'oacute',
  43895. 'ograve',
  43896. 'ocircumflex',
  43897. 'odieresis',
  43898. 'otilde',
  43899. 'uacute',
  43900. 'ugrave',
  43901. 'ucircumflex',
  43902. 'udieresis',
  43903. 'dagger',
  43904. 'degree',
  43905. 'cent',
  43906. 'sterling',
  43907. 'section',
  43908. 'bullet',
  43909. 'paragraph',
  43910. 'germandbls',
  43911. 'registered',
  43912. 'copyright',
  43913. 'trademark',
  43914. 'acute',
  43915. 'dieresis',
  43916. 'notequal',
  43917. 'AE',
  43918. 'Oslash',
  43919. 'infinity',
  43920. 'plusminus',
  43921. 'lessequal',
  43922. 'greaterequal',
  43923. 'yen',
  43924. 'mu',
  43925. 'partialdiff',
  43926. 'summation',
  43927. 'product',
  43928. 'pi',
  43929. 'integral',
  43930. 'ordfeminine',
  43931. 'ordmasculine',
  43932. 'Omega',
  43933. 'ae',
  43934. 'oslash',
  43935. 'questiondown',
  43936. 'exclamdown',
  43937. 'logicalnot',
  43938. 'radical',
  43939. 'florin',
  43940. 'approxequal',
  43941. 'Delta',
  43942. 'guillemotleft',
  43943. 'guillemotright',
  43944. 'ellipsis',
  43945. 'nonbreakingspace',
  43946. 'Agrave',
  43947. 'Atilde',
  43948. 'Otilde',
  43949. 'OE',
  43950. 'oe',
  43951. 'endash',
  43952. 'emdash',
  43953. 'quotedblleft',
  43954. 'quotedblright',
  43955. 'quoteleft',
  43956. 'quoteright',
  43957. 'divide',
  43958. 'lozenge',
  43959. 'ydieresis',
  43960. 'Ydieresis',
  43961. 'fraction',
  43962. 'currency',
  43963. 'guilsinglleft',
  43964. 'guilsinglright',
  43965. 'fi',
  43966. 'fl',
  43967. 'daggerdbl',
  43968. 'periodcentered',
  43969. 'quotesinglbase',
  43970. 'quotedblbase',
  43971. 'perthousand',
  43972. 'Acircumflex',
  43973. 'Ecircumflex',
  43974. 'Aacute',
  43975. 'Edieresis',
  43976. 'Egrave',
  43977. 'Iacute',
  43978. 'Icircumflex',
  43979. 'Idieresis',
  43980. 'Igrave',
  43981. 'Oacute',
  43982. 'Ocircumflex',
  43983. 'apple',
  43984. 'Ograve',
  43985. 'Uacute',
  43986. 'Ucircumflex',
  43987. 'Ugrave',
  43988. 'dotlessi',
  43989. 'circumflex',
  43990. 'tilde',
  43991. 'macron',
  43992. 'breve',
  43993. 'dotaccent',
  43994. 'ring',
  43995. 'cedilla',
  43996. 'hungarumlaut',
  43997. 'ogonek',
  43998. 'caron',
  43999. 'Lslash',
  44000. 'lslash',
  44001. 'Scaron',
  44002. 'scaron',
  44003. 'Zcaron',
  44004. 'zcaron',
  44005. 'brokenbar',
  44006. 'Eth',
  44007. 'eth',
  44008. 'Yacute',
  44009. 'yacute',
  44010. 'Thorn',
  44011. 'thorn',
  44012. 'minus',
  44013. 'multiply',
  44014. 'onesuperior',
  44015. 'twosuperior',
  44016. 'threesuperior',
  44017. 'onehalf',
  44018. 'onequarter',
  44019. 'threequarters',
  44020. 'franc',
  44021. 'Gbreve',
  44022. 'gbreve',
  44023. 'Idotaccent',
  44024. 'Scedilla',
  44025. 'scedilla',
  44026. 'Cacute',
  44027. 'cacute',
  44028. 'Ccaron',
  44029. 'ccaron',
  44030. 'dcroat'
  44031. ];
  44032. function adjustWidths(properties) {
  44033. if (!properties.fontMatrix) {
  44034. return;
  44035. }
  44036. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44037. return;
  44038. }
  44039. var scale = 0.001 / properties.fontMatrix[0];
  44040. var glyphsWidths = properties.widths;
  44041. for (var glyph in glyphsWidths) {
  44042. glyphsWidths[glyph] *= scale;
  44043. }
  44044. properties.defaultWidth *= scale;
  44045. }
  44046. function adjustToUnicode(properties, builtInEncoding) {
  44047. if (properties.hasIncludedToUnicodeMap) {
  44048. return;
  44049. }
  44050. if (properties.hasEncoding) {
  44051. return;
  44052. }
  44053. if (builtInEncoding === properties.defaultEncoding) {
  44054. return;
  44055. }
  44056. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44057. return;
  44058. }
  44059. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44060. for (var charCode in builtInEncoding) {
  44061. var glyphName = builtInEncoding[charCode];
  44062. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44063. if (unicode !== -1) {
  44064. toUnicode[charCode] = String.fromCharCode(unicode);
  44065. }
  44066. }
  44067. properties.toUnicode.amend(toUnicode);
  44068. }
  44069. function getFontType(type, subtype) {
  44070. switch (type) {
  44071. case 'Type1':
  44072. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44073. case 'CIDFontType0':
  44074. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44075. case 'OpenType':
  44076. return FontType.OPENTYPE;
  44077. case 'TrueType':
  44078. return FontType.TRUETYPE;
  44079. case 'CIDFontType2':
  44080. return FontType.CIDFONTTYPE2;
  44081. case 'MMType1':
  44082. return FontType.MMTYPE1;
  44083. case 'Type0':
  44084. return FontType.TYPE0;
  44085. default:
  44086. return FontType.UNKNOWN;
  44087. }
  44088. }
  44089. function recoverGlyphName(name, glyphsUnicodeMap) {
  44090. if (glyphsUnicodeMap[name] !== undefined) {
  44091. return name;
  44092. }
  44093. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44094. if (unicode !== -1) {
  44095. for (var key in glyphsUnicodeMap) {
  44096. if (glyphsUnicodeMap[key] === unicode) {
  44097. return key;
  44098. }
  44099. }
  44100. }
  44101. info('Unable to recover a standard glyph name for: ' + name);
  44102. return name;
  44103. }
  44104. var Glyph = function GlyphClosure() {
  44105. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44106. this.fontChar = fontChar;
  44107. this.unicode = unicode;
  44108. this.accent = accent;
  44109. this.width = width;
  44110. this.vmetric = vmetric;
  44111. this.operatorListId = operatorListId;
  44112. this.isSpace = isSpace;
  44113. this.isInFont = isInFont;
  44114. }
  44115. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44116. 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;
  44117. };
  44118. return Glyph;
  44119. }();
  44120. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44121. function ToUnicodeMap(cmap) {
  44122. this._map = cmap;
  44123. }
  44124. ToUnicodeMap.prototype = {
  44125. get length() {
  44126. return this._map.length;
  44127. },
  44128. forEach: function (callback) {
  44129. for (var charCode in this._map) {
  44130. callback(charCode, this._map[charCode].charCodeAt(0));
  44131. }
  44132. },
  44133. has: function (i) {
  44134. return this._map[i] !== undefined;
  44135. },
  44136. get: function (i) {
  44137. return this._map[i];
  44138. },
  44139. charCodeOf: function (v) {
  44140. return this._map.indexOf(v);
  44141. },
  44142. amend: function (map) {
  44143. for (var charCode in map) {
  44144. this._map[charCode] = map[charCode];
  44145. }
  44146. }
  44147. };
  44148. return ToUnicodeMap;
  44149. }();
  44150. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44151. function IdentityToUnicodeMap(firstChar, lastChar) {
  44152. this.firstChar = firstChar;
  44153. this.lastChar = lastChar;
  44154. }
  44155. IdentityToUnicodeMap.prototype = {
  44156. get length() {
  44157. return this.lastChar + 1 - this.firstChar;
  44158. },
  44159. forEach: function (callback) {
  44160. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44161. callback(i, i);
  44162. }
  44163. },
  44164. has: function (i) {
  44165. return this.firstChar <= i && i <= this.lastChar;
  44166. },
  44167. get: function (i) {
  44168. if (this.firstChar <= i && i <= this.lastChar) {
  44169. return String.fromCharCode(i);
  44170. }
  44171. return undefined;
  44172. },
  44173. charCodeOf: function (v) {
  44174. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44175. },
  44176. amend: function (map) {
  44177. error('Should not call amend()');
  44178. }
  44179. };
  44180. return IdentityToUnicodeMap;
  44181. }();
  44182. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44183. function writeInt16(dest, offset, num) {
  44184. dest[offset] = num >> 8 & 0xFF;
  44185. dest[offset + 1] = num & 0xFF;
  44186. }
  44187. function writeInt32(dest, offset, num) {
  44188. dest[offset] = num >> 24 & 0xFF;
  44189. dest[offset + 1] = num >> 16 & 0xFF;
  44190. dest[offset + 2] = num >> 8 & 0xFF;
  44191. dest[offset + 3] = num & 0xFF;
  44192. }
  44193. function writeData(dest, offset, data) {
  44194. var i, ii;
  44195. if (data instanceof Uint8Array) {
  44196. dest.set(data, offset);
  44197. } else if (typeof data === 'string') {
  44198. for (i = 0, ii = data.length; i < ii; i++) {
  44199. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44200. }
  44201. } else {
  44202. for (i = 0, ii = data.length; i < ii; i++) {
  44203. dest[offset++] = data[i] & 0xFF;
  44204. }
  44205. }
  44206. }
  44207. function OpenTypeFileBuilder(sfnt) {
  44208. this.sfnt = sfnt;
  44209. this.tables = Object.create(null);
  44210. }
  44211. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44212. var maxPower2 = 1, log2 = 0;
  44213. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44214. maxPower2 <<= 1;
  44215. log2++;
  44216. }
  44217. var searchRange = maxPower2 * entrySize;
  44218. return {
  44219. range: searchRange,
  44220. entry: log2,
  44221. rangeShift: entrySize * entriesCount - searchRange
  44222. };
  44223. };
  44224. var OTF_HEADER_SIZE = 12;
  44225. var OTF_TABLE_ENTRY_SIZE = 16;
  44226. OpenTypeFileBuilder.prototype = {
  44227. toArray: function OpenTypeFileBuilder_toArray() {
  44228. var sfnt = this.sfnt;
  44229. var tables = this.tables;
  44230. var tablesNames = Object.keys(tables);
  44231. tablesNames.sort();
  44232. var numTables = tablesNames.length;
  44233. var i, j, jj, table, tableName;
  44234. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44235. var tableOffsets = [offset];
  44236. for (i = 0; i < numTables; i++) {
  44237. table = tables[tablesNames[i]];
  44238. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44239. offset += paddedLength;
  44240. tableOffsets.push(offset);
  44241. }
  44242. var file = new Uint8Array(offset);
  44243. for (i = 0; i < numTables; i++) {
  44244. table = tables[tablesNames[i]];
  44245. writeData(file, tableOffsets[i], table);
  44246. }
  44247. if (sfnt === 'true') {
  44248. sfnt = string32(0x00010000);
  44249. }
  44250. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44251. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44252. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44253. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44254. writeInt16(file, 4, numTables);
  44255. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44256. writeInt16(file, 6, searchParams.range);
  44257. writeInt16(file, 8, searchParams.entry);
  44258. writeInt16(file, 10, searchParams.rangeShift);
  44259. offset = OTF_HEADER_SIZE;
  44260. for (i = 0; i < numTables; i++) {
  44261. tableName = tablesNames[i];
  44262. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44263. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44264. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44265. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44266. var checksum = 0;
  44267. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44268. var quad = readUint32(file, j);
  44269. checksum = checksum + quad >>> 0;
  44270. }
  44271. writeInt32(file, offset + 4, checksum);
  44272. writeInt32(file, offset + 8, tableOffsets[i]);
  44273. writeInt32(file, offset + 12, tables[tableName].length);
  44274. offset += OTF_TABLE_ENTRY_SIZE;
  44275. }
  44276. return file;
  44277. },
  44278. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44279. if (tag in this.tables) {
  44280. throw new Error('Table ' + tag + ' already exists');
  44281. }
  44282. this.tables[tag] = data;
  44283. }
  44284. };
  44285. return OpenTypeFileBuilder;
  44286. }();
  44287. var ProblematicCharRanges = new Int32Array([
  44288. 0x0000,
  44289. 0x0020,
  44290. 0x007F,
  44291. 0x00A1,
  44292. 0x00AD,
  44293. 0x00AE,
  44294. 0x0600,
  44295. 0x0780,
  44296. 0x08A0,
  44297. 0x10A0,
  44298. 0x1780,
  44299. 0x1800,
  44300. 0x1C00,
  44301. 0x1C50,
  44302. 0x2000,
  44303. 0x2010,
  44304. 0x2011,
  44305. 0x2012,
  44306. 0x2028,
  44307. 0x2030,
  44308. 0x205F,
  44309. 0x2070,
  44310. 0x25CC,
  44311. 0x25CD,
  44312. 0x3000,
  44313. 0x3001,
  44314. 0xAA60,
  44315. 0xAA80,
  44316. 0xFFF0,
  44317. 0x10000
  44318. ]);
  44319. var Font = function FontClosure() {
  44320. function Font(name, file, properties) {
  44321. var charCode, glyphName, unicode;
  44322. this.name = name;
  44323. this.loadedName = properties.loadedName;
  44324. this.isType3Font = properties.isType3Font;
  44325. this.sizes = [];
  44326. this.missingFile = false;
  44327. this.glyphCache = Object.create(null);
  44328. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44329. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44330. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44331. var type = properties.type;
  44332. var subtype = properties.subtype;
  44333. this.type = type;
  44334. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44335. this.differences = properties.differences;
  44336. this.widths = properties.widths;
  44337. this.defaultWidth = properties.defaultWidth;
  44338. this.composite = properties.composite;
  44339. this.wideChars = properties.wideChars;
  44340. this.cMap = properties.cMap;
  44341. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44342. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44343. this.fontMatrix = properties.fontMatrix;
  44344. this.bbox = properties.bbox;
  44345. this.toUnicode = properties.toUnicode;
  44346. this.toFontChar = [];
  44347. if (properties.type === 'Type3') {
  44348. for (charCode = 0; charCode < 256; charCode++) {
  44349. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44350. }
  44351. this.fontType = FontType.TYPE3;
  44352. return;
  44353. }
  44354. this.cidEncoding = properties.cidEncoding;
  44355. this.vertical = properties.vertical;
  44356. if (this.vertical) {
  44357. this.vmetrics = properties.vmetrics;
  44358. this.defaultVMetrics = properties.defaultVMetrics;
  44359. }
  44360. var glyphsUnicodeMap;
  44361. if (!file || file.isEmpty) {
  44362. if (file) {
  44363. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44364. }
  44365. this.missingFile = true;
  44366. var fontName = name.replace(/[,_]/g, '-');
  44367. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44368. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44369. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44370. this.bold = fontName.search(/bold/gi) !== -1;
  44371. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44372. this.black = name.search(/Black/g) !== -1;
  44373. this.remeasure = Object.keys(this.widths).length > 0;
  44374. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44375. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44376. var map = [];
  44377. for (charCode in GlyphMapForStandardFonts) {
  44378. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44379. }
  44380. if (/Arial-?Black/i.test(name)) {
  44381. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44382. for (charCode in SupplementalGlyphMapForArialBlack) {
  44383. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44384. }
  44385. }
  44386. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44387. if (!isIdentityUnicode) {
  44388. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44389. map[+charCode] = unicodeCharCode;
  44390. });
  44391. }
  44392. this.toFontChar = map;
  44393. this.toUnicode = new ToUnicodeMap(map);
  44394. } else if (/Symbol/i.test(fontName)) {
  44395. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44396. } else if (/Dingbats/i.test(fontName)) {
  44397. if (/Wingdings/i.test(name)) {
  44398. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44399. }
  44400. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44401. } else if (isStandardFont) {
  44402. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44403. } else {
  44404. glyphsUnicodeMap = getGlyphsUnicode();
  44405. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44406. if (!this.composite) {
  44407. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44408. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44409. if (unicode !== -1) {
  44410. unicodeCharCode = unicode;
  44411. }
  44412. }
  44413. this.toFontChar[charCode] = unicodeCharCode;
  44414. }.bind(this));
  44415. }
  44416. this.loadedName = fontName.split('-')[0];
  44417. this.loading = false;
  44418. this.fontType = getFontType(type, subtype);
  44419. return;
  44420. }
  44421. if (subtype === 'Type1C') {
  44422. if (type !== 'Type1' && type !== 'MMType1') {
  44423. if (isTrueTypeFile(file)) {
  44424. subtype = 'TrueType';
  44425. } else {
  44426. type = 'Type1';
  44427. }
  44428. } else if (isOpenTypeFile(file)) {
  44429. type = subtype = 'OpenType';
  44430. }
  44431. }
  44432. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44433. type = 'CIDFontType0';
  44434. }
  44435. if (subtype === 'OpenType') {
  44436. type = 'OpenType';
  44437. }
  44438. if (type === 'CIDFontType0') {
  44439. if (isType1File(file)) {
  44440. subtype = 'CIDFontType0';
  44441. } else if (isOpenTypeFile(file)) {
  44442. type = subtype = 'OpenType';
  44443. } else {
  44444. subtype = 'CIDFontType0C';
  44445. }
  44446. }
  44447. var data;
  44448. switch (type) {
  44449. case 'MMType1':
  44450. info('MMType1 font (' + name + '), falling back to Type1.');
  44451. case 'Type1':
  44452. case 'CIDFontType0':
  44453. this.mimetype = 'font/opentype';
  44454. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44455. adjustWidths(properties);
  44456. data = this.convert(name, cff, properties);
  44457. break;
  44458. case 'OpenType':
  44459. case 'TrueType':
  44460. case 'CIDFontType2':
  44461. this.mimetype = 'font/opentype';
  44462. data = this.checkAndRepair(name, file, properties);
  44463. if (this.isOpenType) {
  44464. adjustWidths(properties);
  44465. type = 'OpenType';
  44466. }
  44467. break;
  44468. default:
  44469. error('Font ' + type + ' is not supported');
  44470. break;
  44471. }
  44472. this.data = data;
  44473. this.fontType = getFontType(type, subtype);
  44474. this.fontMatrix = properties.fontMatrix;
  44475. this.widths = properties.widths;
  44476. this.defaultWidth = properties.defaultWidth;
  44477. this.toUnicode = properties.toUnicode;
  44478. this.encoding = properties.baseEncoding;
  44479. this.seacMap = properties.seacMap;
  44480. this.loading = true;
  44481. }
  44482. Font.getFontID = function () {
  44483. var ID = 1;
  44484. return function Font_getFontID() {
  44485. return String(ID++);
  44486. };
  44487. }();
  44488. function int16(b0, b1) {
  44489. return (b0 << 8) + b1;
  44490. }
  44491. function signedInt16(b0, b1) {
  44492. var value = (b0 << 8) + b1;
  44493. return value & 1 << 15 ? value - 0x10000 : value;
  44494. }
  44495. function int32(b0, b1, b2, b3) {
  44496. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44497. }
  44498. function string16(value) {
  44499. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44500. }
  44501. function safeString16(value) {
  44502. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44503. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44504. }
  44505. function isTrueTypeFile(file) {
  44506. var header = file.peekBytes(4);
  44507. return readUint32(header, 0) === 0x00010000;
  44508. }
  44509. function isOpenTypeFile(file) {
  44510. var header = file.peekBytes(4);
  44511. return bytesToString(header) === 'OTTO';
  44512. }
  44513. function isType1File(file) {
  44514. var header = file.peekBytes(2);
  44515. if (header[0] === 0x25 && header[1] === 0x21) {
  44516. return true;
  44517. }
  44518. if (header[0] === 0x80 && header[1] === 0x01) {
  44519. return true;
  44520. }
  44521. return false;
  44522. }
  44523. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44524. var toFontChar = [], unicode;
  44525. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44526. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44527. if (unicode !== -1) {
  44528. toFontChar[i] = unicode;
  44529. }
  44530. }
  44531. for (var charCode in differences) {
  44532. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44533. if (unicode !== -1) {
  44534. toFontChar[+charCode] = unicode;
  44535. }
  44536. }
  44537. return toFontChar;
  44538. }
  44539. function isProblematicUnicodeLocation(code) {
  44540. var i = 0, j = ProblematicCharRanges.length - 1;
  44541. while (i < j) {
  44542. var c = i + j + 1 >> 1;
  44543. if (code < ProblematicCharRanges[c]) {
  44544. j = c - 1;
  44545. } else {
  44546. i = c;
  44547. }
  44548. }
  44549. return !(i & 1);
  44550. }
  44551. function adjustMapping(charCodeToGlyphId, properties) {
  44552. var toUnicode = properties.toUnicode;
  44553. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44554. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44555. var newMap = Object.create(null);
  44556. var toFontChar = [];
  44557. var usedFontCharCodes = [];
  44558. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44559. for (var originalCharCode in charCodeToGlyphId) {
  44560. originalCharCode |= 0;
  44561. var glyphId = charCodeToGlyphId[originalCharCode];
  44562. var fontCharCode = originalCharCode;
  44563. var hasUnicodeValue = false;
  44564. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44565. hasUnicodeValue = true;
  44566. var unicode = toUnicode.get(fontCharCode);
  44567. if (unicode.length === 1) {
  44568. fontCharCode = unicode.charCodeAt(0);
  44569. }
  44570. }
  44571. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44572. do {
  44573. fontCharCode = nextAvailableFontCharCode++;
  44574. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44575. fontCharCode = 0xF020;
  44576. nextAvailableFontCharCode = fontCharCode + 1;
  44577. }
  44578. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44579. }
  44580. newMap[fontCharCode] = glyphId;
  44581. toFontChar[originalCharCode] = fontCharCode;
  44582. usedFontCharCodes[fontCharCode] = true;
  44583. }
  44584. return {
  44585. toFontChar: toFontChar,
  44586. charCodeToGlyphId: newMap,
  44587. nextAvailableFontCharCode: nextAvailableFontCharCode
  44588. };
  44589. }
  44590. function getRanges(glyphs, numGlyphs) {
  44591. var codes = [];
  44592. for (var charCode in glyphs) {
  44593. if (glyphs[charCode] >= numGlyphs) {
  44594. continue;
  44595. }
  44596. codes.push({
  44597. fontCharCode: charCode | 0,
  44598. glyphId: glyphs[charCode]
  44599. });
  44600. }
  44601. codes.sort(function fontGetRangesSort(a, b) {
  44602. return a.fontCharCode - b.fontCharCode;
  44603. });
  44604. var ranges = [];
  44605. var length = codes.length;
  44606. for (var n = 0; n < length;) {
  44607. var start = codes[n].fontCharCode;
  44608. var codeIndices = [codes[n].glyphId];
  44609. ++n;
  44610. var end = start;
  44611. while (n < length && end + 1 === codes[n].fontCharCode) {
  44612. codeIndices.push(codes[n].glyphId);
  44613. ++end;
  44614. ++n;
  44615. if (end === 0xFFFF) {
  44616. break;
  44617. }
  44618. }
  44619. ranges.push([
  44620. start,
  44621. end,
  44622. codeIndices
  44623. ]);
  44624. }
  44625. return ranges;
  44626. }
  44627. function createCmapTable(glyphs, numGlyphs) {
  44628. var ranges = getRanges(glyphs, numGlyphs);
  44629. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44630. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44631. var i, ii, j, jj;
  44632. for (i = ranges.length - 1; i >= 0; --i) {
  44633. if (ranges[i][0] <= 0xFFFF) {
  44634. break;
  44635. }
  44636. }
  44637. var bmpLength = i + 1;
  44638. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44639. ranges[i][1] = 0xFFFE;
  44640. }
  44641. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44642. var segCount = bmpLength + trailingRangesCount;
  44643. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44644. var startCount = '';
  44645. var endCount = '';
  44646. var idDeltas = '';
  44647. var idRangeOffsets = '';
  44648. var glyphsIds = '';
  44649. var bias = 0;
  44650. var range, start, end, codes;
  44651. for (i = 0, ii = bmpLength; i < ii; i++) {
  44652. range = ranges[i];
  44653. start = range[0];
  44654. end = range[1];
  44655. startCount += string16(start);
  44656. endCount += string16(end);
  44657. codes = range[2];
  44658. var contiguous = true;
  44659. for (j = 1, jj = codes.length; j < jj; ++j) {
  44660. if (codes[j] !== codes[j - 1] + 1) {
  44661. contiguous = false;
  44662. break;
  44663. }
  44664. }
  44665. if (!contiguous) {
  44666. var offset = (segCount - i) * 2 + bias * 2;
  44667. bias += end - start + 1;
  44668. idDeltas += string16(0);
  44669. idRangeOffsets += string16(offset);
  44670. for (j = 0, jj = codes.length; j < jj; ++j) {
  44671. glyphsIds += string16(codes[j]);
  44672. }
  44673. } else {
  44674. var startCode = codes[0];
  44675. idDeltas += string16(startCode - start & 0xFFFF);
  44676. idRangeOffsets += string16(0);
  44677. }
  44678. }
  44679. if (trailingRangesCount > 0) {
  44680. endCount += '\xFF\xFF';
  44681. startCount += '\xFF\xFF';
  44682. idDeltas += '\x00\x01';
  44683. idRangeOffsets += '\x00\x00';
  44684. }
  44685. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44686. var format31012 = '';
  44687. var header31012 = '';
  44688. if (numTables > 1) {
  44689. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44690. format31012 = '';
  44691. for (i = 0, ii = ranges.length; i < ii; i++) {
  44692. range = ranges[i];
  44693. start = range[0];
  44694. codes = range[2];
  44695. var code = codes[0];
  44696. for (j = 1, jj = codes.length; j < jj; ++j) {
  44697. if (codes[j] !== codes[j - 1] + 1) {
  44698. end = range[0] + j - 1;
  44699. format31012 += string32(start) + string32(end) + string32(code);
  44700. start = end + 1;
  44701. code = codes[j];
  44702. }
  44703. }
  44704. format31012 += string32(start) + string32(range[1]) + string32(code);
  44705. }
  44706. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44707. }
  44708. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44709. }
  44710. function validateOS2Table(os2) {
  44711. var stream = new Stream(os2.data);
  44712. var version = stream.getUint16();
  44713. stream.getBytes(60);
  44714. var selection = stream.getUint16();
  44715. if (version < 4 && selection & 0x0300) {
  44716. return false;
  44717. }
  44718. var firstChar = stream.getUint16();
  44719. var lastChar = stream.getUint16();
  44720. if (firstChar > lastChar) {
  44721. return false;
  44722. }
  44723. stream.getBytes(6);
  44724. var usWinAscent = stream.getUint16();
  44725. if (usWinAscent === 0) {
  44726. return false;
  44727. }
  44728. os2.data[8] = os2.data[9] = 0;
  44729. return true;
  44730. }
  44731. function createOS2Table(properties, charstrings, override) {
  44732. override = override || {
  44733. unitsPerEm: 0,
  44734. yMax: 0,
  44735. yMin: 0,
  44736. ascent: 0,
  44737. descent: 0
  44738. };
  44739. var ulUnicodeRange1 = 0;
  44740. var ulUnicodeRange2 = 0;
  44741. var ulUnicodeRange3 = 0;
  44742. var ulUnicodeRange4 = 0;
  44743. var firstCharIndex = null;
  44744. var lastCharIndex = 0;
  44745. if (charstrings) {
  44746. for (var code in charstrings) {
  44747. code |= 0;
  44748. if (firstCharIndex > code || !firstCharIndex) {
  44749. firstCharIndex = code;
  44750. }
  44751. if (lastCharIndex < code) {
  44752. lastCharIndex = code;
  44753. }
  44754. var position = getUnicodeRangeFor(code);
  44755. if (position < 32) {
  44756. ulUnicodeRange1 |= 1 << position;
  44757. } else if (position < 64) {
  44758. ulUnicodeRange2 |= 1 << position - 32;
  44759. } else if (position < 96) {
  44760. ulUnicodeRange3 |= 1 << position - 64;
  44761. } else if (position < 123) {
  44762. ulUnicodeRange4 |= 1 << position - 96;
  44763. } else {
  44764. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44765. }
  44766. }
  44767. } else {
  44768. firstCharIndex = 0;
  44769. lastCharIndex = 255;
  44770. }
  44771. var bbox = properties.bbox || [
  44772. 0,
  44773. 0,
  44774. 0,
  44775. 0
  44776. ];
  44777. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44778. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44779. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44780. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44781. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44782. typoDescent = -typoDescent;
  44783. }
  44784. var winAscent = override.yMax || typoAscent;
  44785. var winDescent = -override.yMin || -typoDescent;
  44786. 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';
  44787. }
  44788. function createPostTable(properties) {
  44789. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44790. 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';
  44791. }
  44792. function createNameTable(name, proto) {
  44793. if (!proto) {
  44794. proto = [
  44795. [],
  44796. []
  44797. ];
  44798. }
  44799. var strings = [
  44800. proto[0][0] || 'Original licence',
  44801. proto[0][1] || name,
  44802. proto[0][2] || 'Unknown',
  44803. proto[0][3] || 'uniqueID',
  44804. proto[0][4] || name,
  44805. proto[0][5] || 'Version 0.11',
  44806. proto[0][6] || '',
  44807. proto[0][7] || 'Unknown',
  44808. proto[0][8] || 'Unknown',
  44809. proto[0][9] || 'Unknown'
  44810. ];
  44811. var stringsUnicode = [];
  44812. var i, ii, j, jj, str;
  44813. for (i = 0, ii = strings.length; i < ii; i++) {
  44814. str = proto[1][i] || strings[i];
  44815. var strBufUnicode = [];
  44816. for (j = 0, jj = str.length; j < jj; j++) {
  44817. strBufUnicode.push(string16(str.charCodeAt(j)));
  44818. }
  44819. stringsUnicode.push(strBufUnicode.join(''));
  44820. }
  44821. var names = [
  44822. strings,
  44823. stringsUnicode
  44824. ];
  44825. var platforms = [
  44826. '\x00\x01',
  44827. '\x00\x03'
  44828. ];
  44829. var encodings = [
  44830. '\x00\x00',
  44831. '\x00\x01'
  44832. ];
  44833. var languages = [
  44834. '\x00\x00',
  44835. '\x04\x09'
  44836. ];
  44837. var namesRecordCount = strings.length * platforms.length;
  44838. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44839. var strOffset = 0;
  44840. for (i = 0, ii = platforms.length; i < ii; i++) {
  44841. var strs = names[i];
  44842. for (j = 0, jj = strs.length; j < jj; j++) {
  44843. str = strs[j];
  44844. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44845. nameTable += nameRecord;
  44846. strOffset += str.length;
  44847. }
  44848. }
  44849. nameTable += strings.join('') + stringsUnicode.join('');
  44850. return nameTable;
  44851. }
  44852. Font.prototype = {
  44853. name: null,
  44854. font: null,
  44855. mimetype: null,
  44856. encoding: null,
  44857. get renderer() {
  44858. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44859. return shadow(this, 'renderer', renderer);
  44860. },
  44861. exportData: function Font_exportData() {
  44862. var data = {};
  44863. for (var i in this) {
  44864. if (this.hasOwnProperty(i)) {
  44865. data[i] = this[i];
  44866. }
  44867. }
  44868. return data;
  44869. },
  44870. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44871. function readTableEntry(file) {
  44872. var tag = bytesToString(file.getBytes(4));
  44873. var checksum = file.getInt32() >>> 0;
  44874. var offset = file.getInt32() >>> 0;
  44875. var length = file.getInt32() >>> 0;
  44876. var previousPosition = file.pos;
  44877. file.pos = file.start ? file.start : 0;
  44878. file.skip(offset);
  44879. var data = file.getBytes(length);
  44880. file.pos = previousPosition;
  44881. if (tag === 'head') {
  44882. data[8] = data[9] = data[10] = data[11] = 0;
  44883. data[17] |= 0x20;
  44884. }
  44885. return {
  44886. tag: tag,
  44887. checksum: checksum,
  44888. length: length,
  44889. offset: offset,
  44890. data: data
  44891. };
  44892. }
  44893. function readOpenTypeHeader(ttf) {
  44894. return {
  44895. version: bytesToString(ttf.getBytes(4)),
  44896. numTables: ttf.getUint16(),
  44897. searchRange: ttf.getUint16(),
  44898. entrySelector: ttf.getUint16(),
  44899. rangeShift: ttf.getUint16()
  44900. };
  44901. }
  44902. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44903. if (!cmap) {
  44904. warn('No cmap table available.');
  44905. return {
  44906. platformId: -1,
  44907. encodingId: -1,
  44908. mappings: [],
  44909. hasShortCmap: false
  44910. };
  44911. }
  44912. var segment;
  44913. var start = (font.start ? font.start : 0) + cmap.offset;
  44914. font.pos = start;
  44915. font.getUint16();
  44916. var numTables = font.getUint16();
  44917. var potentialTable;
  44918. var canBreak = false;
  44919. for (var i = 0; i < numTables; i++) {
  44920. var platformId = font.getUint16();
  44921. var encodingId = font.getUint16();
  44922. var offset = font.getInt32() >>> 0;
  44923. var useTable = false;
  44924. if (platformId === 0 && encodingId === 0) {
  44925. useTable = true;
  44926. } else if (platformId === 1 && encodingId === 0) {
  44927. useTable = true;
  44928. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  44929. useTable = true;
  44930. if (!isSymbolicFont) {
  44931. canBreak = true;
  44932. }
  44933. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44934. useTable = true;
  44935. canBreak = true;
  44936. }
  44937. if (useTable) {
  44938. potentialTable = {
  44939. platformId: platformId,
  44940. encodingId: encodingId,
  44941. offset: offset
  44942. };
  44943. }
  44944. if (canBreak) {
  44945. break;
  44946. }
  44947. }
  44948. if (potentialTable) {
  44949. font.pos = start + potentialTable.offset;
  44950. }
  44951. if (!potentialTable || font.peekByte() === -1) {
  44952. warn('Could not find a preferred cmap table.');
  44953. return {
  44954. platformId: -1,
  44955. encodingId: -1,
  44956. mappings: [],
  44957. hasShortCmap: false
  44958. };
  44959. }
  44960. var format = font.getUint16();
  44961. font.getUint16();
  44962. font.getUint16();
  44963. var hasShortCmap = false;
  44964. var mappings = [];
  44965. var j, glyphId;
  44966. if (format === 0) {
  44967. for (j = 0; j < 256; j++) {
  44968. var index = font.getByte();
  44969. if (!index) {
  44970. continue;
  44971. }
  44972. mappings.push({
  44973. charCode: j,
  44974. glyphId: index
  44975. });
  44976. }
  44977. hasShortCmap = true;
  44978. } else if (format === 4) {
  44979. var segCount = font.getUint16() >> 1;
  44980. font.getBytes(6);
  44981. var segIndex, segments = [];
  44982. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44983. segments.push({ end: font.getUint16() });
  44984. }
  44985. font.getUint16();
  44986. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44987. segments[segIndex].start = font.getUint16();
  44988. }
  44989. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44990. segments[segIndex].delta = font.getUint16();
  44991. }
  44992. var offsetsCount = 0;
  44993. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44994. segment = segments[segIndex];
  44995. var rangeOffset = font.getUint16();
  44996. if (!rangeOffset) {
  44997. segment.offsetIndex = -1;
  44998. continue;
  44999. }
  45000. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45001. segment.offsetIndex = offsetIndex;
  45002. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45003. }
  45004. var offsets = [];
  45005. for (j = 0; j < offsetsCount; j++) {
  45006. offsets.push(font.getUint16());
  45007. }
  45008. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45009. segment = segments[segIndex];
  45010. start = segment.start;
  45011. var end = segment.end;
  45012. var delta = segment.delta;
  45013. offsetIndex = segment.offsetIndex;
  45014. for (j = start; j <= end; j++) {
  45015. if (j === 0xFFFF) {
  45016. continue;
  45017. }
  45018. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45019. glyphId = glyphId + delta & 0xFFFF;
  45020. if (glyphId === 0) {
  45021. continue;
  45022. }
  45023. mappings.push({
  45024. charCode: j,
  45025. glyphId: glyphId
  45026. });
  45027. }
  45028. }
  45029. } else if (format === 6) {
  45030. var firstCode = font.getUint16();
  45031. var entryCount = font.getUint16();
  45032. for (j = 0; j < entryCount; j++) {
  45033. glyphId = font.getUint16();
  45034. var charCode = firstCode + j;
  45035. mappings.push({
  45036. charCode: charCode,
  45037. glyphId: glyphId
  45038. });
  45039. }
  45040. } else {
  45041. warn('cmap table has unsupported format: ' + format);
  45042. return {
  45043. platformId: -1,
  45044. encodingId: -1,
  45045. mappings: [],
  45046. hasShortCmap: false
  45047. };
  45048. }
  45049. mappings.sort(function (a, b) {
  45050. return a.charCode - b.charCode;
  45051. });
  45052. for (i = 1; i < mappings.length; i++) {
  45053. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45054. mappings.splice(i, 1);
  45055. i--;
  45056. }
  45057. }
  45058. return {
  45059. platformId: potentialTable.platformId,
  45060. encodingId: potentialTable.encodingId,
  45061. mappings: mappings,
  45062. hasShortCmap: hasShortCmap
  45063. };
  45064. }
  45065. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45066. if (!header) {
  45067. if (metrics) {
  45068. metrics.data = null;
  45069. }
  45070. return;
  45071. }
  45072. font.pos = (font.start ? font.start : 0) + header.offset;
  45073. font.pos += header.length - 2;
  45074. var numOfMetrics = font.getUint16();
  45075. if (numOfMetrics > numGlyphs) {
  45076. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45077. numOfMetrics = numGlyphs;
  45078. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45079. header.data[35] = numOfMetrics & 0x00ff;
  45080. }
  45081. var numOfSidebearings = numGlyphs - numOfMetrics;
  45082. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45083. if (numMissing > 0) {
  45084. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45085. entries.set(metrics.data);
  45086. metrics.data = entries;
  45087. }
  45088. }
  45089. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45090. if (sourceEnd - sourceStart <= 12) {
  45091. return 0;
  45092. }
  45093. var glyf = source.subarray(sourceStart, sourceEnd);
  45094. var contoursCount = glyf[0] << 8 | glyf[1];
  45095. if (contoursCount & 0x8000) {
  45096. dest.set(glyf, destStart);
  45097. return glyf.length;
  45098. }
  45099. var i, j = 10, flagsCount = 0;
  45100. for (i = 0; i < contoursCount; i++) {
  45101. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45102. flagsCount = endPoint + 1;
  45103. j += 2;
  45104. }
  45105. var instructionsStart = j;
  45106. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45107. j += 2 + instructionsLength;
  45108. var instructionsEnd = j;
  45109. var coordinatesLength = 0;
  45110. for (i = 0; i < flagsCount; i++) {
  45111. var flag = glyf[j++];
  45112. if (flag & 0xC0) {
  45113. glyf[j - 1] = flag & 0x3F;
  45114. }
  45115. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45116. coordinatesLength += xyLength;
  45117. if (flag & 8) {
  45118. var repeat = glyf[j++];
  45119. i += repeat;
  45120. coordinatesLength += repeat * xyLength;
  45121. }
  45122. }
  45123. if (coordinatesLength === 0) {
  45124. return 0;
  45125. }
  45126. var glyphDataLength = j + coordinatesLength;
  45127. if (glyphDataLength > glyf.length) {
  45128. return 0;
  45129. }
  45130. if (!hintsValid && instructionsLength > 0) {
  45131. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45132. dest.set([
  45133. 0,
  45134. 0
  45135. ], destStart + instructionsStart);
  45136. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45137. glyphDataLength -= instructionsLength;
  45138. if (glyf.length - glyphDataLength > 3) {
  45139. glyphDataLength = glyphDataLength + 3 & ~3;
  45140. }
  45141. return glyphDataLength;
  45142. }
  45143. if (glyf.length - glyphDataLength > 3) {
  45144. glyphDataLength = glyphDataLength + 3 & ~3;
  45145. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45146. return glyphDataLength;
  45147. }
  45148. dest.set(glyf, destStart);
  45149. return glyf.length;
  45150. }
  45151. function sanitizeHead(head, numGlyphs, locaLength) {
  45152. var data = head.data;
  45153. var version = int32(data[0], data[1], data[2], data[3]);
  45154. if (version >> 16 !== 1) {
  45155. info('Attempting to fix invalid version in head table: ' + version);
  45156. data[0] = 0;
  45157. data[1] = 1;
  45158. data[2] = 0;
  45159. data[3] = 0;
  45160. }
  45161. var indexToLocFormat = int16(data[50], data[51]);
  45162. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45163. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45164. var numGlyphsPlusOne = numGlyphs + 1;
  45165. if (locaLength === numGlyphsPlusOne << 1) {
  45166. data[50] = 0;
  45167. data[51] = 0;
  45168. } else if (locaLength === numGlyphsPlusOne << 2) {
  45169. data[50] = 0;
  45170. data[51] = 1;
  45171. } else {
  45172. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45173. }
  45174. }
  45175. }
  45176. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45177. var itemSize, itemDecode, itemEncode;
  45178. if (isGlyphLocationsLong) {
  45179. itemSize = 4;
  45180. itemDecode = function fontItemDecodeLong(data, offset) {
  45181. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45182. };
  45183. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45184. data[offset] = value >>> 24 & 0xFF;
  45185. data[offset + 1] = value >> 16 & 0xFF;
  45186. data[offset + 2] = value >> 8 & 0xFF;
  45187. data[offset + 3] = value & 0xFF;
  45188. };
  45189. } else {
  45190. itemSize = 2;
  45191. itemDecode = function fontItemDecode(data, offset) {
  45192. return data[offset] << 9 | data[offset + 1] << 1;
  45193. };
  45194. itemEncode = function fontItemEncode(data, offset, value) {
  45195. data[offset] = value >> 9 & 0xFF;
  45196. data[offset + 1] = value >> 1 & 0xFF;
  45197. };
  45198. }
  45199. var locaData = loca.data;
  45200. var locaDataSize = itemSize * (1 + numGlyphs);
  45201. if (locaData.length !== locaDataSize) {
  45202. locaData = new Uint8Array(locaDataSize);
  45203. locaData.set(loca.data.subarray(0, locaDataSize));
  45204. loca.data = locaData;
  45205. }
  45206. var oldGlyfData = glyf.data;
  45207. var oldGlyfDataLength = oldGlyfData.length;
  45208. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45209. var startOffset = itemDecode(locaData, 0);
  45210. var writeOffset = 0;
  45211. var missingGlyphData = Object.create(null);
  45212. itemEncode(locaData, 0, writeOffset);
  45213. var i, j;
  45214. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45215. var endOffset = itemDecode(locaData, j);
  45216. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45217. endOffset = oldGlyfDataLength;
  45218. }
  45219. if (endOffset > oldGlyfDataLength) {
  45220. itemEncode(locaData, j, writeOffset);
  45221. startOffset = endOffset;
  45222. continue;
  45223. }
  45224. if (startOffset === endOffset) {
  45225. missingGlyphData[i] = true;
  45226. }
  45227. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45228. writeOffset += newLength;
  45229. itemEncode(locaData, j, writeOffset);
  45230. startOffset = endOffset;
  45231. }
  45232. if (writeOffset === 0) {
  45233. var simpleGlyph = new Uint8Array([
  45234. 0,
  45235. 1,
  45236. 0,
  45237. 0,
  45238. 0,
  45239. 0,
  45240. 0,
  45241. 0,
  45242. 0,
  45243. 0,
  45244. 0,
  45245. 0,
  45246. 0,
  45247. 0,
  45248. 49,
  45249. 0
  45250. ]);
  45251. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45252. itemEncode(locaData, j, simpleGlyph.length);
  45253. }
  45254. glyf.data = simpleGlyph;
  45255. return missingGlyphData;
  45256. }
  45257. if (dupFirstEntry) {
  45258. var firstEntryLength = itemDecode(locaData, itemSize);
  45259. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45260. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45261. } else {
  45262. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45263. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45264. }
  45265. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45266. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45267. } else {
  45268. glyf.data = newGlyfData.subarray(0, writeOffset);
  45269. }
  45270. return missingGlyphData;
  45271. }
  45272. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45273. var start = (font.start ? font.start : 0) + post.offset;
  45274. font.pos = start;
  45275. var length = post.length, end = start + length;
  45276. var version = font.getInt32();
  45277. font.getBytes(28);
  45278. var glyphNames;
  45279. var valid = true;
  45280. var i;
  45281. switch (version) {
  45282. case 0x00010000:
  45283. glyphNames = MacStandardGlyphOrdering;
  45284. break;
  45285. case 0x00020000:
  45286. var numGlyphs = font.getUint16();
  45287. if (numGlyphs !== maxpNumGlyphs) {
  45288. valid = false;
  45289. break;
  45290. }
  45291. var glyphNameIndexes = [];
  45292. for (i = 0; i < numGlyphs; ++i) {
  45293. var index = font.getUint16();
  45294. if (index >= 32768) {
  45295. valid = false;
  45296. break;
  45297. }
  45298. glyphNameIndexes.push(index);
  45299. }
  45300. if (!valid) {
  45301. break;
  45302. }
  45303. var customNames = [];
  45304. var strBuf = [];
  45305. while (font.pos < end) {
  45306. var stringLength = font.getByte();
  45307. strBuf.length = stringLength;
  45308. for (i = 0; i < stringLength; ++i) {
  45309. strBuf[i] = String.fromCharCode(font.getByte());
  45310. }
  45311. customNames.push(strBuf.join(''));
  45312. }
  45313. glyphNames = [];
  45314. for (i = 0; i < numGlyphs; ++i) {
  45315. var j = glyphNameIndexes[i];
  45316. if (j < 258) {
  45317. glyphNames.push(MacStandardGlyphOrdering[j]);
  45318. continue;
  45319. }
  45320. glyphNames.push(customNames[j - 258]);
  45321. }
  45322. break;
  45323. case 0x00030000:
  45324. break;
  45325. default:
  45326. warn('Unknown/unsupported post table version ' + version);
  45327. valid = false;
  45328. if (properties.defaultEncoding) {
  45329. glyphNames = properties.defaultEncoding;
  45330. }
  45331. break;
  45332. }
  45333. properties.glyphNames = glyphNames;
  45334. return valid;
  45335. }
  45336. function readNameTable(nameTable) {
  45337. var start = (font.start ? font.start : 0) + nameTable.offset;
  45338. font.pos = start;
  45339. var names = [
  45340. [],
  45341. []
  45342. ];
  45343. var length = nameTable.length, end = start + length;
  45344. var format = font.getUint16();
  45345. var FORMAT_0_HEADER_LENGTH = 6;
  45346. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45347. return names;
  45348. }
  45349. var numRecords = font.getUint16();
  45350. var stringsStart = font.getUint16();
  45351. var records = [];
  45352. var NAME_RECORD_LENGTH = 12;
  45353. var i, ii;
  45354. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45355. var r = {
  45356. platform: font.getUint16(),
  45357. encoding: font.getUint16(),
  45358. language: font.getUint16(),
  45359. name: font.getUint16(),
  45360. length: font.getUint16(),
  45361. offset: font.getUint16()
  45362. };
  45363. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45364. records.push(r);
  45365. }
  45366. }
  45367. for (i = 0, ii = records.length; i < ii; i++) {
  45368. var record = records[i];
  45369. if (record.length <= 0) {
  45370. continue;
  45371. }
  45372. var pos = start + stringsStart + record.offset;
  45373. if (pos + record.length > end) {
  45374. continue;
  45375. }
  45376. font.pos = pos;
  45377. var nameIndex = record.name;
  45378. if (record.encoding) {
  45379. var str = '';
  45380. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45381. str += String.fromCharCode(font.getUint16());
  45382. }
  45383. names[1][nameIndex] = str;
  45384. } else {
  45385. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45386. }
  45387. }
  45388. return names;
  45389. }
  45390. var TTOpsStackDeltas = [
  45391. 0,
  45392. 0,
  45393. 0,
  45394. 0,
  45395. 0,
  45396. 0,
  45397. 0,
  45398. 0,
  45399. -2,
  45400. -2,
  45401. -2,
  45402. -2,
  45403. 0,
  45404. 0,
  45405. -2,
  45406. -5,
  45407. -1,
  45408. -1,
  45409. -1,
  45410. -1,
  45411. -1,
  45412. -1,
  45413. -1,
  45414. -1,
  45415. 0,
  45416. 0,
  45417. -1,
  45418. 0,
  45419. -1,
  45420. -1,
  45421. -1,
  45422. -1,
  45423. 1,
  45424. -1,
  45425. -999,
  45426. 0,
  45427. 1,
  45428. 0,
  45429. -1,
  45430. -2,
  45431. 0,
  45432. -1,
  45433. -2,
  45434. -1,
  45435. -1,
  45436. 0,
  45437. -1,
  45438. -1,
  45439. 0,
  45440. 0,
  45441. -999,
  45442. -999,
  45443. -1,
  45444. -1,
  45445. -1,
  45446. -1,
  45447. -2,
  45448. -999,
  45449. -2,
  45450. -2,
  45451. -999,
  45452. 0,
  45453. -2,
  45454. -2,
  45455. 0,
  45456. 0,
  45457. -2,
  45458. 0,
  45459. -2,
  45460. 0,
  45461. 0,
  45462. 0,
  45463. -2,
  45464. -1,
  45465. -1,
  45466. 1,
  45467. 1,
  45468. 0,
  45469. 0,
  45470. -1,
  45471. -1,
  45472. -1,
  45473. -1,
  45474. -1,
  45475. -1,
  45476. -1,
  45477. 0,
  45478. 0,
  45479. -1,
  45480. 0,
  45481. -1,
  45482. -1,
  45483. 0,
  45484. -999,
  45485. -1,
  45486. -1,
  45487. -1,
  45488. -1,
  45489. -1,
  45490. -1,
  45491. 0,
  45492. 0,
  45493. 0,
  45494. 0,
  45495. 0,
  45496. 0,
  45497. 0,
  45498. 0,
  45499. 0,
  45500. 0,
  45501. 0,
  45502. 0,
  45503. -2,
  45504. -999,
  45505. -999,
  45506. -999,
  45507. -999,
  45508. -999,
  45509. -1,
  45510. -1,
  45511. -2,
  45512. -2,
  45513. 0,
  45514. 0,
  45515. 0,
  45516. 0,
  45517. -1,
  45518. -1,
  45519. -999,
  45520. -2,
  45521. -2,
  45522. 0,
  45523. 0,
  45524. -1,
  45525. -2,
  45526. -2,
  45527. 0,
  45528. 0,
  45529. 0,
  45530. -1,
  45531. -1,
  45532. -1,
  45533. -2
  45534. ];
  45535. function sanitizeTTProgram(table, ttContext) {
  45536. var data = table.data;
  45537. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45538. var stack = [];
  45539. var callstack = [];
  45540. var functionsCalled = [];
  45541. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45542. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45543. for (var ii = data.length; i < ii;) {
  45544. var op = data[i++];
  45545. if (op === 0x40) {
  45546. n = data[i++];
  45547. if (inFDEF || inELSE) {
  45548. i += n;
  45549. } else {
  45550. for (j = 0; j < n; j++) {
  45551. stack.push(data[i++]);
  45552. }
  45553. }
  45554. } else if (op === 0x41) {
  45555. n = data[i++];
  45556. if (inFDEF || inELSE) {
  45557. i += n * 2;
  45558. } else {
  45559. for (j = 0; j < n; j++) {
  45560. b = data[i++];
  45561. stack.push(b << 8 | data[i++]);
  45562. }
  45563. }
  45564. } else if ((op & 0xF8) === 0xB0) {
  45565. n = op - 0xB0 + 1;
  45566. if (inFDEF || inELSE) {
  45567. i += n;
  45568. } else {
  45569. for (j = 0; j < n; j++) {
  45570. stack.push(data[i++]);
  45571. }
  45572. }
  45573. } else if ((op & 0xF8) === 0xB8) {
  45574. n = op - 0xB8 + 1;
  45575. if (inFDEF || inELSE) {
  45576. i += n * 2;
  45577. } else {
  45578. for (j = 0; j < n; j++) {
  45579. b = data[i++];
  45580. stack.push(b << 8 | data[i++]);
  45581. }
  45582. }
  45583. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45584. if (!inFDEF && !inELSE) {
  45585. funcId = stack[stack.length - 1];
  45586. ttContext.functionsUsed[funcId] = true;
  45587. if (funcId in ttContext.functionsStackDeltas) {
  45588. stack.length += ttContext.functionsStackDeltas[funcId];
  45589. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45590. callstack.push({
  45591. data: data,
  45592. i: i,
  45593. stackTop: stack.length - 1
  45594. });
  45595. functionsCalled.push(funcId);
  45596. pc = ttContext.functionsDefined[funcId];
  45597. if (!pc) {
  45598. warn('TT: CALL non-existent function');
  45599. ttContext.hintsValid = false;
  45600. return;
  45601. }
  45602. data = pc.data;
  45603. i = pc.i;
  45604. }
  45605. }
  45606. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45607. if (inFDEF || inELSE) {
  45608. warn('TT: nested FDEFs not allowed');
  45609. tooComplexToFollowFunctions = true;
  45610. }
  45611. inFDEF = true;
  45612. lastDeff = i;
  45613. funcId = stack.pop();
  45614. ttContext.functionsDefined[funcId] = {
  45615. data: data,
  45616. i: i
  45617. };
  45618. } else if (op === 0x2D) {
  45619. if (inFDEF) {
  45620. inFDEF = false;
  45621. lastEndf = i;
  45622. } else {
  45623. pc = callstack.pop();
  45624. if (!pc) {
  45625. warn('TT: ENDF bad stack');
  45626. ttContext.hintsValid = false;
  45627. return;
  45628. }
  45629. funcId = functionsCalled.pop();
  45630. data = pc.data;
  45631. i = pc.i;
  45632. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45633. }
  45634. } else if (op === 0x89) {
  45635. if (inFDEF || inELSE) {
  45636. warn('TT: nested IDEFs not allowed');
  45637. tooComplexToFollowFunctions = true;
  45638. }
  45639. inFDEF = true;
  45640. lastDeff = i;
  45641. } else if (op === 0x58) {
  45642. ++ifLevel;
  45643. } else if (op === 0x1B) {
  45644. inELSE = ifLevel;
  45645. } else if (op === 0x59) {
  45646. if (inELSE === ifLevel) {
  45647. inELSE = 0;
  45648. }
  45649. --ifLevel;
  45650. } else if (op === 0x1C) {
  45651. if (!inFDEF && !inELSE) {
  45652. var offset = stack[stack.length - 1];
  45653. if (offset > 0) {
  45654. i += offset - 1;
  45655. }
  45656. }
  45657. }
  45658. if (!inFDEF && !inELSE) {
  45659. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45660. if (op >= 0x71 && op <= 0x75) {
  45661. n = stack.pop();
  45662. if (!isNaN(n)) {
  45663. stackDelta = -n * 2;
  45664. }
  45665. }
  45666. while (stackDelta < 0 && stack.length > 0) {
  45667. stack.pop();
  45668. stackDelta++;
  45669. }
  45670. while (stackDelta > 0) {
  45671. stack.push(NaN);
  45672. stackDelta--;
  45673. }
  45674. }
  45675. }
  45676. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45677. var content = [data];
  45678. if (i > data.length) {
  45679. content.push(new Uint8Array(i - data.length));
  45680. }
  45681. if (lastDeff > lastEndf) {
  45682. warn('TT: complementing a missing function tail');
  45683. content.push(new Uint8Array([
  45684. 0x22,
  45685. 0x2D
  45686. ]));
  45687. }
  45688. foldTTTable(table, content);
  45689. }
  45690. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45691. if (ttContext.tooComplexToFollowFunctions) {
  45692. return;
  45693. }
  45694. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45695. warn('TT: more functions defined than expected');
  45696. ttContext.hintsValid = false;
  45697. return;
  45698. }
  45699. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45700. if (j > maxFunctionDefs) {
  45701. warn('TT: invalid function id: ' + j);
  45702. ttContext.hintsValid = false;
  45703. return;
  45704. }
  45705. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45706. warn('TT: undefined function: ' + j);
  45707. ttContext.hintsValid = false;
  45708. return;
  45709. }
  45710. }
  45711. }
  45712. function foldTTTable(table, content) {
  45713. if (content.length > 1) {
  45714. var newLength = 0;
  45715. var j, jj;
  45716. for (j = 0, jj = content.length; j < jj; j++) {
  45717. newLength += content[j].length;
  45718. }
  45719. newLength = newLength + 3 & ~3;
  45720. var result = new Uint8Array(newLength);
  45721. var pos = 0;
  45722. for (j = 0, jj = content.length; j < jj; j++) {
  45723. result.set(content[j], pos);
  45724. pos += content[j].length;
  45725. }
  45726. table.data = result;
  45727. table.length = newLength;
  45728. }
  45729. }
  45730. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45731. var ttContext = {
  45732. functionsDefined: [],
  45733. functionsUsed: [],
  45734. functionsStackDeltas: [],
  45735. tooComplexToFollowFunctions: false,
  45736. hintsValid: true
  45737. };
  45738. if (fpgm) {
  45739. sanitizeTTProgram(fpgm, ttContext);
  45740. }
  45741. if (prep) {
  45742. sanitizeTTProgram(prep, ttContext);
  45743. }
  45744. if (fpgm) {
  45745. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45746. }
  45747. if (cvt && cvt.length & 1) {
  45748. var cvtData = new Uint8Array(cvt.length + 1);
  45749. cvtData.set(cvt.data);
  45750. cvt.data = cvtData;
  45751. }
  45752. return ttContext.hintsValid;
  45753. }
  45754. font = new Stream(new Uint8Array(font.getBytes()));
  45755. var VALID_TABLES = [
  45756. 'OS/2',
  45757. 'cmap',
  45758. 'head',
  45759. 'hhea',
  45760. 'hmtx',
  45761. 'maxp',
  45762. 'name',
  45763. 'post',
  45764. 'loca',
  45765. 'glyf',
  45766. 'fpgm',
  45767. 'prep',
  45768. 'cvt ',
  45769. 'CFF '
  45770. ];
  45771. var header = readOpenTypeHeader(font);
  45772. var numTables = header.numTables;
  45773. var cff, cffFile;
  45774. var tables = Object.create(null);
  45775. tables['OS/2'] = null;
  45776. tables['cmap'] = null;
  45777. tables['head'] = null;
  45778. tables['hhea'] = null;
  45779. tables['hmtx'] = null;
  45780. tables['maxp'] = null;
  45781. tables['name'] = null;
  45782. tables['post'] = null;
  45783. var table;
  45784. for (var i = 0; i < numTables; i++) {
  45785. table = readTableEntry(font);
  45786. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45787. continue;
  45788. }
  45789. if (table.length === 0) {
  45790. continue;
  45791. }
  45792. tables[table.tag] = table;
  45793. }
  45794. var isTrueType = !tables['CFF '];
  45795. if (!isTrueType) {
  45796. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45797. cffFile = new Stream(tables['CFF '].data);
  45798. cff = new CFFFont(cffFile, properties);
  45799. adjustWidths(properties);
  45800. return this.convert(name, cff, properties);
  45801. }
  45802. delete tables['glyf'];
  45803. delete tables['loca'];
  45804. delete tables['fpgm'];
  45805. delete tables['prep'];
  45806. delete tables['cvt '];
  45807. this.isOpenType = true;
  45808. } else {
  45809. if (!tables['loca']) {
  45810. error('Required "loca" table is not found');
  45811. }
  45812. if (!tables['glyf']) {
  45813. warn('Required "glyf" table is not found -- trying to recover.');
  45814. tables['glyf'] = {
  45815. tag: 'glyf',
  45816. data: new Uint8Array(0)
  45817. };
  45818. }
  45819. this.isOpenType = false;
  45820. }
  45821. if (!tables['maxp']) {
  45822. error('Required "maxp" table is not found');
  45823. }
  45824. font.pos = (font.start || 0) + tables['maxp'].offset;
  45825. var version = font.getInt32();
  45826. var numGlyphs = font.getUint16();
  45827. var maxFunctionDefs = 0;
  45828. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45829. font.pos += 8;
  45830. var maxZones = font.getUint16();
  45831. if (maxZones > 2) {
  45832. tables['maxp'].data[14] = 0;
  45833. tables['maxp'].data[15] = 2;
  45834. }
  45835. font.pos += 4;
  45836. maxFunctionDefs = font.getUint16();
  45837. }
  45838. var dupFirstEntry = false;
  45839. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45840. dupFirstEntry = true;
  45841. numGlyphs++;
  45842. tables['maxp'].data[4] = numGlyphs >> 8;
  45843. tables['maxp'].data[5] = numGlyphs & 255;
  45844. }
  45845. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45846. if (!hintsValid) {
  45847. delete tables['fpgm'];
  45848. delete tables['prep'];
  45849. delete tables['cvt '];
  45850. }
  45851. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45852. if (!tables['head']) {
  45853. error('Required "head" table is not found');
  45854. }
  45855. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45856. var missingGlyphs = Object.create(null);
  45857. if (isTrueType) {
  45858. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45859. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45860. }
  45861. if (!tables['hhea']) {
  45862. error('Required "hhea" table is not found');
  45863. }
  45864. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45865. tables['hhea'].data[10] = 0xFF;
  45866. tables['hhea'].data[11] = 0xFF;
  45867. }
  45868. var metricsOverride = {
  45869. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45870. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45871. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45872. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45873. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45874. };
  45875. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45876. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45877. if (tables['post']) {
  45878. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45879. if (!valid) {
  45880. tables['post'] = null;
  45881. }
  45882. }
  45883. var charCodeToGlyphId = [], charCode;
  45884. var toUnicode = properties.toUnicode, widths = properties.widths;
  45885. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45886. function hasGlyph(glyphId, charCode, widthCode) {
  45887. if (!missingGlyphs[glyphId]) {
  45888. return true;
  45889. }
  45890. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45891. return true;
  45892. }
  45893. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45894. return true;
  45895. }
  45896. return false;
  45897. }
  45898. if (properties.composite) {
  45899. var cidToGidMap = properties.cidToGidMap || [];
  45900. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45901. properties.cMap.forEach(function (charCode, cid) {
  45902. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45903. var glyphId = -1;
  45904. if (isCidToGidMapEmpty) {
  45905. glyphId = cid;
  45906. } else if (cidToGidMap[cid] !== undefined) {
  45907. glyphId = cidToGidMap[cid];
  45908. }
  45909. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45910. charCodeToGlyphId[charCode] = glyphId;
  45911. }
  45912. });
  45913. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45914. charCodeToGlyphId[0] = numGlyphs - 1;
  45915. }
  45916. } else {
  45917. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45918. var cmapPlatformId = cmapTable.platformId;
  45919. var cmapEncodingId = cmapTable.encodingId;
  45920. var cmapMappings = cmapTable.mappings;
  45921. var cmapMappingsLength = cmapMappings.length;
  45922. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45923. var baseEncoding = [];
  45924. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45925. baseEncoding = getEncoding(properties.baseEncodingName);
  45926. }
  45927. var glyphsUnicodeMap = getGlyphsUnicode();
  45928. for (charCode = 0; charCode < 256; charCode++) {
  45929. var glyphName, standardGlyphName;
  45930. if (this.differences && charCode in this.differences) {
  45931. glyphName = this.differences[charCode];
  45932. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45933. glyphName = baseEncoding[charCode];
  45934. } else {
  45935. glyphName = StandardEncoding[charCode];
  45936. }
  45937. if (!glyphName) {
  45938. continue;
  45939. }
  45940. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45941. var unicodeOrCharCode, isUnicode = false;
  45942. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45943. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45944. isUnicode = true;
  45945. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45946. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45947. }
  45948. var found = false;
  45949. for (i = 0; i < cmapMappingsLength; ++i) {
  45950. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45951. continue;
  45952. }
  45953. var code = isUnicode ? charCode : unicodeOrCharCode;
  45954. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45955. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45956. found = true;
  45957. break;
  45958. }
  45959. }
  45960. if (!found && properties.glyphNames) {
  45961. var glyphId = properties.glyphNames.indexOf(glyphName);
  45962. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45963. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45964. }
  45965. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45966. charCodeToGlyphId[charCode] = glyphId;
  45967. found = true;
  45968. }
  45969. }
  45970. if (!found) {
  45971. charCodeToGlyphId[charCode] = 0;
  45972. }
  45973. }
  45974. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45975. for (i = 0; i < cmapMappingsLength; ++i) {
  45976. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45977. }
  45978. } else {
  45979. for (i = 0; i < cmapMappingsLength; ++i) {
  45980. charCode = cmapMappings[i].charCode & 0xFF;
  45981. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45982. }
  45983. }
  45984. }
  45985. if (charCodeToGlyphId.length === 0) {
  45986. charCodeToGlyphId[0] = 0;
  45987. }
  45988. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45989. this.toFontChar = newMapping.toFontChar;
  45990. tables['cmap'] = {
  45991. tag: 'cmap',
  45992. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45993. };
  45994. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45995. tables['OS/2'] = {
  45996. tag: 'OS/2',
  45997. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45998. };
  45999. }
  46000. if (!tables['post']) {
  46001. tables['post'] = {
  46002. tag: 'post',
  46003. data: createPostTable(properties)
  46004. };
  46005. }
  46006. if (!isTrueType) {
  46007. try {
  46008. cffFile = new Stream(tables['CFF '].data);
  46009. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46010. cff = parser.parse();
  46011. var compiler = new CFFCompiler(cff);
  46012. tables['CFF '].data = compiler.compile();
  46013. } catch (e) {
  46014. warn('Failed to compile font ' + properties.loadedName);
  46015. }
  46016. }
  46017. if (!tables['name']) {
  46018. tables['name'] = {
  46019. tag: 'name',
  46020. data: createNameTable(this.name)
  46021. };
  46022. } else {
  46023. var namePrototype = readNameTable(tables['name']);
  46024. tables['name'].data = createNameTable(name, namePrototype);
  46025. }
  46026. var builder = new OpenTypeFileBuilder(header.version);
  46027. for (var tableTag in tables) {
  46028. builder.addTable(tableTag, tables[tableTag].data);
  46029. }
  46030. return builder.toArray();
  46031. },
  46032. convert: function Font_convert(fontName, font, properties) {
  46033. properties.fixedPitch = false;
  46034. if (properties.builtInEncoding) {
  46035. adjustToUnicode(properties, properties.builtInEncoding);
  46036. }
  46037. var mapping = font.getGlyphMapping(properties);
  46038. var newMapping = adjustMapping(mapping, properties);
  46039. this.toFontChar = newMapping.toFontChar;
  46040. var numGlyphs = font.numGlyphs;
  46041. function getCharCodes(charCodeToGlyphId, glyphId) {
  46042. var charCodes = null;
  46043. for (var charCode in charCodeToGlyphId) {
  46044. if (glyphId === charCodeToGlyphId[charCode]) {
  46045. if (!charCodes) {
  46046. charCodes = [];
  46047. }
  46048. charCodes.push(charCode | 0);
  46049. }
  46050. }
  46051. return charCodes;
  46052. }
  46053. function createCharCode(charCodeToGlyphId, glyphId) {
  46054. for (var charCode in charCodeToGlyphId) {
  46055. if (glyphId === charCodeToGlyphId[charCode]) {
  46056. return charCode | 0;
  46057. }
  46058. }
  46059. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46060. return newMapping.nextAvailableFontCharCode++;
  46061. }
  46062. var seacs = font.seacs;
  46063. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46064. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46065. var charset = font.getCharset();
  46066. var seacMap = Object.create(null);
  46067. for (var glyphId in seacs) {
  46068. glyphId |= 0;
  46069. var seac = seacs[glyphId];
  46070. var baseGlyphName = StandardEncoding[seac[2]];
  46071. var accentGlyphName = StandardEncoding[seac[3]];
  46072. var baseGlyphId = charset.indexOf(baseGlyphName);
  46073. var accentGlyphId = charset.indexOf(accentGlyphName);
  46074. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46075. continue;
  46076. }
  46077. var accentOffset = {
  46078. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46079. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46080. };
  46081. var charCodes = getCharCodes(mapping, glyphId);
  46082. if (!charCodes) {
  46083. continue;
  46084. }
  46085. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46086. var charCode = charCodes[i];
  46087. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46088. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46089. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46090. seacMap[charCode] = {
  46091. baseFontCharCode: baseFontCharCode,
  46092. accentFontCharCode: accentFontCharCode,
  46093. accentOffset: accentOffset
  46094. };
  46095. }
  46096. }
  46097. properties.seacMap = seacMap;
  46098. }
  46099. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46100. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46101. builder.addTable('CFF ', font.data);
  46102. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46103. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46104. 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');
  46105. 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));
  46106. builder.addTable('hmtx', function fontFieldsHmtx() {
  46107. var charstrings = font.charstrings;
  46108. var cffWidths = font.cff ? font.cff.widths : null;
  46109. var hmtx = '\x00\x00\x00\x00';
  46110. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46111. var width = 0;
  46112. if (charstrings) {
  46113. var charstring = charstrings[i - 1];
  46114. width = 'width' in charstring ? charstring.width : 0;
  46115. } else if (cffWidths) {
  46116. width = Math.ceil(cffWidths[i] || 0);
  46117. }
  46118. hmtx += string16(width) + string16(0);
  46119. }
  46120. return hmtx;
  46121. }());
  46122. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46123. builder.addTable('name', createNameTable(fontName));
  46124. builder.addTable('post', createPostTable(properties));
  46125. return builder.toArray();
  46126. },
  46127. get spaceWidth() {
  46128. if ('_shadowWidth' in this) {
  46129. return this._shadowWidth;
  46130. }
  46131. var possibleSpaceReplacements = [
  46132. 'space',
  46133. 'minus',
  46134. 'one',
  46135. 'i',
  46136. 'I'
  46137. ];
  46138. var width;
  46139. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46140. var glyphName = possibleSpaceReplacements[i];
  46141. if (glyphName in this.widths) {
  46142. width = this.widths[glyphName];
  46143. break;
  46144. }
  46145. var glyphsUnicodeMap = getGlyphsUnicode();
  46146. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46147. var charcode = 0;
  46148. if (this.composite) {
  46149. if (this.cMap.contains(glyphUnicode)) {
  46150. charcode = this.cMap.lookup(glyphUnicode);
  46151. }
  46152. }
  46153. if (!charcode && this.toUnicode) {
  46154. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46155. }
  46156. if (charcode <= 0) {
  46157. charcode = glyphUnicode;
  46158. }
  46159. width = this.widths[charcode];
  46160. if (width) {
  46161. break;
  46162. }
  46163. }
  46164. width = width || this.defaultWidth;
  46165. this._shadowWidth = width;
  46166. return width;
  46167. },
  46168. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46169. var fontCharCode, width, operatorListId;
  46170. var widthCode = charcode;
  46171. if (this.cMap && this.cMap.contains(charcode)) {
  46172. widthCode = this.cMap.lookup(charcode);
  46173. }
  46174. width = this.widths[widthCode];
  46175. width = isNum(width) ? width : this.defaultWidth;
  46176. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46177. var unicode = this.toUnicode.get(charcode) || charcode;
  46178. if (typeof unicode === 'number') {
  46179. unicode = String.fromCharCode(unicode);
  46180. }
  46181. var isInFont = charcode in this.toFontChar;
  46182. fontCharCode = this.toFontChar[charcode] || charcode;
  46183. if (this.missingFile) {
  46184. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46185. }
  46186. if (this.isType3Font) {
  46187. operatorListId = fontCharCode;
  46188. }
  46189. var accent = null;
  46190. if (this.seacMap && this.seacMap[charcode]) {
  46191. isInFont = true;
  46192. var seac = this.seacMap[charcode];
  46193. fontCharCode = seac.baseFontCharCode;
  46194. accent = {
  46195. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46196. offset: seac.accentOffset
  46197. };
  46198. }
  46199. var fontChar = String.fromCharCode(fontCharCode);
  46200. var glyph = this.glyphCache[charcode];
  46201. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46202. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46203. this.glyphCache[charcode] = glyph;
  46204. }
  46205. return glyph;
  46206. },
  46207. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46208. var charsCache = this.charsCache;
  46209. var glyphs, glyph, charcode;
  46210. if (charsCache) {
  46211. glyphs = charsCache[chars];
  46212. if (glyphs) {
  46213. return glyphs;
  46214. }
  46215. }
  46216. if (!charsCache) {
  46217. charsCache = this.charsCache = Object.create(null);
  46218. }
  46219. glyphs = [];
  46220. var charsCacheKey = chars;
  46221. var i = 0, ii;
  46222. if (this.cMap) {
  46223. var c = Object.create(null);
  46224. while (i < chars.length) {
  46225. this.cMap.readCharCode(chars, i, c);
  46226. charcode = c.charcode;
  46227. var length = c.length;
  46228. i += length;
  46229. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46230. glyph = this.charToGlyph(charcode, isSpace);
  46231. glyphs.push(glyph);
  46232. }
  46233. } else {
  46234. for (i = 0, ii = chars.length; i < ii; ++i) {
  46235. charcode = chars.charCodeAt(i);
  46236. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46237. glyphs.push(glyph);
  46238. }
  46239. }
  46240. return charsCache[charsCacheKey] = glyphs;
  46241. }
  46242. };
  46243. return Font;
  46244. }();
  46245. var ErrorFont = function ErrorFontClosure() {
  46246. function ErrorFont(error) {
  46247. this.error = error;
  46248. this.loadedName = 'g_font_error';
  46249. this.loading = false;
  46250. }
  46251. ErrorFont.prototype = {
  46252. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46253. return [];
  46254. },
  46255. exportData: function ErrorFont_exportData() {
  46256. return { error: this.error };
  46257. }
  46258. };
  46259. return ErrorFont;
  46260. }();
  46261. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46262. var charCodeToGlyphId = Object.create(null);
  46263. var glyphId, charCode, baseEncoding;
  46264. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46265. if (properties.baseEncodingName) {
  46266. baseEncoding = getEncoding(properties.baseEncodingName);
  46267. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46268. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46269. if (glyphId >= 0) {
  46270. charCodeToGlyphId[charCode] = glyphId;
  46271. } else {
  46272. charCodeToGlyphId[charCode] = 0;
  46273. }
  46274. }
  46275. } else if (isSymbolicFont) {
  46276. for (charCode in builtInEncoding) {
  46277. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46278. }
  46279. } else {
  46280. baseEncoding = StandardEncoding;
  46281. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46282. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46283. if (glyphId >= 0) {
  46284. charCodeToGlyphId[charCode] = glyphId;
  46285. } else {
  46286. charCodeToGlyphId[charCode] = 0;
  46287. }
  46288. }
  46289. }
  46290. var differences = properties.differences, glyphsUnicodeMap;
  46291. if (differences) {
  46292. for (charCode in differences) {
  46293. var glyphName = differences[charCode];
  46294. glyphId = glyphNames.indexOf(glyphName);
  46295. if (glyphId === -1) {
  46296. if (!glyphsUnicodeMap) {
  46297. glyphsUnicodeMap = getGlyphsUnicode();
  46298. }
  46299. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46300. if (standardGlyphName !== glyphName) {
  46301. glyphId = glyphNames.indexOf(standardGlyphName);
  46302. }
  46303. }
  46304. if (glyphId >= 0) {
  46305. charCodeToGlyphId[charCode] = glyphId;
  46306. } else {
  46307. charCodeToGlyphId[charCode] = 0;
  46308. }
  46309. }
  46310. }
  46311. return charCodeToGlyphId;
  46312. }
  46313. var Type1Font = function Type1FontClosure() {
  46314. function findBlock(streamBytes, signature, startIndex) {
  46315. var streamBytesLength = streamBytes.length;
  46316. var signatureLength = signature.length;
  46317. var scanLength = streamBytesLength - signatureLength;
  46318. var i = startIndex, j, found = false;
  46319. while (i < scanLength) {
  46320. j = 0;
  46321. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46322. j++;
  46323. }
  46324. if (j >= signatureLength) {
  46325. i += j;
  46326. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46327. i++;
  46328. }
  46329. found = true;
  46330. break;
  46331. }
  46332. i++;
  46333. }
  46334. return {
  46335. found: found,
  46336. length: i
  46337. };
  46338. }
  46339. function getHeaderBlock(stream, suggestedLength) {
  46340. var EEXEC_SIGNATURE = [
  46341. 0x65,
  46342. 0x65,
  46343. 0x78,
  46344. 0x65,
  46345. 0x63
  46346. ];
  46347. var streamStartPos = stream.pos;
  46348. var headerBytes, headerBytesLength, block;
  46349. try {
  46350. headerBytes = stream.getBytes(suggestedLength);
  46351. headerBytesLength = headerBytes.length;
  46352. } catch (ex) {
  46353. if (ex instanceof MissingDataException) {
  46354. throw ex;
  46355. }
  46356. }
  46357. if (headerBytesLength === suggestedLength) {
  46358. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46359. if (block.found && block.length === suggestedLength) {
  46360. return {
  46361. stream: new Stream(headerBytes),
  46362. length: suggestedLength
  46363. };
  46364. }
  46365. }
  46366. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46367. stream.pos = streamStartPos;
  46368. var SCAN_BLOCK_LENGTH = 2048;
  46369. var actualLength;
  46370. while (true) {
  46371. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46372. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46373. if (block.length === 0) {
  46374. break;
  46375. }
  46376. stream.pos += block.length;
  46377. if (block.found) {
  46378. actualLength = stream.pos - streamStartPos;
  46379. break;
  46380. }
  46381. }
  46382. stream.pos = streamStartPos;
  46383. if (actualLength) {
  46384. return {
  46385. stream: new Stream(stream.getBytes(actualLength)),
  46386. length: actualLength
  46387. };
  46388. }
  46389. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46390. return {
  46391. stream: new Stream(stream.getBytes(suggestedLength)),
  46392. length: suggestedLength
  46393. };
  46394. }
  46395. function getEexecBlock(stream, suggestedLength) {
  46396. var eexecBytes = stream.getBytes();
  46397. return {
  46398. stream: new Stream(eexecBytes),
  46399. length: eexecBytes.length
  46400. };
  46401. }
  46402. function Type1Font(name, file, properties) {
  46403. var PFB_HEADER_SIZE = 6;
  46404. var headerBlockLength = properties.length1;
  46405. var eexecBlockLength = properties.length2;
  46406. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46407. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46408. if (pfbHeaderPresent) {
  46409. file.skip(PFB_HEADER_SIZE);
  46410. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46411. }
  46412. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46413. headerBlockLength = headerBlock.length;
  46414. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46415. headerBlockParser.extractFontHeader(properties);
  46416. if (pfbHeaderPresent) {
  46417. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46418. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46419. }
  46420. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46421. eexecBlockLength = eexecBlock.length;
  46422. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46423. var data = eexecBlockParser.extractFontProgram();
  46424. for (var info in data.properties) {
  46425. properties[info] = data.properties[info];
  46426. }
  46427. var charstrings = data.charstrings;
  46428. var type2Charstrings = this.getType2Charstrings(charstrings);
  46429. var subrs = this.getType2Subrs(data.subrs);
  46430. this.charstrings = charstrings;
  46431. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46432. this.seacs = this.getSeacs(data.charstrings);
  46433. }
  46434. Type1Font.prototype = {
  46435. get numGlyphs() {
  46436. return this.charstrings.length + 1;
  46437. },
  46438. getCharset: function Type1Font_getCharset() {
  46439. var charset = ['.notdef'];
  46440. var charstrings = this.charstrings;
  46441. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46442. charset.push(charstrings[glyphId].glyphName);
  46443. }
  46444. return charset;
  46445. },
  46446. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46447. var charstrings = this.charstrings;
  46448. var glyphNames = ['.notdef'], glyphId;
  46449. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46450. glyphNames.push(charstrings[glyphId].glyphName);
  46451. }
  46452. var encoding = properties.builtInEncoding;
  46453. if (encoding) {
  46454. var builtInEncoding = Object.create(null);
  46455. for (var charCode in encoding) {
  46456. glyphId = glyphNames.indexOf(encoding[charCode]);
  46457. if (glyphId >= 0) {
  46458. builtInEncoding[charCode] = glyphId;
  46459. }
  46460. }
  46461. }
  46462. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46463. },
  46464. getSeacs: function Type1Font_getSeacs(charstrings) {
  46465. var i, ii;
  46466. var seacMap = [];
  46467. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46468. var charstring = charstrings[i];
  46469. if (charstring.seac) {
  46470. seacMap[i + 1] = charstring.seac;
  46471. }
  46472. }
  46473. return seacMap;
  46474. },
  46475. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46476. var type2Charstrings = [];
  46477. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46478. type2Charstrings.push(type1Charstrings[i].charstring);
  46479. }
  46480. return type2Charstrings;
  46481. },
  46482. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46483. var bias = 0;
  46484. var count = type1Subrs.length;
  46485. if (count < 1133) {
  46486. bias = 107;
  46487. } else if (count < 33769) {
  46488. bias = 1131;
  46489. } else {
  46490. bias = 32768;
  46491. }
  46492. var type2Subrs = [];
  46493. var i;
  46494. for (i = 0; i < bias; i++) {
  46495. type2Subrs.push([0x0B]);
  46496. }
  46497. for (i = 0; i < count; i++) {
  46498. type2Subrs.push(type1Subrs[i]);
  46499. }
  46500. return type2Subrs;
  46501. },
  46502. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46503. var cff = new CFF();
  46504. cff.header = new CFFHeader(1, 0, 4, 4);
  46505. cff.names = [name];
  46506. var topDict = new CFFTopDict();
  46507. topDict.setByName('version', 391);
  46508. topDict.setByName('Notice', 392);
  46509. topDict.setByName('FullName', 393);
  46510. topDict.setByName('FamilyName', 394);
  46511. topDict.setByName('Weight', 395);
  46512. topDict.setByName('Encoding', null);
  46513. topDict.setByName('FontMatrix', properties.fontMatrix);
  46514. topDict.setByName('FontBBox', properties.bbox);
  46515. topDict.setByName('charset', null);
  46516. topDict.setByName('CharStrings', null);
  46517. topDict.setByName('Private', null);
  46518. cff.topDict = topDict;
  46519. var strings = new CFFStrings();
  46520. strings.add('Version 0.11');
  46521. strings.add('See original notice');
  46522. strings.add(name);
  46523. strings.add(name);
  46524. strings.add('Medium');
  46525. cff.strings = strings;
  46526. cff.globalSubrIndex = new CFFIndex();
  46527. var count = glyphs.length;
  46528. var charsetArray = [0];
  46529. var i, ii;
  46530. for (i = 0; i < count; i++) {
  46531. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46532. if (index === -1) {
  46533. index = 0;
  46534. }
  46535. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46536. }
  46537. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46538. var charStringsIndex = new CFFIndex();
  46539. charStringsIndex.add([
  46540. 0x8B,
  46541. 0x0E
  46542. ]);
  46543. for (i = 0; i < count; i++) {
  46544. var glyph = glyphs[i];
  46545. if (glyph.length === 0) {
  46546. charStringsIndex.add([
  46547. 0x8B,
  46548. 0x0E
  46549. ]);
  46550. continue;
  46551. }
  46552. charStringsIndex.add(glyph);
  46553. }
  46554. cff.charStrings = charStringsIndex;
  46555. var privateDict = new CFFPrivateDict();
  46556. privateDict.setByName('Subrs', null);
  46557. var fields = [
  46558. 'BlueValues',
  46559. 'OtherBlues',
  46560. 'FamilyBlues',
  46561. 'FamilyOtherBlues',
  46562. 'StemSnapH',
  46563. 'StemSnapV',
  46564. 'BlueShift',
  46565. 'BlueFuzz',
  46566. 'BlueScale',
  46567. 'LanguageGroup',
  46568. 'ExpansionFactor',
  46569. 'ForceBold',
  46570. 'StdHW',
  46571. 'StdVW'
  46572. ];
  46573. for (i = 0, ii = fields.length; i < ii; i++) {
  46574. var field = fields[i];
  46575. if (!(field in properties.privateData)) {
  46576. continue;
  46577. }
  46578. var value = properties.privateData[field];
  46579. if (isArray(value)) {
  46580. for (var j = value.length - 1; j > 0; j--) {
  46581. value[j] -= value[j - 1];
  46582. }
  46583. }
  46584. privateDict.setByName(field, value);
  46585. }
  46586. cff.topDict.privateDict = privateDict;
  46587. var subrIndex = new CFFIndex();
  46588. for (i = 0, ii = subrs.length; i < ii; i++) {
  46589. subrIndex.add(subrs[i]);
  46590. }
  46591. privateDict.subrsIndex = subrIndex;
  46592. var compiler = new CFFCompiler(cff);
  46593. return compiler.compile();
  46594. }
  46595. };
  46596. return Type1Font;
  46597. }();
  46598. var CFFFont = function CFFFontClosure() {
  46599. function CFFFont(file, properties) {
  46600. this.properties = properties;
  46601. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46602. this.cff = parser.parse();
  46603. var compiler = new CFFCompiler(this.cff);
  46604. this.seacs = this.cff.seacs;
  46605. try {
  46606. this.data = compiler.compile();
  46607. } catch (e) {
  46608. warn('Failed to compile font ' + properties.loadedName);
  46609. this.data = file;
  46610. }
  46611. }
  46612. CFFFont.prototype = {
  46613. get numGlyphs() {
  46614. return this.cff.charStrings.count;
  46615. },
  46616. getCharset: function CFFFont_getCharset() {
  46617. return this.cff.charset.charset;
  46618. },
  46619. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46620. var cff = this.cff;
  46621. var properties = this.properties;
  46622. var charsets = cff.charset.charset;
  46623. var charCodeToGlyphId;
  46624. var glyphId;
  46625. if (properties.composite) {
  46626. charCodeToGlyphId = Object.create(null);
  46627. if (cff.isCIDFont) {
  46628. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46629. var cid = charsets[glyphId];
  46630. var charCode = properties.cMap.charCodeOf(cid);
  46631. charCodeToGlyphId[charCode] = glyphId;
  46632. }
  46633. } else {
  46634. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46635. charCodeToGlyphId[glyphId] = glyphId;
  46636. }
  46637. }
  46638. return charCodeToGlyphId;
  46639. }
  46640. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46641. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46642. return charCodeToGlyphId;
  46643. }
  46644. };
  46645. return CFFFont;
  46646. }();
  46647. (function checkSeacSupport() {
  46648. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46649. SEAC_ANALYSIS_ENABLED = true;
  46650. }
  46651. }());
  46652. (function checkChromeWindows() {
  46653. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46654. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46655. }
  46656. }());
  46657. exports.ErrorFont = ErrorFont;
  46658. exports.Font = Font;
  46659. exports.FontFlags = FontFlags;
  46660. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46661. exports.ToUnicodeMap = ToUnicodeMap;
  46662. exports.getFontType = getFontType;
  46663. /***/ }),
  46664. /* 35 */
  46665. /***/ (function(module, exports, __w_pdfjs_require__) {
  46666. "use strict";
  46667. var sharedUtil = __w_pdfjs_require__(0);
  46668. var corePrimitives = __w_pdfjs_require__(1);
  46669. var coreColorSpace = __w_pdfjs_require__(4);
  46670. var coreStream = __w_pdfjs_require__(2);
  46671. var coreJpx = __w_pdfjs_require__(18);
  46672. var ImageKind = sharedUtil.ImageKind;
  46673. var assert = sharedUtil.assert;
  46674. var error = sharedUtil.error;
  46675. var info = sharedUtil.info;
  46676. var isArray = sharedUtil.isArray;
  46677. var warn = sharedUtil.warn;
  46678. var Name = corePrimitives.Name;
  46679. var isStream = corePrimitives.isStream;
  46680. var ColorSpace = coreColorSpace.ColorSpace;
  46681. var DecodeStream = coreStream.DecodeStream;
  46682. var JpegStream = coreStream.JpegStream;
  46683. var JpxImage = coreJpx.JpxImage;
  46684. var PDFImage = function PDFImageClosure() {
  46685. function handleImageData(image, nativeDecoder) {
  46686. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46687. return nativeDecoder.decode(image);
  46688. }
  46689. return Promise.resolve(image);
  46690. }
  46691. function decodeAndClamp(value, addend, coefficient, max) {
  46692. value = addend + value * coefficient;
  46693. return value < 0 ? 0 : value > max ? max : value;
  46694. }
  46695. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46696. var length = w2 * h2;
  46697. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46698. var xRatio = w1 / w2;
  46699. var yRatio = h1 / h2;
  46700. var i, j, py, newIndex = 0, oldIndex;
  46701. var xScaled = new Uint16Array(w2);
  46702. var w1Scanline = w1;
  46703. for (i = 0; i < w2; i++) {
  46704. xScaled[i] = Math.floor(i * xRatio);
  46705. }
  46706. for (i = 0; i < h2; i++) {
  46707. py = Math.floor(i * yRatio) * w1Scanline;
  46708. for (j = 0; j < w2; j++) {
  46709. oldIndex = py + xScaled[j];
  46710. dest[newIndex++] = src[oldIndex];
  46711. }
  46712. }
  46713. return dest;
  46714. }
  46715. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46716. this.image = image;
  46717. var dict = image.dict;
  46718. if (dict.has('Filter')) {
  46719. var filter = dict.get('Filter').name;
  46720. if (filter === 'JPXDecode') {
  46721. var jpxImage = new JpxImage();
  46722. jpxImage.parseImageProperties(image.stream);
  46723. image.stream.reset();
  46724. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46725. image.numComps = jpxImage.componentsCount;
  46726. } else if (filter === 'JBIG2Decode') {
  46727. image.bitsPerComponent = 1;
  46728. image.numComps = 1;
  46729. }
  46730. }
  46731. this.width = dict.get('Width', 'W');
  46732. this.height = dict.get('Height', 'H');
  46733. if (this.width < 1 || this.height < 1) {
  46734. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46735. }
  46736. this.interpolate = dict.get('Interpolate', 'I') || false;
  46737. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46738. this.matte = dict.get('Matte') || false;
  46739. var bitsPerComponent = image.bitsPerComponent;
  46740. if (!bitsPerComponent) {
  46741. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46742. if (!bitsPerComponent) {
  46743. if (this.imageMask) {
  46744. bitsPerComponent = 1;
  46745. } else {
  46746. error('Bits per component missing in image: ' + this.imageMask);
  46747. }
  46748. }
  46749. }
  46750. this.bpc = bitsPerComponent;
  46751. if (!this.imageMask) {
  46752. var colorSpace = dict.get('ColorSpace', 'CS');
  46753. if (!colorSpace) {
  46754. info('JPX images (which do not require color spaces)');
  46755. switch (image.numComps) {
  46756. case 1:
  46757. colorSpace = Name.get('DeviceGray');
  46758. break;
  46759. case 3:
  46760. colorSpace = Name.get('DeviceRGB');
  46761. break;
  46762. case 4:
  46763. colorSpace = Name.get('DeviceCMYK');
  46764. break;
  46765. default:
  46766. error('JPX images with ' + this.numComps + ' color components not supported.');
  46767. }
  46768. }
  46769. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46770. this.numComps = this.colorSpace.numComps;
  46771. }
  46772. this.decode = dict.getArray('Decode', 'D');
  46773. this.needsDecode = false;
  46774. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46775. this.needsDecode = true;
  46776. var max = (1 << bitsPerComponent) - 1;
  46777. this.decodeCoefficients = [];
  46778. this.decodeAddends = [];
  46779. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46780. var dmin = this.decode[i];
  46781. var dmax = this.decode[i + 1];
  46782. this.decodeCoefficients[j] = dmax - dmin;
  46783. this.decodeAddends[j] = max * dmin;
  46784. }
  46785. }
  46786. if (smask) {
  46787. this.smask = new PDFImage(xref, res, smask, false);
  46788. } else if (mask) {
  46789. if (isStream(mask)) {
  46790. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46791. if (!imageMask) {
  46792. warn('Ignoring /Mask in image without /ImageMask.');
  46793. } else {
  46794. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46795. }
  46796. } else {
  46797. this.mask = mask;
  46798. }
  46799. }
  46800. }
  46801. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46802. var imagePromise = handleImageData(image, nativeDecoder);
  46803. var smaskPromise;
  46804. var maskPromise;
  46805. var smask = image.dict.get('SMask');
  46806. var mask = image.dict.get('Mask');
  46807. if (smask) {
  46808. smaskPromise = handleImageData(smask, nativeDecoder);
  46809. maskPromise = Promise.resolve(null);
  46810. } else {
  46811. smaskPromise = Promise.resolve(null);
  46812. if (mask) {
  46813. if (isStream(mask)) {
  46814. maskPromise = handleImageData(mask, nativeDecoder);
  46815. } else if (isArray(mask)) {
  46816. maskPromise = Promise.resolve(mask);
  46817. } else {
  46818. warn('Unsupported mask format.');
  46819. maskPromise = Promise.resolve(null);
  46820. }
  46821. } else {
  46822. maskPromise = Promise.resolve(null);
  46823. }
  46824. }
  46825. return Promise.all([
  46826. imagePromise,
  46827. smaskPromise,
  46828. maskPromise
  46829. ]).then(function (results) {
  46830. var imageData = results[0];
  46831. var smaskData = results[1];
  46832. var maskData = results[2];
  46833. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46834. });
  46835. };
  46836. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46837. var computedLength = (width + 7 >> 3) * height;
  46838. var actualLength = imgArray.byteLength;
  46839. var haveFullData = computedLength === actualLength;
  46840. var data, i;
  46841. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46842. data = imgArray;
  46843. } else if (!inverseDecode) {
  46844. data = new Uint8Array(actualLength);
  46845. data.set(imgArray);
  46846. } else {
  46847. data = new Uint8Array(computedLength);
  46848. data.set(imgArray);
  46849. for (i = actualLength; i < computedLength; i++) {
  46850. data[i] = 0xff;
  46851. }
  46852. }
  46853. if (inverseDecode) {
  46854. for (i = 0; i < actualLength; i++) {
  46855. data[i] = ~data[i];
  46856. }
  46857. }
  46858. return {
  46859. data: data,
  46860. width: width,
  46861. height: height
  46862. };
  46863. };
  46864. PDFImage.prototype = {
  46865. get drawWidth() {
  46866. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46867. },
  46868. get drawHeight() {
  46869. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46870. },
  46871. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46872. var bpc = this.bpc;
  46873. var numComps = this.numComps;
  46874. var decodeAddends = this.decodeAddends;
  46875. var decodeCoefficients = this.decodeCoefficients;
  46876. var max = (1 << bpc) - 1;
  46877. var i, ii;
  46878. if (bpc === 1) {
  46879. for (i = 0, ii = buffer.length; i < ii; i++) {
  46880. buffer[i] = +!buffer[i];
  46881. }
  46882. return;
  46883. }
  46884. var index = 0;
  46885. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46886. for (var j = 0; j < numComps; j++) {
  46887. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46888. index++;
  46889. }
  46890. }
  46891. },
  46892. getComponents: function PDFImage_getComponents(buffer) {
  46893. var bpc = this.bpc;
  46894. if (bpc === 8) {
  46895. return buffer;
  46896. }
  46897. var width = this.width;
  46898. var height = this.height;
  46899. var numComps = this.numComps;
  46900. var length = width * height * numComps;
  46901. var bufferPos = 0;
  46902. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46903. var rowComps = width * numComps;
  46904. var max = (1 << bpc) - 1;
  46905. var i = 0, ii, buf;
  46906. if (bpc === 1) {
  46907. var mask, loop1End, loop2End;
  46908. for (var j = 0; j < height; j++) {
  46909. loop1End = i + (rowComps & ~7);
  46910. loop2End = i + rowComps;
  46911. while (i < loop1End) {
  46912. buf = buffer[bufferPos++];
  46913. output[i] = buf >> 7 & 1;
  46914. output[i + 1] = buf >> 6 & 1;
  46915. output[i + 2] = buf >> 5 & 1;
  46916. output[i + 3] = buf >> 4 & 1;
  46917. output[i + 4] = buf >> 3 & 1;
  46918. output[i + 5] = buf >> 2 & 1;
  46919. output[i + 6] = buf >> 1 & 1;
  46920. output[i + 7] = buf & 1;
  46921. i += 8;
  46922. }
  46923. if (i < loop2End) {
  46924. buf = buffer[bufferPos++];
  46925. mask = 128;
  46926. while (i < loop2End) {
  46927. output[i++] = +!!(buf & mask);
  46928. mask >>= 1;
  46929. }
  46930. }
  46931. }
  46932. } else {
  46933. var bits = 0;
  46934. buf = 0;
  46935. for (i = 0, ii = length; i < ii; ++i) {
  46936. if (i % rowComps === 0) {
  46937. buf = 0;
  46938. bits = 0;
  46939. }
  46940. while (bits < bpc) {
  46941. buf = buf << 8 | buffer[bufferPos++];
  46942. bits += 8;
  46943. }
  46944. var remainingBits = bits - bpc;
  46945. var value = buf >> remainingBits;
  46946. output[i] = value < 0 ? 0 : value > max ? max : value;
  46947. buf = buf & (1 << remainingBits) - 1;
  46948. bits = remainingBits;
  46949. }
  46950. }
  46951. return output;
  46952. },
  46953. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46954. var smask = this.smask;
  46955. var mask = this.mask;
  46956. var alphaBuf, sw, sh, i, ii, j;
  46957. if (smask) {
  46958. sw = smask.width;
  46959. sh = smask.height;
  46960. alphaBuf = new Uint8Array(sw * sh);
  46961. smask.fillGrayBuffer(alphaBuf);
  46962. if (sw !== width || sh !== height) {
  46963. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46964. }
  46965. } else if (mask) {
  46966. if (mask instanceof PDFImage) {
  46967. sw = mask.width;
  46968. sh = mask.height;
  46969. alphaBuf = new Uint8Array(sw * sh);
  46970. mask.numComps = 1;
  46971. mask.fillGrayBuffer(alphaBuf);
  46972. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46973. alphaBuf[i] = 255 - alphaBuf[i];
  46974. }
  46975. if (sw !== width || sh !== height) {
  46976. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46977. }
  46978. } else if (isArray(mask)) {
  46979. alphaBuf = new Uint8Array(width * height);
  46980. var numComps = this.numComps;
  46981. for (i = 0, ii = width * height; i < ii; ++i) {
  46982. var opacity = 0;
  46983. var imageOffset = i * numComps;
  46984. for (j = 0; j < numComps; ++j) {
  46985. var color = image[imageOffset + j];
  46986. var maskOffset = j * 2;
  46987. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46988. opacity = 255;
  46989. break;
  46990. }
  46991. }
  46992. alphaBuf[i] = opacity;
  46993. }
  46994. } else {
  46995. error('Unknown mask format.');
  46996. }
  46997. }
  46998. if (alphaBuf) {
  46999. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47000. rgbaBuf[j] = alphaBuf[i];
  47001. }
  47002. } else {
  47003. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47004. rgbaBuf[j] = 255;
  47005. }
  47006. }
  47007. },
  47008. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47009. var matte = this.smask && this.smask.matte;
  47010. if (!matte) {
  47011. return;
  47012. }
  47013. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47014. var matteR = matteRgb[0];
  47015. var matteG = matteRgb[1];
  47016. var matteB = matteRgb[2];
  47017. var length = width * height * 4;
  47018. var r, g, b;
  47019. for (var i = 0; i < length; i += 4) {
  47020. var alpha = buffer[i + 3];
  47021. if (alpha === 0) {
  47022. buffer[i] = 255;
  47023. buffer[i + 1] = 255;
  47024. buffer[i + 2] = 255;
  47025. continue;
  47026. }
  47027. var k = 255 / alpha;
  47028. r = (buffer[i] - matteR) * k + matteR;
  47029. g = (buffer[i + 1] - matteG) * k + matteG;
  47030. b = (buffer[i + 2] - matteB) * k + matteB;
  47031. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47032. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47033. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47034. }
  47035. },
  47036. createImageData: function PDFImage_createImageData(forceRGBA) {
  47037. var drawWidth = this.drawWidth;
  47038. var drawHeight = this.drawHeight;
  47039. var imgData = {
  47040. width: drawWidth,
  47041. height: drawHeight
  47042. };
  47043. var numComps = this.numComps;
  47044. var originalWidth = this.width;
  47045. var originalHeight = this.height;
  47046. var bpc = this.bpc;
  47047. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47048. var imgArray;
  47049. if (!forceRGBA) {
  47050. var kind;
  47051. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47052. kind = ImageKind.GRAYSCALE_1BPP;
  47053. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47054. kind = ImageKind.RGB_24BPP;
  47055. }
  47056. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47057. imgData.kind = kind;
  47058. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47059. if (this.image instanceof DecodeStream) {
  47060. imgData.data = imgArray;
  47061. } else {
  47062. var newArray = new Uint8Array(imgArray.length);
  47063. newArray.set(imgArray);
  47064. imgData.data = newArray;
  47065. }
  47066. if (this.needsDecode) {
  47067. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47068. var buffer = imgData.data;
  47069. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47070. buffer[i] ^= 0xff;
  47071. }
  47072. }
  47073. return imgData;
  47074. }
  47075. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47076. imgData.kind = ImageKind.RGB_24BPP;
  47077. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47078. return imgData;
  47079. }
  47080. }
  47081. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47082. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47083. var comps = this.getComponents(imgArray);
  47084. var alpha01, maybeUndoPreblend;
  47085. if (!forceRGBA && !this.smask && !this.mask) {
  47086. imgData.kind = ImageKind.RGB_24BPP;
  47087. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47088. alpha01 = 0;
  47089. maybeUndoPreblend = false;
  47090. } else {
  47091. imgData.kind = ImageKind.RGBA_32BPP;
  47092. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47093. alpha01 = 1;
  47094. maybeUndoPreblend = true;
  47095. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47096. }
  47097. if (this.needsDecode) {
  47098. this.decodeBuffer(comps);
  47099. }
  47100. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47101. if (maybeUndoPreblend) {
  47102. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47103. }
  47104. return imgData;
  47105. },
  47106. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47107. var numComps = this.numComps;
  47108. if (numComps !== 1) {
  47109. error('Reading gray scale from a color image: ' + numComps);
  47110. }
  47111. var width = this.width;
  47112. var height = this.height;
  47113. var bpc = this.bpc;
  47114. var rowBytes = width * numComps * bpc + 7 >> 3;
  47115. var imgArray = this.getImageBytes(height * rowBytes);
  47116. var comps = this.getComponents(imgArray);
  47117. var i, length;
  47118. if (bpc === 1) {
  47119. length = width * height;
  47120. if (this.needsDecode) {
  47121. for (i = 0; i < length; ++i) {
  47122. buffer[i] = comps[i] - 1 & 255;
  47123. }
  47124. } else {
  47125. for (i = 0; i < length; ++i) {
  47126. buffer[i] = -comps[i] & 255;
  47127. }
  47128. }
  47129. return;
  47130. }
  47131. if (this.needsDecode) {
  47132. this.decodeBuffer(comps);
  47133. }
  47134. length = width * height;
  47135. var scale = 255 / ((1 << bpc) - 1);
  47136. for (i = 0; i < length; ++i) {
  47137. buffer[i] = scale * comps[i] | 0;
  47138. }
  47139. },
  47140. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47141. this.image.reset();
  47142. this.image.drawWidth = drawWidth || this.width;
  47143. this.image.drawHeight = drawHeight || this.height;
  47144. this.image.forceRGB = !!forceRGB;
  47145. return this.image.getBytes(length);
  47146. }
  47147. };
  47148. return PDFImage;
  47149. }();
  47150. exports.PDFImage = PDFImage;
  47151. /***/ }),
  47152. /* 36 */
  47153. /***/ (function(module, exports, __w_pdfjs_require__) {
  47154. "use strict";
  47155. var sharedUtil = __w_pdfjs_require__(0);
  47156. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47157. var error = sharedUtil.error;
  47158. var log2 = sharedUtil.log2;
  47159. var readInt8 = sharedUtil.readInt8;
  47160. var readUint16 = sharedUtil.readUint16;
  47161. var readUint32 = sharedUtil.readUint32;
  47162. var shadow = sharedUtil.shadow;
  47163. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47164. var Jbig2Image = function Jbig2ImageClosure() {
  47165. function ContextCache() {
  47166. }
  47167. ContextCache.prototype = {
  47168. getContexts: function (id) {
  47169. if (id in this) {
  47170. return this[id];
  47171. }
  47172. return this[id] = new Int8Array(1 << 16);
  47173. }
  47174. };
  47175. function DecodingContext(data, start, end) {
  47176. this.data = data;
  47177. this.start = start;
  47178. this.end = end;
  47179. }
  47180. DecodingContext.prototype = {
  47181. get decoder() {
  47182. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47183. return shadow(this, 'decoder', decoder);
  47184. },
  47185. get contextCache() {
  47186. var cache = new ContextCache();
  47187. return shadow(this, 'contextCache', cache);
  47188. }
  47189. };
  47190. function decodeInteger(contextCache, procedure, decoder) {
  47191. var contexts = contextCache.getContexts(procedure);
  47192. var prev = 1;
  47193. function readBits(length) {
  47194. var v = 0;
  47195. for (var i = 0; i < length; i++) {
  47196. var bit = decoder.readBit(contexts, prev);
  47197. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47198. v = v << 1 | bit;
  47199. }
  47200. return v >>> 0;
  47201. }
  47202. var sign = readBits(1);
  47203. 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);
  47204. return sign === 0 ? value : value > 0 ? -value : null;
  47205. }
  47206. function decodeIAID(contextCache, decoder, codeLength) {
  47207. var contexts = contextCache.getContexts('IAID');
  47208. var prev = 1;
  47209. for (var i = 0; i < codeLength; i++) {
  47210. var bit = decoder.readBit(contexts, prev);
  47211. prev = prev << 1 | bit;
  47212. }
  47213. if (codeLength < 31) {
  47214. return prev & (1 << codeLength) - 1;
  47215. }
  47216. return prev & 0x7FFFFFFF;
  47217. }
  47218. var SegmentTypes = [
  47219. 'SymbolDictionary',
  47220. null,
  47221. null,
  47222. null,
  47223. 'IntermediateTextRegion',
  47224. null,
  47225. 'ImmediateTextRegion',
  47226. 'ImmediateLosslessTextRegion',
  47227. null,
  47228. null,
  47229. null,
  47230. null,
  47231. null,
  47232. null,
  47233. null,
  47234. null,
  47235. 'patternDictionary',
  47236. null,
  47237. null,
  47238. null,
  47239. 'IntermediateHalftoneRegion',
  47240. null,
  47241. 'ImmediateHalftoneRegion',
  47242. 'ImmediateLosslessHalftoneRegion',
  47243. null,
  47244. null,
  47245. null,
  47246. null,
  47247. null,
  47248. null,
  47249. null,
  47250. null,
  47251. null,
  47252. null,
  47253. null,
  47254. null,
  47255. 'IntermediateGenericRegion',
  47256. null,
  47257. 'ImmediateGenericRegion',
  47258. 'ImmediateLosslessGenericRegion',
  47259. 'IntermediateGenericRefinementRegion',
  47260. null,
  47261. 'ImmediateGenericRefinementRegion',
  47262. 'ImmediateLosslessGenericRefinementRegion',
  47263. null,
  47264. null,
  47265. null,
  47266. null,
  47267. 'PageInformation',
  47268. 'EndOfPage',
  47269. 'EndOfStripe',
  47270. 'EndOfFile',
  47271. 'Profiles',
  47272. 'Tables',
  47273. null,
  47274. null,
  47275. null,
  47276. null,
  47277. null,
  47278. null,
  47279. null,
  47280. null,
  47281. 'Extension'
  47282. ];
  47283. var CodingTemplates = [
  47284. [
  47285. {
  47286. x: -1,
  47287. y: -2
  47288. },
  47289. {
  47290. x: 0,
  47291. y: -2
  47292. },
  47293. {
  47294. x: 1,
  47295. y: -2
  47296. },
  47297. {
  47298. x: -2,
  47299. y: -1
  47300. },
  47301. {
  47302. x: -1,
  47303. y: -1
  47304. },
  47305. {
  47306. x: 0,
  47307. y: -1
  47308. },
  47309. {
  47310. x: 1,
  47311. y: -1
  47312. },
  47313. {
  47314. x: 2,
  47315. y: -1
  47316. },
  47317. {
  47318. x: -4,
  47319. y: 0
  47320. },
  47321. {
  47322. x: -3,
  47323. y: 0
  47324. },
  47325. {
  47326. x: -2,
  47327. y: 0
  47328. },
  47329. {
  47330. x: -1,
  47331. y: 0
  47332. }
  47333. ],
  47334. [
  47335. {
  47336. x: -1,
  47337. y: -2
  47338. },
  47339. {
  47340. x: 0,
  47341. y: -2
  47342. },
  47343. {
  47344. x: 1,
  47345. y: -2
  47346. },
  47347. {
  47348. x: 2,
  47349. y: -2
  47350. },
  47351. {
  47352. x: -2,
  47353. y: -1
  47354. },
  47355. {
  47356. x: -1,
  47357. y: -1
  47358. },
  47359. {
  47360. x: 0,
  47361. y: -1
  47362. },
  47363. {
  47364. x: 1,
  47365. y: -1
  47366. },
  47367. {
  47368. x: 2,
  47369. y: -1
  47370. },
  47371. {
  47372. x: -3,
  47373. y: 0
  47374. },
  47375. {
  47376. x: -2,
  47377. y: 0
  47378. },
  47379. {
  47380. x: -1,
  47381. y: 0
  47382. }
  47383. ],
  47384. [
  47385. {
  47386. x: -1,
  47387. y: -2
  47388. },
  47389. {
  47390. x: 0,
  47391. y: -2
  47392. },
  47393. {
  47394. x: 1,
  47395. y: -2
  47396. },
  47397. {
  47398. x: -2,
  47399. y: -1
  47400. },
  47401. {
  47402. x: -1,
  47403. y: -1
  47404. },
  47405. {
  47406. x: 0,
  47407. y: -1
  47408. },
  47409. {
  47410. x: 1,
  47411. y: -1
  47412. },
  47413. {
  47414. x: -2,
  47415. y: 0
  47416. },
  47417. {
  47418. x: -1,
  47419. y: 0
  47420. }
  47421. ],
  47422. [
  47423. {
  47424. x: -3,
  47425. y: -1
  47426. },
  47427. {
  47428. x: -2,
  47429. y: -1
  47430. },
  47431. {
  47432. x: -1,
  47433. y: -1
  47434. },
  47435. {
  47436. x: 0,
  47437. y: -1
  47438. },
  47439. {
  47440. x: 1,
  47441. y: -1
  47442. },
  47443. {
  47444. x: -4,
  47445. y: 0
  47446. },
  47447. {
  47448. x: -3,
  47449. y: 0
  47450. },
  47451. {
  47452. x: -2,
  47453. y: 0
  47454. },
  47455. {
  47456. x: -1,
  47457. y: 0
  47458. }
  47459. ]
  47460. ];
  47461. var RefinementTemplates = [
  47462. {
  47463. coding: [
  47464. {
  47465. x: 0,
  47466. y: -1
  47467. },
  47468. {
  47469. x: 1,
  47470. y: -1
  47471. },
  47472. {
  47473. x: -1,
  47474. y: 0
  47475. }
  47476. ],
  47477. reference: [
  47478. {
  47479. x: 0,
  47480. y: -1
  47481. },
  47482. {
  47483. x: 1,
  47484. y: -1
  47485. },
  47486. {
  47487. x: -1,
  47488. y: 0
  47489. },
  47490. {
  47491. x: 0,
  47492. y: 0
  47493. },
  47494. {
  47495. x: 1,
  47496. y: 0
  47497. },
  47498. {
  47499. x: -1,
  47500. y: 1
  47501. },
  47502. {
  47503. x: 0,
  47504. y: 1
  47505. },
  47506. {
  47507. x: 1,
  47508. y: 1
  47509. }
  47510. ]
  47511. },
  47512. {
  47513. coding: [
  47514. {
  47515. x: -1,
  47516. y: -1
  47517. },
  47518. {
  47519. x: 0,
  47520. y: -1
  47521. },
  47522. {
  47523. x: 1,
  47524. y: -1
  47525. },
  47526. {
  47527. x: -1,
  47528. y: 0
  47529. }
  47530. ],
  47531. reference: [
  47532. {
  47533. x: 0,
  47534. y: -1
  47535. },
  47536. {
  47537. x: -1,
  47538. y: 0
  47539. },
  47540. {
  47541. x: 0,
  47542. y: 0
  47543. },
  47544. {
  47545. x: 1,
  47546. y: 0
  47547. },
  47548. {
  47549. x: 0,
  47550. y: 1
  47551. },
  47552. {
  47553. x: 1,
  47554. y: 1
  47555. }
  47556. ]
  47557. }
  47558. ];
  47559. var ReusedContexts = [
  47560. 0x9B25,
  47561. 0x0795,
  47562. 0x00E5,
  47563. 0x0195
  47564. ];
  47565. var RefinementReusedContexts = [
  47566. 0x0020,
  47567. 0x0008
  47568. ];
  47569. function decodeBitmapTemplate0(width, height, decodingContext) {
  47570. var decoder = decodingContext.decoder;
  47571. var contexts = decodingContext.contextCache.getContexts('GB');
  47572. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47573. var OLD_PIXEL_MASK = 0x7BF7;
  47574. for (i = 0; i < height; i++) {
  47575. row = bitmap[i] = new Uint8Array(width);
  47576. row1 = i < 1 ? row : bitmap[i - 1];
  47577. row2 = i < 2 ? row : bitmap[i - 2];
  47578. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47579. for (j = 0; j < width; j++) {
  47580. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47581. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47582. }
  47583. }
  47584. return bitmap;
  47585. }
  47586. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47587. if (mmr) {
  47588. error('JBIG2 error: MMR encoding is not supported');
  47589. }
  47590. 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) {
  47591. return decodeBitmapTemplate0(width, height, decodingContext);
  47592. }
  47593. var useskip = !!skip;
  47594. var template = CodingTemplates[templateIndex].concat(at);
  47595. template.sort(function (a, b) {
  47596. return a.y - b.y || a.x - b.x;
  47597. });
  47598. var templateLength = template.length;
  47599. var templateX = new Int8Array(templateLength);
  47600. var templateY = new Int8Array(templateLength);
  47601. var changingTemplateEntries = [];
  47602. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47603. var c, k;
  47604. for (k = 0; k < templateLength; k++) {
  47605. templateX[k] = template[k].x;
  47606. templateY[k] = template[k].y;
  47607. minX = Math.min(minX, template[k].x);
  47608. maxX = Math.max(maxX, template[k].x);
  47609. minY = Math.min(minY, template[k].y);
  47610. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47611. reuseMask |= 1 << templateLength - 1 - k;
  47612. } else {
  47613. changingTemplateEntries.push(k);
  47614. }
  47615. }
  47616. var changingEntriesLength = changingTemplateEntries.length;
  47617. var changingTemplateX = new Int8Array(changingEntriesLength);
  47618. var changingTemplateY = new Int8Array(changingEntriesLength);
  47619. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47620. for (c = 0; c < changingEntriesLength; c++) {
  47621. k = changingTemplateEntries[c];
  47622. changingTemplateX[c] = template[k].x;
  47623. changingTemplateY[c] = template[k].y;
  47624. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47625. }
  47626. var sbb_left = -minX;
  47627. var sbb_top = -minY;
  47628. var sbb_right = width - maxX;
  47629. var pseudoPixelContext = ReusedContexts[templateIndex];
  47630. var row = new Uint8Array(width);
  47631. var bitmap = [];
  47632. var decoder = decodingContext.decoder;
  47633. var contexts = decodingContext.contextCache.getContexts('GB');
  47634. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47635. for (var i = 0; i < height; i++) {
  47636. if (prediction) {
  47637. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47638. ltp ^= sltp;
  47639. if (ltp) {
  47640. bitmap.push(row);
  47641. continue;
  47642. }
  47643. }
  47644. row = new Uint8Array(row);
  47645. bitmap.push(row);
  47646. for (j = 0; j < width; j++) {
  47647. if (useskip && skip[i][j]) {
  47648. row[j] = 0;
  47649. continue;
  47650. }
  47651. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47652. contextLabel = contextLabel << 1 & reuseMask;
  47653. for (k = 0; k < changingEntriesLength; k++) {
  47654. i0 = i + changingTemplateY[k];
  47655. j0 = j + changingTemplateX[k];
  47656. bit = bitmap[i0][j0];
  47657. if (bit) {
  47658. bit = changingTemplateBit[k];
  47659. contextLabel |= bit;
  47660. }
  47661. }
  47662. } else {
  47663. contextLabel = 0;
  47664. shift = templateLength - 1;
  47665. for (k = 0; k < templateLength; k++, shift--) {
  47666. j0 = j + templateX[k];
  47667. if (j0 >= 0 && j0 < width) {
  47668. i0 = i + templateY[k];
  47669. if (i0 >= 0) {
  47670. bit = bitmap[i0][j0];
  47671. if (bit) {
  47672. contextLabel |= bit << shift;
  47673. }
  47674. }
  47675. }
  47676. }
  47677. }
  47678. var pixel = decoder.readBit(contexts, contextLabel);
  47679. row[j] = pixel;
  47680. }
  47681. }
  47682. return bitmap;
  47683. }
  47684. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47685. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47686. if (templateIndex === 0) {
  47687. codingTemplate = codingTemplate.concat([at[0]]);
  47688. }
  47689. var codingTemplateLength = codingTemplate.length;
  47690. var codingTemplateX = new Int32Array(codingTemplateLength);
  47691. var codingTemplateY = new Int32Array(codingTemplateLength);
  47692. var k;
  47693. for (k = 0; k < codingTemplateLength; k++) {
  47694. codingTemplateX[k] = codingTemplate[k].x;
  47695. codingTemplateY[k] = codingTemplate[k].y;
  47696. }
  47697. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47698. if (templateIndex === 0) {
  47699. referenceTemplate = referenceTemplate.concat([at[1]]);
  47700. }
  47701. var referenceTemplateLength = referenceTemplate.length;
  47702. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47703. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47704. for (k = 0; k < referenceTemplateLength; k++) {
  47705. referenceTemplateX[k] = referenceTemplate[k].x;
  47706. referenceTemplateY[k] = referenceTemplate[k].y;
  47707. }
  47708. var referenceWidth = referenceBitmap[0].length;
  47709. var referenceHeight = referenceBitmap.length;
  47710. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47711. var bitmap = [];
  47712. var decoder = decodingContext.decoder;
  47713. var contexts = decodingContext.contextCache.getContexts('GR');
  47714. var ltp = 0;
  47715. for (var i = 0; i < height; i++) {
  47716. if (prediction) {
  47717. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47718. ltp ^= sltp;
  47719. if (ltp) {
  47720. error('JBIG2 error: prediction is not supported');
  47721. }
  47722. }
  47723. var row = new Uint8Array(width);
  47724. bitmap.push(row);
  47725. for (var j = 0; j < width; j++) {
  47726. var i0, j0;
  47727. var contextLabel = 0;
  47728. for (k = 0; k < codingTemplateLength; k++) {
  47729. i0 = i + codingTemplateY[k];
  47730. j0 = j + codingTemplateX[k];
  47731. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47732. contextLabel <<= 1;
  47733. } else {
  47734. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47735. }
  47736. }
  47737. for (k = 0; k < referenceTemplateLength; k++) {
  47738. i0 = i + referenceTemplateY[k] + offsetY;
  47739. j0 = j + referenceTemplateX[k] + offsetX;
  47740. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47741. contextLabel <<= 1;
  47742. } else {
  47743. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47744. }
  47745. }
  47746. var pixel = decoder.readBit(contexts, contextLabel);
  47747. row[j] = pixel;
  47748. }
  47749. }
  47750. return bitmap;
  47751. }
  47752. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47753. if (huffman) {
  47754. error('JBIG2 error: huffman is not supported');
  47755. }
  47756. var newSymbols = [];
  47757. var currentHeight = 0;
  47758. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47759. var decoder = decodingContext.decoder;
  47760. var contextCache = decodingContext.contextCache;
  47761. while (newSymbols.length < numberOfNewSymbols) {
  47762. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47763. currentHeight += deltaHeight;
  47764. var currentWidth = 0;
  47765. while (true) {
  47766. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47767. if (deltaWidth === null) {
  47768. break;
  47769. }
  47770. currentWidth += deltaWidth;
  47771. var bitmap;
  47772. if (refinement) {
  47773. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47774. if (numberOfInstances > 1) {
  47775. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47776. } else {
  47777. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47778. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47779. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47780. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47781. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47782. }
  47783. } else {
  47784. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47785. }
  47786. newSymbols.push(bitmap);
  47787. }
  47788. }
  47789. var exportedSymbols = [];
  47790. var flags = [], currentFlag = false;
  47791. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47792. while (flags.length < totalSymbolsLength) {
  47793. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47794. while (runLength--) {
  47795. flags.push(currentFlag);
  47796. }
  47797. currentFlag = !currentFlag;
  47798. }
  47799. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47800. if (flags[i]) {
  47801. exportedSymbols.push(symbols[i]);
  47802. }
  47803. }
  47804. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47805. if (flags[i]) {
  47806. exportedSymbols.push(newSymbols[j]);
  47807. }
  47808. }
  47809. return exportedSymbols;
  47810. }
  47811. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47812. if (huffman) {
  47813. error('JBIG2 error: huffman is not supported');
  47814. }
  47815. var bitmap = [];
  47816. var i, row;
  47817. for (i = 0; i < height; i++) {
  47818. row = new Uint8Array(width);
  47819. if (defaultPixelValue) {
  47820. for (var j = 0; j < width; j++) {
  47821. row[j] = defaultPixelValue;
  47822. }
  47823. }
  47824. bitmap.push(row);
  47825. }
  47826. var decoder = decodingContext.decoder;
  47827. var contextCache = decodingContext.contextCache;
  47828. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47829. var firstS = 0;
  47830. i = 0;
  47831. while (i < numberOfSymbolInstances) {
  47832. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47833. stripT += deltaT;
  47834. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47835. firstS += deltaFirstS;
  47836. var currentS = firstS;
  47837. do {
  47838. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47839. var t = stripSize * stripT + currentT;
  47840. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47841. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47842. var symbolBitmap = inputSymbols[symbolId];
  47843. var symbolWidth = symbolBitmap[0].length;
  47844. var symbolHeight = symbolBitmap.length;
  47845. if (applyRefinement) {
  47846. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47847. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47848. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47849. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47850. symbolWidth += rdw;
  47851. symbolHeight += rdh;
  47852. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47853. }
  47854. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47855. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47856. var s2, t2, symbolRow;
  47857. if (transposed) {
  47858. for (s2 = 0; s2 < symbolHeight; s2++) {
  47859. row = bitmap[offsetS + s2];
  47860. if (!row) {
  47861. continue;
  47862. }
  47863. symbolRow = symbolBitmap[s2];
  47864. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47865. switch (combinationOperator) {
  47866. case 0:
  47867. for (t2 = 0; t2 < maxWidth; t2++) {
  47868. row[offsetT + t2] |= symbolRow[t2];
  47869. }
  47870. break;
  47871. case 2:
  47872. for (t2 = 0; t2 < maxWidth; t2++) {
  47873. row[offsetT + t2] ^= symbolRow[t2];
  47874. }
  47875. break;
  47876. default:
  47877. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47878. }
  47879. }
  47880. currentS += symbolHeight - 1;
  47881. } else {
  47882. for (t2 = 0; t2 < symbolHeight; t2++) {
  47883. row = bitmap[offsetT + t2];
  47884. if (!row) {
  47885. continue;
  47886. }
  47887. symbolRow = symbolBitmap[t2];
  47888. switch (combinationOperator) {
  47889. case 0:
  47890. for (s2 = 0; s2 < symbolWidth; s2++) {
  47891. row[offsetS + s2] |= symbolRow[s2];
  47892. }
  47893. break;
  47894. case 2:
  47895. for (s2 = 0; s2 < symbolWidth; s2++) {
  47896. row[offsetS + s2] ^= symbolRow[s2];
  47897. }
  47898. break;
  47899. default:
  47900. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47901. }
  47902. }
  47903. currentS += symbolWidth - 1;
  47904. }
  47905. i++;
  47906. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47907. if (deltaS === null) {
  47908. break;
  47909. }
  47910. currentS += deltaS + dsOffset;
  47911. } while (true);
  47912. }
  47913. return bitmap;
  47914. }
  47915. function readSegmentHeader(data, start) {
  47916. var segmentHeader = {};
  47917. segmentHeader.number = readUint32(data, start);
  47918. var flags = data[start + 4];
  47919. var segmentType = flags & 0x3F;
  47920. if (!SegmentTypes[segmentType]) {
  47921. error('JBIG2 error: invalid segment type: ' + segmentType);
  47922. }
  47923. segmentHeader.type = segmentType;
  47924. segmentHeader.typeName = SegmentTypes[segmentType];
  47925. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47926. var pageAssociationFieldSize = !!(flags & 0x40);
  47927. var referredFlags = data[start + 5];
  47928. var referredToCount = referredFlags >> 5 & 7;
  47929. var retainBits = [referredFlags & 31];
  47930. var position = start + 6;
  47931. if (referredFlags === 7) {
  47932. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47933. position += 3;
  47934. var bytes = referredToCount + 7 >> 3;
  47935. retainBits[0] = data[position++];
  47936. while (--bytes > 0) {
  47937. retainBits.push(data[position++]);
  47938. }
  47939. } else if (referredFlags === 5 || referredFlags === 6) {
  47940. error('JBIG2 error: invalid referred-to flags');
  47941. }
  47942. segmentHeader.retainBits = retainBits;
  47943. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47944. var referredTo = [];
  47945. var i, ii;
  47946. for (i = 0; i < referredToCount; i++) {
  47947. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47948. referredTo.push(number);
  47949. position += referredToSegmentNumberSize;
  47950. }
  47951. segmentHeader.referredTo = referredTo;
  47952. if (!pageAssociationFieldSize) {
  47953. segmentHeader.pageAssociation = data[position++];
  47954. } else {
  47955. segmentHeader.pageAssociation = readUint32(data, position);
  47956. position += 4;
  47957. }
  47958. segmentHeader.length = readUint32(data, position);
  47959. position += 4;
  47960. if (segmentHeader.length === 0xFFFFFFFF) {
  47961. if (segmentType === 38) {
  47962. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47963. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47964. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47965. var searchPatternLength = 6;
  47966. var searchPattern = new Uint8Array(searchPatternLength);
  47967. if (!genericRegionMmr) {
  47968. searchPattern[0] = 0xFF;
  47969. searchPattern[1] = 0xAC;
  47970. }
  47971. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47972. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47973. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47974. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47975. for (i = position, ii = data.length; i < ii; i++) {
  47976. var j = 0;
  47977. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47978. j++;
  47979. }
  47980. if (j === searchPatternLength) {
  47981. segmentHeader.length = i + searchPatternLength;
  47982. break;
  47983. }
  47984. }
  47985. if (segmentHeader.length === 0xFFFFFFFF) {
  47986. error('JBIG2 error: segment end was not found');
  47987. }
  47988. } else {
  47989. error('JBIG2 error: invalid unknown segment length');
  47990. }
  47991. }
  47992. segmentHeader.headerEnd = position;
  47993. return segmentHeader;
  47994. }
  47995. function readSegments(header, data, start, end) {
  47996. var segments = [];
  47997. var position = start;
  47998. while (position < end) {
  47999. var segmentHeader = readSegmentHeader(data, position);
  48000. position = segmentHeader.headerEnd;
  48001. var segment = {
  48002. header: segmentHeader,
  48003. data: data
  48004. };
  48005. if (!header.randomAccess) {
  48006. segment.start = position;
  48007. position += segmentHeader.length;
  48008. segment.end = position;
  48009. }
  48010. segments.push(segment);
  48011. if (segmentHeader.type === 51) {
  48012. break;
  48013. }
  48014. }
  48015. if (header.randomAccess) {
  48016. for (var i = 0, ii = segments.length; i < ii; i++) {
  48017. segments[i].start = position;
  48018. position += segments[i].header.length;
  48019. segments[i].end = position;
  48020. }
  48021. }
  48022. return segments;
  48023. }
  48024. function readRegionSegmentInformation(data, start) {
  48025. return {
  48026. width: readUint32(data, start),
  48027. height: readUint32(data, start + 4),
  48028. x: readUint32(data, start + 8),
  48029. y: readUint32(data, start + 12),
  48030. combinationOperator: data[start + 16] & 7
  48031. };
  48032. }
  48033. var RegionSegmentInformationFieldLength = 17;
  48034. function processSegment(segment, visitor) {
  48035. var header = segment.header;
  48036. var data = segment.data, position = segment.start, end = segment.end;
  48037. var args, at, i, atLength;
  48038. switch (header.type) {
  48039. case 0:
  48040. var dictionary = {};
  48041. var dictionaryFlags = readUint16(data, position);
  48042. dictionary.huffman = !!(dictionaryFlags & 1);
  48043. dictionary.refinement = !!(dictionaryFlags & 2);
  48044. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48045. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48046. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48047. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48048. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48049. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48050. dictionary.template = dictionaryFlags >> 10 & 3;
  48051. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48052. position += 2;
  48053. if (!dictionary.huffman) {
  48054. atLength = dictionary.template === 0 ? 4 : 1;
  48055. at = [];
  48056. for (i = 0; i < atLength; i++) {
  48057. at.push({
  48058. x: readInt8(data, position),
  48059. y: readInt8(data, position + 1)
  48060. });
  48061. position += 2;
  48062. }
  48063. dictionary.at = at;
  48064. }
  48065. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48066. at = [];
  48067. for (i = 0; i < 2; i++) {
  48068. at.push({
  48069. x: readInt8(data, position),
  48070. y: readInt8(data, position + 1)
  48071. });
  48072. position += 2;
  48073. }
  48074. dictionary.refinementAt = at;
  48075. }
  48076. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48077. position += 4;
  48078. dictionary.numberOfNewSymbols = readUint32(data, position);
  48079. position += 4;
  48080. args = [
  48081. dictionary,
  48082. header.number,
  48083. header.referredTo,
  48084. data,
  48085. position,
  48086. end
  48087. ];
  48088. break;
  48089. case 6:
  48090. case 7:
  48091. var textRegion = {};
  48092. textRegion.info = readRegionSegmentInformation(data, position);
  48093. position += RegionSegmentInformationFieldLength;
  48094. var textRegionSegmentFlags = readUint16(data, position);
  48095. position += 2;
  48096. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48097. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48098. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48099. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48100. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48101. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48102. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48103. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48104. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48105. if (textRegion.huffman) {
  48106. var textRegionHuffmanFlags = readUint16(data, position);
  48107. position += 2;
  48108. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48109. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48110. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48111. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48112. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48113. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48114. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48115. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48116. }
  48117. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48118. at = [];
  48119. for (i = 0; i < 2; i++) {
  48120. at.push({
  48121. x: readInt8(data, position),
  48122. y: readInt8(data, position + 1)
  48123. });
  48124. position += 2;
  48125. }
  48126. textRegion.refinementAt = at;
  48127. }
  48128. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48129. position += 4;
  48130. if (textRegion.huffman) {
  48131. error('JBIG2 error: huffman is not supported');
  48132. }
  48133. args = [
  48134. textRegion,
  48135. header.referredTo,
  48136. data,
  48137. position,
  48138. end
  48139. ];
  48140. break;
  48141. case 38:
  48142. case 39:
  48143. var genericRegion = {};
  48144. genericRegion.info = readRegionSegmentInformation(data, position);
  48145. position += RegionSegmentInformationFieldLength;
  48146. var genericRegionSegmentFlags = data[position++];
  48147. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48148. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48149. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48150. if (!genericRegion.mmr) {
  48151. atLength = genericRegion.template === 0 ? 4 : 1;
  48152. at = [];
  48153. for (i = 0; i < atLength; i++) {
  48154. at.push({
  48155. x: readInt8(data, position),
  48156. y: readInt8(data, position + 1)
  48157. });
  48158. position += 2;
  48159. }
  48160. genericRegion.at = at;
  48161. }
  48162. args = [
  48163. genericRegion,
  48164. data,
  48165. position,
  48166. end
  48167. ];
  48168. break;
  48169. case 48:
  48170. var pageInfo = {
  48171. width: readUint32(data, position),
  48172. height: readUint32(data, position + 4),
  48173. resolutionX: readUint32(data, position + 8),
  48174. resolutionY: readUint32(data, position + 12)
  48175. };
  48176. if (pageInfo.height === 0xFFFFFFFF) {
  48177. delete pageInfo.height;
  48178. }
  48179. var pageSegmentFlags = data[position + 16];
  48180. readUint16(data, position + 17);
  48181. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48182. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48183. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48184. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48185. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48186. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48187. args = [pageInfo];
  48188. break;
  48189. case 49:
  48190. break;
  48191. case 50:
  48192. break;
  48193. case 51:
  48194. break;
  48195. case 62:
  48196. break;
  48197. default:
  48198. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48199. }
  48200. var callbackName = 'on' + header.typeName;
  48201. if (callbackName in visitor) {
  48202. visitor[callbackName].apply(visitor, args);
  48203. }
  48204. }
  48205. function processSegments(segments, visitor) {
  48206. for (var i = 0, ii = segments.length; i < ii; i++) {
  48207. processSegment(segments[i], visitor);
  48208. }
  48209. }
  48210. function parseJbig2(data, start, end) {
  48211. var position = start;
  48212. 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) {
  48213. error('JBIG2 error: invalid header');
  48214. }
  48215. var header = {};
  48216. position += 8;
  48217. var flags = data[position++];
  48218. header.randomAccess = !(flags & 1);
  48219. if (!(flags & 2)) {
  48220. header.numberOfPages = readUint32(data, position);
  48221. position += 4;
  48222. }
  48223. readSegments(header, data, position, end);
  48224. error('Not implemented');
  48225. }
  48226. function parseJbig2Chunks(chunks) {
  48227. var visitor = new SimpleSegmentVisitor();
  48228. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48229. var chunk = chunks[i];
  48230. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48231. processSegments(segments, visitor);
  48232. }
  48233. return visitor.buffer;
  48234. }
  48235. function SimpleSegmentVisitor() {
  48236. }
  48237. SimpleSegmentVisitor.prototype = {
  48238. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48239. this.currentPageInfo = info;
  48240. var rowSize = info.width + 7 >> 3;
  48241. var buffer = new Uint8Array(rowSize * info.height);
  48242. if (info.defaultPixelValue) {
  48243. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48244. buffer[i] = 0xFF;
  48245. }
  48246. }
  48247. this.buffer = buffer;
  48248. },
  48249. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48250. var pageInfo = this.currentPageInfo;
  48251. var width = regionInfo.width, height = regionInfo.height;
  48252. var rowSize = pageInfo.width + 7 >> 3;
  48253. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48254. var buffer = this.buffer;
  48255. var mask0 = 128 >> (regionInfo.x & 7);
  48256. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48257. var i, j, mask, offset;
  48258. switch (combinationOperator) {
  48259. case 0:
  48260. for (i = 0; i < height; i++) {
  48261. mask = mask0;
  48262. offset = offset0;
  48263. for (j = 0; j < width; j++) {
  48264. if (bitmap[i][j]) {
  48265. buffer[offset] |= mask;
  48266. }
  48267. mask >>= 1;
  48268. if (!mask) {
  48269. mask = 128;
  48270. offset++;
  48271. }
  48272. }
  48273. offset0 += rowSize;
  48274. }
  48275. break;
  48276. case 2:
  48277. for (i = 0; i < height; i++) {
  48278. mask = mask0;
  48279. offset = offset0;
  48280. for (j = 0; j < width; j++) {
  48281. if (bitmap[i][j]) {
  48282. buffer[offset] ^= mask;
  48283. }
  48284. mask >>= 1;
  48285. if (!mask) {
  48286. mask = 128;
  48287. offset++;
  48288. }
  48289. }
  48290. offset0 += rowSize;
  48291. }
  48292. break;
  48293. default:
  48294. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48295. }
  48296. },
  48297. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48298. var regionInfo = region.info;
  48299. var decodingContext = new DecodingContext(data, start, end);
  48300. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48301. this.drawBitmap(regionInfo, bitmap);
  48302. },
  48303. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48304. this.onImmediateGenericRegion.apply(this, arguments);
  48305. },
  48306. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48307. var huffmanTables;
  48308. if (dictionary.huffman) {
  48309. error('JBIG2 error: huffman is not supported');
  48310. }
  48311. var symbols = this.symbols;
  48312. if (!symbols) {
  48313. this.symbols = symbols = {};
  48314. }
  48315. var inputSymbols = [];
  48316. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48317. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48318. }
  48319. var decodingContext = new DecodingContext(data, start, end);
  48320. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48321. },
  48322. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48323. var regionInfo = region.info;
  48324. var huffmanTables;
  48325. var symbols = this.symbols;
  48326. var inputSymbols = [];
  48327. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48328. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48329. }
  48330. var symbolCodeLength = log2(inputSymbols.length);
  48331. var decodingContext = new DecodingContext(data, start, end);
  48332. 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);
  48333. this.drawBitmap(regionInfo, bitmap);
  48334. },
  48335. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48336. this.onImmediateTextRegion.apply(this, arguments);
  48337. }
  48338. };
  48339. function Jbig2Image() {
  48340. }
  48341. Jbig2Image.prototype = {
  48342. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48343. return parseJbig2Chunks(chunks);
  48344. }
  48345. };
  48346. return Jbig2Image;
  48347. }();
  48348. exports.Jbig2Image = Jbig2Image;
  48349. /***/ }),
  48350. /* 37 */
  48351. /***/ (function(module, exports, __w_pdfjs_require__) {
  48352. "use strict";
  48353. var sharedUtil = __w_pdfjs_require__(0);
  48354. var error = sharedUtil.error;
  48355. var JpegImage = function JpegImageClosure() {
  48356. var dctZigZag = new Uint8Array([
  48357. 0,
  48358. 1,
  48359. 8,
  48360. 16,
  48361. 9,
  48362. 2,
  48363. 3,
  48364. 10,
  48365. 17,
  48366. 24,
  48367. 32,
  48368. 25,
  48369. 18,
  48370. 11,
  48371. 4,
  48372. 5,
  48373. 12,
  48374. 19,
  48375. 26,
  48376. 33,
  48377. 40,
  48378. 48,
  48379. 41,
  48380. 34,
  48381. 27,
  48382. 20,
  48383. 13,
  48384. 6,
  48385. 7,
  48386. 14,
  48387. 21,
  48388. 28,
  48389. 35,
  48390. 42,
  48391. 49,
  48392. 56,
  48393. 57,
  48394. 50,
  48395. 43,
  48396. 36,
  48397. 29,
  48398. 22,
  48399. 15,
  48400. 23,
  48401. 30,
  48402. 37,
  48403. 44,
  48404. 51,
  48405. 58,
  48406. 59,
  48407. 52,
  48408. 45,
  48409. 38,
  48410. 31,
  48411. 39,
  48412. 46,
  48413. 53,
  48414. 60,
  48415. 61,
  48416. 54,
  48417. 47,
  48418. 55,
  48419. 62,
  48420. 63
  48421. ]);
  48422. var dctCos1 = 4017;
  48423. var dctSin1 = 799;
  48424. var dctCos3 = 3406;
  48425. var dctSin3 = 2276;
  48426. var dctCos6 = 1567;
  48427. var dctSin6 = 3784;
  48428. var dctSqrt2 = 5793;
  48429. var dctSqrt1d2 = 2896;
  48430. function JpegImage() {
  48431. this.decodeTransform = null;
  48432. this.colorTransform = -1;
  48433. }
  48434. function buildHuffmanTable(codeLengths, values) {
  48435. var k = 0, code = [], i, j, length = 16;
  48436. while (length > 0 && !codeLengths[length - 1]) {
  48437. length--;
  48438. }
  48439. code.push({
  48440. children: [],
  48441. index: 0
  48442. });
  48443. var p = code[0], q;
  48444. for (i = 0; i < length; i++) {
  48445. for (j = 0; j < codeLengths[i]; j++) {
  48446. p = code.pop();
  48447. p.children[p.index] = values[k];
  48448. while (p.index > 0) {
  48449. p = code.pop();
  48450. }
  48451. p.index++;
  48452. code.push(p);
  48453. while (code.length <= i) {
  48454. code.push(q = {
  48455. children: [],
  48456. index: 0
  48457. });
  48458. p.children[p.index] = q.children;
  48459. p = q;
  48460. }
  48461. k++;
  48462. }
  48463. if (i + 1 < length) {
  48464. code.push(q = {
  48465. children: [],
  48466. index: 0
  48467. });
  48468. p.children[p.index] = q.children;
  48469. p = q;
  48470. }
  48471. }
  48472. return code[0].children;
  48473. }
  48474. function getBlockBufferOffset(component, row, col) {
  48475. return 64 * ((component.blocksPerLine + 1) * row + col);
  48476. }
  48477. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48478. var mcusPerLine = frame.mcusPerLine;
  48479. var progressive = frame.progressive;
  48480. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48481. function readBit() {
  48482. if (bitsCount > 0) {
  48483. bitsCount--;
  48484. return bitsData >> bitsCount & 1;
  48485. }
  48486. bitsData = data[offset++];
  48487. if (bitsData === 0xFF) {
  48488. var nextByte = data[offset++];
  48489. if (nextByte) {
  48490. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48491. }
  48492. }
  48493. bitsCount = 7;
  48494. return bitsData >>> 7;
  48495. }
  48496. function decodeHuffman(tree) {
  48497. var node = tree;
  48498. while (true) {
  48499. node = node[readBit()];
  48500. if (typeof node === 'number') {
  48501. return node;
  48502. }
  48503. if (typeof node !== 'object') {
  48504. error('JPEG error: invalid huffman sequence');
  48505. }
  48506. }
  48507. }
  48508. function receive(length) {
  48509. var n = 0;
  48510. while (length > 0) {
  48511. n = n << 1 | readBit();
  48512. length--;
  48513. }
  48514. return n;
  48515. }
  48516. function receiveAndExtend(length) {
  48517. if (length === 1) {
  48518. return readBit() === 1 ? 1 : -1;
  48519. }
  48520. var n = receive(length);
  48521. if (n >= 1 << length - 1) {
  48522. return n;
  48523. }
  48524. return n + (-1 << length) + 1;
  48525. }
  48526. function decodeBaseline(component, offset) {
  48527. var t = decodeHuffman(component.huffmanTableDC);
  48528. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48529. component.blockData[offset] = component.pred += diff;
  48530. var k = 1;
  48531. while (k < 64) {
  48532. var rs = decodeHuffman(component.huffmanTableAC);
  48533. var s = rs & 15, r = rs >> 4;
  48534. if (s === 0) {
  48535. if (r < 15) {
  48536. break;
  48537. }
  48538. k += 16;
  48539. continue;
  48540. }
  48541. k += r;
  48542. var z = dctZigZag[k];
  48543. component.blockData[offset + z] = receiveAndExtend(s);
  48544. k++;
  48545. }
  48546. }
  48547. function decodeDCFirst(component, offset) {
  48548. var t = decodeHuffman(component.huffmanTableDC);
  48549. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48550. component.blockData[offset] = component.pred += diff;
  48551. }
  48552. function decodeDCSuccessive(component, offset) {
  48553. component.blockData[offset] |= readBit() << successive;
  48554. }
  48555. var eobrun = 0;
  48556. function decodeACFirst(component, offset) {
  48557. if (eobrun > 0) {
  48558. eobrun--;
  48559. return;
  48560. }
  48561. var k = spectralStart, e = spectralEnd;
  48562. while (k <= e) {
  48563. var rs = decodeHuffman(component.huffmanTableAC);
  48564. var s = rs & 15, r = rs >> 4;
  48565. if (s === 0) {
  48566. if (r < 15) {
  48567. eobrun = receive(r) + (1 << r) - 1;
  48568. break;
  48569. }
  48570. k += 16;
  48571. continue;
  48572. }
  48573. k += r;
  48574. var z = dctZigZag[k];
  48575. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48576. k++;
  48577. }
  48578. }
  48579. var successiveACState = 0, successiveACNextValue;
  48580. function decodeACSuccessive(component, offset) {
  48581. var k = spectralStart;
  48582. var e = spectralEnd;
  48583. var r = 0;
  48584. var s;
  48585. var rs;
  48586. while (k <= e) {
  48587. var z = dctZigZag[k];
  48588. switch (successiveACState) {
  48589. case 0:
  48590. rs = decodeHuffman(component.huffmanTableAC);
  48591. s = rs & 15;
  48592. r = rs >> 4;
  48593. if (s === 0) {
  48594. if (r < 15) {
  48595. eobrun = receive(r) + (1 << r);
  48596. successiveACState = 4;
  48597. } else {
  48598. r = 16;
  48599. successiveACState = 1;
  48600. }
  48601. } else {
  48602. if (s !== 1) {
  48603. error('JPEG error: invalid ACn encoding');
  48604. }
  48605. successiveACNextValue = receiveAndExtend(s);
  48606. successiveACState = r ? 2 : 3;
  48607. }
  48608. continue;
  48609. case 1:
  48610. case 2:
  48611. if (component.blockData[offset + z]) {
  48612. component.blockData[offset + z] += readBit() << successive;
  48613. } else {
  48614. r--;
  48615. if (r === 0) {
  48616. successiveACState = successiveACState === 2 ? 3 : 0;
  48617. }
  48618. }
  48619. break;
  48620. case 3:
  48621. if (component.blockData[offset + z]) {
  48622. component.blockData[offset + z] += readBit() << successive;
  48623. } else {
  48624. component.blockData[offset + z] = successiveACNextValue << successive;
  48625. successiveACState = 0;
  48626. }
  48627. break;
  48628. case 4:
  48629. if (component.blockData[offset + z]) {
  48630. component.blockData[offset + z] += readBit() << successive;
  48631. }
  48632. break;
  48633. }
  48634. k++;
  48635. }
  48636. if (successiveACState === 4) {
  48637. eobrun--;
  48638. if (eobrun === 0) {
  48639. successiveACState = 0;
  48640. }
  48641. }
  48642. }
  48643. function decodeMcu(component, decode, mcu, row, col) {
  48644. var mcuRow = mcu / mcusPerLine | 0;
  48645. var mcuCol = mcu % mcusPerLine;
  48646. var blockRow = mcuRow * component.v + row;
  48647. var blockCol = mcuCol * component.h + col;
  48648. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48649. decode(component, offset);
  48650. }
  48651. function decodeBlock(component, decode, mcu) {
  48652. var blockRow = mcu / component.blocksPerLine | 0;
  48653. var blockCol = mcu % component.blocksPerLine;
  48654. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48655. decode(component, offset);
  48656. }
  48657. var componentsLength = components.length;
  48658. var component, i, j, k, n;
  48659. var decodeFn;
  48660. if (progressive) {
  48661. if (spectralStart === 0) {
  48662. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48663. } else {
  48664. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48665. }
  48666. } else {
  48667. decodeFn = decodeBaseline;
  48668. }
  48669. var mcu = 0, marker;
  48670. var mcuExpected;
  48671. if (componentsLength === 1) {
  48672. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48673. } else {
  48674. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48675. }
  48676. if (!resetInterval) {
  48677. resetInterval = mcuExpected;
  48678. }
  48679. var h, v;
  48680. while (mcu < mcuExpected) {
  48681. for (i = 0; i < componentsLength; i++) {
  48682. components[i].pred = 0;
  48683. }
  48684. eobrun = 0;
  48685. if (componentsLength === 1) {
  48686. component = components[0];
  48687. for (n = 0; n < resetInterval; n++) {
  48688. decodeBlock(component, decodeFn, mcu);
  48689. mcu++;
  48690. }
  48691. } else {
  48692. for (n = 0; n < resetInterval; n++) {
  48693. for (i = 0; i < componentsLength; i++) {
  48694. component = components[i];
  48695. h = component.h;
  48696. v = component.v;
  48697. for (j = 0; j < v; j++) {
  48698. for (k = 0; k < h; k++) {
  48699. decodeMcu(component, decodeFn, mcu, j, k);
  48700. }
  48701. }
  48702. }
  48703. mcu++;
  48704. }
  48705. }
  48706. bitsCount = 0;
  48707. marker = data[offset] << 8 | data[offset + 1];
  48708. while (data[offset] === 0x00 && offset < data.length - 1) {
  48709. offset++;
  48710. marker = data[offset] << 8 | data[offset + 1];
  48711. }
  48712. if (marker <= 0xFF00) {
  48713. error('JPEG error: marker was not found');
  48714. }
  48715. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48716. offset += 2;
  48717. } else {
  48718. break;
  48719. }
  48720. }
  48721. return offset - startOffset;
  48722. }
  48723. function quantizeAndInverse(component, blockBufferOffset, p) {
  48724. var qt = component.quantizationTable, blockData = component.blockData;
  48725. var v0, v1, v2, v3, v4, v5, v6, v7;
  48726. var p0, p1, p2, p3, p4, p5, p6, p7;
  48727. var t;
  48728. if (!qt) {
  48729. error('JPEG error: missing required Quantization Table.');
  48730. }
  48731. for (var row = 0; row < 64; row += 8) {
  48732. p0 = blockData[blockBufferOffset + row];
  48733. p1 = blockData[blockBufferOffset + row + 1];
  48734. p2 = blockData[blockBufferOffset + row + 2];
  48735. p3 = blockData[blockBufferOffset + row + 3];
  48736. p4 = blockData[blockBufferOffset + row + 4];
  48737. p5 = blockData[blockBufferOffset + row + 5];
  48738. p6 = blockData[blockBufferOffset + row + 6];
  48739. p7 = blockData[blockBufferOffset + row + 7];
  48740. p0 *= qt[row];
  48741. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48742. t = dctSqrt2 * p0 + 512 >> 10;
  48743. p[row] = t;
  48744. p[row + 1] = t;
  48745. p[row + 2] = t;
  48746. p[row + 3] = t;
  48747. p[row + 4] = t;
  48748. p[row + 5] = t;
  48749. p[row + 6] = t;
  48750. p[row + 7] = t;
  48751. continue;
  48752. }
  48753. p1 *= qt[row + 1];
  48754. p2 *= qt[row + 2];
  48755. p3 *= qt[row + 3];
  48756. p4 *= qt[row + 4];
  48757. p5 *= qt[row + 5];
  48758. p6 *= qt[row + 6];
  48759. p7 *= qt[row + 7];
  48760. v0 = dctSqrt2 * p0 + 128 >> 8;
  48761. v1 = dctSqrt2 * p4 + 128 >> 8;
  48762. v2 = p2;
  48763. v3 = p6;
  48764. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48765. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48766. v5 = p3 << 4;
  48767. v6 = p5 << 4;
  48768. v0 = v0 + v1 + 1 >> 1;
  48769. v1 = v0 - v1;
  48770. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48771. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48772. v3 = t;
  48773. v4 = v4 + v6 + 1 >> 1;
  48774. v6 = v4 - v6;
  48775. v7 = v7 + v5 + 1 >> 1;
  48776. v5 = v7 - v5;
  48777. v0 = v0 + v3 + 1 >> 1;
  48778. v3 = v0 - v3;
  48779. v1 = v1 + v2 + 1 >> 1;
  48780. v2 = v1 - v2;
  48781. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48782. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48783. v7 = t;
  48784. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48785. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48786. v6 = t;
  48787. p[row] = v0 + v7;
  48788. p[row + 7] = v0 - v7;
  48789. p[row + 1] = v1 + v6;
  48790. p[row + 6] = v1 - v6;
  48791. p[row + 2] = v2 + v5;
  48792. p[row + 5] = v2 - v5;
  48793. p[row + 3] = v3 + v4;
  48794. p[row + 4] = v3 - v4;
  48795. }
  48796. for (var col = 0; col < 8; ++col) {
  48797. p0 = p[col];
  48798. p1 = p[col + 8];
  48799. p2 = p[col + 16];
  48800. p3 = p[col + 24];
  48801. p4 = p[col + 32];
  48802. p5 = p[col + 40];
  48803. p6 = p[col + 48];
  48804. p7 = p[col + 56];
  48805. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48806. t = dctSqrt2 * p0 + 8192 >> 14;
  48807. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48808. blockData[blockBufferOffset + col] = t;
  48809. blockData[blockBufferOffset + col + 8] = t;
  48810. blockData[blockBufferOffset + col + 16] = t;
  48811. blockData[blockBufferOffset + col + 24] = t;
  48812. blockData[blockBufferOffset + col + 32] = t;
  48813. blockData[blockBufferOffset + col + 40] = t;
  48814. blockData[blockBufferOffset + col + 48] = t;
  48815. blockData[blockBufferOffset + col + 56] = t;
  48816. continue;
  48817. }
  48818. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48819. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48820. v2 = p2;
  48821. v3 = p6;
  48822. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48823. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48824. v5 = p3;
  48825. v6 = p5;
  48826. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48827. v1 = v0 - v1;
  48828. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48829. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48830. v3 = t;
  48831. v4 = v4 + v6 + 1 >> 1;
  48832. v6 = v4 - v6;
  48833. v7 = v7 + v5 + 1 >> 1;
  48834. v5 = v7 - v5;
  48835. v0 = v0 + v3 + 1 >> 1;
  48836. v3 = v0 - v3;
  48837. v1 = v1 + v2 + 1 >> 1;
  48838. v2 = v1 - v2;
  48839. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48840. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48841. v7 = t;
  48842. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48843. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48844. v6 = t;
  48845. p0 = v0 + v7;
  48846. p7 = v0 - v7;
  48847. p1 = v1 + v6;
  48848. p6 = v1 - v6;
  48849. p2 = v2 + v5;
  48850. p5 = v2 - v5;
  48851. p3 = v3 + v4;
  48852. p4 = v3 - v4;
  48853. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48854. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48855. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48856. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48857. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48858. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48859. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48860. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48861. blockData[blockBufferOffset + col] = p0;
  48862. blockData[blockBufferOffset + col + 8] = p1;
  48863. blockData[blockBufferOffset + col + 16] = p2;
  48864. blockData[blockBufferOffset + col + 24] = p3;
  48865. blockData[blockBufferOffset + col + 32] = p4;
  48866. blockData[blockBufferOffset + col + 40] = p5;
  48867. blockData[blockBufferOffset + col + 48] = p6;
  48868. blockData[blockBufferOffset + col + 56] = p7;
  48869. }
  48870. }
  48871. function buildComponentData(frame, component) {
  48872. var blocksPerLine = component.blocksPerLine;
  48873. var blocksPerColumn = component.blocksPerColumn;
  48874. var computationBuffer = new Int16Array(64);
  48875. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48876. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48877. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48878. quantizeAndInverse(component, offset, computationBuffer);
  48879. }
  48880. }
  48881. return component.blockData;
  48882. }
  48883. function clamp0to255(a) {
  48884. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48885. }
  48886. JpegImage.prototype = {
  48887. parse: function parse(data) {
  48888. function readUint16() {
  48889. var value = data[offset] << 8 | data[offset + 1];
  48890. offset += 2;
  48891. return value;
  48892. }
  48893. function readDataBlock() {
  48894. var length = readUint16();
  48895. var array = data.subarray(offset, offset + length - 2);
  48896. offset += array.length;
  48897. return array;
  48898. }
  48899. function prepareComponents(frame) {
  48900. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48901. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48902. for (var i = 0; i < frame.components.length; i++) {
  48903. component = frame.components[i];
  48904. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48905. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48906. var blocksPerLineForMcu = mcusPerLine * component.h;
  48907. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48908. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48909. component.blockData = new Int16Array(blocksBufferSize);
  48910. component.blocksPerLine = blocksPerLine;
  48911. component.blocksPerColumn = blocksPerColumn;
  48912. }
  48913. frame.mcusPerLine = mcusPerLine;
  48914. frame.mcusPerColumn = mcusPerColumn;
  48915. }
  48916. var offset = 0;
  48917. var jfif = null;
  48918. var adobe = null;
  48919. var frame, resetInterval;
  48920. var quantizationTables = [];
  48921. var huffmanTablesAC = [], huffmanTablesDC = [];
  48922. var fileMarker = readUint16();
  48923. if (fileMarker !== 0xFFD8) {
  48924. error('JPEG error: SOI not found');
  48925. }
  48926. fileMarker = readUint16();
  48927. while (fileMarker !== 0xFFD9) {
  48928. var i, j, l;
  48929. switch (fileMarker) {
  48930. case 0xFFE0:
  48931. case 0xFFE1:
  48932. case 0xFFE2:
  48933. case 0xFFE3:
  48934. case 0xFFE4:
  48935. case 0xFFE5:
  48936. case 0xFFE6:
  48937. case 0xFFE7:
  48938. case 0xFFE8:
  48939. case 0xFFE9:
  48940. case 0xFFEA:
  48941. case 0xFFEB:
  48942. case 0xFFEC:
  48943. case 0xFFED:
  48944. case 0xFFEE:
  48945. case 0xFFEF:
  48946. case 0xFFFE:
  48947. var appData = readDataBlock();
  48948. if (fileMarker === 0xFFE0) {
  48949. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48950. jfif = {
  48951. version: {
  48952. major: appData[5],
  48953. minor: appData[6]
  48954. },
  48955. densityUnits: appData[7],
  48956. xDensity: appData[8] << 8 | appData[9],
  48957. yDensity: appData[10] << 8 | appData[11],
  48958. thumbWidth: appData[12],
  48959. thumbHeight: appData[13],
  48960. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48961. };
  48962. }
  48963. }
  48964. if (fileMarker === 0xFFEE) {
  48965. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48966. adobe = {
  48967. version: appData[5] << 8 | appData[6],
  48968. flags0: appData[7] << 8 | appData[8],
  48969. flags1: appData[9] << 8 | appData[10],
  48970. transformCode: appData[11]
  48971. };
  48972. }
  48973. }
  48974. break;
  48975. case 0xFFDB:
  48976. var quantizationTablesLength = readUint16();
  48977. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48978. var z;
  48979. while (offset < quantizationTablesEnd) {
  48980. var quantizationTableSpec = data[offset++];
  48981. var tableData = new Uint16Array(64);
  48982. if (quantizationTableSpec >> 4 === 0) {
  48983. for (j = 0; j < 64; j++) {
  48984. z = dctZigZag[j];
  48985. tableData[z] = data[offset++];
  48986. }
  48987. } else if (quantizationTableSpec >> 4 === 1) {
  48988. for (j = 0; j < 64; j++) {
  48989. z = dctZigZag[j];
  48990. tableData[z] = readUint16();
  48991. }
  48992. } else {
  48993. error('JPEG error: DQT - invalid table spec');
  48994. }
  48995. quantizationTables[quantizationTableSpec & 15] = tableData;
  48996. }
  48997. break;
  48998. case 0xFFC0:
  48999. case 0xFFC1:
  49000. case 0xFFC2:
  49001. if (frame) {
  49002. error('JPEG error: Only single frame JPEGs supported');
  49003. }
  49004. readUint16();
  49005. frame = {};
  49006. frame.extended = fileMarker === 0xFFC1;
  49007. frame.progressive = fileMarker === 0xFFC2;
  49008. frame.precision = data[offset++];
  49009. frame.scanLines = readUint16();
  49010. frame.samplesPerLine = readUint16();
  49011. frame.components = [];
  49012. frame.componentIds = {};
  49013. var componentsCount = data[offset++], componentId;
  49014. var maxH = 0, maxV = 0;
  49015. for (i = 0; i < componentsCount; i++) {
  49016. componentId = data[offset];
  49017. var h = data[offset + 1] >> 4;
  49018. var v = data[offset + 1] & 15;
  49019. if (maxH < h) {
  49020. maxH = h;
  49021. }
  49022. if (maxV < v) {
  49023. maxV = v;
  49024. }
  49025. var qId = data[offset + 2];
  49026. l = frame.components.push({
  49027. h: h,
  49028. v: v,
  49029. quantizationId: qId,
  49030. quantizationTable: null
  49031. });
  49032. frame.componentIds[componentId] = l - 1;
  49033. offset += 3;
  49034. }
  49035. frame.maxH = maxH;
  49036. frame.maxV = maxV;
  49037. prepareComponents(frame);
  49038. break;
  49039. case 0xFFC4:
  49040. var huffmanLength = readUint16();
  49041. for (i = 2; i < huffmanLength;) {
  49042. var huffmanTableSpec = data[offset++];
  49043. var codeLengths = new Uint8Array(16);
  49044. var codeLengthSum = 0;
  49045. for (j = 0; j < 16; j++, offset++) {
  49046. codeLengthSum += codeLengths[j] = data[offset];
  49047. }
  49048. var huffmanValues = new Uint8Array(codeLengthSum);
  49049. for (j = 0; j < codeLengthSum; j++, offset++) {
  49050. huffmanValues[j] = data[offset];
  49051. }
  49052. i += 17 + codeLengthSum;
  49053. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49054. }
  49055. break;
  49056. case 0xFFDD:
  49057. readUint16();
  49058. resetInterval = readUint16();
  49059. break;
  49060. case 0xFFDA:
  49061. readUint16();
  49062. var selectorsCount = data[offset++];
  49063. var components = [], component;
  49064. for (i = 0; i < selectorsCount; i++) {
  49065. var componentIndex = frame.componentIds[data[offset++]];
  49066. component = frame.components[componentIndex];
  49067. var tableSpec = data[offset++];
  49068. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49069. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49070. components.push(component);
  49071. }
  49072. var spectralStart = data[offset++];
  49073. var spectralEnd = data[offset++];
  49074. var successiveApproximation = data[offset++];
  49075. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49076. offset += processed;
  49077. break;
  49078. case 0xFFFF:
  49079. if (data[offset] !== 0xFF) {
  49080. offset--;
  49081. }
  49082. break;
  49083. default:
  49084. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49085. offset -= 3;
  49086. break;
  49087. }
  49088. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49089. }
  49090. fileMarker = readUint16();
  49091. }
  49092. this.width = frame.samplesPerLine;
  49093. this.height = frame.scanLines;
  49094. this.jfif = jfif;
  49095. this.adobe = adobe;
  49096. this.components = [];
  49097. for (i = 0; i < frame.components.length; i++) {
  49098. component = frame.components[i];
  49099. var quantizationTable = quantizationTables[component.quantizationId];
  49100. if (quantizationTable) {
  49101. component.quantizationTable = quantizationTable;
  49102. }
  49103. this.components.push({
  49104. output: buildComponentData(frame, component),
  49105. scaleX: component.h / frame.maxH,
  49106. scaleY: component.v / frame.maxV,
  49107. blocksPerLine: component.blocksPerLine,
  49108. blocksPerColumn: component.blocksPerColumn
  49109. });
  49110. }
  49111. this.numComponents = this.components.length;
  49112. },
  49113. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49114. var scaleX = this.width / width, scaleY = this.height / height;
  49115. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49116. var x, y, i, j, k;
  49117. var index;
  49118. var offset = 0;
  49119. var output;
  49120. var numComponents = this.components.length;
  49121. var dataLength = width * height * numComponents;
  49122. var data = new Uint8Array(dataLength);
  49123. var xScaleBlockOffset = new Uint32Array(width);
  49124. var mask3LSB = 0xfffffff8;
  49125. for (i = 0; i < numComponents; i++) {
  49126. component = this.components[i];
  49127. componentScaleX = component.scaleX * scaleX;
  49128. componentScaleY = component.scaleY * scaleY;
  49129. offset = i;
  49130. output = component.output;
  49131. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49132. for (x = 0; x < width; x++) {
  49133. j = 0 | x * componentScaleX;
  49134. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49135. }
  49136. for (y = 0; y < height; y++) {
  49137. j = 0 | y * componentScaleY;
  49138. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49139. for (x = 0; x < width; x++) {
  49140. data[offset] = output[index + xScaleBlockOffset[x]];
  49141. offset += numComponents;
  49142. }
  49143. }
  49144. }
  49145. var transform = this.decodeTransform;
  49146. if (transform) {
  49147. for (i = 0; i < dataLength;) {
  49148. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49149. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49150. }
  49151. }
  49152. }
  49153. return data;
  49154. },
  49155. _isColorConversionNeeded: function isColorConversionNeeded() {
  49156. if (this.adobe && this.adobe.transformCode) {
  49157. return true;
  49158. } else if (this.numComponents === 3) {
  49159. if (!this.adobe && this.colorTransform === 0) {
  49160. return false;
  49161. }
  49162. return true;
  49163. }
  49164. if (!this.adobe && this.colorTransform === 1) {
  49165. return true;
  49166. }
  49167. return false;
  49168. },
  49169. _convertYccToRgb: function convertYccToRgb(data) {
  49170. var Y, Cb, Cr;
  49171. for (var i = 0, length = data.length; i < length; i += 3) {
  49172. Y = data[i];
  49173. Cb = data[i + 1];
  49174. Cr = data[i + 2];
  49175. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49176. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49177. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49178. }
  49179. return data;
  49180. },
  49181. _convertYcckToRgb: function convertYcckToRgb(data) {
  49182. var Y, Cb, Cr, k;
  49183. var offset = 0;
  49184. for (var i = 0, length = data.length; i < length; i += 4) {
  49185. Y = data[i];
  49186. Cb = data[i + 1];
  49187. Cr = data[i + 2];
  49188. k = data[i + 3];
  49189. 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);
  49190. 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);
  49191. 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);
  49192. data[offset++] = clamp0to255(r);
  49193. data[offset++] = clamp0to255(g);
  49194. data[offset++] = clamp0to255(b);
  49195. }
  49196. return data;
  49197. },
  49198. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49199. var Y, Cb, Cr;
  49200. for (var i = 0, length = data.length; i < length; i += 4) {
  49201. Y = data[i];
  49202. Cb = data[i + 1];
  49203. Cr = data[i + 2];
  49204. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49205. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49206. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49207. }
  49208. return data;
  49209. },
  49210. _convertCmykToRgb: function convertCmykToRgb(data) {
  49211. var c, m, y, k;
  49212. var offset = 0;
  49213. var min = -255 * 255 * 255;
  49214. var scale = 1 / 255 / 255;
  49215. for (var i = 0, length = data.length; i < length; i += 4) {
  49216. c = data[i];
  49217. m = data[i + 1];
  49218. y = data[i + 2];
  49219. k = data[i + 3];
  49220. 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);
  49221. 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);
  49222. 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);
  49223. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49224. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49225. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49226. }
  49227. return data;
  49228. },
  49229. getData: function getData(width, height, forceRGBoutput) {
  49230. if (this.numComponents > 4) {
  49231. error('JPEG error: Unsupported color mode');
  49232. }
  49233. var data = this._getLinearizedBlockData(width, height);
  49234. if (this.numComponents === 1 && forceRGBoutput) {
  49235. var dataLength = data.length;
  49236. var rgbData = new Uint8Array(dataLength * 3);
  49237. var offset = 0;
  49238. for (var i = 0; i < dataLength; i++) {
  49239. var grayColor = data[i];
  49240. rgbData[offset++] = grayColor;
  49241. rgbData[offset++] = grayColor;
  49242. rgbData[offset++] = grayColor;
  49243. }
  49244. return rgbData;
  49245. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49246. return this._convertYccToRgb(data);
  49247. } else if (this.numComponents === 4) {
  49248. if (this._isColorConversionNeeded()) {
  49249. if (forceRGBoutput) {
  49250. return this._convertYcckToRgb(data);
  49251. }
  49252. return this._convertYcckToCmyk(data);
  49253. } else if (forceRGBoutput) {
  49254. return this._convertCmykToRgb(data);
  49255. }
  49256. }
  49257. return data;
  49258. }
  49259. };
  49260. return JpegImage;
  49261. }();
  49262. exports.JpegImage = JpegImage;
  49263. /***/ }),
  49264. /* 38 */
  49265. /***/ (function(module, exports, __w_pdfjs_require__) {
  49266. "use strict";
  49267. var sharedUtil = __w_pdfjs_require__(0);
  49268. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49269. var getMetrics = getLookupTableFactory(function (t) {
  49270. t['Courier'] = 600;
  49271. t['Courier-Bold'] = 600;
  49272. t['Courier-BoldOblique'] = 600;
  49273. t['Courier-Oblique'] = 600;
  49274. t['Helvetica'] = getLookupTableFactory(function (t) {
  49275. t['space'] = 278;
  49276. t['exclam'] = 278;
  49277. t['quotedbl'] = 355;
  49278. t['numbersign'] = 556;
  49279. t['dollar'] = 556;
  49280. t['percent'] = 889;
  49281. t['ampersand'] = 667;
  49282. t['quoteright'] = 222;
  49283. t['parenleft'] = 333;
  49284. t['parenright'] = 333;
  49285. t['asterisk'] = 389;
  49286. t['plus'] = 584;
  49287. t['comma'] = 278;
  49288. t['hyphen'] = 333;
  49289. t['period'] = 278;
  49290. t['slash'] = 278;
  49291. t['zero'] = 556;
  49292. t['one'] = 556;
  49293. t['two'] = 556;
  49294. t['three'] = 556;
  49295. t['four'] = 556;
  49296. t['five'] = 556;
  49297. t['six'] = 556;
  49298. t['seven'] = 556;
  49299. t['eight'] = 556;
  49300. t['nine'] = 556;
  49301. t['colon'] = 278;
  49302. t['semicolon'] = 278;
  49303. t['less'] = 584;
  49304. t['equal'] = 584;
  49305. t['greater'] = 584;
  49306. t['question'] = 556;
  49307. t['at'] = 1015;
  49308. t['A'] = 667;
  49309. t['B'] = 667;
  49310. t['C'] = 722;
  49311. t['D'] = 722;
  49312. t['E'] = 667;
  49313. t['F'] = 611;
  49314. t['G'] = 778;
  49315. t['H'] = 722;
  49316. t['I'] = 278;
  49317. t['J'] = 500;
  49318. t['K'] = 667;
  49319. t['L'] = 556;
  49320. t['M'] = 833;
  49321. t['N'] = 722;
  49322. t['O'] = 778;
  49323. t['P'] = 667;
  49324. t['Q'] = 778;
  49325. t['R'] = 722;
  49326. t['S'] = 667;
  49327. t['T'] = 611;
  49328. t['U'] = 722;
  49329. t['V'] = 667;
  49330. t['W'] = 944;
  49331. t['X'] = 667;
  49332. t['Y'] = 667;
  49333. t['Z'] = 611;
  49334. t['bracketleft'] = 278;
  49335. t['backslash'] = 278;
  49336. t['bracketright'] = 278;
  49337. t['asciicircum'] = 469;
  49338. t['underscore'] = 556;
  49339. t['quoteleft'] = 222;
  49340. t['a'] = 556;
  49341. t['b'] = 556;
  49342. t['c'] = 500;
  49343. t['d'] = 556;
  49344. t['e'] = 556;
  49345. t['f'] = 278;
  49346. t['g'] = 556;
  49347. t['h'] = 556;
  49348. t['i'] = 222;
  49349. t['j'] = 222;
  49350. t['k'] = 500;
  49351. t['l'] = 222;
  49352. t['m'] = 833;
  49353. t['n'] = 556;
  49354. t['o'] = 556;
  49355. t['p'] = 556;
  49356. t['q'] = 556;
  49357. t['r'] = 333;
  49358. t['s'] = 500;
  49359. t['t'] = 278;
  49360. t['u'] = 556;
  49361. t['v'] = 500;
  49362. t['w'] = 722;
  49363. t['x'] = 500;
  49364. t['y'] = 500;
  49365. t['z'] = 500;
  49366. t['braceleft'] = 334;
  49367. t['bar'] = 260;
  49368. t['braceright'] = 334;
  49369. t['asciitilde'] = 584;
  49370. t['exclamdown'] = 333;
  49371. t['cent'] = 556;
  49372. t['sterling'] = 556;
  49373. t['fraction'] = 167;
  49374. t['yen'] = 556;
  49375. t['florin'] = 556;
  49376. t['section'] = 556;
  49377. t['currency'] = 556;
  49378. t['quotesingle'] = 191;
  49379. t['quotedblleft'] = 333;
  49380. t['guillemotleft'] = 556;
  49381. t['guilsinglleft'] = 333;
  49382. t['guilsinglright'] = 333;
  49383. t['fi'] = 500;
  49384. t['fl'] = 500;
  49385. t['endash'] = 556;
  49386. t['dagger'] = 556;
  49387. t['daggerdbl'] = 556;
  49388. t['periodcentered'] = 278;
  49389. t['paragraph'] = 537;
  49390. t['bullet'] = 350;
  49391. t['quotesinglbase'] = 222;
  49392. t['quotedblbase'] = 333;
  49393. t['quotedblright'] = 333;
  49394. t['guillemotright'] = 556;
  49395. t['ellipsis'] = 1000;
  49396. t['perthousand'] = 1000;
  49397. t['questiondown'] = 611;
  49398. t['grave'] = 333;
  49399. t['acute'] = 333;
  49400. t['circumflex'] = 333;
  49401. t['tilde'] = 333;
  49402. t['macron'] = 333;
  49403. t['breve'] = 333;
  49404. t['dotaccent'] = 333;
  49405. t['dieresis'] = 333;
  49406. t['ring'] = 333;
  49407. t['cedilla'] = 333;
  49408. t['hungarumlaut'] = 333;
  49409. t['ogonek'] = 333;
  49410. t['caron'] = 333;
  49411. t['emdash'] = 1000;
  49412. t['AE'] = 1000;
  49413. t['ordfeminine'] = 370;
  49414. t['Lslash'] = 556;
  49415. t['Oslash'] = 778;
  49416. t['OE'] = 1000;
  49417. t['ordmasculine'] = 365;
  49418. t['ae'] = 889;
  49419. t['dotlessi'] = 278;
  49420. t['lslash'] = 222;
  49421. t['oslash'] = 611;
  49422. t['oe'] = 944;
  49423. t['germandbls'] = 611;
  49424. t['Idieresis'] = 278;
  49425. t['eacute'] = 556;
  49426. t['abreve'] = 556;
  49427. t['uhungarumlaut'] = 556;
  49428. t['ecaron'] = 556;
  49429. t['Ydieresis'] = 667;
  49430. t['divide'] = 584;
  49431. t['Yacute'] = 667;
  49432. t['Acircumflex'] = 667;
  49433. t['aacute'] = 556;
  49434. t['Ucircumflex'] = 722;
  49435. t['yacute'] = 500;
  49436. t['scommaaccent'] = 500;
  49437. t['ecircumflex'] = 556;
  49438. t['Uring'] = 722;
  49439. t['Udieresis'] = 722;
  49440. t['aogonek'] = 556;
  49441. t['Uacute'] = 722;
  49442. t['uogonek'] = 556;
  49443. t['Edieresis'] = 667;
  49444. t['Dcroat'] = 722;
  49445. t['commaaccent'] = 250;
  49446. t['copyright'] = 737;
  49447. t['Emacron'] = 667;
  49448. t['ccaron'] = 500;
  49449. t['aring'] = 556;
  49450. t['Ncommaaccent'] = 722;
  49451. t['lacute'] = 222;
  49452. t['agrave'] = 556;
  49453. t['Tcommaaccent'] = 611;
  49454. t['Cacute'] = 722;
  49455. t['atilde'] = 556;
  49456. t['Edotaccent'] = 667;
  49457. t['scaron'] = 500;
  49458. t['scedilla'] = 500;
  49459. t['iacute'] = 278;
  49460. t['lozenge'] = 471;
  49461. t['Rcaron'] = 722;
  49462. t['Gcommaaccent'] = 778;
  49463. t['ucircumflex'] = 556;
  49464. t['acircumflex'] = 556;
  49465. t['Amacron'] = 667;
  49466. t['rcaron'] = 333;
  49467. t['ccedilla'] = 500;
  49468. t['Zdotaccent'] = 611;
  49469. t['Thorn'] = 667;
  49470. t['Omacron'] = 778;
  49471. t['Racute'] = 722;
  49472. t['Sacute'] = 667;
  49473. t['dcaron'] = 643;
  49474. t['Umacron'] = 722;
  49475. t['uring'] = 556;
  49476. t['threesuperior'] = 333;
  49477. t['Ograve'] = 778;
  49478. t['Agrave'] = 667;
  49479. t['Abreve'] = 667;
  49480. t['multiply'] = 584;
  49481. t['uacute'] = 556;
  49482. t['Tcaron'] = 611;
  49483. t['partialdiff'] = 476;
  49484. t['ydieresis'] = 500;
  49485. t['Nacute'] = 722;
  49486. t['icircumflex'] = 278;
  49487. t['Ecircumflex'] = 667;
  49488. t['adieresis'] = 556;
  49489. t['edieresis'] = 556;
  49490. t['cacute'] = 500;
  49491. t['nacute'] = 556;
  49492. t['umacron'] = 556;
  49493. t['Ncaron'] = 722;
  49494. t['Iacute'] = 278;
  49495. t['plusminus'] = 584;
  49496. t['brokenbar'] = 260;
  49497. t['registered'] = 737;
  49498. t['Gbreve'] = 778;
  49499. t['Idotaccent'] = 278;
  49500. t['summation'] = 600;
  49501. t['Egrave'] = 667;
  49502. t['racute'] = 333;
  49503. t['omacron'] = 556;
  49504. t['Zacute'] = 611;
  49505. t['Zcaron'] = 611;
  49506. t['greaterequal'] = 549;
  49507. t['Eth'] = 722;
  49508. t['Ccedilla'] = 722;
  49509. t['lcommaaccent'] = 222;
  49510. t['tcaron'] = 317;
  49511. t['eogonek'] = 556;
  49512. t['Uogonek'] = 722;
  49513. t['Aacute'] = 667;
  49514. t['Adieresis'] = 667;
  49515. t['egrave'] = 556;
  49516. t['zacute'] = 500;
  49517. t['iogonek'] = 222;
  49518. t['Oacute'] = 778;
  49519. t['oacute'] = 556;
  49520. t['amacron'] = 556;
  49521. t['sacute'] = 500;
  49522. t['idieresis'] = 278;
  49523. t['Ocircumflex'] = 778;
  49524. t['Ugrave'] = 722;
  49525. t['Delta'] = 612;
  49526. t['thorn'] = 556;
  49527. t['twosuperior'] = 333;
  49528. t['Odieresis'] = 778;
  49529. t['mu'] = 556;
  49530. t['igrave'] = 278;
  49531. t['ohungarumlaut'] = 556;
  49532. t['Eogonek'] = 667;
  49533. t['dcroat'] = 556;
  49534. t['threequarters'] = 834;
  49535. t['Scedilla'] = 667;
  49536. t['lcaron'] = 299;
  49537. t['Kcommaaccent'] = 667;
  49538. t['Lacute'] = 556;
  49539. t['trademark'] = 1000;
  49540. t['edotaccent'] = 556;
  49541. t['Igrave'] = 278;
  49542. t['Imacron'] = 278;
  49543. t['Lcaron'] = 556;
  49544. t['onehalf'] = 834;
  49545. t['lessequal'] = 549;
  49546. t['ocircumflex'] = 556;
  49547. t['ntilde'] = 556;
  49548. t['Uhungarumlaut'] = 722;
  49549. t['Eacute'] = 667;
  49550. t['emacron'] = 556;
  49551. t['gbreve'] = 556;
  49552. t['onequarter'] = 834;
  49553. t['Scaron'] = 667;
  49554. t['Scommaaccent'] = 667;
  49555. t['Ohungarumlaut'] = 778;
  49556. t['degree'] = 400;
  49557. t['ograve'] = 556;
  49558. t['Ccaron'] = 722;
  49559. t['ugrave'] = 556;
  49560. t['radical'] = 453;
  49561. t['Dcaron'] = 722;
  49562. t['rcommaaccent'] = 333;
  49563. t['Ntilde'] = 722;
  49564. t['otilde'] = 556;
  49565. t['Rcommaaccent'] = 722;
  49566. t['Lcommaaccent'] = 556;
  49567. t['Atilde'] = 667;
  49568. t['Aogonek'] = 667;
  49569. t['Aring'] = 667;
  49570. t['Otilde'] = 778;
  49571. t['zdotaccent'] = 500;
  49572. t['Ecaron'] = 667;
  49573. t['Iogonek'] = 278;
  49574. t['kcommaaccent'] = 500;
  49575. t['minus'] = 584;
  49576. t['Icircumflex'] = 278;
  49577. t['ncaron'] = 556;
  49578. t['tcommaaccent'] = 278;
  49579. t['logicalnot'] = 584;
  49580. t['odieresis'] = 556;
  49581. t['udieresis'] = 556;
  49582. t['notequal'] = 549;
  49583. t['gcommaaccent'] = 556;
  49584. t['eth'] = 556;
  49585. t['zcaron'] = 500;
  49586. t['ncommaaccent'] = 556;
  49587. t['onesuperior'] = 333;
  49588. t['imacron'] = 278;
  49589. t['Euro'] = 556;
  49590. });
  49591. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49592. t['space'] = 278;
  49593. t['exclam'] = 333;
  49594. t['quotedbl'] = 474;
  49595. t['numbersign'] = 556;
  49596. t['dollar'] = 556;
  49597. t['percent'] = 889;
  49598. t['ampersand'] = 722;
  49599. t['quoteright'] = 278;
  49600. t['parenleft'] = 333;
  49601. t['parenright'] = 333;
  49602. t['asterisk'] = 389;
  49603. t['plus'] = 584;
  49604. t['comma'] = 278;
  49605. t['hyphen'] = 333;
  49606. t['period'] = 278;
  49607. t['slash'] = 278;
  49608. t['zero'] = 556;
  49609. t['one'] = 556;
  49610. t['two'] = 556;
  49611. t['three'] = 556;
  49612. t['four'] = 556;
  49613. t['five'] = 556;
  49614. t['six'] = 556;
  49615. t['seven'] = 556;
  49616. t['eight'] = 556;
  49617. t['nine'] = 556;
  49618. t['colon'] = 333;
  49619. t['semicolon'] = 333;
  49620. t['less'] = 584;
  49621. t['equal'] = 584;
  49622. t['greater'] = 584;
  49623. t['question'] = 611;
  49624. t['at'] = 975;
  49625. t['A'] = 722;
  49626. t['B'] = 722;
  49627. t['C'] = 722;
  49628. t['D'] = 722;
  49629. t['E'] = 667;
  49630. t['F'] = 611;
  49631. t['G'] = 778;
  49632. t['H'] = 722;
  49633. t['I'] = 278;
  49634. t['J'] = 556;
  49635. t['K'] = 722;
  49636. t['L'] = 611;
  49637. t['M'] = 833;
  49638. t['N'] = 722;
  49639. t['O'] = 778;
  49640. t['P'] = 667;
  49641. t['Q'] = 778;
  49642. t['R'] = 722;
  49643. t['S'] = 667;
  49644. t['T'] = 611;
  49645. t['U'] = 722;
  49646. t['V'] = 667;
  49647. t['W'] = 944;
  49648. t['X'] = 667;
  49649. t['Y'] = 667;
  49650. t['Z'] = 611;
  49651. t['bracketleft'] = 333;
  49652. t['backslash'] = 278;
  49653. t['bracketright'] = 333;
  49654. t['asciicircum'] = 584;
  49655. t['underscore'] = 556;
  49656. t['quoteleft'] = 278;
  49657. t['a'] = 556;
  49658. t['b'] = 611;
  49659. t['c'] = 556;
  49660. t['d'] = 611;
  49661. t['e'] = 556;
  49662. t['f'] = 333;
  49663. t['g'] = 611;
  49664. t['h'] = 611;
  49665. t['i'] = 278;
  49666. t['j'] = 278;
  49667. t['k'] = 556;
  49668. t['l'] = 278;
  49669. t['m'] = 889;
  49670. t['n'] = 611;
  49671. t['o'] = 611;
  49672. t['p'] = 611;
  49673. t['q'] = 611;
  49674. t['r'] = 389;
  49675. t['s'] = 556;
  49676. t['t'] = 333;
  49677. t['u'] = 611;
  49678. t['v'] = 556;
  49679. t['w'] = 778;
  49680. t['x'] = 556;
  49681. t['y'] = 556;
  49682. t['z'] = 500;
  49683. t['braceleft'] = 389;
  49684. t['bar'] = 280;
  49685. t['braceright'] = 389;
  49686. t['asciitilde'] = 584;
  49687. t['exclamdown'] = 333;
  49688. t['cent'] = 556;
  49689. t['sterling'] = 556;
  49690. t['fraction'] = 167;
  49691. t['yen'] = 556;
  49692. t['florin'] = 556;
  49693. t['section'] = 556;
  49694. t['currency'] = 556;
  49695. t['quotesingle'] = 238;
  49696. t['quotedblleft'] = 500;
  49697. t['guillemotleft'] = 556;
  49698. t['guilsinglleft'] = 333;
  49699. t['guilsinglright'] = 333;
  49700. t['fi'] = 611;
  49701. t['fl'] = 611;
  49702. t['endash'] = 556;
  49703. t['dagger'] = 556;
  49704. t['daggerdbl'] = 556;
  49705. t['periodcentered'] = 278;
  49706. t['paragraph'] = 556;
  49707. t['bullet'] = 350;
  49708. t['quotesinglbase'] = 278;
  49709. t['quotedblbase'] = 500;
  49710. t['quotedblright'] = 500;
  49711. t['guillemotright'] = 556;
  49712. t['ellipsis'] = 1000;
  49713. t['perthousand'] = 1000;
  49714. t['questiondown'] = 611;
  49715. t['grave'] = 333;
  49716. t['acute'] = 333;
  49717. t['circumflex'] = 333;
  49718. t['tilde'] = 333;
  49719. t['macron'] = 333;
  49720. t['breve'] = 333;
  49721. t['dotaccent'] = 333;
  49722. t['dieresis'] = 333;
  49723. t['ring'] = 333;
  49724. t['cedilla'] = 333;
  49725. t['hungarumlaut'] = 333;
  49726. t['ogonek'] = 333;
  49727. t['caron'] = 333;
  49728. t['emdash'] = 1000;
  49729. t['AE'] = 1000;
  49730. t['ordfeminine'] = 370;
  49731. t['Lslash'] = 611;
  49732. t['Oslash'] = 778;
  49733. t['OE'] = 1000;
  49734. t['ordmasculine'] = 365;
  49735. t['ae'] = 889;
  49736. t['dotlessi'] = 278;
  49737. t['lslash'] = 278;
  49738. t['oslash'] = 611;
  49739. t['oe'] = 944;
  49740. t['germandbls'] = 611;
  49741. t['Idieresis'] = 278;
  49742. t['eacute'] = 556;
  49743. t['abreve'] = 556;
  49744. t['uhungarumlaut'] = 611;
  49745. t['ecaron'] = 556;
  49746. t['Ydieresis'] = 667;
  49747. t['divide'] = 584;
  49748. t['Yacute'] = 667;
  49749. t['Acircumflex'] = 722;
  49750. t['aacute'] = 556;
  49751. t['Ucircumflex'] = 722;
  49752. t['yacute'] = 556;
  49753. t['scommaaccent'] = 556;
  49754. t['ecircumflex'] = 556;
  49755. t['Uring'] = 722;
  49756. t['Udieresis'] = 722;
  49757. t['aogonek'] = 556;
  49758. t['Uacute'] = 722;
  49759. t['uogonek'] = 611;
  49760. t['Edieresis'] = 667;
  49761. t['Dcroat'] = 722;
  49762. t['commaaccent'] = 250;
  49763. t['copyright'] = 737;
  49764. t['Emacron'] = 667;
  49765. t['ccaron'] = 556;
  49766. t['aring'] = 556;
  49767. t['Ncommaaccent'] = 722;
  49768. t['lacute'] = 278;
  49769. t['agrave'] = 556;
  49770. t['Tcommaaccent'] = 611;
  49771. t['Cacute'] = 722;
  49772. t['atilde'] = 556;
  49773. t['Edotaccent'] = 667;
  49774. t['scaron'] = 556;
  49775. t['scedilla'] = 556;
  49776. t['iacute'] = 278;
  49777. t['lozenge'] = 494;
  49778. t['Rcaron'] = 722;
  49779. t['Gcommaaccent'] = 778;
  49780. t['ucircumflex'] = 611;
  49781. t['acircumflex'] = 556;
  49782. t['Amacron'] = 722;
  49783. t['rcaron'] = 389;
  49784. t['ccedilla'] = 556;
  49785. t['Zdotaccent'] = 611;
  49786. t['Thorn'] = 667;
  49787. t['Omacron'] = 778;
  49788. t['Racute'] = 722;
  49789. t['Sacute'] = 667;
  49790. t['dcaron'] = 743;
  49791. t['Umacron'] = 722;
  49792. t['uring'] = 611;
  49793. t['threesuperior'] = 333;
  49794. t['Ograve'] = 778;
  49795. t['Agrave'] = 722;
  49796. t['Abreve'] = 722;
  49797. t['multiply'] = 584;
  49798. t['uacute'] = 611;
  49799. t['Tcaron'] = 611;
  49800. t['partialdiff'] = 494;
  49801. t['ydieresis'] = 556;
  49802. t['Nacute'] = 722;
  49803. t['icircumflex'] = 278;
  49804. t['Ecircumflex'] = 667;
  49805. t['adieresis'] = 556;
  49806. t['edieresis'] = 556;
  49807. t['cacute'] = 556;
  49808. t['nacute'] = 611;
  49809. t['umacron'] = 611;
  49810. t['Ncaron'] = 722;
  49811. t['Iacute'] = 278;
  49812. t['plusminus'] = 584;
  49813. t['brokenbar'] = 280;
  49814. t['registered'] = 737;
  49815. t['Gbreve'] = 778;
  49816. t['Idotaccent'] = 278;
  49817. t['summation'] = 600;
  49818. t['Egrave'] = 667;
  49819. t['racute'] = 389;
  49820. t['omacron'] = 611;
  49821. t['Zacute'] = 611;
  49822. t['Zcaron'] = 611;
  49823. t['greaterequal'] = 549;
  49824. t['Eth'] = 722;
  49825. t['Ccedilla'] = 722;
  49826. t['lcommaaccent'] = 278;
  49827. t['tcaron'] = 389;
  49828. t['eogonek'] = 556;
  49829. t['Uogonek'] = 722;
  49830. t['Aacute'] = 722;
  49831. t['Adieresis'] = 722;
  49832. t['egrave'] = 556;
  49833. t['zacute'] = 500;
  49834. t['iogonek'] = 278;
  49835. t['Oacute'] = 778;
  49836. t['oacute'] = 611;
  49837. t['amacron'] = 556;
  49838. t['sacute'] = 556;
  49839. t['idieresis'] = 278;
  49840. t['Ocircumflex'] = 778;
  49841. t['Ugrave'] = 722;
  49842. t['Delta'] = 612;
  49843. t['thorn'] = 611;
  49844. t['twosuperior'] = 333;
  49845. t['Odieresis'] = 778;
  49846. t['mu'] = 611;
  49847. t['igrave'] = 278;
  49848. t['ohungarumlaut'] = 611;
  49849. t['Eogonek'] = 667;
  49850. t['dcroat'] = 611;
  49851. t['threequarters'] = 834;
  49852. t['Scedilla'] = 667;
  49853. t['lcaron'] = 400;
  49854. t['Kcommaaccent'] = 722;
  49855. t['Lacute'] = 611;
  49856. t['trademark'] = 1000;
  49857. t['edotaccent'] = 556;
  49858. t['Igrave'] = 278;
  49859. t['Imacron'] = 278;
  49860. t['Lcaron'] = 611;
  49861. t['onehalf'] = 834;
  49862. t['lessequal'] = 549;
  49863. t['ocircumflex'] = 611;
  49864. t['ntilde'] = 611;
  49865. t['Uhungarumlaut'] = 722;
  49866. t['Eacute'] = 667;
  49867. t['emacron'] = 556;
  49868. t['gbreve'] = 611;
  49869. t['onequarter'] = 834;
  49870. t['Scaron'] = 667;
  49871. t['Scommaaccent'] = 667;
  49872. t['Ohungarumlaut'] = 778;
  49873. t['degree'] = 400;
  49874. t['ograve'] = 611;
  49875. t['Ccaron'] = 722;
  49876. t['ugrave'] = 611;
  49877. t['radical'] = 549;
  49878. t['Dcaron'] = 722;
  49879. t['rcommaaccent'] = 389;
  49880. t['Ntilde'] = 722;
  49881. t['otilde'] = 611;
  49882. t['Rcommaaccent'] = 722;
  49883. t['Lcommaaccent'] = 611;
  49884. t['Atilde'] = 722;
  49885. t['Aogonek'] = 722;
  49886. t['Aring'] = 722;
  49887. t['Otilde'] = 778;
  49888. t['zdotaccent'] = 500;
  49889. t['Ecaron'] = 667;
  49890. t['Iogonek'] = 278;
  49891. t['kcommaaccent'] = 556;
  49892. t['minus'] = 584;
  49893. t['Icircumflex'] = 278;
  49894. t['ncaron'] = 611;
  49895. t['tcommaaccent'] = 333;
  49896. t['logicalnot'] = 584;
  49897. t['odieresis'] = 611;
  49898. t['udieresis'] = 611;
  49899. t['notequal'] = 549;
  49900. t['gcommaaccent'] = 611;
  49901. t['eth'] = 611;
  49902. t['zcaron'] = 500;
  49903. t['ncommaaccent'] = 611;
  49904. t['onesuperior'] = 333;
  49905. t['imacron'] = 278;
  49906. t['Euro'] = 556;
  49907. });
  49908. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49909. t['space'] = 278;
  49910. t['exclam'] = 333;
  49911. t['quotedbl'] = 474;
  49912. t['numbersign'] = 556;
  49913. t['dollar'] = 556;
  49914. t['percent'] = 889;
  49915. t['ampersand'] = 722;
  49916. t['quoteright'] = 278;
  49917. t['parenleft'] = 333;
  49918. t['parenright'] = 333;
  49919. t['asterisk'] = 389;
  49920. t['plus'] = 584;
  49921. t['comma'] = 278;
  49922. t['hyphen'] = 333;
  49923. t['period'] = 278;
  49924. t['slash'] = 278;
  49925. t['zero'] = 556;
  49926. t['one'] = 556;
  49927. t['two'] = 556;
  49928. t['three'] = 556;
  49929. t['four'] = 556;
  49930. t['five'] = 556;
  49931. t['six'] = 556;
  49932. t['seven'] = 556;
  49933. t['eight'] = 556;
  49934. t['nine'] = 556;
  49935. t['colon'] = 333;
  49936. t['semicolon'] = 333;
  49937. t['less'] = 584;
  49938. t['equal'] = 584;
  49939. t['greater'] = 584;
  49940. t['question'] = 611;
  49941. t['at'] = 975;
  49942. t['A'] = 722;
  49943. t['B'] = 722;
  49944. t['C'] = 722;
  49945. t['D'] = 722;
  49946. t['E'] = 667;
  49947. t['F'] = 611;
  49948. t['G'] = 778;
  49949. t['H'] = 722;
  49950. t['I'] = 278;
  49951. t['J'] = 556;
  49952. t['K'] = 722;
  49953. t['L'] = 611;
  49954. t['M'] = 833;
  49955. t['N'] = 722;
  49956. t['O'] = 778;
  49957. t['P'] = 667;
  49958. t['Q'] = 778;
  49959. t['R'] = 722;
  49960. t['S'] = 667;
  49961. t['T'] = 611;
  49962. t['U'] = 722;
  49963. t['V'] = 667;
  49964. t['W'] = 944;
  49965. t['X'] = 667;
  49966. t['Y'] = 667;
  49967. t['Z'] = 611;
  49968. t['bracketleft'] = 333;
  49969. t['backslash'] = 278;
  49970. t['bracketright'] = 333;
  49971. t['asciicircum'] = 584;
  49972. t['underscore'] = 556;
  49973. t['quoteleft'] = 278;
  49974. t['a'] = 556;
  49975. t['b'] = 611;
  49976. t['c'] = 556;
  49977. t['d'] = 611;
  49978. t['e'] = 556;
  49979. t['f'] = 333;
  49980. t['g'] = 611;
  49981. t['h'] = 611;
  49982. t['i'] = 278;
  49983. t['j'] = 278;
  49984. t['k'] = 556;
  49985. t['l'] = 278;
  49986. t['m'] = 889;
  49987. t['n'] = 611;
  49988. t['o'] = 611;
  49989. t['p'] = 611;
  49990. t['q'] = 611;
  49991. t['r'] = 389;
  49992. t['s'] = 556;
  49993. t['t'] = 333;
  49994. t['u'] = 611;
  49995. t['v'] = 556;
  49996. t['w'] = 778;
  49997. t['x'] = 556;
  49998. t['y'] = 556;
  49999. t['z'] = 500;
  50000. t['braceleft'] = 389;
  50001. t['bar'] = 280;
  50002. t['braceright'] = 389;
  50003. t['asciitilde'] = 584;
  50004. t['exclamdown'] = 333;
  50005. t['cent'] = 556;
  50006. t['sterling'] = 556;
  50007. t['fraction'] = 167;
  50008. t['yen'] = 556;
  50009. t['florin'] = 556;
  50010. t['section'] = 556;
  50011. t['currency'] = 556;
  50012. t['quotesingle'] = 238;
  50013. t['quotedblleft'] = 500;
  50014. t['guillemotleft'] = 556;
  50015. t['guilsinglleft'] = 333;
  50016. t['guilsinglright'] = 333;
  50017. t['fi'] = 611;
  50018. t['fl'] = 611;
  50019. t['endash'] = 556;
  50020. t['dagger'] = 556;
  50021. t['daggerdbl'] = 556;
  50022. t['periodcentered'] = 278;
  50023. t['paragraph'] = 556;
  50024. t['bullet'] = 350;
  50025. t['quotesinglbase'] = 278;
  50026. t['quotedblbase'] = 500;
  50027. t['quotedblright'] = 500;
  50028. t['guillemotright'] = 556;
  50029. t['ellipsis'] = 1000;
  50030. t['perthousand'] = 1000;
  50031. t['questiondown'] = 611;
  50032. t['grave'] = 333;
  50033. t['acute'] = 333;
  50034. t['circumflex'] = 333;
  50035. t['tilde'] = 333;
  50036. t['macron'] = 333;
  50037. t['breve'] = 333;
  50038. t['dotaccent'] = 333;
  50039. t['dieresis'] = 333;
  50040. t['ring'] = 333;
  50041. t['cedilla'] = 333;
  50042. t['hungarumlaut'] = 333;
  50043. t['ogonek'] = 333;
  50044. t['caron'] = 333;
  50045. t['emdash'] = 1000;
  50046. t['AE'] = 1000;
  50047. t['ordfeminine'] = 370;
  50048. t['Lslash'] = 611;
  50049. t['Oslash'] = 778;
  50050. t['OE'] = 1000;
  50051. t['ordmasculine'] = 365;
  50052. t['ae'] = 889;
  50053. t['dotlessi'] = 278;
  50054. t['lslash'] = 278;
  50055. t['oslash'] = 611;
  50056. t['oe'] = 944;
  50057. t['germandbls'] = 611;
  50058. t['Idieresis'] = 278;
  50059. t['eacute'] = 556;
  50060. t['abreve'] = 556;
  50061. t['uhungarumlaut'] = 611;
  50062. t['ecaron'] = 556;
  50063. t['Ydieresis'] = 667;
  50064. t['divide'] = 584;
  50065. t['Yacute'] = 667;
  50066. t['Acircumflex'] = 722;
  50067. t['aacute'] = 556;
  50068. t['Ucircumflex'] = 722;
  50069. t['yacute'] = 556;
  50070. t['scommaaccent'] = 556;
  50071. t['ecircumflex'] = 556;
  50072. t['Uring'] = 722;
  50073. t['Udieresis'] = 722;
  50074. t['aogonek'] = 556;
  50075. t['Uacute'] = 722;
  50076. t['uogonek'] = 611;
  50077. t['Edieresis'] = 667;
  50078. t['Dcroat'] = 722;
  50079. t['commaaccent'] = 250;
  50080. t['copyright'] = 737;
  50081. t['Emacron'] = 667;
  50082. t['ccaron'] = 556;
  50083. t['aring'] = 556;
  50084. t['Ncommaaccent'] = 722;
  50085. t['lacute'] = 278;
  50086. t['agrave'] = 556;
  50087. t['Tcommaaccent'] = 611;
  50088. t['Cacute'] = 722;
  50089. t['atilde'] = 556;
  50090. t['Edotaccent'] = 667;
  50091. t['scaron'] = 556;
  50092. t['scedilla'] = 556;
  50093. t['iacute'] = 278;
  50094. t['lozenge'] = 494;
  50095. t['Rcaron'] = 722;
  50096. t['Gcommaaccent'] = 778;
  50097. t['ucircumflex'] = 611;
  50098. t['acircumflex'] = 556;
  50099. t['Amacron'] = 722;
  50100. t['rcaron'] = 389;
  50101. t['ccedilla'] = 556;
  50102. t['Zdotaccent'] = 611;
  50103. t['Thorn'] = 667;
  50104. t['Omacron'] = 778;
  50105. t['Racute'] = 722;
  50106. t['Sacute'] = 667;
  50107. t['dcaron'] = 743;
  50108. t['Umacron'] = 722;
  50109. t['uring'] = 611;
  50110. t['threesuperior'] = 333;
  50111. t['Ograve'] = 778;
  50112. t['Agrave'] = 722;
  50113. t['Abreve'] = 722;
  50114. t['multiply'] = 584;
  50115. t['uacute'] = 611;
  50116. t['Tcaron'] = 611;
  50117. t['partialdiff'] = 494;
  50118. t['ydieresis'] = 556;
  50119. t['Nacute'] = 722;
  50120. t['icircumflex'] = 278;
  50121. t['Ecircumflex'] = 667;
  50122. t['adieresis'] = 556;
  50123. t['edieresis'] = 556;
  50124. t['cacute'] = 556;
  50125. t['nacute'] = 611;
  50126. t['umacron'] = 611;
  50127. t['Ncaron'] = 722;
  50128. t['Iacute'] = 278;
  50129. t['plusminus'] = 584;
  50130. t['brokenbar'] = 280;
  50131. t['registered'] = 737;
  50132. t['Gbreve'] = 778;
  50133. t['Idotaccent'] = 278;
  50134. t['summation'] = 600;
  50135. t['Egrave'] = 667;
  50136. t['racute'] = 389;
  50137. t['omacron'] = 611;
  50138. t['Zacute'] = 611;
  50139. t['Zcaron'] = 611;
  50140. t['greaterequal'] = 549;
  50141. t['Eth'] = 722;
  50142. t['Ccedilla'] = 722;
  50143. t['lcommaaccent'] = 278;
  50144. t['tcaron'] = 389;
  50145. t['eogonek'] = 556;
  50146. t['Uogonek'] = 722;
  50147. t['Aacute'] = 722;
  50148. t['Adieresis'] = 722;
  50149. t['egrave'] = 556;
  50150. t['zacute'] = 500;
  50151. t['iogonek'] = 278;
  50152. t['Oacute'] = 778;
  50153. t['oacute'] = 611;
  50154. t['amacron'] = 556;
  50155. t['sacute'] = 556;
  50156. t['idieresis'] = 278;
  50157. t['Ocircumflex'] = 778;
  50158. t['Ugrave'] = 722;
  50159. t['Delta'] = 612;
  50160. t['thorn'] = 611;
  50161. t['twosuperior'] = 333;
  50162. t['Odieresis'] = 778;
  50163. t['mu'] = 611;
  50164. t['igrave'] = 278;
  50165. t['ohungarumlaut'] = 611;
  50166. t['Eogonek'] = 667;
  50167. t['dcroat'] = 611;
  50168. t['threequarters'] = 834;
  50169. t['Scedilla'] = 667;
  50170. t['lcaron'] = 400;
  50171. t['Kcommaaccent'] = 722;
  50172. t['Lacute'] = 611;
  50173. t['trademark'] = 1000;
  50174. t['edotaccent'] = 556;
  50175. t['Igrave'] = 278;
  50176. t['Imacron'] = 278;
  50177. t['Lcaron'] = 611;
  50178. t['onehalf'] = 834;
  50179. t['lessequal'] = 549;
  50180. t['ocircumflex'] = 611;
  50181. t['ntilde'] = 611;
  50182. t['Uhungarumlaut'] = 722;
  50183. t['Eacute'] = 667;
  50184. t['emacron'] = 556;
  50185. t['gbreve'] = 611;
  50186. t['onequarter'] = 834;
  50187. t['Scaron'] = 667;
  50188. t['Scommaaccent'] = 667;
  50189. t['Ohungarumlaut'] = 778;
  50190. t['degree'] = 400;
  50191. t['ograve'] = 611;
  50192. t['Ccaron'] = 722;
  50193. t['ugrave'] = 611;
  50194. t['radical'] = 549;
  50195. t['Dcaron'] = 722;
  50196. t['rcommaaccent'] = 389;
  50197. t['Ntilde'] = 722;
  50198. t['otilde'] = 611;
  50199. t['Rcommaaccent'] = 722;
  50200. t['Lcommaaccent'] = 611;
  50201. t['Atilde'] = 722;
  50202. t['Aogonek'] = 722;
  50203. t['Aring'] = 722;
  50204. t['Otilde'] = 778;
  50205. t['zdotaccent'] = 500;
  50206. t['Ecaron'] = 667;
  50207. t['Iogonek'] = 278;
  50208. t['kcommaaccent'] = 556;
  50209. t['minus'] = 584;
  50210. t['Icircumflex'] = 278;
  50211. t['ncaron'] = 611;
  50212. t['tcommaaccent'] = 333;
  50213. t['logicalnot'] = 584;
  50214. t['odieresis'] = 611;
  50215. t['udieresis'] = 611;
  50216. t['notequal'] = 549;
  50217. t['gcommaaccent'] = 611;
  50218. t['eth'] = 611;
  50219. t['zcaron'] = 500;
  50220. t['ncommaaccent'] = 611;
  50221. t['onesuperior'] = 333;
  50222. t['imacron'] = 278;
  50223. t['Euro'] = 556;
  50224. });
  50225. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50226. t['space'] = 278;
  50227. t['exclam'] = 278;
  50228. t['quotedbl'] = 355;
  50229. t['numbersign'] = 556;
  50230. t['dollar'] = 556;
  50231. t['percent'] = 889;
  50232. t['ampersand'] = 667;
  50233. t['quoteright'] = 222;
  50234. t['parenleft'] = 333;
  50235. t['parenright'] = 333;
  50236. t['asterisk'] = 389;
  50237. t['plus'] = 584;
  50238. t['comma'] = 278;
  50239. t['hyphen'] = 333;
  50240. t['period'] = 278;
  50241. t['slash'] = 278;
  50242. t['zero'] = 556;
  50243. t['one'] = 556;
  50244. t['two'] = 556;
  50245. t['three'] = 556;
  50246. t['four'] = 556;
  50247. t['five'] = 556;
  50248. t['six'] = 556;
  50249. t['seven'] = 556;
  50250. t['eight'] = 556;
  50251. t['nine'] = 556;
  50252. t['colon'] = 278;
  50253. t['semicolon'] = 278;
  50254. t['less'] = 584;
  50255. t['equal'] = 584;
  50256. t['greater'] = 584;
  50257. t['question'] = 556;
  50258. t['at'] = 1015;
  50259. t['A'] = 667;
  50260. t['B'] = 667;
  50261. t['C'] = 722;
  50262. t['D'] = 722;
  50263. t['E'] = 667;
  50264. t['F'] = 611;
  50265. t['G'] = 778;
  50266. t['H'] = 722;
  50267. t['I'] = 278;
  50268. t['J'] = 500;
  50269. t['K'] = 667;
  50270. t['L'] = 556;
  50271. t['M'] = 833;
  50272. t['N'] = 722;
  50273. t['O'] = 778;
  50274. t['P'] = 667;
  50275. t['Q'] = 778;
  50276. t['R'] = 722;
  50277. t['S'] = 667;
  50278. t['T'] = 611;
  50279. t['U'] = 722;
  50280. t['V'] = 667;
  50281. t['W'] = 944;
  50282. t['X'] = 667;
  50283. t['Y'] = 667;
  50284. t['Z'] = 611;
  50285. t['bracketleft'] = 278;
  50286. t['backslash'] = 278;
  50287. t['bracketright'] = 278;
  50288. t['asciicircum'] = 469;
  50289. t['underscore'] = 556;
  50290. t['quoteleft'] = 222;
  50291. t['a'] = 556;
  50292. t['b'] = 556;
  50293. t['c'] = 500;
  50294. t['d'] = 556;
  50295. t['e'] = 556;
  50296. t['f'] = 278;
  50297. t['g'] = 556;
  50298. t['h'] = 556;
  50299. t['i'] = 222;
  50300. t['j'] = 222;
  50301. t['k'] = 500;
  50302. t['l'] = 222;
  50303. t['m'] = 833;
  50304. t['n'] = 556;
  50305. t['o'] = 556;
  50306. t['p'] = 556;
  50307. t['q'] = 556;
  50308. t['r'] = 333;
  50309. t['s'] = 500;
  50310. t['t'] = 278;
  50311. t['u'] = 556;
  50312. t['v'] = 500;
  50313. t['w'] = 722;
  50314. t['x'] = 500;
  50315. t['y'] = 500;
  50316. t['z'] = 500;
  50317. t['braceleft'] = 334;
  50318. t['bar'] = 260;
  50319. t['braceright'] = 334;
  50320. t['asciitilde'] = 584;
  50321. t['exclamdown'] = 333;
  50322. t['cent'] = 556;
  50323. t['sterling'] = 556;
  50324. t['fraction'] = 167;
  50325. t['yen'] = 556;
  50326. t['florin'] = 556;
  50327. t['section'] = 556;
  50328. t['currency'] = 556;
  50329. t['quotesingle'] = 191;
  50330. t['quotedblleft'] = 333;
  50331. t['guillemotleft'] = 556;
  50332. t['guilsinglleft'] = 333;
  50333. t['guilsinglright'] = 333;
  50334. t['fi'] = 500;
  50335. t['fl'] = 500;
  50336. t['endash'] = 556;
  50337. t['dagger'] = 556;
  50338. t['daggerdbl'] = 556;
  50339. t['periodcentered'] = 278;
  50340. t['paragraph'] = 537;
  50341. t['bullet'] = 350;
  50342. t['quotesinglbase'] = 222;
  50343. t['quotedblbase'] = 333;
  50344. t['quotedblright'] = 333;
  50345. t['guillemotright'] = 556;
  50346. t['ellipsis'] = 1000;
  50347. t['perthousand'] = 1000;
  50348. t['questiondown'] = 611;
  50349. t['grave'] = 333;
  50350. t['acute'] = 333;
  50351. t['circumflex'] = 333;
  50352. t['tilde'] = 333;
  50353. t['macron'] = 333;
  50354. t['breve'] = 333;
  50355. t['dotaccent'] = 333;
  50356. t['dieresis'] = 333;
  50357. t['ring'] = 333;
  50358. t['cedilla'] = 333;
  50359. t['hungarumlaut'] = 333;
  50360. t['ogonek'] = 333;
  50361. t['caron'] = 333;
  50362. t['emdash'] = 1000;
  50363. t['AE'] = 1000;
  50364. t['ordfeminine'] = 370;
  50365. t['Lslash'] = 556;
  50366. t['Oslash'] = 778;
  50367. t['OE'] = 1000;
  50368. t['ordmasculine'] = 365;
  50369. t['ae'] = 889;
  50370. t['dotlessi'] = 278;
  50371. t['lslash'] = 222;
  50372. t['oslash'] = 611;
  50373. t['oe'] = 944;
  50374. t['germandbls'] = 611;
  50375. t['Idieresis'] = 278;
  50376. t['eacute'] = 556;
  50377. t['abreve'] = 556;
  50378. t['uhungarumlaut'] = 556;
  50379. t['ecaron'] = 556;
  50380. t['Ydieresis'] = 667;
  50381. t['divide'] = 584;
  50382. t['Yacute'] = 667;
  50383. t['Acircumflex'] = 667;
  50384. t['aacute'] = 556;
  50385. t['Ucircumflex'] = 722;
  50386. t['yacute'] = 500;
  50387. t['scommaaccent'] = 500;
  50388. t['ecircumflex'] = 556;
  50389. t['Uring'] = 722;
  50390. t['Udieresis'] = 722;
  50391. t['aogonek'] = 556;
  50392. t['Uacute'] = 722;
  50393. t['uogonek'] = 556;
  50394. t['Edieresis'] = 667;
  50395. t['Dcroat'] = 722;
  50396. t['commaaccent'] = 250;
  50397. t['copyright'] = 737;
  50398. t['Emacron'] = 667;
  50399. t['ccaron'] = 500;
  50400. t['aring'] = 556;
  50401. t['Ncommaaccent'] = 722;
  50402. t['lacute'] = 222;
  50403. t['agrave'] = 556;
  50404. t['Tcommaaccent'] = 611;
  50405. t['Cacute'] = 722;
  50406. t['atilde'] = 556;
  50407. t['Edotaccent'] = 667;
  50408. t['scaron'] = 500;
  50409. t['scedilla'] = 500;
  50410. t['iacute'] = 278;
  50411. t['lozenge'] = 471;
  50412. t['Rcaron'] = 722;
  50413. t['Gcommaaccent'] = 778;
  50414. t['ucircumflex'] = 556;
  50415. t['acircumflex'] = 556;
  50416. t['Amacron'] = 667;
  50417. t['rcaron'] = 333;
  50418. t['ccedilla'] = 500;
  50419. t['Zdotaccent'] = 611;
  50420. t['Thorn'] = 667;
  50421. t['Omacron'] = 778;
  50422. t['Racute'] = 722;
  50423. t['Sacute'] = 667;
  50424. t['dcaron'] = 643;
  50425. t['Umacron'] = 722;
  50426. t['uring'] = 556;
  50427. t['threesuperior'] = 333;
  50428. t['Ograve'] = 778;
  50429. t['Agrave'] = 667;
  50430. t['Abreve'] = 667;
  50431. t['multiply'] = 584;
  50432. t['uacute'] = 556;
  50433. t['Tcaron'] = 611;
  50434. t['partialdiff'] = 476;
  50435. t['ydieresis'] = 500;
  50436. t['Nacute'] = 722;
  50437. t['icircumflex'] = 278;
  50438. t['Ecircumflex'] = 667;
  50439. t['adieresis'] = 556;
  50440. t['edieresis'] = 556;
  50441. t['cacute'] = 500;
  50442. t['nacute'] = 556;
  50443. t['umacron'] = 556;
  50444. t['Ncaron'] = 722;
  50445. t['Iacute'] = 278;
  50446. t['plusminus'] = 584;
  50447. t['brokenbar'] = 260;
  50448. t['registered'] = 737;
  50449. t['Gbreve'] = 778;
  50450. t['Idotaccent'] = 278;
  50451. t['summation'] = 600;
  50452. t['Egrave'] = 667;
  50453. t['racute'] = 333;
  50454. t['omacron'] = 556;
  50455. t['Zacute'] = 611;
  50456. t['Zcaron'] = 611;
  50457. t['greaterequal'] = 549;
  50458. t['Eth'] = 722;
  50459. t['Ccedilla'] = 722;
  50460. t['lcommaaccent'] = 222;
  50461. t['tcaron'] = 317;
  50462. t['eogonek'] = 556;
  50463. t['Uogonek'] = 722;
  50464. t['Aacute'] = 667;
  50465. t['Adieresis'] = 667;
  50466. t['egrave'] = 556;
  50467. t['zacute'] = 500;
  50468. t['iogonek'] = 222;
  50469. t['Oacute'] = 778;
  50470. t['oacute'] = 556;
  50471. t['amacron'] = 556;
  50472. t['sacute'] = 500;
  50473. t['idieresis'] = 278;
  50474. t['Ocircumflex'] = 778;
  50475. t['Ugrave'] = 722;
  50476. t['Delta'] = 612;
  50477. t['thorn'] = 556;
  50478. t['twosuperior'] = 333;
  50479. t['Odieresis'] = 778;
  50480. t['mu'] = 556;
  50481. t['igrave'] = 278;
  50482. t['ohungarumlaut'] = 556;
  50483. t['Eogonek'] = 667;
  50484. t['dcroat'] = 556;
  50485. t['threequarters'] = 834;
  50486. t['Scedilla'] = 667;
  50487. t['lcaron'] = 299;
  50488. t['Kcommaaccent'] = 667;
  50489. t['Lacute'] = 556;
  50490. t['trademark'] = 1000;
  50491. t['edotaccent'] = 556;
  50492. t['Igrave'] = 278;
  50493. t['Imacron'] = 278;
  50494. t['Lcaron'] = 556;
  50495. t['onehalf'] = 834;
  50496. t['lessequal'] = 549;
  50497. t['ocircumflex'] = 556;
  50498. t['ntilde'] = 556;
  50499. t['Uhungarumlaut'] = 722;
  50500. t['Eacute'] = 667;
  50501. t['emacron'] = 556;
  50502. t['gbreve'] = 556;
  50503. t['onequarter'] = 834;
  50504. t['Scaron'] = 667;
  50505. t['Scommaaccent'] = 667;
  50506. t['Ohungarumlaut'] = 778;
  50507. t['degree'] = 400;
  50508. t['ograve'] = 556;
  50509. t['Ccaron'] = 722;
  50510. t['ugrave'] = 556;
  50511. t['radical'] = 453;
  50512. t['Dcaron'] = 722;
  50513. t['rcommaaccent'] = 333;
  50514. t['Ntilde'] = 722;
  50515. t['otilde'] = 556;
  50516. t['Rcommaaccent'] = 722;
  50517. t['Lcommaaccent'] = 556;
  50518. t['Atilde'] = 667;
  50519. t['Aogonek'] = 667;
  50520. t['Aring'] = 667;
  50521. t['Otilde'] = 778;
  50522. t['zdotaccent'] = 500;
  50523. t['Ecaron'] = 667;
  50524. t['Iogonek'] = 278;
  50525. t['kcommaaccent'] = 500;
  50526. t['minus'] = 584;
  50527. t['Icircumflex'] = 278;
  50528. t['ncaron'] = 556;
  50529. t['tcommaaccent'] = 278;
  50530. t['logicalnot'] = 584;
  50531. t['odieresis'] = 556;
  50532. t['udieresis'] = 556;
  50533. t['notequal'] = 549;
  50534. t['gcommaaccent'] = 556;
  50535. t['eth'] = 556;
  50536. t['zcaron'] = 500;
  50537. t['ncommaaccent'] = 556;
  50538. t['onesuperior'] = 333;
  50539. t['imacron'] = 278;
  50540. t['Euro'] = 556;
  50541. });
  50542. t['Symbol'] = getLookupTableFactory(function (t) {
  50543. t['space'] = 250;
  50544. t['exclam'] = 333;
  50545. t['universal'] = 713;
  50546. t['numbersign'] = 500;
  50547. t['existential'] = 549;
  50548. t['percent'] = 833;
  50549. t['ampersand'] = 778;
  50550. t['suchthat'] = 439;
  50551. t['parenleft'] = 333;
  50552. t['parenright'] = 333;
  50553. t['asteriskmath'] = 500;
  50554. t['plus'] = 549;
  50555. t['comma'] = 250;
  50556. t['minus'] = 549;
  50557. t['period'] = 250;
  50558. t['slash'] = 278;
  50559. t['zero'] = 500;
  50560. t['one'] = 500;
  50561. t['two'] = 500;
  50562. t['three'] = 500;
  50563. t['four'] = 500;
  50564. t['five'] = 500;
  50565. t['six'] = 500;
  50566. t['seven'] = 500;
  50567. t['eight'] = 500;
  50568. t['nine'] = 500;
  50569. t['colon'] = 278;
  50570. t['semicolon'] = 278;
  50571. t['less'] = 549;
  50572. t['equal'] = 549;
  50573. t['greater'] = 549;
  50574. t['question'] = 444;
  50575. t['congruent'] = 549;
  50576. t['Alpha'] = 722;
  50577. t['Beta'] = 667;
  50578. t['Chi'] = 722;
  50579. t['Delta'] = 612;
  50580. t['Epsilon'] = 611;
  50581. t['Phi'] = 763;
  50582. t['Gamma'] = 603;
  50583. t['Eta'] = 722;
  50584. t['Iota'] = 333;
  50585. t['theta1'] = 631;
  50586. t['Kappa'] = 722;
  50587. t['Lambda'] = 686;
  50588. t['Mu'] = 889;
  50589. t['Nu'] = 722;
  50590. t['Omicron'] = 722;
  50591. t['Pi'] = 768;
  50592. t['Theta'] = 741;
  50593. t['Rho'] = 556;
  50594. t['Sigma'] = 592;
  50595. t['Tau'] = 611;
  50596. t['Upsilon'] = 690;
  50597. t['sigma1'] = 439;
  50598. t['Omega'] = 768;
  50599. t['Xi'] = 645;
  50600. t['Psi'] = 795;
  50601. t['Zeta'] = 611;
  50602. t['bracketleft'] = 333;
  50603. t['therefore'] = 863;
  50604. t['bracketright'] = 333;
  50605. t['perpendicular'] = 658;
  50606. t['underscore'] = 500;
  50607. t['radicalex'] = 500;
  50608. t['alpha'] = 631;
  50609. t['beta'] = 549;
  50610. t['chi'] = 549;
  50611. t['delta'] = 494;
  50612. t['epsilon'] = 439;
  50613. t['phi'] = 521;
  50614. t['gamma'] = 411;
  50615. t['eta'] = 603;
  50616. t['iota'] = 329;
  50617. t['phi1'] = 603;
  50618. t['kappa'] = 549;
  50619. t['lambda'] = 549;
  50620. t['mu'] = 576;
  50621. t['nu'] = 521;
  50622. t['omicron'] = 549;
  50623. t['pi'] = 549;
  50624. t['theta'] = 521;
  50625. t['rho'] = 549;
  50626. t['sigma'] = 603;
  50627. t['tau'] = 439;
  50628. t['upsilon'] = 576;
  50629. t['omega1'] = 713;
  50630. t['omega'] = 686;
  50631. t['xi'] = 493;
  50632. t['psi'] = 686;
  50633. t['zeta'] = 494;
  50634. t['braceleft'] = 480;
  50635. t['bar'] = 200;
  50636. t['braceright'] = 480;
  50637. t['similar'] = 549;
  50638. t['Euro'] = 750;
  50639. t['Upsilon1'] = 620;
  50640. t['minute'] = 247;
  50641. t['lessequal'] = 549;
  50642. t['fraction'] = 167;
  50643. t['infinity'] = 713;
  50644. t['florin'] = 500;
  50645. t['club'] = 753;
  50646. t['diamond'] = 753;
  50647. t['heart'] = 753;
  50648. t['spade'] = 753;
  50649. t['arrowboth'] = 1042;
  50650. t['arrowleft'] = 987;
  50651. t['arrowup'] = 603;
  50652. t['arrowright'] = 987;
  50653. t['arrowdown'] = 603;
  50654. t['degree'] = 400;
  50655. t['plusminus'] = 549;
  50656. t['second'] = 411;
  50657. t['greaterequal'] = 549;
  50658. t['multiply'] = 549;
  50659. t['proportional'] = 713;
  50660. t['partialdiff'] = 494;
  50661. t['bullet'] = 460;
  50662. t['divide'] = 549;
  50663. t['notequal'] = 549;
  50664. t['equivalence'] = 549;
  50665. t['approxequal'] = 549;
  50666. t['ellipsis'] = 1000;
  50667. t['arrowvertex'] = 603;
  50668. t['arrowhorizex'] = 1000;
  50669. t['carriagereturn'] = 658;
  50670. t['aleph'] = 823;
  50671. t['Ifraktur'] = 686;
  50672. t['Rfraktur'] = 795;
  50673. t['weierstrass'] = 987;
  50674. t['circlemultiply'] = 768;
  50675. t['circleplus'] = 768;
  50676. t['emptyset'] = 823;
  50677. t['intersection'] = 768;
  50678. t['union'] = 768;
  50679. t['propersuperset'] = 713;
  50680. t['reflexsuperset'] = 713;
  50681. t['notsubset'] = 713;
  50682. t['propersubset'] = 713;
  50683. t['reflexsubset'] = 713;
  50684. t['element'] = 713;
  50685. t['notelement'] = 713;
  50686. t['angle'] = 768;
  50687. t['gradient'] = 713;
  50688. t['registerserif'] = 790;
  50689. t['copyrightserif'] = 790;
  50690. t['trademarkserif'] = 890;
  50691. t['product'] = 823;
  50692. t['radical'] = 549;
  50693. t['dotmath'] = 250;
  50694. t['logicalnot'] = 713;
  50695. t['logicaland'] = 603;
  50696. t['logicalor'] = 603;
  50697. t['arrowdblboth'] = 1042;
  50698. t['arrowdblleft'] = 987;
  50699. t['arrowdblup'] = 603;
  50700. t['arrowdblright'] = 987;
  50701. t['arrowdbldown'] = 603;
  50702. t['lozenge'] = 494;
  50703. t['angleleft'] = 329;
  50704. t['registersans'] = 790;
  50705. t['copyrightsans'] = 790;
  50706. t['trademarksans'] = 786;
  50707. t['summation'] = 713;
  50708. t['parenlefttp'] = 384;
  50709. t['parenleftex'] = 384;
  50710. t['parenleftbt'] = 384;
  50711. t['bracketlefttp'] = 384;
  50712. t['bracketleftex'] = 384;
  50713. t['bracketleftbt'] = 384;
  50714. t['bracelefttp'] = 494;
  50715. t['braceleftmid'] = 494;
  50716. t['braceleftbt'] = 494;
  50717. t['braceex'] = 494;
  50718. t['angleright'] = 329;
  50719. t['integral'] = 274;
  50720. t['integraltp'] = 686;
  50721. t['integralex'] = 686;
  50722. t['integralbt'] = 686;
  50723. t['parenrighttp'] = 384;
  50724. t['parenrightex'] = 384;
  50725. t['parenrightbt'] = 384;
  50726. t['bracketrighttp'] = 384;
  50727. t['bracketrightex'] = 384;
  50728. t['bracketrightbt'] = 384;
  50729. t['bracerighttp'] = 494;
  50730. t['bracerightmid'] = 494;
  50731. t['bracerightbt'] = 494;
  50732. t['apple'] = 790;
  50733. });
  50734. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50735. t['space'] = 250;
  50736. t['exclam'] = 333;
  50737. t['quotedbl'] = 408;
  50738. t['numbersign'] = 500;
  50739. t['dollar'] = 500;
  50740. t['percent'] = 833;
  50741. t['ampersand'] = 778;
  50742. t['quoteright'] = 333;
  50743. t['parenleft'] = 333;
  50744. t['parenright'] = 333;
  50745. t['asterisk'] = 500;
  50746. t['plus'] = 564;
  50747. t['comma'] = 250;
  50748. t['hyphen'] = 333;
  50749. t['period'] = 250;
  50750. t['slash'] = 278;
  50751. t['zero'] = 500;
  50752. t['one'] = 500;
  50753. t['two'] = 500;
  50754. t['three'] = 500;
  50755. t['four'] = 500;
  50756. t['five'] = 500;
  50757. t['six'] = 500;
  50758. t['seven'] = 500;
  50759. t['eight'] = 500;
  50760. t['nine'] = 500;
  50761. t['colon'] = 278;
  50762. t['semicolon'] = 278;
  50763. t['less'] = 564;
  50764. t['equal'] = 564;
  50765. t['greater'] = 564;
  50766. t['question'] = 444;
  50767. t['at'] = 921;
  50768. t['A'] = 722;
  50769. t['B'] = 667;
  50770. t['C'] = 667;
  50771. t['D'] = 722;
  50772. t['E'] = 611;
  50773. t['F'] = 556;
  50774. t['G'] = 722;
  50775. t['H'] = 722;
  50776. t['I'] = 333;
  50777. t['J'] = 389;
  50778. t['K'] = 722;
  50779. t['L'] = 611;
  50780. t['M'] = 889;
  50781. t['N'] = 722;
  50782. t['O'] = 722;
  50783. t['P'] = 556;
  50784. t['Q'] = 722;
  50785. t['R'] = 667;
  50786. t['S'] = 556;
  50787. t['T'] = 611;
  50788. t['U'] = 722;
  50789. t['V'] = 722;
  50790. t['W'] = 944;
  50791. t['X'] = 722;
  50792. t['Y'] = 722;
  50793. t['Z'] = 611;
  50794. t['bracketleft'] = 333;
  50795. t['backslash'] = 278;
  50796. t['bracketright'] = 333;
  50797. t['asciicircum'] = 469;
  50798. t['underscore'] = 500;
  50799. t['quoteleft'] = 333;
  50800. t['a'] = 444;
  50801. t['b'] = 500;
  50802. t['c'] = 444;
  50803. t['d'] = 500;
  50804. t['e'] = 444;
  50805. t['f'] = 333;
  50806. t['g'] = 500;
  50807. t['h'] = 500;
  50808. t['i'] = 278;
  50809. t['j'] = 278;
  50810. t['k'] = 500;
  50811. t['l'] = 278;
  50812. t['m'] = 778;
  50813. t['n'] = 500;
  50814. t['o'] = 500;
  50815. t['p'] = 500;
  50816. t['q'] = 500;
  50817. t['r'] = 333;
  50818. t['s'] = 389;
  50819. t['t'] = 278;
  50820. t['u'] = 500;
  50821. t['v'] = 500;
  50822. t['w'] = 722;
  50823. t['x'] = 500;
  50824. t['y'] = 500;
  50825. t['z'] = 444;
  50826. t['braceleft'] = 480;
  50827. t['bar'] = 200;
  50828. t['braceright'] = 480;
  50829. t['asciitilde'] = 541;
  50830. t['exclamdown'] = 333;
  50831. t['cent'] = 500;
  50832. t['sterling'] = 500;
  50833. t['fraction'] = 167;
  50834. t['yen'] = 500;
  50835. t['florin'] = 500;
  50836. t['section'] = 500;
  50837. t['currency'] = 500;
  50838. t['quotesingle'] = 180;
  50839. t['quotedblleft'] = 444;
  50840. t['guillemotleft'] = 500;
  50841. t['guilsinglleft'] = 333;
  50842. t['guilsinglright'] = 333;
  50843. t['fi'] = 556;
  50844. t['fl'] = 556;
  50845. t['endash'] = 500;
  50846. t['dagger'] = 500;
  50847. t['daggerdbl'] = 500;
  50848. t['periodcentered'] = 250;
  50849. t['paragraph'] = 453;
  50850. t['bullet'] = 350;
  50851. t['quotesinglbase'] = 333;
  50852. t['quotedblbase'] = 444;
  50853. t['quotedblright'] = 444;
  50854. t['guillemotright'] = 500;
  50855. t['ellipsis'] = 1000;
  50856. t['perthousand'] = 1000;
  50857. t['questiondown'] = 444;
  50858. t['grave'] = 333;
  50859. t['acute'] = 333;
  50860. t['circumflex'] = 333;
  50861. t['tilde'] = 333;
  50862. t['macron'] = 333;
  50863. t['breve'] = 333;
  50864. t['dotaccent'] = 333;
  50865. t['dieresis'] = 333;
  50866. t['ring'] = 333;
  50867. t['cedilla'] = 333;
  50868. t['hungarumlaut'] = 333;
  50869. t['ogonek'] = 333;
  50870. t['caron'] = 333;
  50871. t['emdash'] = 1000;
  50872. t['AE'] = 889;
  50873. t['ordfeminine'] = 276;
  50874. t['Lslash'] = 611;
  50875. t['Oslash'] = 722;
  50876. t['OE'] = 889;
  50877. t['ordmasculine'] = 310;
  50878. t['ae'] = 667;
  50879. t['dotlessi'] = 278;
  50880. t['lslash'] = 278;
  50881. t['oslash'] = 500;
  50882. t['oe'] = 722;
  50883. t['germandbls'] = 500;
  50884. t['Idieresis'] = 333;
  50885. t['eacute'] = 444;
  50886. t['abreve'] = 444;
  50887. t['uhungarumlaut'] = 500;
  50888. t['ecaron'] = 444;
  50889. t['Ydieresis'] = 722;
  50890. t['divide'] = 564;
  50891. t['Yacute'] = 722;
  50892. t['Acircumflex'] = 722;
  50893. t['aacute'] = 444;
  50894. t['Ucircumflex'] = 722;
  50895. t['yacute'] = 500;
  50896. t['scommaaccent'] = 389;
  50897. t['ecircumflex'] = 444;
  50898. t['Uring'] = 722;
  50899. t['Udieresis'] = 722;
  50900. t['aogonek'] = 444;
  50901. t['Uacute'] = 722;
  50902. t['uogonek'] = 500;
  50903. t['Edieresis'] = 611;
  50904. t['Dcroat'] = 722;
  50905. t['commaaccent'] = 250;
  50906. t['copyright'] = 760;
  50907. t['Emacron'] = 611;
  50908. t['ccaron'] = 444;
  50909. t['aring'] = 444;
  50910. t['Ncommaaccent'] = 722;
  50911. t['lacute'] = 278;
  50912. t['agrave'] = 444;
  50913. t['Tcommaaccent'] = 611;
  50914. t['Cacute'] = 667;
  50915. t['atilde'] = 444;
  50916. t['Edotaccent'] = 611;
  50917. t['scaron'] = 389;
  50918. t['scedilla'] = 389;
  50919. t['iacute'] = 278;
  50920. t['lozenge'] = 471;
  50921. t['Rcaron'] = 667;
  50922. t['Gcommaaccent'] = 722;
  50923. t['ucircumflex'] = 500;
  50924. t['acircumflex'] = 444;
  50925. t['Amacron'] = 722;
  50926. t['rcaron'] = 333;
  50927. t['ccedilla'] = 444;
  50928. t['Zdotaccent'] = 611;
  50929. t['Thorn'] = 556;
  50930. t['Omacron'] = 722;
  50931. t['Racute'] = 667;
  50932. t['Sacute'] = 556;
  50933. t['dcaron'] = 588;
  50934. t['Umacron'] = 722;
  50935. t['uring'] = 500;
  50936. t['threesuperior'] = 300;
  50937. t['Ograve'] = 722;
  50938. t['Agrave'] = 722;
  50939. t['Abreve'] = 722;
  50940. t['multiply'] = 564;
  50941. t['uacute'] = 500;
  50942. t['Tcaron'] = 611;
  50943. t['partialdiff'] = 476;
  50944. t['ydieresis'] = 500;
  50945. t['Nacute'] = 722;
  50946. t['icircumflex'] = 278;
  50947. t['Ecircumflex'] = 611;
  50948. t['adieresis'] = 444;
  50949. t['edieresis'] = 444;
  50950. t['cacute'] = 444;
  50951. t['nacute'] = 500;
  50952. t['umacron'] = 500;
  50953. t['Ncaron'] = 722;
  50954. t['Iacute'] = 333;
  50955. t['plusminus'] = 564;
  50956. t['brokenbar'] = 200;
  50957. t['registered'] = 760;
  50958. t['Gbreve'] = 722;
  50959. t['Idotaccent'] = 333;
  50960. t['summation'] = 600;
  50961. t['Egrave'] = 611;
  50962. t['racute'] = 333;
  50963. t['omacron'] = 500;
  50964. t['Zacute'] = 611;
  50965. t['Zcaron'] = 611;
  50966. t['greaterequal'] = 549;
  50967. t['Eth'] = 722;
  50968. t['Ccedilla'] = 667;
  50969. t['lcommaaccent'] = 278;
  50970. t['tcaron'] = 326;
  50971. t['eogonek'] = 444;
  50972. t['Uogonek'] = 722;
  50973. t['Aacute'] = 722;
  50974. t['Adieresis'] = 722;
  50975. t['egrave'] = 444;
  50976. t['zacute'] = 444;
  50977. t['iogonek'] = 278;
  50978. t['Oacute'] = 722;
  50979. t['oacute'] = 500;
  50980. t['amacron'] = 444;
  50981. t['sacute'] = 389;
  50982. t['idieresis'] = 278;
  50983. t['Ocircumflex'] = 722;
  50984. t['Ugrave'] = 722;
  50985. t['Delta'] = 612;
  50986. t['thorn'] = 500;
  50987. t['twosuperior'] = 300;
  50988. t['Odieresis'] = 722;
  50989. t['mu'] = 500;
  50990. t['igrave'] = 278;
  50991. t['ohungarumlaut'] = 500;
  50992. t['Eogonek'] = 611;
  50993. t['dcroat'] = 500;
  50994. t['threequarters'] = 750;
  50995. t['Scedilla'] = 556;
  50996. t['lcaron'] = 344;
  50997. t['Kcommaaccent'] = 722;
  50998. t['Lacute'] = 611;
  50999. t['trademark'] = 980;
  51000. t['edotaccent'] = 444;
  51001. t['Igrave'] = 333;
  51002. t['Imacron'] = 333;
  51003. t['Lcaron'] = 611;
  51004. t['onehalf'] = 750;
  51005. t['lessequal'] = 549;
  51006. t['ocircumflex'] = 500;
  51007. t['ntilde'] = 500;
  51008. t['Uhungarumlaut'] = 722;
  51009. t['Eacute'] = 611;
  51010. t['emacron'] = 444;
  51011. t['gbreve'] = 500;
  51012. t['onequarter'] = 750;
  51013. t['Scaron'] = 556;
  51014. t['Scommaaccent'] = 556;
  51015. t['Ohungarumlaut'] = 722;
  51016. t['degree'] = 400;
  51017. t['ograve'] = 500;
  51018. t['Ccaron'] = 667;
  51019. t['ugrave'] = 500;
  51020. t['radical'] = 453;
  51021. t['Dcaron'] = 722;
  51022. t['rcommaaccent'] = 333;
  51023. t['Ntilde'] = 722;
  51024. t['otilde'] = 500;
  51025. t['Rcommaaccent'] = 667;
  51026. t['Lcommaaccent'] = 611;
  51027. t['Atilde'] = 722;
  51028. t['Aogonek'] = 722;
  51029. t['Aring'] = 722;
  51030. t['Otilde'] = 722;
  51031. t['zdotaccent'] = 444;
  51032. t['Ecaron'] = 611;
  51033. t['Iogonek'] = 333;
  51034. t['kcommaaccent'] = 500;
  51035. t['minus'] = 564;
  51036. t['Icircumflex'] = 333;
  51037. t['ncaron'] = 500;
  51038. t['tcommaaccent'] = 278;
  51039. t['logicalnot'] = 564;
  51040. t['odieresis'] = 500;
  51041. t['udieresis'] = 500;
  51042. t['notequal'] = 549;
  51043. t['gcommaaccent'] = 500;
  51044. t['eth'] = 500;
  51045. t['zcaron'] = 444;
  51046. t['ncommaaccent'] = 500;
  51047. t['onesuperior'] = 300;
  51048. t['imacron'] = 278;
  51049. t['Euro'] = 500;
  51050. });
  51051. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51052. t['space'] = 250;
  51053. t['exclam'] = 333;
  51054. t['quotedbl'] = 555;
  51055. t['numbersign'] = 500;
  51056. t['dollar'] = 500;
  51057. t['percent'] = 1000;
  51058. t['ampersand'] = 833;
  51059. t['quoteright'] = 333;
  51060. t['parenleft'] = 333;
  51061. t['parenright'] = 333;
  51062. t['asterisk'] = 500;
  51063. t['plus'] = 570;
  51064. t['comma'] = 250;
  51065. t['hyphen'] = 333;
  51066. t['period'] = 250;
  51067. t['slash'] = 278;
  51068. t['zero'] = 500;
  51069. t['one'] = 500;
  51070. t['two'] = 500;
  51071. t['three'] = 500;
  51072. t['four'] = 500;
  51073. t['five'] = 500;
  51074. t['six'] = 500;
  51075. t['seven'] = 500;
  51076. t['eight'] = 500;
  51077. t['nine'] = 500;
  51078. t['colon'] = 333;
  51079. t['semicolon'] = 333;
  51080. t['less'] = 570;
  51081. t['equal'] = 570;
  51082. t['greater'] = 570;
  51083. t['question'] = 500;
  51084. t['at'] = 930;
  51085. t['A'] = 722;
  51086. t['B'] = 667;
  51087. t['C'] = 722;
  51088. t['D'] = 722;
  51089. t['E'] = 667;
  51090. t['F'] = 611;
  51091. t['G'] = 778;
  51092. t['H'] = 778;
  51093. t['I'] = 389;
  51094. t['J'] = 500;
  51095. t['K'] = 778;
  51096. t['L'] = 667;
  51097. t['M'] = 944;
  51098. t['N'] = 722;
  51099. t['O'] = 778;
  51100. t['P'] = 611;
  51101. t['Q'] = 778;
  51102. t['R'] = 722;
  51103. t['S'] = 556;
  51104. t['T'] = 667;
  51105. t['U'] = 722;
  51106. t['V'] = 722;
  51107. t['W'] = 1000;
  51108. t['X'] = 722;
  51109. t['Y'] = 722;
  51110. t['Z'] = 667;
  51111. t['bracketleft'] = 333;
  51112. t['backslash'] = 278;
  51113. t['bracketright'] = 333;
  51114. t['asciicircum'] = 581;
  51115. t['underscore'] = 500;
  51116. t['quoteleft'] = 333;
  51117. t['a'] = 500;
  51118. t['b'] = 556;
  51119. t['c'] = 444;
  51120. t['d'] = 556;
  51121. t['e'] = 444;
  51122. t['f'] = 333;
  51123. t['g'] = 500;
  51124. t['h'] = 556;
  51125. t['i'] = 278;
  51126. t['j'] = 333;
  51127. t['k'] = 556;
  51128. t['l'] = 278;
  51129. t['m'] = 833;
  51130. t['n'] = 556;
  51131. t['o'] = 500;
  51132. t['p'] = 556;
  51133. t['q'] = 556;
  51134. t['r'] = 444;
  51135. t['s'] = 389;
  51136. t['t'] = 333;
  51137. t['u'] = 556;
  51138. t['v'] = 500;
  51139. t['w'] = 722;
  51140. t['x'] = 500;
  51141. t['y'] = 500;
  51142. t['z'] = 444;
  51143. t['braceleft'] = 394;
  51144. t['bar'] = 220;
  51145. t['braceright'] = 394;
  51146. t['asciitilde'] = 520;
  51147. t['exclamdown'] = 333;
  51148. t['cent'] = 500;
  51149. t['sterling'] = 500;
  51150. t['fraction'] = 167;
  51151. t['yen'] = 500;
  51152. t['florin'] = 500;
  51153. t['section'] = 500;
  51154. t['currency'] = 500;
  51155. t['quotesingle'] = 278;
  51156. t['quotedblleft'] = 500;
  51157. t['guillemotleft'] = 500;
  51158. t['guilsinglleft'] = 333;
  51159. t['guilsinglright'] = 333;
  51160. t['fi'] = 556;
  51161. t['fl'] = 556;
  51162. t['endash'] = 500;
  51163. t['dagger'] = 500;
  51164. t['daggerdbl'] = 500;
  51165. t['periodcentered'] = 250;
  51166. t['paragraph'] = 540;
  51167. t['bullet'] = 350;
  51168. t['quotesinglbase'] = 333;
  51169. t['quotedblbase'] = 500;
  51170. t['quotedblright'] = 500;
  51171. t['guillemotright'] = 500;
  51172. t['ellipsis'] = 1000;
  51173. t['perthousand'] = 1000;
  51174. t['questiondown'] = 500;
  51175. t['grave'] = 333;
  51176. t['acute'] = 333;
  51177. t['circumflex'] = 333;
  51178. t['tilde'] = 333;
  51179. t['macron'] = 333;
  51180. t['breve'] = 333;
  51181. t['dotaccent'] = 333;
  51182. t['dieresis'] = 333;
  51183. t['ring'] = 333;
  51184. t['cedilla'] = 333;
  51185. t['hungarumlaut'] = 333;
  51186. t['ogonek'] = 333;
  51187. t['caron'] = 333;
  51188. t['emdash'] = 1000;
  51189. t['AE'] = 1000;
  51190. t['ordfeminine'] = 300;
  51191. t['Lslash'] = 667;
  51192. t['Oslash'] = 778;
  51193. t['OE'] = 1000;
  51194. t['ordmasculine'] = 330;
  51195. t['ae'] = 722;
  51196. t['dotlessi'] = 278;
  51197. t['lslash'] = 278;
  51198. t['oslash'] = 500;
  51199. t['oe'] = 722;
  51200. t['germandbls'] = 556;
  51201. t['Idieresis'] = 389;
  51202. t['eacute'] = 444;
  51203. t['abreve'] = 500;
  51204. t['uhungarumlaut'] = 556;
  51205. t['ecaron'] = 444;
  51206. t['Ydieresis'] = 722;
  51207. t['divide'] = 570;
  51208. t['Yacute'] = 722;
  51209. t['Acircumflex'] = 722;
  51210. t['aacute'] = 500;
  51211. t['Ucircumflex'] = 722;
  51212. t['yacute'] = 500;
  51213. t['scommaaccent'] = 389;
  51214. t['ecircumflex'] = 444;
  51215. t['Uring'] = 722;
  51216. t['Udieresis'] = 722;
  51217. t['aogonek'] = 500;
  51218. t['Uacute'] = 722;
  51219. t['uogonek'] = 556;
  51220. t['Edieresis'] = 667;
  51221. t['Dcroat'] = 722;
  51222. t['commaaccent'] = 250;
  51223. t['copyright'] = 747;
  51224. t['Emacron'] = 667;
  51225. t['ccaron'] = 444;
  51226. t['aring'] = 500;
  51227. t['Ncommaaccent'] = 722;
  51228. t['lacute'] = 278;
  51229. t['agrave'] = 500;
  51230. t['Tcommaaccent'] = 667;
  51231. t['Cacute'] = 722;
  51232. t['atilde'] = 500;
  51233. t['Edotaccent'] = 667;
  51234. t['scaron'] = 389;
  51235. t['scedilla'] = 389;
  51236. t['iacute'] = 278;
  51237. t['lozenge'] = 494;
  51238. t['Rcaron'] = 722;
  51239. t['Gcommaaccent'] = 778;
  51240. t['ucircumflex'] = 556;
  51241. t['acircumflex'] = 500;
  51242. t['Amacron'] = 722;
  51243. t['rcaron'] = 444;
  51244. t['ccedilla'] = 444;
  51245. t['Zdotaccent'] = 667;
  51246. t['Thorn'] = 611;
  51247. t['Omacron'] = 778;
  51248. t['Racute'] = 722;
  51249. t['Sacute'] = 556;
  51250. t['dcaron'] = 672;
  51251. t['Umacron'] = 722;
  51252. t['uring'] = 556;
  51253. t['threesuperior'] = 300;
  51254. t['Ograve'] = 778;
  51255. t['Agrave'] = 722;
  51256. t['Abreve'] = 722;
  51257. t['multiply'] = 570;
  51258. t['uacute'] = 556;
  51259. t['Tcaron'] = 667;
  51260. t['partialdiff'] = 494;
  51261. t['ydieresis'] = 500;
  51262. t['Nacute'] = 722;
  51263. t['icircumflex'] = 278;
  51264. t['Ecircumflex'] = 667;
  51265. t['adieresis'] = 500;
  51266. t['edieresis'] = 444;
  51267. t['cacute'] = 444;
  51268. t['nacute'] = 556;
  51269. t['umacron'] = 556;
  51270. t['Ncaron'] = 722;
  51271. t['Iacute'] = 389;
  51272. t['plusminus'] = 570;
  51273. t['brokenbar'] = 220;
  51274. t['registered'] = 747;
  51275. t['Gbreve'] = 778;
  51276. t['Idotaccent'] = 389;
  51277. t['summation'] = 600;
  51278. t['Egrave'] = 667;
  51279. t['racute'] = 444;
  51280. t['omacron'] = 500;
  51281. t['Zacute'] = 667;
  51282. t['Zcaron'] = 667;
  51283. t['greaterequal'] = 549;
  51284. t['Eth'] = 722;
  51285. t['Ccedilla'] = 722;
  51286. t['lcommaaccent'] = 278;
  51287. t['tcaron'] = 416;
  51288. t['eogonek'] = 444;
  51289. t['Uogonek'] = 722;
  51290. t['Aacute'] = 722;
  51291. t['Adieresis'] = 722;
  51292. t['egrave'] = 444;
  51293. t['zacute'] = 444;
  51294. t['iogonek'] = 278;
  51295. t['Oacute'] = 778;
  51296. t['oacute'] = 500;
  51297. t['amacron'] = 500;
  51298. t['sacute'] = 389;
  51299. t['idieresis'] = 278;
  51300. t['Ocircumflex'] = 778;
  51301. t['Ugrave'] = 722;
  51302. t['Delta'] = 612;
  51303. t['thorn'] = 556;
  51304. t['twosuperior'] = 300;
  51305. t['Odieresis'] = 778;
  51306. t['mu'] = 556;
  51307. t['igrave'] = 278;
  51308. t['ohungarumlaut'] = 500;
  51309. t['Eogonek'] = 667;
  51310. t['dcroat'] = 556;
  51311. t['threequarters'] = 750;
  51312. t['Scedilla'] = 556;
  51313. t['lcaron'] = 394;
  51314. t['Kcommaaccent'] = 778;
  51315. t['Lacute'] = 667;
  51316. t['trademark'] = 1000;
  51317. t['edotaccent'] = 444;
  51318. t['Igrave'] = 389;
  51319. t['Imacron'] = 389;
  51320. t['Lcaron'] = 667;
  51321. t['onehalf'] = 750;
  51322. t['lessequal'] = 549;
  51323. t['ocircumflex'] = 500;
  51324. t['ntilde'] = 556;
  51325. t['Uhungarumlaut'] = 722;
  51326. t['Eacute'] = 667;
  51327. t['emacron'] = 444;
  51328. t['gbreve'] = 500;
  51329. t['onequarter'] = 750;
  51330. t['Scaron'] = 556;
  51331. t['Scommaaccent'] = 556;
  51332. t['Ohungarumlaut'] = 778;
  51333. t['degree'] = 400;
  51334. t['ograve'] = 500;
  51335. t['Ccaron'] = 722;
  51336. t['ugrave'] = 556;
  51337. t['radical'] = 549;
  51338. t['Dcaron'] = 722;
  51339. t['rcommaaccent'] = 444;
  51340. t['Ntilde'] = 722;
  51341. t['otilde'] = 500;
  51342. t['Rcommaaccent'] = 722;
  51343. t['Lcommaaccent'] = 667;
  51344. t['Atilde'] = 722;
  51345. t['Aogonek'] = 722;
  51346. t['Aring'] = 722;
  51347. t['Otilde'] = 778;
  51348. t['zdotaccent'] = 444;
  51349. t['Ecaron'] = 667;
  51350. t['Iogonek'] = 389;
  51351. t['kcommaaccent'] = 556;
  51352. t['minus'] = 570;
  51353. t['Icircumflex'] = 389;
  51354. t['ncaron'] = 556;
  51355. t['tcommaaccent'] = 333;
  51356. t['logicalnot'] = 570;
  51357. t['odieresis'] = 500;
  51358. t['udieresis'] = 556;
  51359. t['notequal'] = 549;
  51360. t['gcommaaccent'] = 500;
  51361. t['eth'] = 500;
  51362. t['zcaron'] = 444;
  51363. t['ncommaaccent'] = 556;
  51364. t['onesuperior'] = 300;
  51365. t['imacron'] = 278;
  51366. t['Euro'] = 500;
  51367. });
  51368. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51369. t['space'] = 250;
  51370. t['exclam'] = 389;
  51371. t['quotedbl'] = 555;
  51372. t['numbersign'] = 500;
  51373. t['dollar'] = 500;
  51374. t['percent'] = 833;
  51375. t['ampersand'] = 778;
  51376. t['quoteright'] = 333;
  51377. t['parenleft'] = 333;
  51378. t['parenright'] = 333;
  51379. t['asterisk'] = 500;
  51380. t['plus'] = 570;
  51381. t['comma'] = 250;
  51382. t['hyphen'] = 333;
  51383. t['period'] = 250;
  51384. t['slash'] = 278;
  51385. t['zero'] = 500;
  51386. t['one'] = 500;
  51387. t['two'] = 500;
  51388. t['three'] = 500;
  51389. t['four'] = 500;
  51390. t['five'] = 500;
  51391. t['six'] = 500;
  51392. t['seven'] = 500;
  51393. t['eight'] = 500;
  51394. t['nine'] = 500;
  51395. t['colon'] = 333;
  51396. t['semicolon'] = 333;
  51397. t['less'] = 570;
  51398. t['equal'] = 570;
  51399. t['greater'] = 570;
  51400. t['question'] = 500;
  51401. t['at'] = 832;
  51402. t['A'] = 667;
  51403. t['B'] = 667;
  51404. t['C'] = 667;
  51405. t['D'] = 722;
  51406. t['E'] = 667;
  51407. t['F'] = 667;
  51408. t['G'] = 722;
  51409. t['H'] = 778;
  51410. t['I'] = 389;
  51411. t['J'] = 500;
  51412. t['K'] = 667;
  51413. t['L'] = 611;
  51414. t['M'] = 889;
  51415. t['N'] = 722;
  51416. t['O'] = 722;
  51417. t['P'] = 611;
  51418. t['Q'] = 722;
  51419. t['R'] = 667;
  51420. t['S'] = 556;
  51421. t['T'] = 611;
  51422. t['U'] = 722;
  51423. t['V'] = 667;
  51424. t['W'] = 889;
  51425. t['X'] = 667;
  51426. t['Y'] = 611;
  51427. t['Z'] = 611;
  51428. t['bracketleft'] = 333;
  51429. t['backslash'] = 278;
  51430. t['bracketright'] = 333;
  51431. t['asciicircum'] = 570;
  51432. t['underscore'] = 500;
  51433. t['quoteleft'] = 333;
  51434. t['a'] = 500;
  51435. t['b'] = 500;
  51436. t['c'] = 444;
  51437. t['d'] = 500;
  51438. t['e'] = 444;
  51439. t['f'] = 333;
  51440. t['g'] = 500;
  51441. t['h'] = 556;
  51442. t['i'] = 278;
  51443. t['j'] = 278;
  51444. t['k'] = 500;
  51445. t['l'] = 278;
  51446. t['m'] = 778;
  51447. t['n'] = 556;
  51448. t['o'] = 500;
  51449. t['p'] = 500;
  51450. t['q'] = 500;
  51451. t['r'] = 389;
  51452. t['s'] = 389;
  51453. t['t'] = 278;
  51454. t['u'] = 556;
  51455. t['v'] = 444;
  51456. t['w'] = 667;
  51457. t['x'] = 500;
  51458. t['y'] = 444;
  51459. t['z'] = 389;
  51460. t['braceleft'] = 348;
  51461. t['bar'] = 220;
  51462. t['braceright'] = 348;
  51463. t['asciitilde'] = 570;
  51464. t['exclamdown'] = 389;
  51465. t['cent'] = 500;
  51466. t['sterling'] = 500;
  51467. t['fraction'] = 167;
  51468. t['yen'] = 500;
  51469. t['florin'] = 500;
  51470. t['section'] = 500;
  51471. t['currency'] = 500;
  51472. t['quotesingle'] = 278;
  51473. t['quotedblleft'] = 500;
  51474. t['guillemotleft'] = 500;
  51475. t['guilsinglleft'] = 333;
  51476. t['guilsinglright'] = 333;
  51477. t['fi'] = 556;
  51478. t['fl'] = 556;
  51479. t['endash'] = 500;
  51480. t['dagger'] = 500;
  51481. t['daggerdbl'] = 500;
  51482. t['periodcentered'] = 250;
  51483. t['paragraph'] = 500;
  51484. t['bullet'] = 350;
  51485. t['quotesinglbase'] = 333;
  51486. t['quotedblbase'] = 500;
  51487. t['quotedblright'] = 500;
  51488. t['guillemotright'] = 500;
  51489. t['ellipsis'] = 1000;
  51490. t['perthousand'] = 1000;
  51491. t['questiondown'] = 500;
  51492. t['grave'] = 333;
  51493. t['acute'] = 333;
  51494. t['circumflex'] = 333;
  51495. t['tilde'] = 333;
  51496. t['macron'] = 333;
  51497. t['breve'] = 333;
  51498. t['dotaccent'] = 333;
  51499. t['dieresis'] = 333;
  51500. t['ring'] = 333;
  51501. t['cedilla'] = 333;
  51502. t['hungarumlaut'] = 333;
  51503. t['ogonek'] = 333;
  51504. t['caron'] = 333;
  51505. t['emdash'] = 1000;
  51506. t['AE'] = 944;
  51507. t['ordfeminine'] = 266;
  51508. t['Lslash'] = 611;
  51509. t['Oslash'] = 722;
  51510. t['OE'] = 944;
  51511. t['ordmasculine'] = 300;
  51512. t['ae'] = 722;
  51513. t['dotlessi'] = 278;
  51514. t['lslash'] = 278;
  51515. t['oslash'] = 500;
  51516. t['oe'] = 722;
  51517. t['germandbls'] = 500;
  51518. t['Idieresis'] = 389;
  51519. t['eacute'] = 444;
  51520. t['abreve'] = 500;
  51521. t['uhungarumlaut'] = 556;
  51522. t['ecaron'] = 444;
  51523. t['Ydieresis'] = 611;
  51524. t['divide'] = 570;
  51525. t['Yacute'] = 611;
  51526. t['Acircumflex'] = 667;
  51527. t['aacute'] = 500;
  51528. t['Ucircumflex'] = 722;
  51529. t['yacute'] = 444;
  51530. t['scommaaccent'] = 389;
  51531. t['ecircumflex'] = 444;
  51532. t['Uring'] = 722;
  51533. t['Udieresis'] = 722;
  51534. t['aogonek'] = 500;
  51535. t['Uacute'] = 722;
  51536. t['uogonek'] = 556;
  51537. t['Edieresis'] = 667;
  51538. t['Dcroat'] = 722;
  51539. t['commaaccent'] = 250;
  51540. t['copyright'] = 747;
  51541. t['Emacron'] = 667;
  51542. t['ccaron'] = 444;
  51543. t['aring'] = 500;
  51544. t['Ncommaaccent'] = 722;
  51545. t['lacute'] = 278;
  51546. t['agrave'] = 500;
  51547. t['Tcommaaccent'] = 611;
  51548. t['Cacute'] = 667;
  51549. t['atilde'] = 500;
  51550. t['Edotaccent'] = 667;
  51551. t['scaron'] = 389;
  51552. t['scedilla'] = 389;
  51553. t['iacute'] = 278;
  51554. t['lozenge'] = 494;
  51555. t['Rcaron'] = 667;
  51556. t['Gcommaaccent'] = 722;
  51557. t['ucircumflex'] = 556;
  51558. t['acircumflex'] = 500;
  51559. t['Amacron'] = 667;
  51560. t['rcaron'] = 389;
  51561. t['ccedilla'] = 444;
  51562. t['Zdotaccent'] = 611;
  51563. t['Thorn'] = 611;
  51564. t['Omacron'] = 722;
  51565. t['Racute'] = 667;
  51566. t['Sacute'] = 556;
  51567. t['dcaron'] = 608;
  51568. t['Umacron'] = 722;
  51569. t['uring'] = 556;
  51570. t['threesuperior'] = 300;
  51571. t['Ograve'] = 722;
  51572. t['Agrave'] = 667;
  51573. t['Abreve'] = 667;
  51574. t['multiply'] = 570;
  51575. t['uacute'] = 556;
  51576. t['Tcaron'] = 611;
  51577. t['partialdiff'] = 494;
  51578. t['ydieresis'] = 444;
  51579. t['Nacute'] = 722;
  51580. t['icircumflex'] = 278;
  51581. t['Ecircumflex'] = 667;
  51582. t['adieresis'] = 500;
  51583. t['edieresis'] = 444;
  51584. t['cacute'] = 444;
  51585. t['nacute'] = 556;
  51586. t['umacron'] = 556;
  51587. t['Ncaron'] = 722;
  51588. t['Iacute'] = 389;
  51589. t['plusminus'] = 570;
  51590. t['brokenbar'] = 220;
  51591. t['registered'] = 747;
  51592. t['Gbreve'] = 722;
  51593. t['Idotaccent'] = 389;
  51594. t['summation'] = 600;
  51595. t['Egrave'] = 667;
  51596. t['racute'] = 389;
  51597. t['omacron'] = 500;
  51598. t['Zacute'] = 611;
  51599. t['Zcaron'] = 611;
  51600. t['greaterequal'] = 549;
  51601. t['Eth'] = 722;
  51602. t['Ccedilla'] = 667;
  51603. t['lcommaaccent'] = 278;
  51604. t['tcaron'] = 366;
  51605. t['eogonek'] = 444;
  51606. t['Uogonek'] = 722;
  51607. t['Aacute'] = 667;
  51608. t['Adieresis'] = 667;
  51609. t['egrave'] = 444;
  51610. t['zacute'] = 389;
  51611. t['iogonek'] = 278;
  51612. t['Oacute'] = 722;
  51613. t['oacute'] = 500;
  51614. t['amacron'] = 500;
  51615. t['sacute'] = 389;
  51616. t['idieresis'] = 278;
  51617. t['Ocircumflex'] = 722;
  51618. t['Ugrave'] = 722;
  51619. t['Delta'] = 612;
  51620. t['thorn'] = 500;
  51621. t['twosuperior'] = 300;
  51622. t['Odieresis'] = 722;
  51623. t['mu'] = 576;
  51624. t['igrave'] = 278;
  51625. t['ohungarumlaut'] = 500;
  51626. t['Eogonek'] = 667;
  51627. t['dcroat'] = 500;
  51628. t['threequarters'] = 750;
  51629. t['Scedilla'] = 556;
  51630. t['lcaron'] = 382;
  51631. t['Kcommaaccent'] = 667;
  51632. t['Lacute'] = 611;
  51633. t['trademark'] = 1000;
  51634. t['edotaccent'] = 444;
  51635. t['Igrave'] = 389;
  51636. t['Imacron'] = 389;
  51637. t['Lcaron'] = 611;
  51638. t['onehalf'] = 750;
  51639. t['lessequal'] = 549;
  51640. t['ocircumflex'] = 500;
  51641. t['ntilde'] = 556;
  51642. t['Uhungarumlaut'] = 722;
  51643. t['Eacute'] = 667;
  51644. t['emacron'] = 444;
  51645. t['gbreve'] = 500;
  51646. t['onequarter'] = 750;
  51647. t['Scaron'] = 556;
  51648. t['Scommaaccent'] = 556;
  51649. t['Ohungarumlaut'] = 722;
  51650. t['degree'] = 400;
  51651. t['ograve'] = 500;
  51652. t['Ccaron'] = 667;
  51653. t['ugrave'] = 556;
  51654. t['radical'] = 549;
  51655. t['Dcaron'] = 722;
  51656. t['rcommaaccent'] = 389;
  51657. t['Ntilde'] = 722;
  51658. t['otilde'] = 500;
  51659. t['Rcommaaccent'] = 667;
  51660. t['Lcommaaccent'] = 611;
  51661. t['Atilde'] = 667;
  51662. t['Aogonek'] = 667;
  51663. t['Aring'] = 667;
  51664. t['Otilde'] = 722;
  51665. t['zdotaccent'] = 389;
  51666. t['Ecaron'] = 667;
  51667. t['Iogonek'] = 389;
  51668. t['kcommaaccent'] = 500;
  51669. t['minus'] = 606;
  51670. t['Icircumflex'] = 389;
  51671. t['ncaron'] = 556;
  51672. t['tcommaaccent'] = 278;
  51673. t['logicalnot'] = 606;
  51674. t['odieresis'] = 500;
  51675. t['udieresis'] = 556;
  51676. t['notequal'] = 549;
  51677. t['gcommaaccent'] = 500;
  51678. t['eth'] = 500;
  51679. t['zcaron'] = 389;
  51680. t['ncommaaccent'] = 556;
  51681. t['onesuperior'] = 300;
  51682. t['imacron'] = 278;
  51683. t['Euro'] = 500;
  51684. });
  51685. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51686. t['space'] = 250;
  51687. t['exclam'] = 333;
  51688. t['quotedbl'] = 420;
  51689. t['numbersign'] = 500;
  51690. t['dollar'] = 500;
  51691. t['percent'] = 833;
  51692. t['ampersand'] = 778;
  51693. t['quoteright'] = 333;
  51694. t['parenleft'] = 333;
  51695. t['parenright'] = 333;
  51696. t['asterisk'] = 500;
  51697. t['plus'] = 675;
  51698. t['comma'] = 250;
  51699. t['hyphen'] = 333;
  51700. t['period'] = 250;
  51701. t['slash'] = 278;
  51702. t['zero'] = 500;
  51703. t['one'] = 500;
  51704. t['two'] = 500;
  51705. t['three'] = 500;
  51706. t['four'] = 500;
  51707. t['five'] = 500;
  51708. t['six'] = 500;
  51709. t['seven'] = 500;
  51710. t['eight'] = 500;
  51711. t['nine'] = 500;
  51712. t['colon'] = 333;
  51713. t['semicolon'] = 333;
  51714. t['less'] = 675;
  51715. t['equal'] = 675;
  51716. t['greater'] = 675;
  51717. t['question'] = 500;
  51718. t['at'] = 920;
  51719. t['A'] = 611;
  51720. t['B'] = 611;
  51721. t['C'] = 667;
  51722. t['D'] = 722;
  51723. t['E'] = 611;
  51724. t['F'] = 611;
  51725. t['G'] = 722;
  51726. t['H'] = 722;
  51727. t['I'] = 333;
  51728. t['J'] = 444;
  51729. t['K'] = 667;
  51730. t['L'] = 556;
  51731. t['M'] = 833;
  51732. t['N'] = 667;
  51733. t['O'] = 722;
  51734. t['P'] = 611;
  51735. t['Q'] = 722;
  51736. t['R'] = 611;
  51737. t['S'] = 500;
  51738. t['T'] = 556;
  51739. t['U'] = 722;
  51740. t['V'] = 611;
  51741. t['W'] = 833;
  51742. t['X'] = 611;
  51743. t['Y'] = 556;
  51744. t['Z'] = 556;
  51745. t['bracketleft'] = 389;
  51746. t['backslash'] = 278;
  51747. t['bracketright'] = 389;
  51748. t['asciicircum'] = 422;
  51749. t['underscore'] = 500;
  51750. t['quoteleft'] = 333;
  51751. t['a'] = 500;
  51752. t['b'] = 500;
  51753. t['c'] = 444;
  51754. t['d'] = 500;
  51755. t['e'] = 444;
  51756. t['f'] = 278;
  51757. t['g'] = 500;
  51758. t['h'] = 500;
  51759. t['i'] = 278;
  51760. t['j'] = 278;
  51761. t['k'] = 444;
  51762. t['l'] = 278;
  51763. t['m'] = 722;
  51764. t['n'] = 500;
  51765. t['o'] = 500;
  51766. t['p'] = 500;
  51767. t['q'] = 500;
  51768. t['r'] = 389;
  51769. t['s'] = 389;
  51770. t['t'] = 278;
  51771. t['u'] = 500;
  51772. t['v'] = 444;
  51773. t['w'] = 667;
  51774. t['x'] = 444;
  51775. t['y'] = 444;
  51776. t['z'] = 389;
  51777. t['braceleft'] = 400;
  51778. t['bar'] = 275;
  51779. t['braceright'] = 400;
  51780. t['asciitilde'] = 541;
  51781. t['exclamdown'] = 389;
  51782. t['cent'] = 500;
  51783. t['sterling'] = 500;
  51784. t['fraction'] = 167;
  51785. t['yen'] = 500;
  51786. t['florin'] = 500;
  51787. t['section'] = 500;
  51788. t['currency'] = 500;
  51789. t['quotesingle'] = 214;
  51790. t['quotedblleft'] = 556;
  51791. t['guillemotleft'] = 500;
  51792. t['guilsinglleft'] = 333;
  51793. t['guilsinglright'] = 333;
  51794. t['fi'] = 500;
  51795. t['fl'] = 500;
  51796. t['endash'] = 500;
  51797. t['dagger'] = 500;
  51798. t['daggerdbl'] = 500;
  51799. t['periodcentered'] = 250;
  51800. t['paragraph'] = 523;
  51801. t['bullet'] = 350;
  51802. t['quotesinglbase'] = 333;
  51803. t['quotedblbase'] = 556;
  51804. t['quotedblright'] = 556;
  51805. t['guillemotright'] = 500;
  51806. t['ellipsis'] = 889;
  51807. t['perthousand'] = 1000;
  51808. t['questiondown'] = 500;
  51809. t['grave'] = 333;
  51810. t['acute'] = 333;
  51811. t['circumflex'] = 333;
  51812. t['tilde'] = 333;
  51813. t['macron'] = 333;
  51814. t['breve'] = 333;
  51815. t['dotaccent'] = 333;
  51816. t['dieresis'] = 333;
  51817. t['ring'] = 333;
  51818. t['cedilla'] = 333;
  51819. t['hungarumlaut'] = 333;
  51820. t['ogonek'] = 333;
  51821. t['caron'] = 333;
  51822. t['emdash'] = 889;
  51823. t['AE'] = 889;
  51824. t['ordfeminine'] = 276;
  51825. t['Lslash'] = 556;
  51826. t['Oslash'] = 722;
  51827. t['OE'] = 944;
  51828. t['ordmasculine'] = 310;
  51829. t['ae'] = 667;
  51830. t['dotlessi'] = 278;
  51831. t['lslash'] = 278;
  51832. t['oslash'] = 500;
  51833. t['oe'] = 667;
  51834. t['germandbls'] = 500;
  51835. t['Idieresis'] = 333;
  51836. t['eacute'] = 444;
  51837. t['abreve'] = 500;
  51838. t['uhungarumlaut'] = 500;
  51839. t['ecaron'] = 444;
  51840. t['Ydieresis'] = 556;
  51841. t['divide'] = 675;
  51842. t['Yacute'] = 556;
  51843. t['Acircumflex'] = 611;
  51844. t['aacute'] = 500;
  51845. t['Ucircumflex'] = 722;
  51846. t['yacute'] = 444;
  51847. t['scommaaccent'] = 389;
  51848. t['ecircumflex'] = 444;
  51849. t['Uring'] = 722;
  51850. t['Udieresis'] = 722;
  51851. t['aogonek'] = 500;
  51852. t['Uacute'] = 722;
  51853. t['uogonek'] = 500;
  51854. t['Edieresis'] = 611;
  51855. t['Dcroat'] = 722;
  51856. t['commaaccent'] = 250;
  51857. t['copyright'] = 760;
  51858. t['Emacron'] = 611;
  51859. t['ccaron'] = 444;
  51860. t['aring'] = 500;
  51861. t['Ncommaaccent'] = 667;
  51862. t['lacute'] = 278;
  51863. t['agrave'] = 500;
  51864. t['Tcommaaccent'] = 556;
  51865. t['Cacute'] = 667;
  51866. t['atilde'] = 500;
  51867. t['Edotaccent'] = 611;
  51868. t['scaron'] = 389;
  51869. t['scedilla'] = 389;
  51870. t['iacute'] = 278;
  51871. t['lozenge'] = 471;
  51872. t['Rcaron'] = 611;
  51873. t['Gcommaaccent'] = 722;
  51874. t['ucircumflex'] = 500;
  51875. t['acircumflex'] = 500;
  51876. t['Amacron'] = 611;
  51877. t['rcaron'] = 389;
  51878. t['ccedilla'] = 444;
  51879. t['Zdotaccent'] = 556;
  51880. t['Thorn'] = 611;
  51881. t['Omacron'] = 722;
  51882. t['Racute'] = 611;
  51883. t['Sacute'] = 500;
  51884. t['dcaron'] = 544;
  51885. t['Umacron'] = 722;
  51886. t['uring'] = 500;
  51887. t['threesuperior'] = 300;
  51888. t['Ograve'] = 722;
  51889. t['Agrave'] = 611;
  51890. t['Abreve'] = 611;
  51891. t['multiply'] = 675;
  51892. t['uacute'] = 500;
  51893. t['Tcaron'] = 556;
  51894. t['partialdiff'] = 476;
  51895. t['ydieresis'] = 444;
  51896. t['Nacute'] = 667;
  51897. t['icircumflex'] = 278;
  51898. t['Ecircumflex'] = 611;
  51899. t['adieresis'] = 500;
  51900. t['edieresis'] = 444;
  51901. t['cacute'] = 444;
  51902. t['nacute'] = 500;
  51903. t['umacron'] = 500;
  51904. t['Ncaron'] = 667;
  51905. t['Iacute'] = 333;
  51906. t['plusminus'] = 675;
  51907. t['brokenbar'] = 275;
  51908. t['registered'] = 760;
  51909. t['Gbreve'] = 722;
  51910. t['Idotaccent'] = 333;
  51911. t['summation'] = 600;
  51912. t['Egrave'] = 611;
  51913. t['racute'] = 389;
  51914. t['omacron'] = 500;
  51915. t['Zacute'] = 556;
  51916. t['Zcaron'] = 556;
  51917. t['greaterequal'] = 549;
  51918. t['Eth'] = 722;
  51919. t['Ccedilla'] = 667;
  51920. t['lcommaaccent'] = 278;
  51921. t['tcaron'] = 300;
  51922. t['eogonek'] = 444;
  51923. t['Uogonek'] = 722;
  51924. t['Aacute'] = 611;
  51925. t['Adieresis'] = 611;
  51926. t['egrave'] = 444;
  51927. t['zacute'] = 389;
  51928. t['iogonek'] = 278;
  51929. t['Oacute'] = 722;
  51930. t['oacute'] = 500;
  51931. t['amacron'] = 500;
  51932. t['sacute'] = 389;
  51933. t['idieresis'] = 278;
  51934. t['Ocircumflex'] = 722;
  51935. t['Ugrave'] = 722;
  51936. t['Delta'] = 612;
  51937. t['thorn'] = 500;
  51938. t['twosuperior'] = 300;
  51939. t['Odieresis'] = 722;
  51940. t['mu'] = 500;
  51941. t['igrave'] = 278;
  51942. t['ohungarumlaut'] = 500;
  51943. t['Eogonek'] = 611;
  51944. t['dcroat'] = 500;
  51945. t['threequarters'] = 750;
  51946. t['Scedilla'] = 500;
  51947. t['lcaron'] = 300;
  51948. t['Kcommaaccent'] = 667;
  51949. t['Lacute'] = 556;
  51950. t['trademark'] = 980;
  51951. t['edotaccent'] = 444;
  51952. t['Igrave'] = 333;
  51953. t['Imacron'] = 333;
  51954. t['Lcaron'] = 611;
  51955. t['onehalf'] = 750;
  51956. t['lessequal'] = 549;
  51957. t['ocircumflex'] = 500;
  51958. t['ntilde'] = 500;
  51959. t['Uhungarumlaut'] = 722;
  51960. t['Eacute'] = 611;
  51961. t['emacron'] = 444;
  51962. t['gbreve'] = 500;
  51963. t['onequarter'] = 750;
  51964. t['Scaron'] = 500;
  51965. t['Scommaaccent'] = 500;
  51966. t['Ohungarumlaut'] = 722;
  51967. t['degree'] = 400;
  51968. t['ograve'] = 500;
  51969. t['Ccaron'] = 667;
  51970. t['ugrave'] = 500;
  51971. t['radical'] = 453;
  51972. t['Dcaron'] = 722;
  51973. t['rcommaaccent'] = 389;
  51974. t['Ntilde'] = 667;
  51975. t['otilde'] = 500;
  51976. t['Rcommaaccent'] = 611;
  51977. t['Lcommaaccent'] = 556;
  51978. t['Atilde'] = 611;
  51979. t['Aogonek'] = 611;
  51980. t['Aring'] = 611;
  51981. t['Otilde'] = 722;
  51982. t['zdotaccent'] = 389;
  51983. t['Ecaron'] = 611;
  51984. t['Iogonek'] = 333;
  51985. t['kcommaaccent'] = 444;
  51986. t['minus'] = 675;
  51987. t['Icircumflex'] = 333;
  51988. t['ncaron'] = 500;
  51989. t['tcommaaccent'] = 278;
  51990. t['logicalnot'] = 675;
  51991. t['odieresis'] = 500;
  51992. t['udieresis'] = 500;
  51993. t['notequal'] = 549;
  51994. t['gcommaaccent'] = 500;
  51995. t['eth'] = 500;
  51996. t['zcaron'] = 389;
  51997. t['ncommaaccent'] = 500;
  51998. t['onesuperior'] = 300;
  51999. t['imacron'] = 278;
  52000. t['Euro'] = 500;
  52001. });
  52002. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52003. t['space'] = 278;
  52004. t['a1'] = 974;
  52005. t['a2'] = 961;
  52006. t['a202'] = 974;
  52007. t['a3'] = 980;
  52008. t['a4'] = 719;
  52009. t['a5'] = 789;
  52010. t['a119'] = 790;
  52011. t['a118'] = 791;
  52012. t['a117'] = 690;
  52013. t['a11'] = 960;
  52014. t['a12'] = 939;
  52015. t['a13'] = 549;
  52016. t['a14'] = 855;
  52017. t['a15'] = 911;
  52018. t['a16'] = 933;
  52019. t['a105'] = 911;
  52020. t['a17'] = 945;
  52021. t['a18'] = 974;
  52022. t['a19'] = 755;
  52023. t['a20'] = 846;
  52024. t['a21'] = 762;
  52025. t['a22'] = 761;
  52026. t['a23'] = 571;
  52027. t['a24'] = 677;
  52028. t['a25'] = 763;
  52029. t['a26'] = 760;
  52030. t['a27'] = 759;
  52031. t['a28'] = 754;
  52032. t['a6'] = 494;
  52033. t['a7'] = 552;
  52034. t['a8'] = 537;
  52035. t['a9'] = 577;
  52036. t['a10'] = 692;
  52037. t['a29'] = 786;
  52038. t['a30'] = 788;
  52039. t['a31'] = 788;
  52040. t['a32'] = 790;
  52041. t['a33'] = 793;
  52042. t['a34'] = 794;
  52043. t['a35'] = 816;
  52044. t['a36'] = 823;
  52045. t['a37'] = 789;
  52046. t['a38'] = 841;
  52047. t['a39'] = 823;
  52048. t['a40'] = 833;
  52049. t['a41'] = 816;
  52050. t['a42'] = 831;
  52051. t['a43'] = 923;
  52052. t['a44'] = 744;
  52053. t['a45'] = 723;
  52054. t['a46'] = 749;
  52055. t['a47'] = 790;
  52056. t['a48'] = 792;
  52057. t['a49'] = 695;
  52058. t['a50'] = 776;
  52059. t['a51'] = 768;
  52060. t['a52'] = 792;
  52061. t['a53'] = 759;
  52062. t['a54'] = 707;
  52063. t['a55'] = 708;
  52064. t['a56'] = 682;
  52065. t['a57'] = 701;
  52066. t['a58'] = 826;
  52067. t['a59'] = 815;
  52068. t['a60'] = 789;
  52069. t['a61'] = 789;
  52070. t['a62'] = 707;
  52071. t['a63'] = 687;
  52072. t['a64'] = 696;
  52073. t['a65'] = 689;
  52074. t['a66'] = 786;
  52075. t['a67'] = 787;
  52076. t['a68'] = 713;
  52077. t['a69'] = 791;
  52078. t['a70'] = 785;
  52079. t['a71'] = 791;
  52080. t['a72'] = 873;
  52081. t['a73'] = 761;
  52082. t['a74'] = 762;
  52083. t['a203'] = 762;
  52084. t['a75'] = 759;
  52085. t['a204'] = 759;
  52086. t['a76'] = 892;
  52087. t['a77'] = 892;
  52088. t['a78'] = 788;
  52089. t['a79'] = 784;
  52090. t['a81'] = 438;
  52091. t['a82'] = 138;
  52092. t['a83'] = 277;
  52093. t['a84'] = 415;
  52094. t['a97'] = 392;
  52095. t['a98'] = 392;
  52096. t['a99'] = 668;
  52097. t['a100'] = 668;
  52098. t['a89'] = 390;
  52099. t['a90'] = 390;
  52100. t['a93'] = 317;
  52101. t['a94'] = 317;
  52102. t['a91'] = 276;
  52103. t['a92'] = 276;
  52104. t['a205'] = 509;
  52105. t['a85'] = 509;
  52106. t['a206'] = 410;
  52107. t['a86'] = 410;
  52108. t['a87'] = 234;
  52109. t['a88'] = 234;
  52110. t['a95'] = 334;
  52111. t['a96'] = 334;
  52112. t['a101'] = 732;
  52113. t['a102'] = 544;
  52114. t['a103'] = 544;
  52115. t['a104'] = 910;
  52116. t['a106'] = 667;
  52117. t['a107'] = 760;
  52118. t['a108'] = 760;
  52119. t['a112'] = 776;
  52120. t['a111'] = 595;
  52121. t['a110'] = 694;
  52122. t['a109'] = 626;
  52123. t['a120'] = 788;
  52124. t['a121'] = 788;
  52125. t['a122'] = 788;
  52126. t['a123'] = 788;
  52127. t['a124'] = 788;
  52128. t['a125'] = 788;
  52129. t['a126'] = 788;
  52130. t['a127'] = 788;
  52131. t['a128'] = 788;
  52132. t['a129'] = 788;
  52133. t['a130'] = 788;
  52134. t['a131'] = 788;
  52135. t['a132'] = 788;
  52136. t['a133'] = 788;
  52137. t['a134'] = 788;
  52138. t['a135'] = 788;
  52139. t['a136'] = 788;
  52140. t['a137'] = 788;
  52141. t['a138'] = 788;
  52142. t['a139'] = 788;
  52143. t['a140'] = 788;
  52144. t['a141'] = 788;
  52145. t['a142'] = 788;
  52146. t['a143'] = 788;
  52147. t['a144'] = 788;
  52148. t['a145'] = 788;
  52149. t['a146'] = 788;
  52150. t['a147'] = 788;
  52151. t['a148'] = 788;
  52152. t['a149'] = 788;
  52153. t['a150'] = 788;
  52154. t['a151'] = 788;
  52155. t['a152'] = 788;
  52156. t['a153'] = 788;
  52157. t['a154'] = 788;
  52158. t['a155'] = 788;
  52159. t['a156'] = 788;
  52160. t['a157'] = 788;
  52161. t['a158'] = 788;
  52162. t['a159'] = 788;
  52163. t['a160'] = 894;
  52164. t['a161'] = 838;
  52165. t['a163'] = 1016;
  52166. t['a164'] = 458;
  52167. t['a196'] = 748;
  52168. t['a165'] = 924;
  52169. t['a192'] = 748;
  52170. t['a166'] = 918;
  52171. t['a167'] = 927;
  52172. t['a168'] = 928;
  52173. t['a169'] = 928;
  52174. t['a170'] = 834;
  52175. t['a171'] = 873;
  52176. t['a172'] = 828;
  52177. t['a173'] = 924;
  52178. t['a162'] = 924;
  52179. t['a174'] = 917;
  52180. t['a175'] = 930;
  52181. t['a176'] = 931;
  52182. t['a177'] = 463;
  52183. t['a178'] = 883;
  52184. t['a179'] = 836;
  52185. t['a193'] = 836;
  52186. t['a180'] = 867;
  52187. t['a199'] = 867;
  52188. t['a181'] = 696;
  52189. t['a200'] = 696;
  52190. t['a182'] = 874;
  52191. t['a201'] = 874;
  52192. t['a183'] = 760;
  52193. t['a184'] = 946;
  52194. t['a197'] = 771;
  52195. t['a185'] = 865;
  52196. t['a194'] = 771;
  52197. t['a198'] = 888;
  52198. t['a186'] = 967;
  52199. t['a195'] = 888;
  52200. t['a187'] = 831;
  52201. t['a188'] = 873;
  52202. t['a189'] = 927;
  52203. t['a190'] = 970;
  52204. t['a191'] = 918;
  52205. });
  52206. });
  52207. exports.getMetrics = getMetrics;
  52208. /***/ }),
  52209. /* 39 */
  52210. /***/ (function(module, exports, __w_pdfjs_require__) {
  52211. "use strict";
  52212. var sharedUtil = __w_pdfjs_require__(0);
  52213. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52214. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52215. var MASK_HIGH = 0xffff0000;
  52216. var MASK_LOW = 0xffff;
  52217. function MurmurHash3_64(seed) {
  52218. var SEED = 0xc3d2e1f0;
  52219. this.h1 = seed ? seed & 0xffffffff : SEED;
  52220. this.h2 = seed ? seed & 0xffffffff : SEED;
  52221. }
  52222. var alwaysUseUint32ArrayView = false;
  52223. try {
  52224. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52225. } catch (e) {
  52226. alwaysUseUint32ArrayView = true;
  52227. }
  52228. MurmurHash3_64.prototype = {
  52229. update: function MurmurHash3_64_update(input) {
  52230. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52231. var i;
  52232. if (typeof input === 'string') {
  52233. var data = new Uint8Array(input.length * 2);
  52234. var length = 0;
  52235. for (i = 0; i < input.length; i++) {
  52236. var code = input.charCodeAt(i);
  52237. if (code <= 0xff) {
  52238. data[length++] = code;
  52239. } else {
  52240. data[length++] = code >>> 8;
  52241. data[length++] = code & 0xff;
  52242. }
  52243. }
  52244. } else if (input instanceof Uint8Array) {
  52245. data = input;
  52246. length = data.length;
  52247. } else if (typeof input === 'object' && 'length' in input) {
  52248. data = input;
  52249. length = data.length;
  52250. useUint32ArrayView = true;
  52251. } else {
  52252. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52253. }
  52254. var blockCounts = length >> 2;
  52255. var tailLength = length - blockCounts * 4;
  52256. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52257. var k1 = 0;
  52258. var k2 = 0;
  52259. var h1 = this.h1;
  52260. var h2 = this.h2;
  52261. var C1 = 0xcc9e2d51;
  52262. var C2 = 0x1b873593;
  52263. var C1_LOW = C1 & MASK_LOW;
  52264. var C2_LOW = C2 & MASK_LOW;
  52265. for (i = 0; i < blockCounts; i++) {
  52266. if (i & 1) {
  52267. k1 = dataUint32[i];
  52268. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52269. k1 = k1 << 15 | k1 >>> 17;
  52270. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52271. h1 ^= k1;
  52272. h1 = h1 << 13 | h1 >>> 19;
  52273. h1 = h1 * 5 + 0xe6546b64;
  52274. } else {
  52275. k2 = dataUint32[i];
  52276. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52277. k2 = k2 << 15 | k2 >>> 17;
  52278. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52279. h2 ^= k2;
  52280. h2 = h2 << 13 | h2 >>> 19;
  52281. h2 = h2 * 5 + 0xe6546b64;
  52282. }
  52283. }
  52284. k1 = 0;
  52285. switch (tailLength) {
  52286. case 3:
  52287. k1 ^= data[blockCounts * 4 + 2] << 16;
  52288. case 2:
  52289. k1 ^= data[blockCounts * 4 + 1] << 8;
  52290. case 1:
  52291. k1 ^= data[blockCounts * 4];
  52292. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52293. k1 = k1 << 15 | k1 >>> 17;
  52294. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52295. if (blockCounts & 1) {
  52296. h1 ^= k1;
  52297. } else {
  52298. h2 ^= k1;
  52299. }
  52300. }
  52301. this.h1 = h1;
  52302. this.h2 = h2;
  52303. return this;
  52304. },
  52305. hexdigest: function MurmurHash3_64_hexdigest() {
  52306. var h1 = this.h1;
  52307. var h2 = this.h2;
  52308. h1 ^= h2 >>> 1;
  52309. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52310. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52311. h1 ^= h2 >>> 1;
  52312. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52313. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52314. h1 ^= h2 >>> 1;
  52315. for (var i = 0, arr = [
  52316. h1,
  52317. h2
  52318. ], str = ''; i < arr.length; i++) {
  52319. var hex = (arr[i] >>> 0).toString(16);
  52320. while (hex.length < 8) {
  52321. hex = '0' + hex;
  52322. }
  52323. str += hex;
  52324. }
  52325. return str;
  52326. }
  52327. };
  52328. return MurmurHash3_64;
  52329. }();
  52330. exports.MurmurHash3_64 = MurmurHash3_64;
  52331. /***/ }),
  52332. /* 40 */
  52333. /***/ (function(module, exports, __w_pdfjs_require__) {
  52334. "use strict";
  52335. var sharedUtil = __w_pdfjs_require__(0);
  52336. var coreWorker = __w_pdfjs_require__(22);
  52337. var OK_RESPONSE = 200;
  52338. var PARTIAL_CONTENT_RESPONSE = 206;
  52339. function NetworkManager(url, args) {
  52340. this.url = url;
  52341. args = args || {};
  52342. this.isHttp = /^https?:/i.test(url);
  52343. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52344. this.withCredentials = args.withCredentials || false;
  52345. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52346. return new XMLHttpRequest();
  52347. };
  52348. this.currXhrId = 0;
  52349. this.pendingRequests = Object.create(null);
  52350. this.loadedRequests = Object.create(null);
  52351. }
  52352. function getArrayBuffer(xhr) {
  52353. var data = xhr.response;
  52354. if (typeof data !== 'string') {
  52355. return data;
  52356. }
  52357. var length = data.length;
  52358. var array = new Uint8Array(length);
  52359. for (var i = 0; i < length; i++) {
  52360. array[i] = data.charCodeAt(i) & 0xFF;
  52361. }
  52362. return array.buffer;
  52363. }
  52364. var supportsMozChunked = function supportsMozChunkedClosure() {
  52365. try {
  52366. var x = new XMLHttpRequest();
  52367. x.open('GET', 'https://example.com');
  52368. x.responseType = 'moz-chunked-arraybuffer';
  52369. return x.responseType === 'moz-chunked-arraybuffer';
  52370. } catch (e) {
  52371. return false;
  52372. }
  52373. }();
  52374. NetworkManager.prototype = {
  52375. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52376. var args = {
  52377. begin: begin,
  52378. end: end
  52379. };
  52380. for (var prop in listeners) {
  52381. args[prop] = listeners[prop];
  52382. }
  52383. return this.request(args);
  52384. },
  52385. requestFull: function NetworkManager_requestFull(listeners) {
  52386. return this.request(listeners);
  52387. },
  52388. request: function NetworkManager_request(args) {
  52389. var xhr = this.getXhr();
  52390. var xhrId = this.currXhrId++;
  52391. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52392. xhr.open('GET', this.url);
  52393. xhr.withCredentials = this.withCredentials;
  52394. for (var property in this.httpHeaders) {
  52395. var value = this.httpHeaders[property];
  52396. if (typeof value === 'undefined') {
  52397. continue;
  52398. }
  52399. xhr.setRequestHeader(property, value);
  52400. }
  52401. if (this.isHttp && 'begin' in args && 'end' in args) {
  52402. var rangeStr = args.begin + '-' + (args.end - 1);
  52403. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52404. pendingRequest.expectedStatus = 206;
  52405. } else {
  52406. pendingRequest.expectedStatus = 200;
  52407. }
  52408. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52409. if (useMozChunkedLoading) {
  52410. xhr.responseType = 'moz-chunked-arraybuffer';
  52411. pendingRequest.onProgressiveData = args.onProgressiveData;
  52412. pendingRequest.mozChunked = true;
  52413. } else {
  52414. xhr.responseType = 'arraybuffer';
  52415. }
  52416. if (args.onError) {
  52417. xhr.onerror = function (evt) {
  52418. args.onError(xhr.status);
  52419. };
  52420. }
  52421. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52422. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52423. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52424. pendingRequest.onDone = args.onDone;
  52425. pendingRequest.onError = args.onError;
  52426. pendingRequest.onProgress = args.onProgress;
  52427. xhr.send(null);
  52428. return xhrId;
  52429. },
  52430. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52431. var pendingRequest = this.pendingRequests[xhrId];
  52432. if (!pendingRequest) {
  52433. return;
  52434. }
  52435. if (pendingRequest.mozChunked) {
  52436. var chunk = getArrayBuffer(pendingRequest.xhr);
  52437. pendingRequest.onProgressiveData(chunk);
  52438. }
  52439. var onProgress = pendingRequest.onProgress;
  52440. if (onProgress) {
  52441. onProgress(evt);
  52442. }
  52443. },
  52444. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52445. var pendingRequest = this.pendingRequests[xhrId];
  52446. if (!pendingRequest) {
  52447. return;
  52448. }
  52449. var xhr = pendingRequest.xhr;
  52450. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52451. pendingRequest.onHeadersReceived();
  52452. delete pendingRequest.onHeadersReceived;
  52453. }
  52454. if (xhr.readyState !== 4) {
  52455. return;
  52456. }
  52457. if (!(xhrId in this.pendingRequests)) {
  52458. return;
  52459. }
  52460. delete this.pendingRequests[xhrId];
  52461. if (xhr.status === 0 && this.isHttp) {
  52462. if (pendingRequest.onError) {
  52463. pendingRequest.onError(xhr.status);
  52464. }
  52465. return;
  52466. }
  52467. var xhrStatus = xhr.status || OK_RESPONSE;
  52468. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52469. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52470. if (pendingRequest.onError) {
  52471. pendingRequest.onError(xhr.status);
  52472. }
  52473. return;
  52474. }
  52475. this.loadedRequests[xhrId] = true;
  52476. var chunk = getArrayBuffer(xhr);
  52477. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52478. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52479. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52480. var begin = parseInt(matches[1], 10);
  52481. pendingRequest.onDone({
  52482. begin: begin,
  52483. chunk: chunk
  52484. });
  52485. } else if (pendingRequest.onProgressiveData) {
  52486. pendingRequest.onDone(null);
  52487. } else if (chunk) {
  52488. pendingRequest.onDone({
  52489. begin: 0,
  52490. chunk: chunk
  52491. });
  52492. } else if (pendingRequest.onError) {
  52493. pendingRequest.onError(xhr.status);
  52494. }
  52495. },
  52496. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52497. for (var xhrId in this.pendingRequests) {
  52498. return true;
  52499. }
  52500. return false;
  52501. },
  52502. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52503. return this.pendingRequests[xhrId].xhr;
  52504. },
  52505. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52506. return !!this.pendingRequests[xhrId].onProgressiveData;
  52507. },
  52508. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52509. return xhrId in this.pendingRequests;
  52510. },
  52511. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52512. return xhrId in this.loadedRequests;
  52513. },
  52514. abortAllRequests: function NetworkManager_abortAllRequests() {
  52515. for (var xhrId in this.pendingRequests) {
  52516. this.abortRequest(xhrId | 0);
  52517. }
  52518. },
  52519. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52520. var xhr = this.pendingRequests[xhrId].xhr;
  52521. delete this.pendingRequests[xhrId];
  52522. xhr.abort();
  52523. }
  52524. };
  52525. var assert = sharedUtil.assert;
  52526. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52527. var isInt = sharedUtil.isInt;
  52528. var MissingPDFException = sharedUtil.MissingPDFException;
  52529. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52530. function PDFNetworkStream(options) {
  52531. this._options = options;
  52532. var source = options.source;
  52533. this._manager = new NetworkManager(source.url, {
  52534. httpHeaders: source.httpHeaders,
  52535. withCredentials: source.withCredentials
  52536. });
  52537. this._rangeChunkSize = source.rangeChunkSize;
  52538. this._fullRequestReader = null;
  52539. this._rangeRequestReaders = [];
  52540. }
  52541. PDFNetworkStream.prototype = {
  52542. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52543. var i = this._rangeRequestReaders.indexOf(reader);
  52544. if (i >= 0) {
  52545. this._rangeRequestReaders.splice(i, 1);
  52546. }
  52547. },
  52548. getFullReader: function PDFNetworkStream_getFullReader() {
  52549. assert(!this._fullRequestReader);
  52550. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52551. return this._fullRequestReader;
  52552. },
  52553. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52554. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52555. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52556. this._rangeRequestReaders.push(reader);
  52557. return reader;
  52558. },
  52559. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52560. if (this._fullRequestReader) {
  52561. this._fullRequestReader.cancel(reason);
  52562. }
  52563. var readers = this._rangeRequestReaders.slice(0);
  52564. readers.forEach(function (reader) {
  52565. reader.cancel(reason);
  52566. });
  52567. }
  52568. };
  52569. function PDFNetworkStreamFullRequestReader(manager, options) {
  52570. this._manager = manager;
  52571. var source = options.source;
  52572. var args = {
  52573. onHeadersReceived: this._onHeadersReceived.bind(this),
  52574. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52575. onDone: this._onDone.bind(this),
  52576. onError: this._onError.bind(this),
  52577. onProgress: this._onProgress.bind(this)
  52578. };
  52579. this._url = source.url;
  52580. this._fullRequestId = manager.requestFull(args);
  52581. this._headersReceivedCapability = createPromiseCapability();
  52582. this._disableRange = options.disableRange || false;
  52583. this._contentLength = source.length;
  52584. this._rangeChunkSize = source.rangeChunkSize;
  52585. if (!this._rangeChunkSize && !this._disableRange) {
  52586. this._disableRange = true;
  52587. }
  52588. this._isStreamingSupported = false;
  52589. this._isRangeSupported = false;
  52590. this._cachedChunks = [];
  52591. this._requests = [];
  52592. this._done = false;
  52593. this._storedError = undefined;
  52594. this.onProgress = null;
  52595. }
  52596. PDFNetworkStreamFullRequestReader.prototype = {
  52597. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52598. if (this._disableRange) {
  52599. return false;
  52600. }
  52601. var networkManager = this._manager;
  52602. if (!networkManager.isHttp) {
  52603. return false;
  52604. }
  52605. var fullRequestXhrId = this._fullRequestId;
  52606. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52607. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52608. return false;
  52609. }
  52610. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52611. if (contentEncoding !== 'identity') {
  52612. return false;
  52613. }
  52614. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52615. length = parseInt(length, 10);
  52616. if (!isInt(length)) {
  52617. return false;
  52618. }
  52619. this._contentLength = length;
  52620. if (length <= 2 * this._rangeChunkSize) {
  52621. return false;
  52622. }
  52623. return true;
  52624. },
  52625. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52626. if (this._validateRangeRequestCapabilities()) {
  52627. this._isRangeSupported = true;
  52628. }
  52629. var networkManager = this._manager;
  52630. var fullRequestXhrId = this._fullRequestId;
  52631. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52632. this._isStreamingSupported = true;
  52633. } else if (this._isRangeSupported) {
  52634. networkManager.abortRequest(fullRequestXhrId);
  52635. }
  52636. this._headersReceivedCapability.resolve();
  52637. },
  52638. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52639. if (this._requests.length > 0) {
  52640. var requestCapability = this._requests.shift();
  52641. requestCapability.resolve({
  52642. value: chunk,
  52643. done: false
  52644. });
  52645. } else {
  52646. this._cachedChunks.push(chunk);
  52647. }
  52648. },
  52649. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52650. if (args) {
  52651. this._onProgressiveData(args.chunk);
  52652. }
  52653. this._done = true;
  52654. if (this._cachedChunks.length > 0) {
  52655. return;
  52656. }
  52657. this._requests.forEach(function (requestCapability) {
  52658. requestCapability.resolve({
  52659. value: undefined,
  52660. done: true
  52661. });
  52662. });
  52663. this._requests = [];
  52664. },
  52665. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52666. var url = this._url;
  52667. var exception;
  52668. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52669. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52670. } else {
  52671. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52672. }
  52673. this._storedError = exception;
  52674. this._headersReceivedCapability.reject(exception);
  52675. this._requests.forEach(function (requestCapability) {
  52676. requestCapability.reject(exception);
  52677. });
  52678. this._requests = [];
  52679. this._cachedChunks = [];
  52680. },
  52681. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52682. if (this.onProgress) {
  52683. this.onProgress({
  52684. loaded: data.loaded,
  52685. total: data.lengthComputable ? data.total : this._contentLength
  52686. });
  52687. }
  52688. },
  52689. get isRangeSupported() {
  52690. return this._isRangeSupported;
  52691. },
  52692. get isStreamingSupported() {
  52693. return this._isStreamingSupported;
  52694. },
  52695. get contentLength() {
  52696. return this._contentLength;
  52697. },
  52698. get headersReady() {
  52699. return this._headersReceivedCapability.promise;
  52700. },
  52701. read: function PDFNetworkStreamFullRequestReader_read() {
  52702. if (this._storedError) {
  52703. return Promise.reject(this._storedError);
  52704. }
  52705. if (this._cachedChunks.length > 0) {
  52706. var chunk = this._cachedChunks.shift();
  52707. return Promise.resolve(chunk);
  52708. }
  52709. if (this._done) {
  52710. return Promise.resolve({
  52711. value: undefined,
  52712. done: true
  52713. });
  52714. }
  52715. var requestCapability = createPromiseCapability();
  52716. this._requests.push(requestCapability);
  52717. return requestCapability.promise;
  52718. },
  52719. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52720. this._done = true;
  52721. this._headersReceivedCapability.reject(reason);
  52722. this._requests.forEach(function (requestCapability) {
  52723. requestCapability.resolve({
  52724. value: undefined,
  52725. done: true
  52726. });
  52727. });
  52728. this._requests = [];
  52729. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52730. this._manager.abortRequest(this._fullRequestId);
  52731. }
  52732. this._fullRequestReader = null;
  52733. }
  52734. };
  52735. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52736. this._manager = manager;
  52737. var args = {
  52738. onDone: this._onDone.bind(this),
  52739. onProgress: this._onProgress.bind(this)
  52740. };
  52741. this._requestId = manager.requestRange(begin, end, args);
  52742. this._requests = [];
  52743. this._queuedChunk = null;
  52744. this._done = false;
  52745. this.onProgress = null;
  52746. this.onClosed = null;
  52747. }
  52748. PDFNetworkStreamRangeRequestReader.prototype = {
  52749. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52750. if (this.onClosed) {
  52751. this.onClosed(this);
  52752. }
  52753. },
  52754. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52755. var chunk = data.chunk;
  52756. if (this._requests.length > 0) {
  52757. var requestCapability = this._requests.shift();
  52758. requestCapability.resolve({
  52759. value: chunk,
  52760. done: false
  52761. });
  52762. } else {
  52763. this._queuedChunk = chunk;
  52764. }
  52765. this._done = true;
  52766. this._requests.forEach(function (requestCapability) {
  52767. requestCapability.resolve({
  52768. value: undefined,
  52769. done: true
  52770. });
  52771. });
  52772. this._requests = [];
  52773. this._close();
  52774. },
  52775. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52776. if (!this.isStreamingSupported && this.onProgress) {
  52777. this.onProgress({ loaded: evt.loaded });
  52778. }
  52779. },
  52780. get isStreamingSupported() {
  52781. return false;
  52782. },
  52783. read: function PDFNetworkStreamRangeRequestReader_read() {
  52784. if (this._queuedChunk !== null) {
  52785. var chunk = this._queuedChunk;
  52786. this._queuedChunk = null;
  52787. return Promise.resolve({
  52788. value: chunk,
  52789. done: false
  52790. });
  52791. }
  52792. if (this._done) {
  52793. return Promise.resolve({
  52794. value: undefined,
  52795. done: true
  52796. });
  52797. }
  52798. var requestCapability = createPromiseCapability();
  52799. this._requests.push(requestCapability);
  52800. return requestCapability.promise;
  52801. },
  52802. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52803. this._done = true;
  52804. this._requests.forEach(function (requestCapability) {
  52805. requestCapability.resolve({
  52806. value: undefined,
  52807. done: true
  52808. });
  52809. });
  52810. this._requests = [];
  52811. if (this._manager.isPendingRequest(this._requestId)) {
  52812. this._manager.abortRequest(this._requestId);
  52813. }
  52814. this._close();
  52815. }
  52816. };
  52817. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52818. exports.PDFNetworkStream = PDFNetworkStream;
  52819. exports.NetworkManager = NetworkManager;
  52820. /***/ }),
  52821. /* 41 */
  52822. /***/ (function(module, exports, __w_pdfjs_require__) {
  52823. "use strict";
  52824. var sharedUtil = __w_pdfjs_require__(0);
  52825. var corePrimitives = __w_pdfjs_require__(1);
  52826. var coreFunction = __w_pdfjs_require__(7);
  52827. var coreColorSpace = __w_pdfjs_require__(4);
  52828. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52829. var MissingDataException = sharedUtil.MissingDataException;
  52830. var Util = sharedUtil.Util;
  52831. var assert = sharedUtil.assert;
  52832. var error = sharedUtil.error;
  52833. var info = sharedUtil.info;
  52834. var warn = sharedUtil.warn;
  52835. var isStream = corePrimitives.isStream;
  52836. var PDFFunction = coreFunction.PDFFunction;
  52837. var ColorSpace = coreColorSpace.ColorSpace;
  52838. var ShadingType = {
  52839. FUNCTION_BASED: 1,
  52840. AXIAL: 2,
  52841. RADIAL: 3,
  52842. FREE_FORM_MESH: 4,
  52843. LATTICE_FORM_MESH: 5,
  52844. COONS_PATCH_MESH: 6,
  52845. TENSOR_PATCH_MESH: 7
  52846. };
  52847. var Pattern = function PatternClosure() {
  52848. function Pattern() {
  52849. error('should not call Pattern constructor');
  52850. }
  52851. Pattern.prototype = {
  52852. getPattern: function Pattern_getPattern(ctx) {
  52853. error('Should not call Pattern.getStyle: ' + ctx);
  52854. }
  52855. };
  52856. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52857. var dict = isStream(shading) ? shading.dict : shading;
  52858. var type = dict.get('ShadingType');
  52859. try {
  52860. switch (type) {
  52861. case ShadingType.AXIAL:
  52862. case ShadingType.RADIAL:
  52863. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52864. case ShadingType.FREE_FORM_MESH:
  52865. case ShadingType.LATTICE_FORM_MESH:
  52866. case ShadingType.COONS_PATCH_MESH:
  52867. case ShadingType.TENSOR_PATCH_MESH:
  52868. return new Shadings.Mesh(shading, matrix, xref, res);
  52869. default:
  52870. throw new Error('Unsupported ShadingType: ' + type);
  52871. }
  52872. } catch (ex) {
  52873. if (ex instanceof MissingDataException) {
  52874. throw ex;
  52875. }
  52876. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52877. warn(ex);
  52878. return new Shadings.Dummy();
  52879. }
  52880. };
  52881. return Pattern;
  52882. }();
  52883. var Shadings = {};
  52884. Shadings.SMALL_NUMBER = 1e-6;
  52885. Shadings.RadialAxial = function RadialAxialClosure() {
  52886. function RadialAxial(dict, matrix, xref, res) {
  52887. this.matrix = matrix;
  52888. this.coordsArr = dict.getArray('Coords');
  52889. this.shadingType = dict.get('ShadingType');
  52890. this.type = 'Pattern';
  52891. var cs = dict.get('ColorSpace', 'CS');
  52892. cs = ColorSpace.parse(cs, xref, res);
  52893. this.cs = cs;
  52894. var t0 = 0.0, t1 = 1.0;
  52895. if (dict.has('Domain')) {
  52896. var domainArr = dict.getArray('Domain');
  52897. t0 = domainArr[0];
  52898. t1 = domainArr[1];
  52899. }
  52900. var extendStart = false, extendEnd = false;
  52901. if (dict.has('Extend')) {
  52902. var extendArr = dict.getArray('Extend');
  52903. extendStart = extendArr[0];
  52904. extendEnd = extendArr[1];
  52905. }
  52906. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52907. var x1 = this.coordsArr[0];
  52908. var y1 = this.coordsArr[1];
  52909. var r1 = this.coordsArr[2];
  52910. var x2 = this.coordsArr[3];
  52911. var y2 = this.coordsArr[4];
  52912. var r2 = this.coordsArr[5];
  52913. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52914. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52915. warn('Unsupported radial gradient.');
  52916. }
  52917. }
  52918. this.extendStart = extendStart;
  52919. this.extendEnd = extendEnd;
  52920. var fnObj = dict.get('Function');
  52921. var fn = PDFFunction.parseArray(xref, fnObj);
  52922. var diff = t1 - t0;
  52923. var step = diff / 10;
  52924. var colorStops = this.colorStops = [];
  52925. if (t0 >= t1 || step <= 0) {
  52926. info('Bad shading domain.');
  52927. return;
  52928. }
  52929. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52930. var rgbColor;
  52931. for (var i = t0; i <= t1; i += step) {
  52932. ratio[0] = i;
  52933. fn(ratio, 0, color, 0);
  52934. rgbColor = cs.getRgb(color, 0);
  52935. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52936. colorStops.push([
  52937. (i - t0) / diff,
  52938. cssColor
  52939. ]);
  52940. }
  52941. var background = 'transparent';
  52942. if (dict.has('Background')) {
  52943. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52944. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52945. }
  52946. if (!extendStart) {
  52947. colorStops.unshift([
  52948. 0,
  52949. background
  52950. ]);
  52951. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52952. }
  52953. if (!extendEnd) {
  52954. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52955. colorStops.push([
  52956. 1,
  52957. background
  52958. ]);
  52959. }
  52960. this.colorStops = colorStops;
  52961. }
  52962. RadialAxial.prototype = {
  52963. getIR: function RadialAxial_getIR() {
  52964. var coordsArr = this.coordsArr;
  52965. var shadingType = this.shadingType;
  52966. var type, p0, p1, r0, r1;
  52967. if (shadingType === ShadingType.AXIAL) {
  52968. p0 = [
  52969. coordsArr[0],
  52970. coordsArr[1]
  52971. ];
  52972. p1 = [
  52973. coordsArr[2],
  52974. coordsArr[3]
  52975. ];
  52976. r0 = null;
  52977. r1 = null;
  52978. type = 'axial';
  52979. } else if (shadingType === ShadingType.RADIAL) {
  52980. p0 = [
  52981. coordsArr[0],
  52982. coordsArr[1]
  52983. ];
  52984. p1 = [
  52985. coordsArr[3],
  52986. coordsArr[4]
  52987. ];
  52988. r0 = coordsArr[2];
  52989. r1 = coordsArr[5];
  52990. type = 'radial';
  52991. } else {
  52992. error('getPattern type unknown: ' + shadingType);
  52993. }
  52994. var matrix = this.matrix;
  52995. if (matrix) {
  52996. p0 = Util.applyTransform(p0, matrix);
  52997. p1 = Util.applyTransform(p1, matrix);
  52998. if (shadingType === ShadingType.RADIAL) {
  52999. var scale = Util.singularValueDecompose2dScale(matrix);
  53000. r0 *= scale[0];
  53001. r1 *= scale[1];
  53002. }
  53003. }
  53004. return [
  53005. 'RadialAxial',
  53006. type,
  53007. this.colorStops,
  53008. p0,
  53009. p1,
  53010. r0,
  53011. r1
  53012. ];
  53013. }
  53014. };
  53015. return RadialAxial;
  53016. }();
  53017. Shadings.Mesh = function MeshClosure() {
  53018. function MeshStreamReader(stream, context) {
  53019. this.stream = stream;
  53020. this.context = context;
  53021. this.buffer = 0;
  53022. this.bufferLength = 0;
  53023. var numComps = context.numComps;
  53024. this.tmpCompsBuf = new Float32Array(numComps);
  53025. var csNumComps = context.colorSpace.numComps;
  53026. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53027. }
  53028. MeshStreamReader.prototype = {
  53029. get hasData() {
  53030. if (this.stream.end) {
  53031. return this.stream.pos < this.stream.end;
  53032. }
  53033. if (this.bufferLength > 0) {
  53034. return true;
  53035. }
  53036. var nextByte = this.stream.getByte();
  53037. if (nextByte < 0) {
  53038. return false;
  53039. }
  53040. this.buffer = nextByte;
  53041. this.bufferLength = 8;
  53042. return true;
  53043. },
  53044. readBits: function MeshStreamReader_readBits(n) {
  53045. var buffer = this.buffer;
  53046. var bufferLength = this.bufferLength;
  53047. if (n === 32) {
  53048. if (bufferLength === 0) {
  53049. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53050. }
  53051. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53052. var nextByte = this.stream.getByte();
  53053. this.buffer = nextByte & (1 << bufferLength) - 1;
  53054. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53055. }
  53056. if (n === 8 && bufferLength === 0) {
  53057. return this.stream.getByte();
  53058. }
  53059. while (bufferLength < n) {
  53060. buffer = buffer << 8 | this.stream.getByte();
  53061. bufferLength += 8;
  53062. }
  53063. bufferLength -= n;
  53064. this.bufferLength = bufferLength;
  53065. this.buffer = buffer & (1 << bufferLength) - 1;
  53066. return buffer >> bufferLength;
  53067. },
  53068. align: function MeshStreamReader_align() {
  53069. this.buffer = 0;
  53070. this.bufferLength = 0;
  53071. },
  53072. readFlag: function MeshStreamReader_readFlag() {
  53073. return this.readBits(this.context.bitsPerFlag);
  53074. },
  53075. readCoordinate: function MeshStreamReader_readCoordinate() {
  53076. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53077. var xi = this.readBits(bitsPerCoordinate);
  53078. var yi = this.readBits(bitsPerCoordinate);
  53079. var decode = this.context.decode;
  53080. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53081. return [
  53082. xi * scale * (decode[1] - decode[0]) + decode[0],
  53083. yi * scale * (decode[3] - decode[2]) + decode[2]
  53084. ];
  53085. },
  53086. readComponents: function MeshStreamReader_readComponents() {
  53087. var numComps = this.context.numComps;
  53088. var bitsPerComponent = this.context.bitsPerComponent;
  53089. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53090. var decode = this.context.decode;
  53091. var components = this.tmpCompsBuf;
  53092. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53093. var ci = this.readBits(bitsPerComponent);
  53094. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53095. }
  53096. var color = this.tmpCsCompsBuf;
  53097. if (this.context.colorFn) {
  53098. this.context.colorFn(components, 0, color, 0);
  53099. }
  53100. return this.context.colorSpace.getRgb(color, 0);
  53101. }
  53102. };
  53103. function decodeType4Shading(mesh, reader) {
  53104. var coords = mesh.coords;
  53105. var colors = mesh.colors;
  53106. var operators = [];
  53107. var ps = [];
  53108. var verticesLeft = 0;
  53109. while (reader.hasData) {
  53110. var f = reader.readFlag();
  53111. var coord = reader.readCoordinate();
  53112. var color = reader.readComponents();
  53113. if (verticesLeft === 0) {
  53114. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53115. switch (f) {
  53116. case 0:
  53117. verticesLeft = 3;
  53118. break;
  53119. case 1:
  53120. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53121. verticesLeft = 1;
  53122. break;
  53123. case 2:
  53124. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53125. verticesLeft = 1;
  53126. break;
  53127. }
  53128. operators.push(f);
  53129. }
  53130. ps.push(coords.length);
  53131. coords.push(coord);
  53132. colors.push(color);
  53133. verticesLeft--;
  53134. reader.align();
  53135. }
  53136. mesh.figures.push({
  53137. type: 'triangles',
  53138. coords: new Int32Array(ps),
  53139. colors: new Int32Array(ps)
  53140. });
  53141. }
  53142. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53143. var coords = mesh.coords;
  53144. var colors = mesh.colors;
  53145. var ps = [];
  53146. while (reader.hasData) {
  53147. var coord = reader.readCoordinate();
  53148. var color = reader.readComponents();
  53149. ps.push(coords.length);
  53150. coords.push(coord);
  53151. colors.push(color);
  53152. }
  53153. mesh.figures.push({
  53154. type: 'lattice',
  53155. coords: new Int32Array(ps),
  53156. colors: new Int32Array(ps),
  53157. verticesPerRow: verticesPerRow
  53158. });
  53159. }
  53160. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53161. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53162. var TRIANGLE_DENSITY = 20;
  53163. var getB = function getBClosure() {
  53164. function buildB(count) {
  53165. var lut = [];
  53166. for (var i = 0; i <= count; i++) {
  53167. var t = i / count, t_ = 1 - t;
  53168. lut.push(new Float32Array([
  53169. t_ * t_ * t_,
  53170. 3 * t * t_ * t_,
  53171. 3 * t * t * t_,
  53172. t * t * t
  53173. ]));
  53174. }
  53175. return lut;
  53176. }
  53177. var cache = [];
  53178. return function getB(count) {
  53179. if (!cache[count]) {
  53180. cache[count] = buildB(count);
  53181. }
  53182. return cache[count];
  53183. };
  53184. }();
  53185. function buildFigureFromPatch(mesh, index) {
  53186. var figure = mesh.figures[index];
  53187. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53188. var coords = mesh.coords, colors = mesh.colors;
  53189. var pi = figure.coords;
  53190. var ci = figure.colors;
  53191. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53192. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53193. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53194. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53195. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53196. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53197. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53198. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53199. var verticesPerRow = splitXBy + 1;
  53200. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53201. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53202. var k = 0;
  53203. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53204. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53205. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53206. for (var row = 0; row <= splitYBy; row++) {
  53207. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53208. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53209. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53210. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53211. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53212. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53213. for (var col = 0; col <= splitXBy; col++, k++) {
  53214. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53215. continue;
  53216. }
  53217. var x = 0, y = 0;
  53218. var q = 0;
  53219. for (var i = 0; i <= 3; i++) {
  53220. for (var j = 0; j <= 3; j++, q++) {
  53221. var m = bRow[row][i] * bCol[col][j];
  53222. x += coords[pi[q]][0] * m;
  53223. y += coords[pi[q]][1] * m;
  53224. }
  53225. }
  53226. figureCoords[k] = coords.length;
  53227. coords.push([
  53228. x,
  53229. y
  53230. ]);
  53231. figureColors[k] = colors.length;
  53232. var newColor = new Uint8Array(3);
  53233. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53234. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53235. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53236. colors.push(newColor);
  53237. }
  53238. }
  53239. figureCoords[0] = pi[0];
  53240. figureColors[0] = ci[0];
  53241. figureCoords[splitXBy] = pi[3];
  53242. figureColors[splitXBy] = ci[1];
  53243. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53244. figureColors[verticesPerRow * splitYBy] = ci[2];
  53245. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53246. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53247. mesh.figures[index] = {
  53248. type: 'lattice',
  53249. coords: figureCoords,
  53250. colors: figureColors,
  53251. verticesPerRow: verticesPerRow
  53252. };
  53253. }
  53254. function decodeType6Shading(mesh, reader) {
  53255. var coords = mesh.coords;
  53256. var colors = mesh.colors;
  53257. var ps = new Int32Array(16);
  53258. var cs = new Int32Array(4);
  53259. while (reader.hasData) {
  53260. var f = reader.readFlag();
  53261. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53262. var i, ii;
  53263. var pi = coords.length;
  53264. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53265. coords.push(reader.readCoordinate());
  53266. }
  53267. var ci = colors.length;
  53268. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53269. colors.push(reader.readComponents());
  53270. }
  53271. var tmp1, tmp2, tmp3, tmp4;
  53272. switch (f) {
  53273. case 0:
  53274. ps[12] = pi + 3;
  53275. ps[13] = pi + 4;
  53276. ps[14] = pi + 5;
  53277. ps[15] = pi + 6;
  53278. ps[8] = pi + 2;
  53279. ps[11] = pi + 7;
  53280. ps[4] = pi + 1;
  53281. ps[7] = pi + 8;
  53282. ps[0] = pi;
  53283. ps[1] = pi + 11;
  53284. ps[2] = pi + 10;
  53285. ps[3] = pi + 9;
  53286. cs[2] = ci + 1;
  53287. cs[3] = ci + 2;
  53288. cs[0] = ci;
  53289. cs[1] = ci + 3;
  53290. break;
  53291. case 1:
  53292. tmp1 = ps[12];
  53293. tmp2 = ps[13];
  53294. tmp3 = ps[14];
  53295. tmp4 = ps[15];
  53296. ps[12] = tmp4;
  53297. ps[13] = pi + 0;
  53298. ps[14] = pi + 1;
  53299. ps[15] = pi + 2;
  53300. ps[8] = tmp3;
  53301. ps[11] = pi + 3;
  53302. ps[4] = tmp2;
  53303. ps[7] = pi + 4;
  53304. ps[0] = tmp1;
  53305. ps[1] = pi + 7;
  53306. ps[2] = pi + 6;
  53307. ps[3] = pi + 5;
  53308. tmp1 = cs[2];
  53309. tmp2 = cs[3];
  53310. cs[2] = tmp2;
  53311. cs[3] = ci;
  53312. cs[0] = tmp1;
  53313. cs[1] = ci + 1;
  53314. break;
  53315. case 2:
  53316. tmp1 = ps[15];
  53317. tmp2 = ps[11];
  53318. ps[12] = ps[3];
  53319. ps[13] = pi + 0;
  53320. ps[14] = pi + 1;
  53321. ps[15] = pi + 2;
  53322. ps[8] = ps[7];
  53323. ps[11] = pi + 3;
  53324. ps[4] = tmp2;
  53325. ps[7] = pi + 4;
  53326. ps[0] = tmp1;
  53327. ps[1] = pi + 7;
  53328. ps[2] = pi + 6;
  53329. ps[3] = pi + 5;
  53330. tmp1 = cs[3];
  53331. cs[2] = cs[1];
  53332. cs[3] = ci;
  53333. cs[0] = tmp1;
  53334. cs[1] = ci + 1;
  53335. break;
  53336. case 3:
  53337. ps[12] = ps[0];
  53338. ps[13] = pi + 0;
  53339. ps[14] = pi + 1;
  53340. ps[15] = pi + 2;
  53341. ps[8] = ps[1];
  53342. ps[11] = pi + 3;
  53343. ps[4] = ps[2];
  53344. ps[7] = pi + 4;
  53345. ps[0] = ps[3];
  53346. ps[1] = pi + 7;
  53347. ps[2] = pi + 6;
  53348. ps[3] = pi + 5;
  53349. cs[2] = cs[0];
  53350. cs[3] = ci;
  53351. cs[0] = cs[1];
  53352. cs[1] = ci + 1;
  53353. break;
  53354. }
  53355. ps[5] = coords.length;
  53356. coords.push([
  53357. (-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,
  53358. (-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
  53359. ]);
  53360. ps[6] = coords.length;
  53361. coords.push([
  53362. (-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,
  53363. (-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
  53364. ]);
  53365. ps[9] = coords.length;
  53366. coords.push([
  53367. (-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,
  53368. (-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
  53369. ]);
  53370. ps[10] = coords.length;
  53371. coords.push([
  53372. (-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,
  53373. (-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
  53374. ]);
  53375. mesh.figures.push({
  53376. type: 'patch',
  53377. coords: new Int32Array(ps),
  53378. colors: new Int32Array(cs)
  53379. });
  53380. }
  53381. }
  53382. function decodeType7Shading(mesh, reader) {
  53383. var coords = mesh.coords;
  53384. var colors = mesh.colors;
  53385. var ps = new Int32Array(16);
  53386. var cs = new Int32Array(4);
  53387. while (reader.hasData) {
  53388. var f = reader.readFlag();
  53389. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53390. var i, ii;
  53391. var pi = coords.length;
  53392. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53393. coords.push(reader.readCoordinate());
  53394. }
  53395. var ci = colors.length;
  53396. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53397. colors.push(reader.readComponents());
  53398. }
  53399. var tmp1, tmp2, tmp3, tmp4;
  53400. switch (f) {
  53401. case 0:
  53402. ps[12] = pi + 3;
  53403. ps[13] = pi + 4;
  53404. ps[14] = pi + 5;
  53405. ps[15] = pi + 6;
  53406. ps[8] = pi + 2;
  53407. ps[9] = pi + 13;
  53408. ps[10] = pi + 14;
  53409. ps[11] = pi + 7;
  53410. ps[4] = pi + 1;
  53411. ps[5] = pi + 12;
  53412. ps[6] = pi + 15;
  53413. ps[7] = pi + 8;
  53414. ps[0] = pi;
  53415. ps[1] = pi + 11;
  53416. ps[2] = pi + 10;
  53417. ps[3] = pi + 9;
  53418. cs[2] = ci + 1;
  53419. cs[3] = ci + 2;
  53420. cs[0] = ci;
  53421. cs[1] = ci + 3;
  53422. break;
  53423. case 1:
  53424. tmp1 = ps[12];
  53425. tmp2 = ps[13];
  53426. tmp3 = ps[14];
  53427. tmp4 = ps[15];
  53428. ps[12] = tmp4;
  53429. ps[13] = pi + 0;
  53430. ps[14] = pi + 1;
  53431. ps[15] = pi + 2;
  53432. ps[8] = tmp3;
  53433. ps[9] = pi + 9;
  53434. ps[10] = pi + 10;
  53435. ps[11] = pi + 3;
  53436. ps[4] = tmp2;
  53437. ps[5] = pi + 8;
  53438. ps[6] = pi + 11;
  53439. ps[7] = pi + 4;
  53440. ps[0] = tmp1;
  53441. ps[1] = pi + 7;
  53442. ps[2] = pi + 6;
  53443. ps[3] = pi + 5;
  53444. tmp1 = cs[2];
  53445. tmp2 = cs[3];
  53446. cs[2] = tmp2;
  53447. cs[3] = ci;
  53448. cs[0] = tmp1;
  53449. cs[1] = ci + 1;
  53450. break;
  53451. case 2:
  53452. tmp1 = ps[15];
  53453. tmp2 = ps[11];
  53454. ps[12] = ps[3];
  53455. ps[13] = pi + 0;
  53456. ps[14] = pi + 1;
  53457. ps[15] = pi + 2;
  53458. ps[8] = ps[7];
  53459. ps[9] = pi + 9;
  53460. ps[10] = pi + 10;
  53461. ps[11] = pi + 3;
  53462. ps[4] = tmp2;
  53463. ps[5] = pi + 8;
  53464. ps[6] = pi + 11;
  53465. ps[7] = pi + 4;
  53466. ps[0] = tmp1;
  53467. ps[1] = pi + 7;
  53468. ps[2] = pi + 6;
  53469. ps[3] = pi + 5;
  53470. tmp1 = cs[3];
  53471. cs[2] = cs[1];
  53472. cs[3] = ci;
  53473. cs[0] = tmp1;
  53474. cs[1] = ci + 1;
  53475. break;
  53476. case 3:
  53477. ps[12] = ps[0];
  53478. ps[13] = pi + 0;
  53479. ps[14] = pi + 1;
  53480. ps[15] = pi + 2;
  53481. ps[8] = ps[1];
  53482. ps[9] = pi + 9;
  53483. ps[10] = pi + 10;
  53484. ps[11] = pi + 3;
  53485. ps[4] = ps[2];
  53486. ps[5] = pi + 8;
  53487. ps[6] = pi + 11;
  53488. ps[7] = pi + 4;
  53489. ps[0] = ps[3];
  53490. ps[1] = pi + 7;
  53491. ps[2] = pi + 6;
  53492. ps[3] = pi + 5;
  53493. cs[2] = cs[0];
  53494. cs[3] = ci;
  53495. cs[0] = cs[1];
  53496. cs[1] = ci + 1;
  53497. break;
  53498. }
  53499. mesh.figures.push({
  53500. type: 'patch',
  53501. coords: new Int32Array(ps),
  53502. colors: new Int32Array(cs)
  53503. });
  53504. }
  53505. }
  53506. function updateBounds(mesh) {
  53507. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53508. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53509. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53510. minX = minX > x ? x : minX;
  53511. minY = minY > y ? y : minY;
  53512. maxX = maxX < x ? x : maxX;
  53513. maxY = maxY < y ? y : maxY;
  53514. }
  53515. mesh.bounds = [
  53516. minX,
  53517. minY,
  53518. maxX,
  53519. maxY
  53520. ];
  53521. }
  53522. function packData(mesh) {
  53523. var i, ii, j, jj;
  53524. var coords = mesh.coords;
  53525. var coordsPacked = new Float32Array(coords.length * 2);
  53526. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53527. var xy = coords[i];
  53528. coordsPacked[j++] = xy[0];
  53529. coordsPacked[j++] = xy[1];
  53530. }
  53531. mesh.coords = coordsPacked;
  53532. var colors = mesh.colors;
  53533. var colorsPacked = new Uint8Array(colors.length * 3);
  53534. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53535. var c = colors[i];
  53536. colorsPacked[j++] = c[0];
  53537. colorsPacked[j++] = c[1];
  53538. colorsPacked[j++] = c[2];
  53539. }
  53540. mesh.colors = colorsPacked;
  53541. var figures = mesh.figures;
  53542. for (i = 0, ii = figures.length; i < ii; i++) {
  53543. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53544. for (j = 0, jj = ps.length; j < jj; j++) {
  53545. ps[j] *= 2;
  53546. cs[j] *= 3;
  53547. }
  53548. }
  53549. }
  53550. function Mesh(stream, matrix, xref, res) {
  53551. assert(isStream(stream), 'Mesh data is not a stream');
  53552. var dict = stream.dict;
  53553. this.matrix = matrix;
  53554. this.shadingType = dict.get('ShadingType');
  53555. this.type = 'Pattern';
  53556. this.bbox = dict.getArray('BBox');
  53557. var cs = dict.get('ColorSpace', 'CS');
  53558. cs = ColorSpace.parse(cs, xref, res);
  53559. this.cs = cs;
  53560. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53561. var fnObj = dict.get('Function');
  53562. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53563. this.coords = [];
  53564. this.colors = [];
  53565. this.figures = [];
  53566. var decodeContext = {
  53567. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53568. bitsPerComponent: dict.get('BitsPerComponent'),
  53569. bitsPerFlag: dict.get('BitsPerFlag'),
  53570. decode: dict.getArray('Decode'),
  53571. colorFn: fn,
  53572. colorSpace: cs,
  53573. numComps: fn ? 1 : cs.numComps
  53574. };
  53575. var reader = new MeshStreamReader(stream, decodeContext);
  53576. var patchMesh = false;
  53577. switch (this.shadingType) {
  53578. case ShadingType.FREE_FORM_MESH:
  53579. decodeType4Shading(this, reader);
  53580. break;
  53581. case ShadingType.LATTICE_FORM_MESH:
  53582. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53583. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53584. decodeType5Shading(this, reader, verticesPerRow);
  53585. break;
  53586. case ShadingType.COONS_PATCH_MESH:
  53587. decodeType6Shading(this, reader);
  53588. patchMesh = true;
  53589. break;
  53590. case ShadingType.TENSOR_PATCH_MESH:
  53591. decodeType7Shading(this, reader);
  53592. patchMesh = true;
  53593. break;
  53594. default:
  53595. error('Unsupported mesh type.');
  53596. break;
  53597. }
  53598. if (patchMesh) {
  53599. updateBounds(this);
  53600. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53601. buildFigureFromPatch(this, i);
  53602. }
  53603. }
  53604. updateBounds(this);
  53605. packData(this);
  53606. }
  53607. Mesh.prototype = {
  53608. getIR: function Mesh_getIR() {
  53609. return [
  53610. 'Mesh',
  53611. this.shadingType,
  53612. this.coords,
  53613. this.colors,
  53614. this.figures,
  53615. this.bounds,
  53616. this.matrix,
  53617. this.bbox,
  53618. this.background
  53619. ];
  53620. }
  53621. };
  53622. return Mesh;
  53623. }();
  53624. Shadings.Dummy = function DummyClosure() {
  53625. function Dummy() {
  53626. this.type = 'Pattern';
  53627. }
  53628. Dummy.prototype = {
  53629. getIR: function Dummy_getIR() {
  53630. return ['Dummy'];
  53631. }
  53632. };
  53633. return Dummy;
  53634. }();
  53635. function getTilingPatternIR(operatorList, dict, args) {
  53636. var matrix = dict.getArray('Matrix');
  53637. var bbox = dict.getArray('BBox');
  53638. var xstep = dict.get('XStep');
  53639. var ystep = dict.get('YStep');
  53640. var paintType = dict.get('PaintType');
  53641. var tilingType = dict.get('TilingType');
  53642. return [
  53643. 'TilingPattern',
  53644. args,
  53645. operatorList,
  53646. matrix,
  53647. bbox,
  53648. xstep,
  53649. ystep,
  53650. paintType,
  53651. tilingType
  53652. ];
  53653. }
  53654. exports.Pattern = Pattern;
  53655. exports.getTilingPatternIR = getTilingPatternIR;
  53656. /***/ }),
  53657. /* 42 */
  53658. /***/ (function(module, exports, __w_pdfjs_require__) {
  53659. "use strict";
  53660. var sharedUtil = __w_pdfjs_require__(0);
  53661. var coreStream = __w_pdfjs_require__(2);
  53662. var coreChunkedStream = __w_pdfjs_require__(15);
  53663. var coreDocument = __w_pdfjs_require__(32);
  53664. var warn = sharedUtil.warn;
  53665. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53666. var shadow = sharedUtil.shadow;
  53667. var NotImplementedException = sharedUtil.NotImplementedException;
  53668. var MissingDataException = sharedUtil.MissingDataException;
  53669. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53670. var Util = sharedUtil.Util;
  53671. var Stream = coreStream.Stream;
  53672. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53673. var PDFDocument = coreDocument.PDFDocument;
  53674. var BasePdfManager = function BasePdfManagerClosure() {
  53675. function BasePdfManager() {
  53676. throw new Error('Cannot initialize BaseManagerManager');
  53677. }
  53678. BasePdfManager.prototype = {
  53679. get docId() {
  53680. return this._docId;
  53681. },
  53682. get password() {
  53683. return this._password;
  53684. },
  53685. get docBaseUrl() {
  53686. var docBaseUrl = null;
  53687. if (this._docBaseUrl) {
  53688. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53689. if (absoluteUrl) {
  53690. docBaseUrl = absoluteUrl.href;
  53691. } else {
  53692. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53693. }
  53694. }
  53695. return shadow(this, 'docBaseUrl', docBaseUrl);
  53696. },
  53697. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53698. throw new NotImplementedException();
  53699. },
  53700. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53701. return this.ensure(this.pdfDocument, prop, args);
  53702. },
  53703. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53704. return this.ensure(this.pdfDocument.xref, prop, args);
  53705. },
  53706. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53707. return this.ensure(this.pdfDocument.catalog, prop, args);
  53708. },
  53709. getPage: function BasePdfManager_getPage(pageIndex) {
  53710. return this.pdfDocument.getPage(pageIndex);
  53711. },
  53712. cleanup: function BasePdfManager_cleanup() {
  53713. return this.pdfDocument.cleanup();
  53714. },
  53715. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53716. return new NotImplementedException();
  53717. },
  53718. requestRange: function BasePdfManager_requestRange(begin, end) {
  53719. return new NotImplementedException();
  53720. },
  53721. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53722. return new NotImplementedException();
  53723. },
  53724. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53725. return new NotImplementedException();
  53726. },
  53727. updatePassword: function BasePdfManager_updatePassword(password) {
  53728. this._password = password;
  53729. },
  53730. terminate: function BasePdfManager_terminate() {
  53731. return new NotImplementedException();
  53732. }
  53733. };
  53734. return BasePdfManager;
  53735. }();
  53736. var LocalPdfManager = function LocalPdfManagerClosure() {
  53737. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53738. this._docId = docId;
  53739. this._password = password;
  53740. this._docBaseUrl = docBaseUrl;
  53741. this.evaluatorOptions = evaluatorOptions;
  53742. var stream = new Stream(data);
  53743. this.pdfDocument = new PDFDocument(this, stream);
  53744. this._loadedStreamCapability = createPromiseCapability();
  53745. this._loadedStreamCapability.resolve(stream);
  53746. }
  53747. Util.inherit(LocalPdfManager, BasePdfManager, {
  53748. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53749. return new Promise(function (resolve, reject) {
  53750. try {
  53751. var value = obj[prop];
  53752. var result;
  53753. if (typeof value === 'function') {
  53754. result = value.apply(obj, args);
  53755. } else {
  53756. result = value;
  53757. }
  53758. resolve(result);
  53759. } catch (e) {
  53760. reject(e);
  53761. }
  53762. });
  53763. },
  53764. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53765. return Promise.resolve();
  53766. },
  53767. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53768. },
  53769. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53770. return this._loadedStreamCapability.promise;
  53771. },
  53772. terminate: function LocalPdfManager_terminate() {
  53773. }
  53774. });
  53775. return LocalPdfManager;
  53776. }();
  53777. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53778. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53779. this._docId = docId;
  53780. this._password = args.password;
  53781. this._docBaseUrl = docBaseUrl;
  53782. this.msgHandler = args.msgHandler;
  53783. this.evaluatorOptions = evaluatorOptions;
  53784. var params = {
  53785. msgHandler: args.msgHandler,
  53786. url: args.url,
  53787. length: args.length,
  53788. disableAutoFetch: args.disableAutoFetch,
  53789. rangeChunkSize: args.rangeChunkSize
  53790. };
  53791. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53792. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53793. }
  53794. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53795. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53796. var pdfManager = this;
  53797. return new Promise(function (resolve, reject) {
  53798. function ensureHelper() {
  53799. try {
  53800. var result;
  53801. var value = obj[prop];
  53802. if (typeof value === 'function') {
  53803. result = value.apply(obj, args);
  53804. } else {
  53805. result = value;
  53806. }
  53807. resolve(result);
  53808. } catch (e) {
  53809. if (!(e instanceof MissingDataException)) {
  53810. reject(e);
  53811. return;
  53812. }
  53813. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53814. }
  53815. }
  53816. ensureHelper();
  53817. });
  53818. },
  53819. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53820. return this.streamManager.requestRange(begin, end);
  53821. },
  53822. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53823. this.streamManager.requestAllChunks();
  53824. },
  53825. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53826. this.streamManager.onReceiveData({ chunk: chunk });
  53827. },
  53828. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53829. return this.streamManager.onLoadedStream();
  53830. },
  53831. terminate: function NetworkPdfManager_terminate() {
  53832. this.streamManager.abort();
  53833. }
  53834. });
  53835. return NetworkPdfManager;
  53836. }();
  53837. exports.LocalPdfManager = LocalPdfManager;
  53838. exports.NetworkPdfManager = NetworkPdfManager;
  53839. /***/ }),
  53840. /* 43 */
  53841. /***/ (function(module, exports, __w_pdfjs_require__) {
  53842. "use strict";
  53843. var sharedUtil = __w_pdfjs_require__(0);
  53844. var corePrimitives = __w_pdfjs_require__(1);
  53845. var error = sharedUtil.error;
  53846. var isSpace = sharedUtil.isSpace;
  53847. var EOF = corePrimitives.EOF;
  53848. var PostScriptParser = function PostScriptParserClosure() {
  53849. function PostScriptParser(lexer) {
  53850. this.lexer = lexer;
  53851. this.operators = [];
  53852. this.token = null;
  53853. this.prev = null;
  53854. }
  53855. PostScriptParser.prototype = {
  53856. nextToken: function PostScriptParser_nextToken() {
  53857. this.prev = this.token;
  53858. this.token = this.lexer.getToken();
  53859. },
  53860. accept: function PostScriptParser_accept(type) {
  53861. if (this.token.type === type) {
  53862. this.nextToken();
  53863. return true;
  53864. }
  53865. return false;
  53866. },
  53867. expect: function PostScriptParser_expect(type) {
  53868. if (this.accept(type)) {
  53869. return true;
  53870. }
  53871. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53872. },
  53873. parse: function PostScriptParser_parse() {
  53874. this.nextToken();
  53875. this.expect(PostScriptTokenTypes.LBRACE);
  53876. this.parseBlock();
  53877. this.expect(PostScriptTokenTypes.RBRACE);
  53878. return this.operators;
  53879. },
  53880. parseBlock: function PostScriptParser_parseBlock() {
  53881. while (true) {
  53882. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53883. this.operators.push(this.prev.value);
  53884. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53885. this.operators.push(this.prev.value);
  53886. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53887. this.parseCondition();
  53888. } else {
  53889. return;
  53890. }
  53891. }
  53892. },
  53893. parseCondition: function PostScriptParser_parseCondition() {
  53894. var conditionLocation = this.operators.length;
  53895. this.operators.push(null, null);
  53896. this.parseBlock();
  53897. this.expect(PostScriptTokenTypes.RBRACE);
  53898. if (this.accept(PostScriptTokenTypes.IF)) {
  53899. this.operators[conditionLocation] = this.operators.length;
  53900. this.operators[conditionLocation + 1] = 'jz';
  53901. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53902. var jumpLocation = this.operators.length;
  53903. this.operators.push(null, null);
  53904. var endOfTrue = this.operators.length;
  53905. this.parseBlock();
  53906. this.expect(PostScriptTokenTypes.RBRACE);
  53907. this.expect(PostScriptTokenTypes.IFELSE);
  53908. this.operators[jumpLocation] = this.operators.length;
  53909. this.operators[jumpLocation + 1] = 'j';
  53910. this.operators[conditionLocation] = endOfTrue;
  53911. this.operators[conditionLocation + 1] = 'jz';
  53912. } else {
  53913. error('PS Function: error parsing conditional.');
  53914. }
  53915. }
  53916. };
  53917. return PostScriptParser;
  53918. }();
  53919. var PostScriptTokenTypes = {
  53920. LBRACE: 0,
  53921. RBRACE: 1,
  53922. NUMBER: 2,
  53923. OPERATOR: 3,
  53924. IF: 4,
  53925. IFELSE: 5
  53926. };
  53927. var PostScriptToken = function PostScriptTokenClosure() {
  53928. function PostScriptToken(type, value) {
  53929. this.type = type;
  53930. this.value = value;
  53931. }
  53932. var opCache = Object.create(null);
  53933. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53934. var opValue = opCache[op];
  53935. if (opValue) {
  53936. return opValue;
  53937. }
  53938. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53939. };
  53940. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53941. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53942. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53943. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53944. return PostScriptToken;
  53945. }();
  53946. var PostScriptLexer = function PostScriptLexerClosure() {
  53947. function PostScriptLexer(stream) {
  53948. this.stream = stream;
  53949. this.nextChar();
  53950. this.strBuf = [];
  53951. }
  53952. PostScriptLexer.prototype = {
  53953. nextChar: function PostScriptLexer_nextChar() {
  53954. return this.currentChar = this.stream.getByte();
  53955. },
  53956. getToken: function PostScriptLexer_getToken() {
  53957. var comment = false;
  53958. var ch = this.currentChar;
  53959. while (true) {
  53960. if (ch < 0) {
  53961. return EOF;
  53962. }
  53963. if (comment) {
  53964. if (ch === 0x0A || ch === 0x0D) {
  53965. comment = false;
  53966. }
  53967. } else if (ch === 0x25) {
  53968. comment = true;
  53969. } else if (!isSpace(ch)) {
  53970. break;
  53971. }
  53972. ch = this.nextChar();
  53973. }
  53974. switch (ch | 0) {
  53975. case 0x30:
  53976. case 0x31:
  53977. case 0x32:
  53978. case 0x33:
  53979. case 0x34:
  53980. case 0x35:
  53981. case 0x36:
  53982. case 0x37:
  53983. case 0x38:
  53984. case 0x39:
  53985. case 0x2B:
  53986. case 0x2D:
  53987. case 0x2E:
  53988. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53989. case 0x7B:
  53990. this.nextChar();
  53991. return PostScriptToken.LBRACE;
  53992. case 0x7D:
  53993. this.nextChar();
  53994. return PostScriptToken.RBRACE;
  53995. }
  53996. var strBuf = this.strBuf;
  53997. strBuf.length = 0;
  53998. strBuf[0] = String.fromCharCode(ch);
  53999. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  54000. strBuf.push(String.fromCharCode(ch));
  54001. }
  54002. var str = strBuf.join('');
  54003. switch (str.toLowerCase()) {
  54004. case 'if':
  54005. return PostScriptToken.IF;
  54006. case 'ifelse':
  54007. return PostScriptToken.IFELSE;
  54008. default:
  54009. return PostScriptToken.getOperator(str);
  54010. }
  54011. },
  54012. getNumber: function PostScriptLexer_getNumber() {
  54013. var ch = this.currentChar;
  54014. var strBuf = this.strBuf;
  54015. strBuf.length = 0;
  54016. strBuf[0] = String.fromCharCode(ch);
  54017. while ((ch = this.nextChar()) >= 0) {
  54018. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54019. strBuf.push(String.fromCharCode(ch));
  54020. } else {
  54021. break;
  54022. }
  54023. }
  54024. var value = parseFloat(strBuf.join(''));
  54025. if (isNaN(value)) {
  54026. error('Invalid floating point number: ' + value);
  54027. }
  54028. return value;
  54029. }
  54030. };
  54031. return PostScriptLexer;
  54032. }();
  54033. exports.PostScriptLexer = PostScriptLexer;
  54034. exports.PostScriptParser = PostScriptParser;
  54035. /***/ }),
  54036. /* 44 */
  54037. /***/ (function(module, exports, __w_pdfjs_require__) {
  54038. "use strict";
  54039. var sharedUtil = __w_pdfjs_require__(0);
  54040. var coreStream = __w_pdfjs_require__(2);
  54041. var coreEncodings = __w_pdfjs_require__(5);
  54042. var warn = sharedUtil.warn;
  54043. var isSpace = sharedUtil.isSpace;
  54044. var Stream = coreStream.Stream;
  54045. var getEncoding = coreEncodings.getEncoding;
  54046. var HINTING_ENABLED = false;
  54047. var Type1CharString = function Type1CharStringClosure() {
  54048. var COMMAND_MAP = {
  54049. 'hstem': [1],
  54050. 'vstem': [3],
  54051. 'vmoveto': [4],
  54052. 'rlineto': [5],
  54053. 'hlineto': [6],
  54054. 'vlineto': [7],
  54055. 'rrcurveto': [8],
  54056. 'callsubr': [10],
  54057. 'flex': [
  54058. 12,
  54059. 35
  54060. ],
  54061. 'drop': [
  54062. 12,
  54063. 18
  54064. ],
  54065. 'endchar': [14],
  54066. 'rmoveto': [21],
  54067. 'hmoveto': [22],
  54068. 'vhcurveto': [30],
  54069. 'hvcurveto': [31]
  54070. };
  54071. function Type1CharString() {
  54072. this.width = 0;
  54073. this.lsb = 0;
  54074. this.flexing = false;
  54075. this.output = [];
  54076. this.stack = [];
  54077. }
  54078. Type1CharString.prototype = {
  54079. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54080. var count = encoded.length;
  54081. var error = false;
  54082. var wx, sbx, subrNumber;
  54083. for (var i = 0; i < count; i++) {
  54084. var value = encoded[i];
  54085. if (value < 32) {
  54086. if (value === 12) {
  54087. value = (value << 8) + encoded[++i];
  54088. }
  54089. switch (value) {
  54090. case 1:
  54091. if (!HINTING_ENABLED) {
  54092. this.stack = [];
  54093. break;
  54094. }
  54095. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54096. break;
  54097. case 3:
  54098. if (!HINTING_ENABLED) {
  54099. this.stack = [];
  54100. break;
  54101. }
  54102. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54103. break;
  54104. case 4:
  54105. if (this.flexing) {
  54106. if (this.stack.length < 1) {
  54107. error = true;
  54108. break;
  54109. }
  54110. var dy = this.stack.pop();
  54111. this.stack.push(0, dy);
  54112. break;
  54113. }
  54114. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54115. break;
  54116. case 5:
  54117. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54118. break;
  54119. case 6:
  54120. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54121. break;
  54122. case 7:
  54123. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54124. break;
  54125. case 8:
  54126. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54127. break;
  54128. case 9:
  54129. this.stack = [];
  54130. break;
  54131. case 10:
  54132. if (this.stack.length < 1) {
  54133. error = true;
  54134. break;
  54135. }
  54136. subrNumber = this.stack.pop();
  54137. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54138. break;
  54139. case 11:
  54140. return error;
  54141. case 13:
  54142. if (this.stack.length < 2) {
  54143. error = true;
  54144. break;
  54145. }
  54146. wx = this.stack.pop();
  54147. sbx = this.stack.pop();
  54148. this.lsb = sbx;
  54149. this.width = wx;
  54150. this.stack.push(wx, sbx);
  54151. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54152. break;
  54153. case 14:
  54154. this.output.push(COMMAND_MAP.endchar[0]);
  54155. break;
  54156. case 21:
  54157. if (this.flexing) {
  54158. break;
  54159. }
  54160. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54161. break;
  54162. case 22:
  54163. if (this.flexing) {
  54164. this.stack.push(0);
  54165. break;
  54166. }
  54167. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54168. break;
  54169. case 30:
  54170. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54171. break;
  54172. case 31:
  54173. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54174. break;
  54175. case (12 << 8) + 0:
  54176. this.stack = [];
  54177. break;
  54178. case (12 << 8) + 1:
  54179. if (!HINTING_ENABLED) {
  54180. this.stack = [];
  54181. break;
  54182. }
  54183. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54184. break;
  54185. case (12 << 8) + 2:
  54186. if (!HINTING_ENABLED) {
  54187. this.stack = [];
  54188. break;
  54189. }
  54190. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54191. break;
  54192. case (12 << 8) + 6:
  54193. if (seacAnalysisEnabled) {
  54194. this.seac = this.stack.splice(-4, 4);
  54195. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54196. } else {
  54197. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54198. }
  54199. break;
  54200. case (12 << 8) + 7:
  54201. if (this.stack.length < 4) {
  54202. error = true;
  54203. break;
  54204. }
  54205. this.stack.pop();
  54206. wx = this.stack.pop();
  54207. var sby = this.stack.pop();
  54208. sbx = this.stack.pop();
  54209. this.lsb = sbx;
  54210. this.width = wx;
  54211. this.stack.push(wx, sbx, sby);
  54212. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54213. break;
  54214. case (12 << 8) + 12:
  54215. if (this.stack.length < 2) {
  54216. error = true;
  54217. break;
  54218. }
  54219. var num2 = this.stack.pop();
  54220. var num1 = this.stack.pop();
  54221. this.stack.push(num1 / num2);
  54222. break;
  54223. case (12 << 8) + 16:
  54224. if (this.stack.length < 2) {
  54225. error = true;
  54226. break;
  54227. }
  54228. subrNumber = this.stack.pop();
  54229. var numArgs = this.stack.pop();
  54230. if (subrNumber === 0 && numArgs === 3) {
  54231. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54232. 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]);
  54233. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54234. this.flexing = false;
  54235. this.stack.push(flexArgs[15], flexArgs[16]);
  54236. } else if (subrNumber === 1 && numArgs === 0) {
  54237. this.flexing = true;
  54238. }
  54239. break;
  54240. case (12 << 8) + 17:
  54241. break;
  54242. case (12 << 8) + 33:
  54243. this.stack = [];
  54244. break;
  54245. default:
  54246. warn('Unknown type 1 charstring command of "' + value + '"');
  54247. break;
  54248. }
  54249. if (error) {
  54250. break;
  54251. }
  54252. continue;
  54253. } else if (value <= 246) {
  54254. value = value - 139;
  54255. } else if (value <= 250) {
  54256. value = (value - 247) * 256 + encoded[++i] + 108;
  54257. } else if (value <= 254) {
  54258. value = -((value - 251) * 256) - encoded[++i] - 108;
  54259. } else {
  54260. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54261. }
  54262. this.stack.push(value);
  54263. }
  54264. return error;
  54265. },
  54266. executeCommand: function (howManyArgs, command, keepStack) {
  54267. var stackLength = this.stack.length;
  54268. if (howManyArgs > stackLength) {
  54269. return true;
  54270. }
  54271. var start = stackLength - howManyArgs;
  54272. for (var i = start; i < stackLength; i++) {
  54273. var value = this.stack[i];
  54274. if (value === (value | 0)) {
  54275. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54276. } else {
  54277. value = 65536 * value | 0;
  54278. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54279. }
  54280. }
  54281. this.output.push.apply(this.output, command);
  54282. if (keepStack) {
  54283. this.stack.splice(start, howManyArgs);
  54284. } else {
  54285. this.stack.length = 0;
  54286. }
  54287. return false;
  54288. }
  54289. };
  54290. return Type1CharString;
  54291. }();
  54292. var Type1Parser = function Type1ParserClosure() {
  54293. var EEXEC_ENCRYPT_KEY = 55665;
  54294. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54295. function isHexDigit(code) {
  54296. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54297. }
  54298. function decrypt(data, key, discardNumber) {
  54299. if (discardNumber >= data.length) {
  54300. return new Uint8Array(0);
  54301. }
  54302. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54303. for (i = 0; i < discardNumber; i++) {
  54304. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54305. }
  54306. var count = data.length - discardNumber;
  54307. var decrypted = new Uint8Array(count);
  54308. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54309. var value = data[i];
  54310. decrypted[j] = value ^ r >> 8;
  54311. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54312. }
  54313. return decrypted;
  54314. }
  54315. function decryptAscii(data, key, discardNumber) {
  54316. var r = key | 0, c1 = 52845, c2 = 22719;
  54317. var count = data.length, maybeLength = count >>> 1;
  54318. var decrypted = new Uint8Array(maybeLength);
  54319. var i, j;
  54320. for (i = 0, j = 0; i < count; i++) {
  54321. var digit1 = data[i];
  54322. if (!isHexDigit(digit1)) {
  54323. continue;
  54324. }
  54325. i++;
  54326. var digit2;
  54327. while (i < count && !isHexDigit(digit2 = data[i])) {
  54328. i++;
  54329. }
  54330. if (i < count) {
  54331. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54332. decrypted[j++] = value ^ r >> 8;
  54333. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54334. }
  54335. }
  54336. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54337. }
  54338. function isSpecial(c) {
  54339. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54340. }
  54341. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54342. if (encrypted) {
  54343. var data = stream.getBytes();
  54344. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54345. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54346. }
  54347. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54348. this.stream = stream;
  54349. this.nextChar();
  54350. }
  54351. Type1Parser.prototype = {
  54352. readNumberArray: function Type1Parser_readNumberArray() {
  54353. this.getToken();
  54354. var array = [];
  54355. while (true) {
  54356. var token = this.getToken();
  54357. if (token === null || token === ']' || token === '}') {
  54358. break;
  54359. }
  54360. array.push(parseFloat(token || 0));
  54361. }
  54362. return array;
  54363. },
  54364. readNumber: function Type1Parser_readNumber() {
  54365. var token = this.getToken();
  54366. return parseFloat(token || 0);
  54367. },
  54368. readInt: function Type1Parser_readInt() {
  54369. var token = this.getToken();
  54370. return parseInt(token || 0, 10) | 0;
  54371. },
  54372. readBoolean: function Type1Parser_readBoolean() {
  54373. var token = this.getToken();
  54374. return token === 'true' ? 1 : 0;
  54375. },
  54376. nextChar: function Type1_nextChar() {
  54377. return this.currentChar = this.stream.getByte();
  54378. },
  54379. getToken: function Type1Parser_getToken() {
  54380. var comment = false;
  54381. var ch = this.currentChar;
  54382. while (true) {
  54383. if (ch === -1) {
  54384. return null;
  54385. }
  54386. if (comment) {
  54387. if (ch === 0x0A || ch === 0x0D) {
  54388. comment = false;
  54389. }
  54390. } else if (ch === 0x25) {
  54391. comment = true;
  54392. } else if (!isSpace(ch)) {
  54393. break;
  54394. }
  54395. ch = this.nextChar();
  54396. }
  54397. if (isSpecial(ch)) {
  54398. this.nextChar();
  54399. return String.fromCharCode(ch);
  54400. }
  54401. var token = '';
  54402. do {
  54403. token += String.fromCharCode(ch);
  54404. ch = this.nextChar();
  54405. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54406. return token;
  54407. },
  54408. extractFontProgram: function Type1Parser_extractFontProgram() {
  54409. var stream = this.stream;
  54410. var subrs = [], charstrings = [];
  54411. var privateData = Object.create(null);
  54412. privateData['lenIV'] = 4;
  54413. var program = {
  54414. subrs: [],
  54415. charstrings: [],
  54416. properties: { 'privateData': privateData }
  54417. };
  54418. var token, length, data, lenIV, encoded;
  54419. while ((token = this.getToken()) !== null) {
  54420. if (token !== '/') {
  54421. continue;
  54422. }
  54423. token = this.getToken();
  54424. switch (token) {
  54425. case 'CharStrings':
  54426. this.getToken();
  54427. this.getToken();
  54428. this.getToken();
  54429. this.getToken();
  54430. while (true) {
  54431. token = this.getToken();
  54432. if (token === null || token === 'end') {
  54433. break;
  54434. }
  54435. if (token !== '/') {
  54436. continue;
  54437. }
  54438. var glyph = this.getToken();
  54439. length = this.readInt();
  54440. this.getToken();
  54441. data = stream.makeSubStream(stream.pos, length);
  54442. lenIV = program.properties.privateData['lenIV'];
  54443. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54444. stream.skip(length);
  54445. this.nextChar();
  54446. token = this.getToken();
  54447. if (token === 'noaccess') {
  54448. this.getToken();
  54449. }
  54450. charstrings.push({
  54451. glyph: glyph,
  54452. encoded: encoded
  54453. });
  54454. }
  54455. break;
  54456. case 'Subrs':
  54457. this.readInt();
  54458. this.getToken();
  54459. while ((token = this.getToken()) === 'dup') {
  54460. var index = this.readInt();
  54461. length = this.readInt();
  54462. this.getToken();
  54463. data = stream.makeSubStream(stream.pos, length);
  54464. lenIV = program.properties.privateData['lenIV'];
  54465. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54466. stream.skip(length);
  54467. this.nextChar();
  54468. token = this.getToken();
  54469. if (token === 'noaccess') {
  54470. this.getToken();
  54471. }
  54472. subrs[index] = encoded;
  54473. }
  54474. break;
  54475. case 'BlueValues':
  54476. case 'OtherBlues':
  54477. case 'FamilyBlues':
  54478. case 'FamilyOtherBlues':
  54479. var blueArray = this.readNumberArray();
  54480. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54481. program.properties.privateData[token] = blueArray;
  54482. }
  54483. break;
  54484. case 'StemSnapH':
  54485. case 'StemSnapV':
  54486. program.properties.privateData[token] = this.readNumberArray();
  54487. break;
  54488. case 'StdHW':
  54489. case 'StdVW':
  54490. program.properties.privateData[token] = this.readNumberArray()[0];
  54491. break;
  54492. case 'BlueShift':
  54493. case 'lenIV':
  54494. case 'BlueFuzz':
  54495. case 'BlueScale':
  54496. case 'LanguageGroup':
  54497. case 'ExpansionFactor':
  54498. program.properties.privateData[token] = this.readNumber();
  54499. break;
  54500. case 'ForceBold':
  54501. program.properties.privateData[token] = this.readBoolean();
  54502. break;
  54503. }
  54504. }
  54505. for (var i = 0; i < charstrings.length; i++) {
  54506. glyph = charstrings[i].glyph;
  54507. encoded = charstrings[i].encoded;
  54508. var charString = new Type1CharString();
  54509. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54510. var output = charString.output;
  54511. if (error) {
  54512. output = [14];
  54513. }
  54514. program.charstrings.push({
  54515. glyphName: glyph,
  54516. charstring: output,
  54517. width: charString.width,
  54518. lsb: charString.lsb,
  54519. seac: charString.seac
  54520. });
  54521. }
  54522. return program;
  54523. },
  54524. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54525. var token;
  54526. while ((token = this.getToken()) !== null) {
  54527. if (token !== '/') {
  54528. continue;
  54529. }
  54530. token = this.getToken();
  54531. switch (token) {
  54532. case 'FontMatrix':
  54533. var matrix = this.readNumberArray();
  54534. properties.fontMatrix = matrix;
  54535. break;
  54536. case 'Encoding':
  54537. var encodingArg = this.getToken();
  54538. var encoding;
  54539. if (!/^\d+$/.test(encodingArg)) {
  54540. encoding = getEncoding(encodingArg);
  54541. } else {
  54542. encoding = [];
  54543. var size = parseInt(encodingArg, 10) | 0;
  54544. this.getToken();
  54545. for (var j = 0; j < size; j++) {
  54546. token = this.getToken();
  54547. while (token !== 'dup' && token !== 'def') {
  54548. token = this.getToken();
  54549. if (token === null) {
  54550. return;
  54551. }
  54552. }
  54553. if (token === 'def') {
  54554. break;
  54555. }
  54556. var index = this.readInt();
  54557. this.getToken();
  54558. var glyph = this.getToken();
  54559. encoding[index] = glyph;
  54560. this.getToken();
  54561. }
  54562. }
  54563. properties.builtInEncoding = encoding;
  54564. break;
  54565. case 'FontBBox':
  54566. var fontBBox = this.readNumberArray();
  54567. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  54568. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  54569. properties.ascentScaled = true;
  54570. break;
  54571. }
  54572. }
  54573. }
  54574. };
  54575. return Type1Parser;
  54576. }();
  54577. exports.Type1Parser = Type1Parser;
  54578. /***/ }),
  54579. /* 45 */
  54580. /***/ (function(module, exports, __w_pdfjs_require__) {
  54581. "use strict";
  54582. var sharedUtil = __w_pdfjs_require__(0);
  54583. var displayDOMUtils = __w_pdfjs_require__(3);
  54584. var displayPatternHelper = __w_pdfjs_require__(47);
  54585. var displayWebGL = __w_pdfjs_require__(24);
  54586. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54587. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54588. var ImageKind = sharedUtil.ImageKind;
  54589. var OPS = sharedUtil.OPS;
  54590. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54591. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54592. var Util = sharedUtil.Util;
  54593. var assert = sharedUtil.assert;
  54594. var info = sharedUtil.info;
  54595. var isNum = sharedUtil.isNum;
  54596. var isArray = sharedUtil.isArray;
  54597. var isLittleEndian = sharedUtil.isLittleEndian;
  54598. var error = sharedUtil.error;
  54599. var shadow = sharedUtil.shadow;
  54600. var warn = sharedUtil.warn;
  54601. var TilingPattern = displayPatternHelper.TilingPattern;
  54602. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54603. var WebGLUtils = displayWebGL.WebGLUtils;
  54604. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54605. var MIN_FONT_SIZE = 16;
  54606. var MAX_FONT_SIZE = 100;
  54607. var MAX_GROUP_SIZE = 4096;
  54608. var MIN_WIDTH_FACTOR = 0.65;
  54609. var COMPILE_TYPE3_GLYPHS = true;
  54610. var MAX_SIZE_TO_COMPILE = 1000;
  54611. var FULL_CHUNK_HEIGHT = 16;
  54612. var HasCanvasTypedArraysCached = {
  54613. get value() {
  54614. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54615. }
  54616. };
  54617. var IsLittleEndianCached = {
  54618. get value() {
  54619. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54620. }
  54621. };
  54622. function addContextCurrentTransform(ctx) {
  54623. if (!ctx.mozCurrentTransform) {
  54624. ctx._originalSave = ctx.save;
  54625. ctx._originalRestore = ctx.restore;
  54626. ctx._originalRotate = ctx.rotate;
  54627. ctx._originalScale = ctx.scale;
  54628. ctx._originalTranslate = ctx.translate;
  54629. ctx._originalTransform = ctx.transform;
  54630. ctx._originalSetTransform = ctx.setTransform;
  54631. ctx._transformMatrix = ctx._transformMatrix || [
  54632. 1,
  54633. 0,
  54634. 0,
  54635. 1,
  54636. 0,
  54637. 0
  54638. ];
  54639. ctx._transformStack = [];
  54640. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54641. get: function getCurrentTransform() {
  54642. return this._transformMatrix;
  54643. }
  54644. });
  54645. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54646. get: function getCurrentTransformInverse() {
  54647. var m = this._transformMatrix;
  54648. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54649. var ad_bc = a * d - b * c;
  54650. var bc_ad = b * c - a * d;
  54651. return [
  54652. d / ad_bc,
  54653. b / bc_ad,
  54654. c / bc_ad,
  54655. a / ad_bc,
  54656. (d * e - c * f) / bc_ad,
  54657. (b * e - a * f) / ad_bc
  54658. ];
  54659. }
  54660. });
  54661. ctx.save = function ctxSave() {
  54662. var old = this._transformMatrix;
  54663. this._transformStack.push(old);
  54664. this._transformMatrix = old.slice(0, 6);
  54665. this._originalSave();
  54666. };
  54667. ctx.restore = function ctxRestore() {
  54668. var prev = this._transformStack.pop();
  54669. if (prev) {
  54670. this._transformMatrix = prev;
  54671. this._originalRestore();
  54672. }
  54673. };
  54674. ctx.translate = function ctxTranslate(x, y) {
  54675. var m = this._transformMatrix;
  54676. m[4] = m[0] * x + m[2] * y + m[4];
  54677. m[5] = m[1] * x + m[3] * y + m[5];
  54678. this._originalTranslate(x, y);
  54679. };
  54680. ctx.scale = function ctxScale(x, y) {
  54681. var m = this._transformMatrix;
  54682. m[0] = m[0] * x;
  54683. m[1] = m[1] * x;
  54684. m[2] = m[2] * y;
  54685. m[3] = m[3] * y;
  54686. this._originalScale(x, y);
  54687. };
  54688. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54689. var m = this._transformMatrix;
  54690. this._transformMatrix = [
  54691. m[0] * a + m[2] * b,
  54692. m[1] * a + m[3] * b,
  54693. m[0] * c + m[2] * d,
  54694. m[1] * c + m[3] * d,
  54695. m[0] * e + m[2] * f + m[4],
  54696. m[1] * e + m[3] * f + m[5]
  54697. ];
  54698. ctx._originalTransform(a, b, c, d, e, f);
  54699. };
  54700. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54701. this._transformMatrix = [
  54702. a,
  54703. b,
  54704. c,
  54705. d,
  54706. e,
  54707. f
  54708. ];
  54709. ctx._originalSetTransform(a, b, c, d, e, f);
  54710. };
  54711. ctx.rotate = function ctxRotate(angle) {
  54712. var cosValue = Math.cos(angle);
  54713. var sinValue = Math.sin(angle);
  54714. var m = this._transformMatrix;
  54715. this._transformMatrix = [
  54716. m[0] * cosValue + m[2] * sinValue,
  54717. m[1] * cosValue + m[3] * sinValue,
  54718. m[0] * -sinValue + m[2] * cosValue,
  54719. m[1] * -sinValue + m[3] * cosValue,
  54720. m[4],
  54721. m[5]
  54722. ];
  54723. this._originalRotate(angle);
  54724. };
  54725. }
  54726. }
  54727. var CachedCanvases = function CachedCanvasesClosure() {
  54728. function CachedCanvases(canvasFactory) {
  54729. this.canvasFactory = canvasFactory;
  54730. this.cache = Object.create(null);
  54731. }
  54732. CachedCanvases.prototype = {
  54733. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54734. var canvasEntry;
  54735. if (this.cache[id] !== undefined) {
  54736. canvasEntry = this.cache[id];
  54737. this.canvasFactory.reset(canvasEntry, width, height);
  54738. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54739. } else {
  54740. canvasEntry = this.canvasFactory.create(width, height);
  54741. this.cache[id] = canvasEntry;
  54742. }
  54743. if (trackTransform) {
  54744. addContextCurrentTransform(canvasEntry.context);
  54745. }
  54746. return canvasEntry;
  54747. },
  54748. clear: function () {
  54749. for (var id in this.cache) {
  54750. var canvasEntry = this.cache[id];
  54751. this.canvasFactory.destroy(canvasEntry);
  54752. delete this.cache[id];
  54753. }
  54754. }
  54755. };
  54756. return CachedCanvases;
  54757. }();
  54758. function compileType3Glyph(imgData) {
  54759. var POINT_TO_PROCESS_LIMIT = 1000;
  54760. var width = imgData.width, height = imgData.height;
  54761. var i, j, j0, width1 = width + 1;
  54762. var points = new Uint8Array(width1 * (height + 1));
  54763. var POINT_TYPES = new Uint8Array([
  54764. 0,
  54765. 2,
  54766. 4,
  54767. 0,
  54768. 1,
  54769. 0,
  54770. 5,
  54771. 4,
  54772. 8,
  54773. 10,
  54774. 0,
  54775. 8,
  54776. 0,
  54777. 2,
  54778. 1,
  54779. 0
  54780. ]);
  54781. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54782. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54783. for (i = 0, ii = data0.length; i < ii; i++) {
  54784. var mask = 128, elem = data0[i];
  54785. while (mask > 0) {
  54786. data[pos++] = elem & mask ? 0 : 255;
  54787. mask >>= 1;
  54788. }
  54789. }
  54790. var count = 0;
  54791. pos = 0;
  54792. if (data[pos] !== 0) {
  54793. points[0] = 1;
  54794. ++count;
  54795. }
  54796. for (j = 1; j < width; j++) {
  54797. if (data[pos] !== data[pos + 1]) {
  54798. points[j] = data[pos] ? 2 : 1;
  54799. ++count;
  54800. }
  54801. pos++;
  54802. }
  54803. if (data[pos] !== 0) {
  54804. points[j] = 2;
  54805. ++count;
  54806. }
  54807. for (i = 1; i < height; i++) {
  54808. pos = i * lineSize;
  54809. j0 = i * width1;
  54810. if (data[pos - lineSize] !== data[pos]) {
  54811. points[j0] = data[pos] ? 1 : 8;
  54812. ++count;
  54813. }
  54814. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54815. for (j = 1; j < width; j++) {
  54816. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54817. if (POINT_TYPES[sum]) {
  54818. points[j0 + j] = POINT_TYPES[sum];
  54819. ++count;
  54820. }
  54821. pos++;
  54822. }
  54823. if (data[pos - lineSize] !== data[pos]) {
  54824. points[j0 + j] = data[pos] ? 2 : 4;
  54825. ++count;
  54826. }
  54827. if (count > POINT_TO_PROCESS_LIMIT) {
  54828. return null;
  54829. }
  54830. }
  54831. pos = lineSize * (height - 1);
  54832. j0 = i * width1;
  54833. if (data[pos] !== 0) {
  54834. points[j0] = 8;
  54835. ++count;
  54836. }
  54837. for (j = 1; j < width; j++) {
  54838. if (data[pos] !== data[pos + 1]) {
  54839. points[j0 + j] = data[pos] ? 4 : 8;
  54840. ++count;
  54841. }
  54842. pos++;
  54843. }
  54844. if (data[pos] !== 0) {
  54845. points[j0 + j] = 4;
  54846. ++count;
  54847. }
  54848. if (count > POINT_TO_PROCESS_LIMIT) {
  54849. return null;
  54850. }
  54851. var steps = new Int32Array([
  54852. 0,
  54853. width1,
  54854. -1,
  54855. 0,
  54856. -width1,
  54857. 0,
  54858. 0,
  54859. 0,
  54860. 1
  54861. ]);
  54862. var outlines = [];
  54863. for (i = 0; count && i <= height; i++) {
  54864. var p = i * width1;
  54865. var end = p + width;
  54866. while (p < end && !points[p]) {
  54867. p++;
  54868. }
  54869. if (p === end) {
  54870. continue;
  54871. }
  54872. var coords = [
  54873. p % width1,
  54874. i
  54875. ];
  54876. var type = points[p], p0 = p, pp;
  54877. do {
  54878. var step = steps[type];
  54879. do {
  54880. p += step;
  54881. } while (!points[p]);
  54882. pp = points[p];
  54883. if (pp !== 5 && pp !== 10) {
  54884. type = pp;
  54885. points[p] = 0;
  54886. } else {
  54887. type = pp & 0x33 * type >> 4;
  54888. points[p] &= type >> 2 | type << 2;
  54889. }
  54890. coords.push(p % width1);
  54891. coords.push(p / width1 | 0);
  54892. --count;
  54893. } while (p0 !== p);
  54894. outlines.push(coords);
  54895. --i;
  54896. }
  54897. var drawOutline = function (c) {
  54898. c.save();
  54899. c.scale(1 / width, -1 / height);
  54900. c.translate(0, -height);
  54901. c.beginPath();
  54902. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54903. var o = outlines[i];
  54904. c.moveTo(o[0], o[1]);
  54905. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54906. c.lineTo(o[j], o[j + 1]);
  54907. }
  54908. }
  54909. c.fill();
  54910. c.beginPath();
  54911. c.restore();
  54912. };
  54913. return drawOutline;
  54914. }
  54915. var CanvasExtraState = function CanvasExtraStateClosure() {
  54916. function CanvasExtraState(old) {
  54917. this.alphaIsShape = false;
  54918. this.fontSize = 0;
  54919. this.fontSizeScale = 1;
  54920. this.textMatrix = IDENTITY_MATRIX;
  54921. this.textMatrixScale = 1;
  54922. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54923. this.leading = 0;
  54924. this.x = 0;
  54925. this.y = 0;
  54926. this.lineX = 0;
  54927. this.lineY = 0;
  54928. this.charSpacing = 0;
  54929. this.wordSpacing = 0;
  54930. this.textHScale = 1;
  54931. this.textRenderingMode = TextRenderingMode.FILL;
  54932. this.textRise = 0;
  54933. this.fillColor = '#000000';
  54934. this.strokeColor = '#000000';
  54935. this.patternFill = false;
  54936. this.fillAlpha = 1;
  54937. this.strokeAlpha = 1;
  54938. this.lineWidth = 1;
  54939. this.activeSMask = null;
  54940. this.resumeSMaskCtx = null;
  54941. this.old = old;
  54942. }
  54943. CanvasExtraState.prototype = {
  54944. clone: function CanvasExtraState_clone() {
  54945. return Object.create(this);
  54946. },
  54947. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54948. this.x = x;
  54949. this.y = y;
  54950. }
  54951. };
  54952. return CanvasExtraState;
  54953. }();
  54954. var CanvasGraphics = function CanvasGraphicsClosure() {
  54955. var EXECUTION_TIME = 15;
  54956. var EXECUTION_STEPS = 10;
  54957. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54958. this.ctx = canvasCtx;
  54959. this.current = new CanvasExtraState();
  54960. this.stateStack = [];
  54961. this.pendingClip = null;
  54962. this.pendingEOFill = false;
  54963. this.res = null;
  54964. this.xobjs = null;
  54965. this.commonObjs = commonObjs;
  54966. this.objs = objs;
  54967. this.canvasFactory = canvasFactory;
  54968. this.imageLayer = imageLayer;
  54969. this.groupStack = [];
  54970. this.processingType3 = null;
  54971. this.baseTransform = null;
  54972. this.baseTransformStack = [];
  54973. this.groupLevel = 0;
  54974. this.smaskStack = [];
  54975. this.smaskCounter = 0;
  54976. this.tempSMask = null;
  54977. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54978. if (canvasCtx) {
  54979. addContextCurrentTransform(canvasCtx);
  54980. }
  54981. this.cachedGetSinglePixelWidth = null;
  54982. }
  54983. function putBinaryImageData(ctx, imgData) {
  54984. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54985. ctx.putImageData(imgData, 0, 0);
  54986. return;
  54987. }
  54988. var height = imgData.height, width = imgData.width;
  54989. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54990. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54991. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54992. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54993. var srcPos = 0, destPos;
  54994. var src = imgData.data;
  54995. var dest = chunkImgData.data;
  54996. var i, j, thisChunkHeight, elemsInThisChunk;
  54997. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54998. var srcLength = src.byteLength;
  54999. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  55000. var dest32DataLength = dest32.length;
  55001. var fullSrcDiff = width + 7 >> 3;
  55002. var white = 0xFFFFFFFF;
  55003. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55004. for (i = 0; i < totalChunks; i++) {
  55005. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55006. destPos = 0;
  55007. for (j = 0; j < thisChunkHeight; j++) {
  55008. var srcDiff = srcLength - srcPos;
  55009. var k = 0;
  55010. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55011. var kEndUnrolled = kEnd & ~7;
  55012. var mask = 0;
  55013. var srcByte = 0;
  55014. for (; k < kEndUnrolled; k += 8) {
  55015. srcByte = src[srcPos++];
  55016. dest32[destPos++] = srcByte & 128 ? white : black;
  55017. dest32[destPos++] = srcByte & 64 ? white : black;
  55018. dest32[destPos++] = srcByte & 32 ? white : black;
  55019. dest32[destPos++] = srcByte & 16 ? white : black;
  55020. dest32[destPos++] = srcByte & 8 ? white : black;
  55021. dest32[destPos++] = srcByte & 4 ? white : black;
  55022. dest32[destPos++] = srcByte & 2 ? white : black;
  55023. dest32[destPos++] = srcByte & 1 ? white : black;
  55024. }
  55025. for (; k < kEnd; k++) {
  55026. if (mask === 0) {
  55027. srcByte = src[srcPos++];
  55028. mask = 128;
  55029. }
  55030. dest32[destPos++] = srcByte & mask ? white : black;
  55031. mask >>= 1;
  55032. }
  55033. }
  55034. while (destPos < dest32DataLength) {
  55035. dest32[destPos++] = 0;
  55036. }
  55037. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55038. }
  55039. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55040. j = 0;
  55041. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55042. for (i = 0; i < fullChunks; i++) {
  55043. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55044. srcPos += elemsInThisChunk;
  55045. ctx.putImageData(chunkImgData, 0, j);
  55046. j += FULL_CHUNK_HEIGHT;
  55047. }
  55048. if (i < totalChunks) {
  55049. elemsInThisChunk = width * partialChunkHeight * 4;
  55050. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55051. ctx.putImageData(chunkImgData, 0, j);
  55052. }
  55053. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55054. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55055. elemsInThisChunk = width * thisChunkHeight;
  55056. for (i = 0; i < totalChunks; i++) {
  55057. if (i >= fullChunks) {
  55058. thisChunkHeight = partialChunkHeight;
  55059. elemsInThisChunk = width * thisChunkHeight;
  55060. }
  55061. destPos = 0;
  55062. for (j = elemsInThisChunk; j--;) {
  55063. dest[destPos++] = src[srcPos++];
  55064. dest[destPos++] = src[srcPos++];
  55065. dest[destPos++] = src[srcPos++];
  55066. dest[destPos++] = 255;
  55067. }
  55068. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55069. }
  55070. } else {
  55071. error('bad image kind: ' + imgData.kind);
  55072. }
  55073. }
  55074. function putBinaryImageMask(ctx, imgData) {
  55075. var height = imgData.height, width = imgData.width;
  55076. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55077. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55078. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55079. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55080. var srcPos = 0;
  55081. var src = imgData.data;
  55082. var dest = chunkImgData.data;
  55083. for (var i = 0; i < totalChunks; i++) {
  55084. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55085. var destPos = 3;
  55086. for (var j = 0; j < thisChunkHeight; j++) {
  55087. var mask = 0;
  55088. for (var k = 0; k < width; k++) {
  55089. if (!mask) {
  55090. var elem = src[srcPos++];
  55091. mask = 128;
  55092. }
  55093. dest[destPos] = elem & mask ? 0 : 255;
  55094. destPos += 4;
  55095. mask >>= 1;
  55096. }
  55097. }
  55098. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55099. }
  55100. }
  55101. function copyCtxState(sourceCtx, destCtx) {
  55102. var properties = [
  55103. 'strokeStyle',
  55104. 'fillStyle',
  55105. 'fillRule',
  55106. 'globalAlpha',
  55107. 'lineWidth',
  55108. 'lineCap',
  55109. 'lineJoin',
  55110. 'miterLimit',
  55111. 'globalCompositeOperation',
  55112. 'font'
  55113. ];
  55114. for (var i = 0, ii = properties.length; i < ii; i++) {
  55115. var property = properties[i];
  55116. if (sourceCtx[property] !== undefined) {
  55117. destCtx[property] = sourceCtx[property];
  55118. }
  55119. }
  55120. if (sourceCtx.setLineDash !== undefined) {
  55121. destCtx.setLineDash(sourceCtx.getLineDash());
  55122. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55123. }
  55124. }
  55125. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55126. var length = bytes.length;
  55127. for (var i = 3; i < length; i += 4) {
  55128. var alpha = bytes[i];
  55129. if (alpha === 0) {
  55130. bytes[i - 3] = r0;
  55131. bytes[i - 2] = g0;
  55132. bytes[i - 1] = b0;
  55133. } else if (alpha < 255) {
  55134. var alpha_ = 255 - alpha;
  55135. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55136. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55137. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55138. }
  55139. }
  55140. }
  55141. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55142. var length = maskData.length;
  55143. var scale = 1 / 255;
  55144. for (var i = 3; i < length; i += 4) {
  55145. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55146. layerData[i] = layerData[i] * alpha * scale | 0;
  55147. }
  55148. }
  55149. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55150. var length = maskData.length;
  55151. for (var i = 3; i < length; i += 4) {
  55152. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55153. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55154. }
  55155. }
  55156. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55157. var hasBackdrop = !!backdrop;
  55158. var r0 = hasBackdrop ? backdrop[0] : 0;
  55159. var g0 = hasBackdrop ? backdrop[1] : 0;
  55160. var b0 = hasBackdrop ? backdrop[2] : 0;
  55161. var composeFn;
  55162. if (subtype === 'Luminosity') {
  55163. composeFn = composeSMaskLuminosity;
  55164. } else {
  55165. composeFn = composeSMaskAlpha;
  55166. }
  55167. var PIXELS_TO_PROCESS = 1048576;
  55168. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55169. for (var row = 0; row < height; row += chunkSize) {
  55170. var chunkHeight = Math.min(chunkSize, height - row);
  55171. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55172. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55173. if (hasBackdrop) {
  55174. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55175. }
  55176. composeFn(maskData.data, layerData.data, transferMap);
  55177. maskCtx.putImageData(layerData, 0, row);
  55178. }
  55179. }
  55180. function composeSMask(ctx, smask, layerCtx) {
  55181. var mask = smask.canvas;
  55182. var maskCtx = smask.context;
  55183. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55184. var backdrop = smask.backdrop || null;
  55185. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55186. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55187. subtype: smask.subtype,
  55188. backdrop: backdrop
  55189. });
  55190. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55191. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55192. return;
  55193. }
  55194. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55195. ctx.drawImage(mask, 0, 0);
  55196. }
  55197. var LINE_CAP_STYLES = [
  55198. 'butt',
  55199. 'round',
  55200. 'square'
  55201. ];
  55202. var LINE_JOIN_STYLES = [
  55203. 'miter',
  55204. 'round',
  55205. 'bevel'
  55206. ];
  55207. var NORMAL_CLIP = {};
  55208. var EO_CLIP = {};
  55209. CanvasGraphics.prototype = {
  55210. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55211. var width = this.ctx.canvas.width;
  55212. var height = this.ctx.canvas.height;
  55213. this.ctx.save();
  55214. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55215. this.ctx.fillRect(0, 0, width, height);
  55216. this.ctx.restore();
  55217. if (transparency) {
  55218. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55219. this.compositeCtx = this.ctx;
  55220. this.transparentCanvas = transparentCanvas.canvas;
  55221. this.ctx = transparentCanvas.context;
  55222. this.ctx.save();
  55223. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55224. }
  55225. this.ctx.save();
  55226. if (transform) {
  55227. this.ctx.transform.apply(this.ctx, transform);
  55228. }
  55229. this.ctx.transform.apply(this.ctx, viewport.transform);
  55230. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55231. if (this.imageLayer) {
  55232. this.imageLayer.beginLayout();
  55233. }
  55234. },
  55235. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55236. var argsArray = operatorList.argsArray;
  55237. var fnArray = operatorList.fnArray;
  55238. var i = executionStartIdx || 0;
  55239. var argsArrayLen = argsArray.length;
  55240. if (argsArrayLen === i) {
  55241. return i;
  55242. }
  55243. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55244. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55245. var steps = 0;
  55246. var commonObjs = this.commonObjs;
  55247. var objs = this.objs;
  55248. var fnId;
  55249. while (true) {
  55250. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55251. stepper.breakIt(i, continueCallback);
  55252. return i;
  55253. }
  55254. fnId = fnArray[i];
  55255. if (fnId !== OPS.dependency) {
  55256. this[fnId].apply(this, argsArray[i]);
  55257. } else {
  55258. var deps = argsArray[i];
  55259. for (var n = 0, nn = deps.length; n < nn; n++) {
  55260. var depObjId = deps[n];
  55261. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55262. var objsPool = common ? commonObjs : objs;
  55263. if (!objsPool.isResolved(depObjId)) {
  55264. objsPool.get(depObjId, continueCallback);
  55265. return i;
  55266. }
  55267. }
  55268. }
  55269. i++;
  55270. if (i === argsArrayLen) {
  55271. return i;
  55272. }
  55273. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55274. if (Date.now() > endTime) {
  55275. continueCallback();
  55276. return i;
  55277. }
  55278. steps = 0;
  55279. }
  55280. }
  55281. },
  55282. endDrawing: function CanvasGraphics_endDrawing() {
  55283. if (this.current.activeSMask !== null) {
  55284. this.endSMaskGroup();
  55285. }
  55286. this.ctx.restore();
  55287. if (this.transparentCanvas) {
  55288. this.ctx = this.compositeCtx;
  55289. this.ctx.save();
  55290. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55291. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55292. this.ctx.restore();
  55293. this.transparentCanvas = null;
  55294. }
  55295. this.cachedCanvases.clear();
  55296. WebGLUtils.clear();
  55297. if (this.imageLayer) {
  55298. this.imageLayer.endLayout();
  55299. }
  55300. },
  55301. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55302. this.current.lineWidth = width;
  55303. this.ctx.lineWidth = width;
  55304. },
  55305. setLineCap: function CanvasGraphics_setLineCap(style) {
  55306. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55307. },
  55308. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55309. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55310. },
  55311. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55312. this.ctx.miterLimit = limit;
  55313. },
  55314. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55315. var ctx = this.ctx;
  55316. if (ctx.setLineDash !== undefined) {
  55317. ctx.setLineDash(dashArray);
  55318. ctx.lineDashOffset = dashPhase;
  55319. }
  55320. },
  55321. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55322. },
  55323. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55324. },
  55325. setGState: function CanvasGraphics_setGState(states) {
  55326. for (var i = 0, ii = states.length; i < ii; i++) {
  55327. var state = states[i];
  55328. var key = state[0];
  55329. var value = state[1];
  55330. switch (key) {
  55331. case 'LW':
  55332. this.setLineWidth(value);
  55333. break;
  55334. case 'LC':
  55335. this.setLineCap(value);
  55336. break;
  55337. case 'LJ':
  55338. this.setLineJoin(value);
  55339. break;
  55340. case 'ML':
  55341. this.setMiterLimit(value);
  55342. break;
  55343. case 'D':
  55344. this.setDash(value[0], value[1]);
  55345. break;
  55346. case 'RI':
  55347. this.setRenderingIntent(value);
  55348. break;
  55349. case 'FL':
  55350. this.setFlatness(value);
  55351. break;
  55352. case 'Font':
  55353. this.setFont(value[0], value[1]);
  55354. break;
  55355. case 'CA':
  55356. this.current.strokeAlpha = state[1];
  55357. break;
  55358. case 'ca':
  55359. this.current.fillAlpha = state[1];
  55360. this.ctx.globalAlpha = state[1];
  55361. break;
  55362. case 'BM':
  55363. if (value && value.name && value.name !== 'Normal') {
  55364. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55365. return '-' + c.toLowerCase();
  55366. }).substring(1);
  55367. this.ctx.globalCompositeOperation = mode;
  55368. if (this.ctx.globalCompositeOperation !== mode) {
  55369. warn('globalCompositeOperation "' + mode + '" is not supported');
  55370. }
  55371. } else {
  55372. this.ctx.globalCompositeOperation = 'source-over';
  55373. }
  55374. break;
  55375. case 'SMask':
  55376. if (this.current.activeSMask) {
  55377. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55378. this.suspendSMaskGroup();
  55379. } else {
  55380. this.endSMaskGroup();
  55381. }
  55382. }
  55383. this.current.activeSMask = value ? this.tempSMask : null;
  55384. if (this.current.activeSMask) {
  55385. this.beginSMaskGroup();
  55386. }
  55387. this.tempSMask = null;
  55388. break;
  55389. }
  55390. }
  55391. },
  55392. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55393. var activeSMask = this.current.activeSMask;
  55394. var drawnWidth = activeSMask.canvas.width;
  55395. var drawnHeight = activeSMask.canvas.height;
  55396. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55397. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55398. var currentCtx = this.ctx;
  55399. var currentTransform = currentCtx.mozCurrentTransform;
  55400. this.ctx.save();
  55401. var groupCtx = scratchCanvas.context;
  55402. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55403. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55404. groupCtx.transform.apply(groupCtx, currentTransform);
  55405. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55406. copyCtxState(currentCtx, groupCtx);
  55407. this.ctx = groupCtx;
  55408. this.setGState([
  55409. [
  55410. 'BM',
  55411. 'Normal'
  55412. ],
  55413. [
  55414. 'ca',
  55415. 1
  55416. ],
  55417. [
  55418. 'CA',
  55419. 1
  55420. ]
  55421. ]);
  55422. this.groupStack.push(currentCtx);
  55423. this.groupLevel++;
  55424. },
  55425. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55426. var groupCtx = this.ctx;
  55427. this.groupLevel--;
  55428. this.ctx = this.groupStack.pop();
  55429. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55430. this.ctx.restore();
  55431. this.ctx.save();
  55432. copyCtxState(groupCtx, this.ctx);
  55433. this.current.resumeSMaskCtx = groupCtx;
  55434. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55435. this.ctx.transform.apply(this.ctx, deltaTransform);
  55436. groupCtx.save();
  55437. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55438. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55439. groupCtx.restore();
  55440. },
  55441. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55442. var groupCtx = this.current.resumeSMaskCtx;
  55443. var currentCtx = this.ctx;
  55444. this.ctx = groupCtx;
  55445. this.groupStack.push(currentCtx);
  55446. this.groupLevel++;
  55447. },
  55448. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55449. var groupCtx = this.ctx;
  55450. this.groupLevel--;
  55451. this.ctx = this.groupStack.pop();
  55452. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55453. this.ctx.restore();
  55454. copyCtxState(groupCtx, this.ctx);
  55455. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55456. this.ctx.transform.apply(this.ctx, deltaTransform);
  55457. },
  55458. save: function CanvasGraphics_save() {
  55459. this.ctx.save();
  55460. var old = this.current;
  55461. this.stateStack.push(old);
  55462. this.current = old.clone();
  55463. this.current.resumeSMaskCtx = null;
  55464. },
  55465. restore: function CanvasGraphics_restore() {
  55466. if (this.current.resumeSMaskCtx) {
  55467. this.resumeSMaskGroup();
  55468. }
  55469. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55470. this.endSMaskGroup();
  55471. }
  55472. if (this.stateStack.length !== 0) {
  55473. this.current = this.stateStack.pop();
  55474. this.ctx.restore();
  55475. this.pendingClip = null;
  55476. this.cachedGetSinglePixelWidth = null;
  55477. }
  55478. },
  55479. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55480. this.ctx.transform(a, b, c, d, e, f);
  55481. this.cachedGetSinglePixelWidth = null;
  55482. },
  55483. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55484. var ctx = this.ctx;
  55485. var current = this.current;
  55486. var x = current.x, y = current.y;
  55487. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55488. switch (ops[i] | 0) {
  55489. case OPS.rectangle:
  55490. x = args[j++];
  55491. y = args[j++];
  55492. var width = args[j++];
  55493. var height = args[j++];
  55494. if (width === 0) {
  55495. width = this.getSinglePixelWidth();
  55496. }
  55497. if (height === 0) {
  55498. height = this.getSinglePixelWidth();
  55499. }
  55500. var xw = x + width;
  55501. var yh = y + height;
  55502. this.ctx.moveTo(x, y);
  55503. this.ctx.lineTo(xw, y);
  55504. this.ctx.lineTo(xw, yh);
  55505. this.ctx.lineTo(x, yh);
  55506. this.ctx.lineTo(x, y);
  55507. this.ctx.closePath();
  55508. break;
  55509. case OPS.moveTo:
  55510. x = args[j++];
  55511. y = args[j++];
  55512. ctx.moveTo(x, y);
  55513. break;
  55514. case OPS.lineTo:
  55515. x = args[j++];
  55516. y = args[j++];
  55517. ctx.lineTo(x, y);
  55518. break;
  55519. case OPS.curveTo:
  55520. x = args[j + 4];
  55521. y = args[j + 5];
  55522. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55523. j += 6;
  55524. break;
  55525. case OPS.curveTo2:
  55526. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55527. x = args[j + 2];
  55528. y = args[j + 3];
  55529. j += 4;
  55530. break;
  55531. case OPS.curveTo3:
  55532. x = args[j + 2];
  55533. y = args[j + 3];
  55534. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55535. j += 4;
  55536. break;
  55537. case OPS.closePath:
  55538. ctx.closePath();
  55539. break;
  55540. }
  55541. }
  55542. current.setCurrentPoint(x, y);
  55543. },
  55544. closePath: function CanvasGraphics_closePath() {
  55545. this.ctx.closePath();
  55546. },
  55547. stroke: function CanvasGraphics_stroke(consumePath) {
  55548. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55549. var ctx = this.ctx;
  55550. var strokeColor = this.current.strokeColor;
  55551. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55552. ctx.globalAlpha = this.current.strokeAlpha;
  55553. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55554. ctx.save();
  55555. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55556. ctx.stroke();
  55557. ctx.restore();
  55558. } else {
  55559. ctx.stroke();
  55560. }
  55561. if (consumePath) {
  55562. this.consumePath();
  55563. }
  55564. ctx.globalAlpha = this.current.fillAlpha;
  55565. },
  55566. closeStroke: function CanvasGraphics_closeStroke() {
  55567. this.closePath();
  55568. this.stroke();
  55569. },
  55570. fill: function CanvasGraphics_fill(consumePath) {
  55571. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55572. var ctx = this.ctx;
  55573. var fillColor = this.current.fillColor;
  55574. var isPatternFill = this.current.patternFill;
  55575. var needRestore = false;
  55576. if (isPatternFill) {
  55577. ctx.save();
  55578. if (this.baseTransform) {
  55579. ctx.setTransform.apply(ctx, this.baseTransform);
  55580. }
  55581. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55582. needRestore = true;
  55583. }
  55584. if (this.pendingEOFill) {
  55585. ctx.fill('evenodd');
  55586. this.pendingEOFill = false;
  55587. } else {
  55588. ctx.fill();
  55589. }
  55590. if (needRestore) {
  55591. ctx.restore();
  55592. }
  55593. if (consumePath) {
  55594. this.consumePath();
  55595. }
  55596. },
  55597. eoFill: function CanvasGraphics_eoFill() {
  55598. this.pendingEOFill = true;
  55599. this.fill();
  55600. },
  55601. fillStroke: function CanvasGraphics_fillStroke() {
  55602. this.fill(false);
  55603. this.stroke(false);
  55604. this.consumePath();
  55605. },
  55606. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55607. this.pendingEOFill = true;
  55608. this.fillStroke();
  55609. },
  55610. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55611. this.closePath();
  55612. this.fillStroke();
  55613. },
  55614. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55615. this.pendingEOFill = true;
  55616. this.closePath();
  55617. this.fillStroke();
  55618. },
  55619. endPath: function CanvasGraphics_endPath() {
  55620. this.consumePath();
  55621. },
  55622. clip: function CanvasGraphics_clip() {
  55623. this.pendingClip = NORMAL_CLIP;
  55624. },
  55625. eoClip: function CanvasGraphics_eoClip() {
  55626. this.pendingClip = EO_CLIP;
  55627. },
  55628. beginText: function CanvasGraphics_beginText() {
  55629. this.current.textMatrix = IDENTITY_MATRIX;
  55630. this.current.textMatrixScale = 1;
  55631. this.current.x = this.current.lineX = 0;
  55632. this.current.y = this.current.lineY = 0;
  55633. },
  55634. endText: function CanvasGraphics_endText() {
  55635. var paths = this.pendingTextPaths;
  55636. var ctx = this.ctx;
  55637. if (paths === undefined) {
  55638. ctx.beginPath();
  55639. return;
  55640. }
  55641. ctx.save();
  55642. ctx.beginPath();
  55643. for (var i = 0; i < paths.length; i++) {
  55644. var path = paths[i];
  55645. ctx.setTransform.apply(ctx, path.transform);
  55646. ctx.translate(path.x, path.y);
  55647. path.addToPath(ctx, path.fontSize);
  55648. }
  55649. ctx.restore();
  55650. ctx.clip();
  55651. ctx.beginPath();
  55652. delete this.pendingTextPaths;
  55653. },
  55654. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55655. this.current.charSpacing = spacing;
  55656. },
  55657. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55658. this.current.wordSpacing = spacing;
  55659. },
  55660. setHScale: function CanvasGraphics_setHScale(scale) {
  55661. this.current.textHScale = scale / 100;
  55662. },
  55663. setLeading: function CanvasGraphics_setLeading(leading) {
  55664. this.current.leading = -leading;
  55665. },
  55666. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55667. var fontObj = this.commonObjs.get(fontRefName);
  55668. var current = this.current;
  55669. if (!fontObj) {
  55670. error('Can\'t find font for ' + fontRefName);
  55671. }
  55672. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55673. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55674. warn('Invalid font matrix for font ' + fontRefName);
  55675. }
  55676. if (size < 0) {
  55677. size = -size;
  55678. current.fontDirection = -1;
  55679. } else {
  55680. current.fontDirection = 1;
  55681. }
  55682. this.current.font = fontObj;
  55683. this.current.fontSize = size;
  55684. if (fontObj.isType3Font) {
  55685. return;
  55686. }
  55687. var name = fontObj.loadedName || 'sans-serif';
  55688. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55689. var italic = fontObj.italic ? 'italic' : 'normal';
  55690. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55691. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55692. this.current.fontSizeScale = size / browserFontSize;
  55693. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55694. this.ctx.font = rule;
  55695. },
  55696. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55697. this.current.textRenderingMode = mode;
  55698. },
  55699. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55700. this.current.textRise = rise;
  55701. },
  55702. moveText: function CanvasGraphics_moveText(x, y) {
  55703. this.current.x = this.current.lineX += x;
  55704. this.current.y = this.current.lineY += y;
  55705. },
  55706. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55707. this.setLeading(-y);
  55708. this.moveText(x, y);
  55709. },
  55710. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55711. this.current.textMatrix = [
  55712. a,
  55713. b,
  55714. c,
  55715. d,
  55716. e,
  55717. f
  55718. ];
  55719. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55720. this.current.x = this.current.lineX = 0;
  55721. this.current.y = this.current.lineY = 0;
  55722. },
  55723. nextLine: function CanvasGraphics_nextLine() {
  55724. this.moveText(0, this.current.leading);
  55725. },
  55726. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55727. var ctx = this.ctx;
  55728. var current = this.current;
  55729. var font = current.font;
  55730. var textRenderingMode = current.textRenderingMode;
  55731. var fontSize = current.fontSize / current.fontSizeScale;
  55732. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55733. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55734. var addToPath;
  55735. if (font.disableFontFace || isAddToPathSet) {
  55736. addToPath = font.getPathGenerator(this.commonObjs, character);
  55737. }
  55738. if (font.disableFontFace) {
  55739. ctx.save();
  55740. ctx.translate(x, y);
  55741. ctx.beginPath();
  55742. addToPath(ctx, fontSize);
  55743. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55744. ctx.fill();
  55745. }
  55746. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55747. ctx.stroke();
  55748. }
  55749. ctx.restore();
  55750. } else {
  55751. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55752. ctx.fillText(character, x, y);
  55753. }
  55754. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55755. ctx.strokeText(character, x, y);
  55756. }
  55757. }
  55758. if (isAddToPathSet) {
  55759. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55760. paths.push({
  55761. transform: ctx.mozCurrentTransform,
  55762. x: x,
  55763. y: y,
  55764. fontSize: fontSize,
  55765. addToPath: addToPath
  55766. });
  55767. }
  55768. },
  55769. get isFontSubpixelAAEnabled() {
  55770. var ctx = this.canvasFactory.create(10, 10).context;
  55771. ctx.scale(1.5, 1);
  55772. ctx.fillText('I', 0, 10);
  55773. var data = ctx.getImageData(0, 0, 10, 10).data;
  55774. var enabled = false;
  55775. for (var i = 3; i < data.length; i += 4) {
  55776. if (data[i] > 0 && data[i] < 255) {
  55777. enabled = true;
  55778. break;
  55779. }
  55780. }
  55781. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55782. },
  55783. showText: function CanvasGraphics_showText(glyphs) {
  55784. var current = this.current;
  55785. var font = current.font;
  55786. if (font.isType3Font) {
  55787. return this.showType3Text(glyphs);
  55788. }
  55789. var fontSize = current.fontSize;
  55790. if (fontSize === 0) {
  55791. return;
  55792. }
  55793. var ctx = this.ctx;
  55794. var fontSizeScale = current.fontSizeScale;
  55795. var charSpacing = current.charSpacing;
  55796. var wordSpacing = current.wordSpacing;
  55797. var fontDirection = current.fontDirection;
  55798. var textHScale = current.textHScale * fontDirection;
  55799. var glyphsLength = glyphs.length;
  55800. var vertical = font.vertical;
  55801. var spacingDir = vertical ? 1 : -1;
  55802. var defaultVMetrics = font.defaultVMetrics;
  55803. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55804. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55805. ctx.save();
  55806. ctx.transform.apply(ctx, current.textMatrix);
  55807. ctx.translate(current.x, current.y + current.textRise);
  55808. if (current.patternFill) {
  55809. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55810. }
  55811. if (fontDirection > 0) {
  55812. ctx.scale(textHScale, -1);
  55813. } else {
  55814. ctx.scale(textHScale, 1);
  55815. }
  55816. var lineWidth = current.lineWidth;
  55817. var scale = current.textMatrixScale;
  55818. if (scale === 0 || lineWidth === 0) {
  55819. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55820. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55821. this.cachedGetSinglePixelWidth = null;
  55822. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55823. }
  55824. } else {
  55825. lineWidth /= scale;
  55826. }
  55827. if (fontSizeScale !== 1.0) {
  55828. ctx.scale(fontSizeScale, fontSizeScale);
  55829. lineWidth /= fontSizeScale;
  55830. }
  55831. ctx.lineWidth = lineWidth;
  55832. var x = 0, i;
  55833. for (i = 0; i < glyphsLength; ++i) {
  55834. var glyph = glyphs[i];
  55835. if (isNum(glyph)) {
  55836. x += spacingDir * glyph * fontSize / 1000;
  55837. continue;
  55838. }
  55839. var restoreNeeded = false;
  55840. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55841. var character = glyph.fontChar;
  55842. var accent = glyph.accent;
  55843. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55844. var width = glyph.width;
  55845. if (vertical) {
  55846. var vmetric, vx, vy;
  55847. vmetric = glyph.vmetric || defaultVMetrics;
  55848. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55849. vx = -vx * widthAdvanceScale;
  55850. vy = vmetric[2] * widthAdvanceScale;
  55851. width = vmetric ? -vmetric[0] : width;
  55852. scaledX = vx / fontSizeScale;
  55853. scaledY = (x + vy) / fontSizeScale;
  55854. } else {
  55855. scaledX = x / fontSizeScale;
  55856. scaledY = 0;
  55857. }
  55858. if (font.remeasure && width > 0) {
  55859. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55860. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55861. var characterScaleX = width / measuredWidth;
  55862. restoreNeeded = true;
  55863. ctx.save();
  55864. ctx.scale(characterScaleX, 1);
  55865. scaledX /= characterScaleX;
  55866. } else if (width !== measuredWidth) {
  55867. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55868. }
  55869. }
  55870. if (glyph.isInFont || font.missingFile) {
  55871. if (simpleFillText && !accent) {
  55872. ctx.fillText(character, scaledX, scaledY);
  55873. } else {
  55874. this.paintChar(character, scaledX, scaledY);
  55875. if (accent) {
  55876. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55877. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55878. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55879. }
  55880. }
  55881. }
  55882. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55883. x += charWidth;
  55884. if (restoreNeeded) {
  55885. ctx.restore();
  55886. }
  55887. }
  55888. if (vertical) {
  55889. current.y -= x * textHScale;
  55890. } else {
  55891. current.x += x * textHScale;
  55892. }
  55893. ctx.restore();
  55894. },
  55895. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55896. var ctx = this.ctx;
  55897. var current = this.current;
  55898. var font = current.font;
  55899. var fontSize = current.fontSize;
  55900. var fontDirection = current.fontDirection;
  55901. var spacingDir = font.vertical ? 1 : -1;
  55902. var charSpacing = current.charSpacing;
  55903. var wordSpacing = current.wordSpacing;
  55904. var textHScale = current.textHScale * fontDirection;
  55905. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55906. var glyphsLength = glyphs.length;
  55907. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55908. var i, glyph, width, spacingLength;
  55909. if (isTextInvisible || fontSize === 0) {
  55910. return;
  55911. }
  55912. this.cachedGetSinglePixelWidth = null;
  55913. ctx.save();
  55914. ctx.transform.apply(ctx, current.textMatrix);
  55915. ctx.translate(current.x, current.y);
  55916. ctx.scale(textHScale, fontDirection);
  55917. for (i = 0; i < glyphsLength; ++i) {
  55918. glyph = glyphs[i];
  55919. if (isNum(glyph)) {
  55920. spacingLength = spacingDir * glyph * fontSize / 1000;
  55921. this.ctx.translate(spacingLength, 0);
  55922. current.x += spacingLength * textHScale;
  55923. continue;
  55924. }
  55925. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55926. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55927. if (!operatorList) {
  55928. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55929. continue;
  55930. }
  55931. this.processingType3 = glyph;
  55932. this.save();
  55933. ctx.scale(fontSize, fontSize);
  55934. ctx.transform.apply(ctx, fontMatrix);
  55935. this.executeOperatorList(operatorList);
  55936. this.restore();
  55937. var transformed = Util.applyTransform([
  55938. glyph.width,
  55939. 0
  55940. ], fontMatrix);
  55941. width = transformed[0] * fontSize + spacing;
  55942. ctx.translate(width, 0);
  55943. current.x += width * textHScale;
  55944. }
  55945. ctx.restore();
  55946. this.processingType3 = null;
  55947. },
  55948. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55949. },
  55950. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55951. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55952. this.clip();
  55953. this.endPath();
  55954. },
  55955. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55956. var pattern;
  55957. if (IR[0] === 'TilingPattern') {
  55958. var color = IR[1];
  55959. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55960. var self = this;
  55961. var canvasGraphicsFactory = {
  55962. createCanvasGraphics: function (ctx) {
  55963. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55964. }
  55965. };
  55966. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55967. } else {
  55968. pattern = getShadingPatternFromIR(IR);
  55969. }
  55970. return pattern;
  55971. },
  55972. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55973. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55974. },
  55975. setFillColorN: function CanvasGraphics_setFillColorN() {
  55976. this.current.fillColor = this.getColorN_Pattern(arguments);
  55977. this.current.patternFill = true;
  55978. },
  55979. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55980. var color = Util.makeCssRgb(r, g, b);
  55981. this.ctx.strokeStyle = color;
  55982. this.current.strokeColor = color;
  55983. },
  55984. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55985. var color = Util.makeCssRgb(r, g, b);
  55986. this.ctx.fillStyle = color;
  55987. this.current.fillColor = color;
  55988. this.current.patternFill = false;
  55989. },
  55990. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55991. var ctx = this.ctx;
  55992. this.save();
  55993. var pattern = getShadingPatternFromIR(patternIR);
  55994. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55995. var inv = ctx.mozCurrentTransformInverse;
  55996. if (inv) {
  55997. var canvas = ctx.canvas;
  55998. var width = canvas.width;
  55999. var height = canvas.height;
  56000. var bl = Util.applyTransform([
  56001. 0,
  56002. 0
  56003. ], inv);
  56004. var br = Util.applyTransform([
  56005. 0,
  56006. height
  56007. ], inv);
  56008. var ul = Util.applyTransform([
  56009. width,
  56010. 0
  56011. ], inv);
  56012. var ur = Util.applyTransform([
  56013. width,
  56014. height
  56015. ], inv);
  56016. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56017. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56018. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56019. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56020. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56021. } else {
  56022. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56023. }
  56024. this.restore();
  56025. },
  56026. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56027. error('Should not call beginInlineImage');
  56028. },
  56029. beginImageData: function CanvasGraphics_beginImageData() {
  56030. error('Should not call beginImageData');
  56031. },
  56032. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56033. this.save();
  56034. this.baseTransformStack.push(this.baseTransform);
  56035. if (isArray(matrix) && matrix.length === 6) {
  56036. this.transform.apply(this, matrix);
  56037. }
  56038. this.baseTransform = this.ctx.mozCurrentTransform;
  56039. if (isArray(bbox) && bbox.length === 4) {
  56040. var width = bbox[2] - bbox[0];
  56041. var height = bbox[3] - bbox[1];
  56042. this.ctx.rect(bbox[0], bbox[1], width, height);
  56043. this.clip();
  56044. this.endPath();
  56045. }
  56046. },
  56047. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56048. this.restore();
  56049. this.baseTransform = this.baseTransformStack.pop();
  56050. },
  56051. beginGroup: function CanvasGraphics_beginGroup(group) {
  56052. this.save();
  56053. var currentCtx = this.ctx;
  56054. if (!group.isolated) {
  56055. info('TODO: Support non-isolated groups.');
  56056. }
  56057. if (group.knockout) {
  56058. warn('Knockout groups not supported.');
  56059. }
  56060. var currentTransform = currentCtx.mozCurrentTransform;
  56061. if (group.matrix) {
  56062. currentCtx.transform.apply(currentCtx, group.matrix);
  56063. }
  56064. assert(group.bbox, 'Bounding box is required.');
  56065. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56066. var canvasBounds = [
  56067. 0,
  56068. 0,
  56069. currentCtx.canvas.width,
  56070. currentCtx.canvas.height
  56071. ];
  56072. bounds = Util.intersect(bounds, canvasBounds) || [
  56073. 0,
  56074. 0,
  56075. 0,
  56076. 0
  56077. ];
  56078. var offsetX = Math.floor(bounds[0]);
  56079. var offsetY = Math.floor(bounds[1]);
  56080. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56081. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56082. var scaleX = 1, scaleY = 1;
  56083. if (drawnWidth > MAX_GROUP_SIZE) {
  56084. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56085. drawnWidth = MAX_GROUP_SIZE;
  56086. }
  56087. if (drawnHeight > MAX_GROUP_SIZE) {
  56088. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56089. drawnHeight = MAX_GROUP_SIZE;
  56090. }
  56091. var cacheId = 'groupAt' + this.groupLevel;
  56092. if (group.smask) {
  56093. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56094. }
  56095. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56096. var groupCtx = scratchCanvas.context;
  56097. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56098. groupCtx.translate(-offsetX, -offsetY);
  56099. groupCtx.transform.apply(groupCtx, currentTransform);
  56100. if (group.smask) {
  56101. this.smaskStack.push({
  56102. canvas: scratchCanvas.canvas,
  56103. context: groupCtx,
  56104. offsetX: offsetX,
  56105. offsetY: offsetY,
  56106. scaleX: scaleX,
  56107. scaleY: scaleY,
  56108. subtype: group.smask.subtype,
  56109. backdrop: group.smask.backdrop,
  56110. transferMap: group.smask.transferMap || null,
  56111. startTransformInverse: null
  56112. });
  56113. } else {
  56114. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56115. currentCtx.translate(offsetX, offsetY);
  56116. currentCtx.scale(scaleX, scaleY);
  56117. }
  56118. copyCtxState(currentCtx, groupCtx);
  56119. this.ctx = groupCtx;
  56120. this.setGState([
  56121. [
  56122. 'BM',
  56123. 'Normal'
  56124. ],
  56125. [
  56126. 'ca',
  56127. 1
  56128. ],
  56129. [
  56130. 'CA',
  56131. 1
  56132. ]
  56133. ]);
  56134. this.groupStack.push(currentCtx);
  56135. this.groupLevel++;
  56136. this.current.activeSMask = null;
  56137. },
  56138. endGroup: function CanvasGraphics_endGroup(group) {
  56139. this.groupLevel--;
  56140. var groupCtx = this.ctx;
  56141. this.ctx = this.groupStack.pop();
  56142. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56143. this.ctx.imageSmoothingEnabled = false;
  56144. } else {
  56145. this.ctx.mozImageSmoothingEnabled = false;
  56146. }
  56147. if (group.smask) {
  56148. this.tempSMask = this.smaskStack.pop();
  56149. } else {
  56150. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56151. }
  56152. this.restore();
  56153. },
  56154. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56155. this.save();
  56156. this.current = new CanvasExtraState();
  56157. if (this.baseTransform) {
  56158. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56159. }
  56160. },
  56161. endAnnotations: function CanvasGraphics_endAnnotations() {
  56162. this.restore();
  56163. },
  56164. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56165. this.save();
  56166. if (isArray(rect) && rect.length === 4) {
  56167. var width = rect[2] - rect[0];
  56168. var height = rect[3] - rect[1];
  56169. this.ctx.rect(rect[0], rect[1], width, height);
  56170. this.clip();
  56171. this.endPath();
  56172. }
  56173. this.transform.apply(this, transform);
  56174. this.transform.apply(this, matrix);
  56175. },
  56176. endAnnotation: function CanvasGraphics_endAnnotation() {
  56177. this.restore();
  56178. },
  56179. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56180. var domImage = this.objs.get(objId);
  56181. if (!domImage) {
  56182. warn('Dependent image isn\'t ready yet');
  56183. return;
  56184. }
  56185. this.save();
  56186. var ctx = this.ctx;
  56187. ctx.scale(1 / w, -1 / h);
  56188. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56189. if (this.imageLayer) {
  56190. var currentTransform = ctx.mozCurrentTransformInverse;
  56191. var position = this.getCanvasPosition(0, 0);
  56192. this.imageLayer.appendImage({
  56193. objId: objId,
  56194. left: position[0],
  56195. top: position[1],
  56196. width: w / currentTransform[0],
  56197. height: h / currentTransform[3]
  56198. });
  56199. }
  56200. this.restore();
  56201. },
  56202. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56203. var ctx = this.ctx;
  56204. var width = img.width, height = img.height;
  56205. var fillColor = this.current.fillColor;
  56206. var isPatternFill = this.current.patternFill;
  56207. var glyph = this.processingType3;
  56208. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56209. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56210. glyph.compiled = compileType3Glyph({
  56211. data: img.data,
  56212. width: width,
  56213. height: height
  56214. });
  56215. } else {
  56216. glyph.compiled = null;
  56217. }
  56218. }
  56219. if (glyph && glyph.compiled) {
  56220. glyph.compiled(ctx);
  56221. return;
  56222. }
  56223. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56224. var maskCtx = maskCanvas.context;
  56225. maskCtx.save();
  56226. putBinaryImageMask(maskCtx, img);
  56227. maskCtx.globalCompositeOperation = 'source-in';
  56228. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56229. maskCtx.fillRect(0, 0, width, height);
  56230. maskCtx.restore();
  56231. this.paintInlineImageXObject(maskCanvas.canvas);
  56232. },
  56233. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56234. var width = imgData.width;
  56235. var height = imgData.height;
  56236. var fillColor = this.current.fillColor;
  56237. var isPatternFill = this.current.patternFill;
  56238. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56239. var maskCtx = maskCanvas.context;
  56240. maskCtx.save();
  56241. putBinaryImageMask(maskCtx, imgData);
  56242. maskCtx.globalCompositeOperation = 'source-in';
  56243. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56244. maskCtx.fillRect(0, 0, width, height);
  56245. maskCtx.restore();
  56246. var ctx = this.ctx;
  56247. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56248. ctx.save();
  56249. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56250. ctx.scale(1, -1);
  56251. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56252. ctx.restore();
  56253. }
  56254. },
  56255. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56256. var ctx = this.ctx;
  56257. var fillColor = this.current.fillColor;
  56258. var isPatternFill = this.current.patternFill;
  56259. for (var i = 0, ii = images.length; i < ii; i++) {
  56260. var image = images[i];
  56261. var width = image.width, height = image.height;
  56262. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56263. var maskCtx = maskCanvas.context;
  56264. maskCtx.save();
  56265. putBinaryImageMask(maskCtx, image);
  56266. maskCtx.globalCompositeOperation = 'source-in';
  56267. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56268. maskCtx.fillRect(0, 0, width, height);
  56269. maskCtx.restore();
  56270. ctx.save();
  56271. ctx.transform.apply(ctx, image.transform);
  56272. ctx.scale(1, -1);
  56273. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56274. ctx.restore();
  56275. }
  56276. },
  56277. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56278. var imgData = this.objs.get(objId);
  56279. if (!imgData) {
  56280. warn('Dependent image isn\'t ready yet');
  56281. return;
  56282. }
  56283. this.paintInlineImageXObject(imgData);
  56284. },
  56285. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56286. var imgData = this.objs.get(objId);
  56287. if (!imgData) {
  56288. warn('Dependent image isn\'t ready yet');
  56289. return;
  56290. }
  56291. var width = imgData.width;
  56292. var height = imgData.height;
  56293. var map = [];
  56294. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56295. map.push({
  56296. transform: [
  56297. scaleX,
  56298. 0,
  56299. 0,
  56300. scaleY,
  56301. positions[i],
  56302. positions[i + 1]
  56303. ],
  56304. x: 0,
  56305. y: 0,
  56306. w: width,
  56307. h: height
  56308. });
  56309. }
  56310. this.paintInlineImageXObjectGroup(imgData, map);
  56311. },
  56312. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56313. var width = imgData.width;
  56314. var height = imgData.height;
  56315. var ctx = this.ctx;
  56316. this.save();
  56317. ctx.scale(1 / width, -1 / height);
  56318. var currentTransform = ctx.mozCurrentTransformInverse;
  56319. var a = currentTransform[0], b = currentTransform[1];
  56320. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56321. var c = currentTransform[2], d = currentTransform[3];
  56322. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56323. var imgToPaint, tmpCanvas;
  56324. if (imgData instanceof HTMLElement || !imgData.data) {
  56325. imgToPaint = imgData;
  56326. } else {
  56327. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56328. var tmpCtx = tmpCanvas.context;
  56329. putBinaryImageData(tmpCtx, imgData);
  56330. imgToPaint = tmpCanvas.canvas;
  56331. }
  56332. var paintWidth = width, paintHeight = height;
  56333. var tmpCanvasId = 'prescale1';
  56334. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56335. var newWidth = paintWidth, newHeight = paintHeight;
  56336. if (widthScale > 2 && paintWidth > 1) {
  56337. newWidth = Math.ceil(paintWidth / 2);
  56338. widthScale /= paintWidth / newWidth;
  56339. }
  56340. if (heightScale > 2 && paintHeight > 1) {
  56341. newHeight = Math.ceil(paintHeight / 2);
  56342. heightScale /= paintHeight / newHeight;
  56343. }
  56344. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56345. tmpCtx = tmpCanvas.context;
  56346. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56347. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56348. imgToPaint = tmpCanvas.canvas;
  56349. paintWidth = newWidth;
  56350. paintHeight = newHeight;
  56351. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56352. }
  56353. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56354. if (this.imageLayer) {
  56355. var position = this.getCanvasPosition(0, -height);
  56356. this.imageLayer.appendImage({
  56357. imgData: imgData,
  56358. left: position[0],
  56359. top: position[1],
  56360. width: width / currentTransform[0],
  56361. height: height / currentTransform[3]
  56362. });
  56363. }
  56364. this.restore();
  56365. },
  56366. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56367. var ctx = this.ctx;
  56368. var w = imgData.width;
  56369. var h = imgData.height;
  56370. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56371. var tmpCtx = tmpCanvas.context;
  56372. putBinaryImageData(tmpCtx, imgData);
  56373. for (var i = 0, ii = map.length; i < ii; i++) {
  56374. var entry = map[i];
  56375. ctx.save();
  56376. ctx.transform.apply(ctx, entry.transform);
  56377. ctx.scale(1, -1);
  56378. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56379. if (this.imageLayer) {
  56380. var position = this.getCanvasPosition(entry.x, entry.y);
  56381. this.imageLayer.appendImage({
  56382. imgData: imgData,
  56383. left: position[0],
  56384. top: position[1],
  56385. width: w,
  56386. height: h
  56387. });
  56388. }
  56389. ctx.restore();
  56390. }
  56391. },
  56392. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56393. this.ctx.fillRect(0, 0, 1, 1);
  56394. },
  56395. paintXObject: function CanvasGraphics_paintXObject() {
  56396. warn('Unsupported \'paintXObject\' command.');
  56397. },
  56398. markPoint: function CanvasGraphics_markPoint(tag) {
  56399. },
  56400. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56401. },
  56402. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56403. },
  56404. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56405. },
  56406. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56407. },
  56408. beginCompat: function CanvasGraphics_beginCompat() {
  56409. },
  56410. endCompat: function CanvasGraphics_endCompat() {
  56411. },
  56412. consumePath: function CanvasGraphics_consumePath() {
  56413. var ctx = this.ctx;
  56414. if (this.pendingClip) {
  56415. if (this.pendingClip === EO_CLIP) {
  56416. ctx.clip('evenodd');
  56417. } else {
  56418. ctx.clip();
  56419. }
  56420. this.pendingClip = null;
  56421. }
  56422. ctx.beginPath();
  56423. },
  56424. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56425. if (this.cachedGetSinglePixelWidth === null) {
  56426. this.ctx.save();
  56427. var inverse = this.ctx.mozCurrentTransformInverse;
  56428. this.ctx.restore();
  56429. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56430. }
  56431. return this.cachedGetSinglePixelWidth;
  56432. },
  56433. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56434. var transform = this.ctx.mozCurrentTransform;
  56435. return [
  56436. transform[0] * x + transform[2] * y + transform[4],
  56437. transform[1] * x + transform[3] * y + transform[5]
  56438. ];
  56439. }
  56440. };
  56441. for (var op in OPS) {
  56442. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56443. }
  56444. return CanvasGraphics;
  56445. }();
  56446. exports.CanvasGraphics = CanvasGraphics;
  56447. /***/ }),
  56448. /* 46 */
  56449. /***/ (function(module, exports, __w_pdfjs_require__) {
  56450. "use strict";
  56451. var sharedUtil = __w_pdfjs_require__(0);
  56452. var assert = sharedUtil.assert;
  56453. var bytesToString = sharedUtil.bytesToString;
  56454. var string32 = sharedUtil.string32;
  56455. var shadow = sharedUtil.shadow;
  56456. var warn = sharedUtil.warn;
  56457. function FontLoader(docId) {
  56458. this.docId = docId;
  56459. this.styleElement = null;
  56460. this.nativeFontFaces = [];
  56461. this.loadTestFontId = 0;
  56462. this.loadingContext = {
  56463. requests: [],
  56464. nextRequestId: 0
  56465. };
  56466. }
  56467. FontLoader.prototype = {
  56468. insertRule: function fontLoaderInsertRule(rule) {
  56469. var styleElement = this.styleElement;
  56470. if (!styleElement) {
  56471. styleElement = this.styleElement = document.createElement('style');
  56472. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56473. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56474. }
  56475. var styleSheet = styleElement.sheet;
  56476. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56477. },
  56478. clear: function fontLoaderClear() {
  56479. if (this.styleElement) {
  56480. this.styleElement.remove();
  56481. this.styleElement = null;
  56482. }
  56483. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56484. document.fonts.delete(nativeFontFace);
  56485. });
  56486. this.nativeFontFaces.length = 0;
  56487. }
  56488. };
  56489. var getLoadTestFont = function () {
  56490. 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==');
  56491. };
  56492. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56493. get: function () {
  56494. return shadow(this, 'loadTestFont', getLoadTestFont());
  56495. },
  56496. configurable: true
  56497. });
  56498. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56499. this.nativeFontFaces.push(nativeFontFace);
  56500. document.fonts.add(nativeFontFace);
  56501. };
  56502. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56503. var rules = [];
  56504. var fontsToLoad = [];
  56505. var fontLoadPromises = [];
  56506. var getNativeFontPromise = function (nativeFontFace) {
  56507. return nativeFontFace.loaded.catch(function (e) {
  56508. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56509. });
  56510. };
  56511. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56512. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56513. var font = fonts[i];
  56514. if (font.attached || font.loading === false) {
  56515. continue;
  56516. }
  56517. font.attached = true;
  56518. if (isFontLoadingAPISupported) {
  56519. var nativeFontFace = font.createNativeFontFace();
  56520. if (nativeFontFace) {
  56521. this.addNativeFontFace(nativeFontFace);
  56522. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56523. }
  56524. } else {
  56525. var rule = font.createFontFaceRule();
  56526. if (rule) {
  56527. this.insertRule(rule);
  56528. rules.push(rule);
  56529. fontsToLoad.push(font);
  56530. }
  56531. }
  56532. }
  56533. var request = this.queueLoadingCallback(callback);
  56534. if (isFontLoadingAPISupported) {
  56535. Promise.all(fontLoadPromises).then(function () {
  56536. request.complete();
  56537. });
  56538. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56539. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56540. } else {
  56541. request.complete();
  56542. }
  56543. };
  56544. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56545. function LoadLoader_completeRequest() {
  56546. assert(!request.end, 'completeRequest() cannot be called twice');
  56547. request.end = Date.now();
  56548. while (context.requests.length > 0 && context.requests[0].end) {
  56549. var otherRequest = context.requests.shift();
  56550. setTimeout(otherRequest.callback, 0);
  56551. }
  56552. }
  56553. var context = this.loadingContext;
  56554. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56555. var request = {
  56556. id: requestId,
  56557. complete: LoadLoader_completeRequest,
  56558. callback: callback,
  56559. started: Date.now()
  56560. };
  56561. context.requests.push(request);
  56562. return request;
  56563. };
  56564. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56565. function int32(data, offset) {
  56566. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56567. }
  56568. function spliceString(s, offset, remove, insert) {
  56569. var chunk1 = s.substr(0, offset);
  56570. var chunk2 = s.substr(offset + remove);
  56571. return chunk1 + insert + chunk2;
  56572. }
  56573. var i, ii;
  56574. var canvas = document.createElement('canvas');
  56575. canvas.width = 1;
  56576. canvas.height = 1;
  56577. var ctx = canvas.getContext('2d');
  56578. var called = 0;
  56579. function isFontReady(name, callback) {
  56580. called++;
  56581. if (called > 30) {
  56582. warn('Load test font never loaded.');
  56583. callback();
  56584. return;
  56585. }
  56586. ctx.font = '30px ' + name;
  56587. ctx.fillText('.', 0, 20);
  56588. var imageData = ctx.getImageData(0, 0, 1, 1);
  56589. if (imageData.data[3] > 0) {
  56590. callback();
  56591. return;
  56592. }
  56593. setTimeout(isFontReady.bind(null, name, callback));
  56594. }
  56595. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56596. var data = this.loadTestFont;
  56597. var COMMENT_OFFSET = 976;
  56598. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56599. var CFF_CHECKSUM_OFFSET = 16;
  56600. var XXXX_VALUE = 0x58585858;
  56601. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56602. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56603. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56604. }
  56605. if (i < loadTestFontId.length) {
  56606. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56607. }
  56608. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56609. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56610. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56611. this.insertRule(rule);
  56612. var names = [];
  56613. for (i = 0, ii = fonts.length; i < ii; i++) {
  56614. names.push(fonts[i].loadedName);
  56615. }
  56616. names.push(loadTestFontId);
  56617. var div = document.createElement('div');
  56618. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56619. for (i = 0, ii = names.length; i < ii; ++i) {
  56620. var span = document.createElement('span');
  56621. span.textContent = 'Hi';
  56622. span.style.fontFamily = names[i];
  56623. div.appendChild(span);
  56624. }
  56625. document.body.appendChild(div);
  56626. isFontReady(loadTestFontId, function () {
  56627. document.body.removeChild(div);
  56628. request.complete();
  56629. });
  56630. };
  56631. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56632. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56633. if (typeof navigator === 'undefined') {
  56634. return true;
  56635. }
  56636. var supported = false;
  56637. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56638. if (m && m[1] >= 14) {
  56639. supported = true;
  56640. }
  56641. return supported;
  56642. };
  56643. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56644. get: function () {
  56645. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56646. },
  56647. enumerable: true,
  56648. configurable: true
  56649. });
  56650. var IsEvalSupportedCached = {
  56651. get value() {
  56652. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56653. }
  56654. };
  56655. var FontFaceObject = function FontFaceObjectClosure() {
  56656. function FontFaceObject(translatedData, options) {
  56657. this.compiledGlyphs = Object.create(null);
  56658. for (var i in translatedData) {
  56659. this[i] = translatedData[i];
  56660. }
  56661. this.options = options;
  56662. }
  56663. FontFaceObject.prototype = {
  56664. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56665. if (!this.data) {
  56666. return null;
  56667. }
  56668. if (this.options.disableFontFace) {
  56669. this.disableFontFace = true;
  56670. return null;
  56671. }
  56672. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56673. if (this.options.fontRegistry) {
  56674. this.options.fontRegistry.registerFont(this);
  56675. }
  56676. return nativeFontFace;
  56677. },
  56678. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56679. if (!this.data) {
  56680. return null;
  56681. }
  56682. if (this.options.disableFontFace) {
  56683. this.disableFontFace = true;
  56684. return null;
  56685. }
  56686. var data = bytesToString(new Uint8Array(this.data));
  56687. var fontName = this.loadedName;
  56688. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56689. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56690. if (this.options.fontRegistry) {
  56691. this.options.fontRegistry.registerFont(this, url);
  56692. }
  56693. return rule;
  56694. },
  56695. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56696. if (!(character in this.compiledGlyphs)) {
  56697. var cmds = objs.get(this.loadedName + '_path_' + character);
  56698. var current, i, len;
  56699. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56700. var args, js = '';
  56701. for (i = 0, len = cmds.length; i < len; i++) {
  56702. current = cmds[i];
  56703. if (current.args !== undefined) {
  56704. args = current.args.join(',');
  56705. } else {
  56706. args = '';
  56707. }
  56708. js += 'c.' + current.cmd + '(' + args + ');\n';
  56709. }
  56710. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56711. } else {
  56712. this.compiledGlyphs[character] = function (c, size) {
  56713. for (i = 0, len = cmds.length; i < len; i++) {
  56714. current = cmds[i];
  56715. if (current.cmd === 'scale') {
  56716. current.args = [
  56717. size,
  56718. -size
  56719. ];
  56720. }
  56721. c[current.cmd].apply(c, current.args);
  56722. }
  56723. };
  56724. }
  56725. }
  56726. return this.compiledGlyphs[character];
  56727. }
  56728. };
  56729. return FontFaceObject;
  56730. }();
  56731. exports.FontFaceObject = FontFaceObject;
  56732. exports.FontLoader = FontLoader;
  56733. /***/ }),
  56734. /* 47 */
  56735. /***/ (function(module, exports, __w_pdfjs_require__) {
  56736. "use strict";
  56737. var sharedUtil = __w_pdfjs_require__(0);
  56738. var displayWebGL = __w_pdfjs_require__(24);
  56739. var Util = sharedUtil.Util;
  56740. var info = sharedUtil.info;
  56741. var isArray = sharedUtil.isArray;
  56742. var error = sharedUtil.error;
  56743. var WebGLUtils = displayWebGL.WebGLUtils;
  56744. var ShadingIRs = {};
  56745. ShadingIRs.RadialAxial = {
  56746. fromIR: function RadialAxial_fromIR(raw) {
  56747. var type = raw[1];
  56748. var colorStops = raw[2];
  56749. var p0 = raw[3];
  56750. var p1 = raw[4];
  56751. var r0 = raw[5];
  56752. var r1 = raw[6];
  56753. return {
  56754. type: 'Pattern',
  56755. getPattern: function RadialAxial_getPattern(ctx) {
  56756. var grad;
  56757. if (type === 'axial') {
  56758. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56759. } else if (type === 'radial') {
  56760. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56761. }
  56762. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56763. var c = colorStops[i];
  56764. grad.addColorStop(c[0], c[1]);
  56765. }
  56766. return grad;
  56767. }
  56768. };
  56769. }
  56770. };
  56771. var createMeshCanvas = function createMeshCanvasClosure() {
  56772. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56773. var coords = context.coords, colors = context.colors;
  56774. var bytes = data.data, rowSize = data.width * 4;
  56775. var tmp;
  56776. if (coords[p1 + 1] > coords[p2 + 1]) {
  56777. tmp = p1;
  56778. p1 = p2;
  56779. p2 = tmp;
  56780. tmp = c1;
  56781. c1 = c2;
  56782. c2 = tmp;
  56783. }
  56784. if (coords[p2 + 1] > coords[p3 + 1]) {
  56785. tmp = p2;
  56786. p2 = p3;
  56787. p3 = tmp;
  56788. tmp = c2;
  56789. c2 = c3;
  56790. c3 = tmp;
  56791. }
  56792. if (coords[p1 + 1] > coords[p2 + 1]) {
  56793. tmp = p1;
  56794. p1 = p2;
  56795. p2 = tmp;
  56796. tmp = c1;
  56797. c1 = c2;
  56798. c2 = tmp;
  56799. }
  56800. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56801. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56802. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56803. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56804. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56805. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56806. if (y1 >= y3) {
  56807. return;
  56808. }
  56809. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56810. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56811. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56812. var minY = Math.round(y1), maxY = Math.round(y3);
  56813. var xa, car, cag, cab;
  56814. var xb, cbr, cbg, cbb;
  56815. var k;
  56816. for (var y = minY; y <= maxY; y++) {
  56817. if (y < y2) {
  56818. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56819. xa = x1 - (x1 - x2) * k;
  56820. car = c1r - (c1r - c2r) * k;
  56821. cag = c1g - (c1g - c2g) * k;
  56822. cab = c1b - (c1b - c2b) * k;
  56823. } else {
  56824. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56825. xa = x2 - (x2 - x3) * k;
  56826. car = c2r - (c2r - c3r) * k;
  56827. cag = c2g - (c2g - c3g) * k;
  56828. cab = c2b - (c2b - c3b) * k;
  56829. }
  56830. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56831. xb = x1 - (x1 - x3) * k;
  56832. cbr = c1r - (c1r - c3r) * k;
  56833. cbg = c1g - (c1g - c3g) * k;
  56834. cbb = c1b - (c1b - c3b) * k;
  56835. var x1_ = Math.round(Math.min(xa, xb));
  56836. var x2_ = Math.round(Math.max(xa, xb));
  56837. var j = rowSize * y + x1_ * 4;
  56838. for (var x = x1_; x <= x2_; x++) {
  56839. k = (xa - x) / (xa - xb);
  56840. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56841. bytes[j++] = car - (car - cbr) * k | 0;
  56842. bytes[j++] = cag - (cag - cbg) * k | 0;
  56843. bytes[j++] = cab - (cab - cbb) * k | 0;
  56844. bytes[j++] = 255;
  56845. }
  56846. }
  56847. }
  56848. function drawFigure(data, figure, context) {
  56849. var ps = figure.coords;
  56850. var cs = figure.colors;
  56851. var i, ii;
  56852. switch (figure.type) {
  56853. case 'lattice':
  56854. var verticesPerRow = figure.verticesPerRow;
  56855. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56856. var cols = verticesPerRow - 1;
  56857. for (i = 0; i < rows; i++) {
  56858. var q = i * verticesPerRow;
  56859. for (var j = 0; j < cols; j++, q++) {
  56860. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56861. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56862. }
  56863. }
  56864. break;
  56865. case 'triangles':
  56866. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56867. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56868. }
  56869. break;
  56870. default:
  56871. error('illigal figure');
  56872. break;
  56873. }
  56874. }
  56875. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56876. var EXPECTED_SCALE = 1.1;
  56877. var MAX_PATTERN_SIZE = 3000;
  56878. var BORDER_SIZE = 2;
  56879. var offsetX = Math.floor(bounds[0]);
  56880. var offsetY = Math.floor(bounds[1]);
  56881. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56882. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56883. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56884. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56885. var scaleX = boundsWidth / width;
  56886. var scaleY = boundsHeight / height;
  56887. var context = {
  56888. coords: coords,
  56889. colors: colors,
  56890. offsetX: -offsetX,
  56891. offsetY: -offsetY,
  56892. scaleX: 1 / scaleX,
  56893. scaleY: 1 / scaleY
  56894. };
  56895. var paddedWidth = width + BORDER_SIZE * 2;
  56896. var paddedHeight = height + BORDER_SIZE * 2;
  56897. var canvas, tmpCanvas, i, ii;
  56898. if (WebGLUtils.isEnabled) {
  56899. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56900. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56901. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56902. canvas = tmpCanvas.canvas;
  56903. } else {
  56904. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56905. var tmpCtx = tmpCanvas.context;
  56906. var data = tmpCtx.createImageData(width, height);
  56907. if (backgroundColor) {
  56908. var bytes = data.data;
  56909. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56910. bytes[i] = backgroundColor[0];
  56911. bytes[i + 1] = backgroundColor[1];
  56912. bytes[i + 2] = backgroundColor[2];
  56913. bytes[i + 3] = 255;
  56914. }
  56915. }
  56916. for (i = 0; i < figures.length; i++) {
  56917. drawFigure(data, figures[i], context);
  56918. }
  56919. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56920. canvas = tmpCanvas.canvas;
  56921. }
  56922. return {
  56923. canvas: canvas,
  56924. offsetX: offsetX - BORDER_SIZE * scaleX,
  56925. offsetY: offsetY - BORDER_SIZE * scaleY,
  56926. scaleX: scaleX,
  56927. scaleY: scaleY
  56928. };
  56929. }
  56930. return createMeshCanvas;
  56931. }();
  56932. ShadingIRs.Mesh = {
  56933. fromIR: function Mesh_fromIR(raw) {
  56934. var coords = raw[2];
  56935. var colors = raw[3];
  56936. var figures = raw[4];
  56937. var bounds = raw[5];
  56938. var matrix = raw[6];
  56939. var background = raw[8];
  56940. return {
  56941. type: 'Pattern',
  56942. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56943. var scale;
  56944. if (shadingFill) {
  56945. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56946. } else {
  56947. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56948. if (matrix) {
  56949. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56950. scale = [
  56951. scale[0] * matrixScale[0],
  56952. scale[1] * matrixScale[1]
  56953. ];
  56954. }
  56955. }
  56956. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56957. if (!shadingFill) {
  56958. ctx.setTransform.apply(ctx, owner.baseTransform);
  56959. if (matrix) {
  56960. ctx.transform.apply(ctx, matrix);
  56961. }
  56962. }
  56963. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56964. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56965. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56966. }
  56967. };
  56968. }
  56969. };
  56970. ShadingIRs.Dummy = {
  56971. fromIR: function Dummy_fromIR() {
  56972. return {
  56973. type: 'Pattern',
  56974. getPattern: function Dummy_fromIR_getPattern() {
  56975. return 'hotpink';
  56976. }
  56977. };
  56978. }
  56979. };
  56980. function getShadingPatternFromIR(raw) {
  56981. var shadingIR = ShadingIRs[raw[0]];
  56982. if (!shadingIR) {
  56983. error('Unknown IR type: ' + raw[0]);
  56984. }
  56985. return shadingIR.fromIR(raw);
  56986. }
  56987. var TilingPattern = function TilingPatternClosure() {
  56988. var PaintType = {
  56989. COLORED: 1,
  56990. UNCOLORED: 2
  56991. };
  56992. var MAX_PATTERN_SIZE = 3000;
  56993. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56994. this.operatorList = IR[2];
  56995. this.matrix = IR[3] || [
  56996. 1,
  56997. 0,
  56998. 0,
  56999. 1,
  57000. 0,
  57001. 0
  57002. ];
  57003. this.bbox = IR[4];
  57004. this.xstep = IR[5];
  57005. this.ystep = IR[6];
  57006. this.paintType = IR[7];
  57007. this.tilingType = IR[8];
  57008. this.color = color;
  57009. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57010. this.baseTransform = baseTransform;
  57011. this.type = 'Pattern';
  57012. this.ctx = ctx;
  57013. }
  57014. TilingPattern.prototype = {
  57015. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57016. var operatorList = this.operatorList;
  57017. var bbox = this.bbox;
  57018. var xstep = this.xstep;
  57019. var ystep = this.ystep;
  57020. var paintType = this.paintType;
  57021. var tilingType = this.tilingType;
  57022. var color = this.color;
  57023. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57024. info('TilingType: ' + tilingType);
  57025. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57026. var topLeft = [
  57027. x0,
  57028. y0
  57029. ];
  57030. var botRight = [
  57031. x0 + xstep,
  57032. y0 + ystep
  57033. ];
  57034. var width = botRight[0] - topLeft[0];
  57035. var height = botRight[1] - topLeft[1];
  57036. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57037. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57038. var combinedScale = [
  57039. matrixScale[0] * curMatrixScale[0],
  57040. matrixScale[1] * curMatrixScale[1]
  57041. ];
  57042. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57043. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57044. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57045. var tmpCtx = tmpCanvas.context;
  57046. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57047. graphics.groupLevel = owner.groupLevel;
  57048. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57049. this.setScale(width, height, xstep, ystep);
  57050. this.transformToScale(graphics);
  57051. var tmpTranslate = [
  57052. 1,
  57053. 0,
  57054. 0,
  57055. 1,
  57056. -topLeft[0],
  57057. -topLeft[1]
  57058. ];
  57059. graphics.transform.apply(graphics, tmpTranslate);
  57060. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57061. graphics.executeOperatorList(operatorList);
  57062. return tmpCanvas.canvas;
  57063. },
  57064. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57065. this.scale = [
  57066. width / xstep,
  57067. height / ystep
  57068. ];
  57069. },
  57070. transformToScale: function TilingPattern_transformToScale(graphics) {
  57071. var scale = this.scale;
  57072. var tmpScale = [
  57073. scale[0],
  57074. 0,
  57075. 0,
  57076. scale[1],
  57077. 0,
  57078. 0
  57079. ];
  57080. graphics.transform.apply(graphics, tmpScale);
  57081. },
  57082. scaleToContext: function TilingPattern_scaleToContext() {
  57083. var scale = this.scale;
  57084. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57085. },
  57086. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57087. if (bbox && isArray(bbox) && bbox.length === 4) {
  57088. var bboxWidth = x1 - x0;
  57089. var bboxHeight = y1 - y0;
  57090. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57091. graphics.clip();
  57092. graphics.endPath();
  57093. }
  57094. },
  57095. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57096. switch (paintType) {
  57097. case PaintType.COLORED:
  57098. var ctx = this.ctx;
  57099. context.fillStyle = ctx.fillStyle;
  57100. context.strokeStyle = ctx.strokeStyle;
  57101. break;
  57102. case PaintType.UNCOLORED:
  57103. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57104. context.fillStyle = cssColor;
  57105. context.strokeStyle = cssColor;
  57106. break;
  57107. default:
  57108. error('Unsupported paint type: ' + paintType);
  57109. }
  57110. },
  57111. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57112. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57113. ctx = this.ctx;
  57114. ctx.setTransform.apply(ctx, this.baseTransform);
  57115. ctx.transform.apply(ctx, this.matrix);
  57116. this.scaleToContext();
  57117. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57118. }
  57119. };
  57120. return TilingPattern;
  57121. }();
  57122. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57123. exports.TilingPattern = TilingPattern;
  57124. /***/ }),
  57125. /* 48 */
  57126. /***/ (function(module, exports, __w_pdfjs_require__) {
  57127. "use strict";
  57128. var pdfjsVersion = '1.7.290';
  57129. var pdfjsBuild = 'b509a3f8';
  57130. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57131. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57132. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57133. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57134. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57135. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57136. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57137. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57138. exports.build = pdfjsDisplayAPI.build;
  57139. exports.version = pdfjsDisplayAPI.version;
  57140. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57141. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57142. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57143. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57144. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57145. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57146. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57147. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57148. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57149. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57150. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57151. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57152. exports.OPS = pdfjsSharedUtil.OPS;
  57153. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57154. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57155. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57156. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57157. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57158. exports.shadow = pdfjsSharedUtil.shadow;
  57159. exports.createBlob = pdfjsSharedUtil.createBlob;
  57160. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57161. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57162. /***/ })
  57163. /******/ ]);
  57164. });