pdf.combined.js 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924
  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 compatibility = __w_pdfjs_require__(47);
  84. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  85. var FONT_IDENTITY_MATRIX = [
  86. 0.001,
  87. 0,
  88. 0,
  89. 0.001,
  90. 0,
  91. 0
  92. ];
  93. var TextRenderingMode = {
  94. FILL: 0,
  95. STROKE: 1,
  96. FILL_STROKE: 2,
  97. INVISIBLE: 3,
  98. FILL_ADD_TO_PATH: 4,
  99. STROKE_ADD_TO_PATH: 5,
  100. FILL_STROKE_ADD_TO_PATH: 6,
  101. ADD_TO_PATH: 7,
  102. FILL_STROKE_MASK: 3,
  103. ADD_TO_PATH_FLAG: 4
  104. };
  105. var ImageKind = {
  106. GRAYSCALE_1BPP: 1,
  107. RGB_24BPP: 2,
  108. RGBA_32BPP: 3
  109. };
  110. var AnnotationType = {
  111. TEXT: 1,
  112. LINK: 2,
  113. FREETEXT: 3,
  114. LINE: 4,
  115. SQUARE: 5,
  116. CIRCLE: 6,
  117. POLYGON: 7,
  118. POLYLINE: 8,
  119. HIGHLIGHT: 9,
  120. UNDERLINE: 10,
  121. SQUIGGLY: 11,
  122. STRIKEOUT: 12,
  123. STAMP: 13,
  124. CARET: 14,
  125. INK: 15,
  126. POPUP: 16,
  127. FILEATTACHMENT: 17,
  128. SOUND: 18,
  129. MOVIE: 19,
  130. WIDGET: 20,
  131. SCREEN: 21,
  132. PRINTERMARK: 22,
  133. TRAPNET: 23,
  134. WATERMARK: 24,
  135. THREED: 25,
  136. REDACT: 26
  137. };
  138. var AnnotationFlag = {
  139. INVISIBLE: 0x01,
  140. HIDDEN: 0x02,
  141. PRINT: 0x04,
  142. NOZOOM: 0x08,
  143. NOROTATE: 0x10,
  144. NOVIEW: 0x20,
  145. READONLY: 0x40,
  146. LOCKED: 0x80,
  147. TOGGLENOVIEW: 0x100,
  148. LOCKEDCONTENTS: 0x200
  149. };
  150. var AnnotationFieldFlag = {
  151. READONLY: 0x0000001,
  152. REQUIRED: 0x0000002,
  153. NOEXPORT: 0x0000004,
  154. MULTILINE: 0x0001000,
  155. PASSWORD: 0x0002000,
  156. NOTOGGLETOOFF: 0x0004000,
  157. RADIO: 0x0008000,
  158. PUSHBUTTON: 0x0010000,
  159. COMBO: 0x0020000,
  160. EDIT: 0x0040000,
  161. SORT: 0x0080000,
  162. FILESELECT: 0x0100000,
  163. MULTISELECT: 0x0200000,
  164. DONOTSPELLCHECK: 0x0400000,
  165. DONOTSCROLL: 0x0800000,
  166. COMB: 0x1000000,
  167. RICHTEXT: 0x2000000,
  168. RADIOSINUNISON: 0x2000000,
  169. COMMITONSELCHANGE: 0x4000000
  170. };
  171. var AnnotationBorderStyleType = {
  172. SOLID: 1,
  173. DASHED: 2,
  174. BEVELED: 3,
  175. INSET: 4,
  176. UNDERLINE: 5
  177. };
  178. var StreamType = {
  179. UNKNOWN: 0,
  180. FLATE: 1,
  181. LZW: 2,
  182. DCT: 3,
  183. JPX: 4,
  184. JBIG: 5,
  185. A85: 6,
  186. AHX: 7,
  187. CCF: 8,
  188. RL: 9
  189. };
  190. var FontType = {
  191. UNKNOWN: 0,
  192. TYPE1: 1,
  193. TYPE1C: 2,
  194. CIDFONTTYPE0: 3,
  195. CIDFONTTYPE0C: 4,
  196. TRUETYPE: 5,
  197. CIDFONTTYPE2: 6,
  198. TYPE3: 7,
  199. OPENTYPE: 8,
  200. TYPE0: 9,
  201. MMTYPE1: 10
  202. };
  203. var VERBOSITY_LEVELS = {
  204. errors: 0,
  205. warnings: 1,
  206. infos: 5
  207. };
  208. var CMapCompressionType = {
  209. NONE: 0,
  210. BINARY: 1,
  211. STREAM: 2
  212. };
  213. var OPS = {
  214. dependency: 1,
  215. setLineWidth: 2,
  216. setLineCap: 3,
  217. setLineJoin: 4,
  218. setMiterLimit: 5,
  219. setDash: 6,
  220. setRenderingIntent: 7,
  221. setFlatness: 8,
  222. setGState: 9,
  223. save: 10,
  224. restore: 11,
  225. transform: 12,
  226. moveTo: 13,
  227. lineTo: 14,
  228. curveTo: 15,
  229. curveTo2: 16,
  230. curveTo3: 17,
  231. closePath: 18,
  232. rectangle: 19,
  233. stroke: 20,
  234. closeStroke: 21,
  235. fill: 22,
  236. eoFill: 23,
  237. fillStroke: 24,
  238. eoFillStroke: 25,
  239. closeFillStroke: 26,
  240. closeEOFillStroke: 27,
  241. endPath: 28,
  242. clip: 29,
  243. eoClip: 30,
  244. beginText: 31,
  245. endText: 32,
  246. setCharSpacing: 33,
  247. setWordSpacing: 34,
  248. setHScale: 35,
  249. setLeading: 36,
  250. setFont: 37,
  251. setTextRenderingMode: 38,
  252. setTextRise: 39,
  253. moveText: 40,
  254. setLeadingMoveText: 41,
  255. setTextMatrix: 42,
  256. nextLine: 43,
  257. showText: 44,
  258. showSpacedText: 45,
  259. nextLineShowText: 46,
  260. nextLineSetSpacingShowText: 47,
  261. setCharWidth: 48,
  262. setCharWidthAndBounds: 49,
  263. setStrokeColorSpace: 50,
  264. setFillColorSpace: 51,
  265. setStrokeColor: 52,
  266. setStrokeColorN: 53,
  267. setFillColor: 54,
  268. setFillColorN: 55,
  269. setStrokeGray: 56,
  270. setFillGray: 57,
  271. setStrokeRGBColor: 58,
  272. setFillRGBColor: 59,
  273. setStrokeCMYKColor: 60,
  274. setFillCMYKColor: 61,
  275. shadingFill: 62,
  276. beginInlineImage: 63,
  277. beginImageData: 64,
  278. endInlineImage: 65,
  279. paintXObject: 66,
  280. markPoint: 67,
  281. markPointProps: 68,
  282. beginMarkedContent: 69,
  283. beginMarkedContentProps: 70,
  284. endMarkedContent: 71,
  285. beginCompat: 72,
  286. endCompat: 73,
  287. paintFormXObjectBegin: 74,
  288. paintFormXObjectEnd: 75,
  289. beginGroup: 76,
  290. endGroup: 77,
  291. beginAnnotations: 78,
  292. endAnnotations: 79,
  293. beginAnnotation: 80,
  294. endAnnotation: 81,
  295. paintJpegXObject: 82,
  296. paintImageMaskXObject: 83,
  297. paintImageMaskXObjectGroup: 84,
  298. paintImageXObject: 85,
  299. paintInlineImageXObject: 86,
  300. paintInlineImageXObjectGroup: 87,
  301. paintImageXObjectRepeat: 88,
  302. paintImageMaskXObjectRepeat: 89,
  303. paintSolidColorImageMask: 90,
  304. constructPath: 91
  305. };
  306. var verbosity = VERBOSITY_LEVELS.warnings;
  307. function setVerbosityLevel(level) {
  308. verbosity = level;
  309. }
  310. function getVerbosityLevel() {
  311. return verbosity;
  312. }
  313. function info(msg) {
  314. if (verbosity >= VERBOSITY_LEVELS.infos) {
  315. console.log('Info: ' + msg);
  316. }
  317. }
  318. function warn(msg) {
  319. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  320. console.log('Warning: ' + msg);
  321. }
  322. }
  323. function deprecated(details) {
  324. console.log('Deprecated API usage: ' + details);
  325. }
  326. function error(msg) {
  327. if (verbosity >= VERBOSITY_LEVELS.errors) {
  328. console.log('Error: ' + msg);
  329. console.log(backtrace());
  330. }
  331. throw new Error(msg);
  332. }
  333. function backtrace() {
  334. try {
  335. throw new Error();
  336. } catch (e) {
  337. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  338. }
  339. }
  340. function assert(cond, msg) {
  341. if (!cond) {
  342. error(msg);
  343. }
  344. }
  345. var UNSUPPORTED_FEATURES = {
  346. unknown: 'unknown',
  347. forms: 'forms',
  348. javaScript: 'javaScript',
  349. smask: 'smask',
  350. shadingPattern: 'shadingPattern',
  351. font: 'font'
  352. };
  353. function isSameOrigin(baseUrl, otherUrl) {
  354. try {
  355. var base = new URL(baseUrl);
  356. if (!base.origin || base.origin === 'null') {
  357. return false;
  358. }
  359. } catch (e) {
  360. return false;
  361. }
  362. var other = new URL(otherUrl, base);
  363. return base.origin === other.origin;
  364. }
  365. function isValidProtocol(url) {
  366. if (!url) {
  367. return false;
  368. }
  369. switch (url.protocol) {
  370. case 'http:':
  371. case 'https:':
  372. case 'ftp:':
  373. case 'mailto:':
  374. case 'tel:':
  375. return true;
  376. default:
  377. return false;
  378. }
  379. }
  380. function createValidAbsoluteUrl(url, baseUrl) {
  381. if (!url) {
  382. return null;
  383. }
  384. try {
  385. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  386. if (isValidProtocol(absoluteUrl)) {
  387. return absoluteUrl;
  388. }
  389. } catch (ex) {
  390. }
  391. return null;
  392. }
  393. function shadow(obj, prop, value) {
  394. Object.defineProperty(obj, prop, {
  395. value: value,
  396. enumerable: true,
  397. configurable: true,
  398. writable: false
  399. });
  400. return value;
  401. }
  402. function getLookupTableFactory(initializer) {
  403. var lookup;
  404. return function () {
  405. if (initializer) {
  406. lookup = Object.create(null);
  407. initializer(lookup);
  408. initializer = null;
  409. }
  410. return lookup;
  411. };
  412. }
  413. var PasswordResponses = {
  414. NEED_PASSWORD: 1,
  415. INCORRECT_PASSWORD: 2
  416. };
  417. var PasswordException = function PasswordExceptionClosure() {
  418. function PasswordException(msg, code) {
  419. this.name = 'PasswordException';
  420. this.message = msg;
  421. this.code = code;
  422. }
  423. PasswordException.prototype = new Error();
  424. PasswordException.constructor = PasswordException;
  425. return PasswordException;
  426. }();
  427. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  428. function UnknownErrorException(msg, details) {
  429. this.name = 'UnknownErrorException';
  430. this.message = msg;
  431. this.details = details;
  432. }
  433. UnknownErrorException.prototype = new Error();
  434. UnknownErrorException.constructor = UnknownErrorException;
  435. return UnknownErrorException;
  436. }();
  437. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  438. function InvalidPDFException(msg) {
  439. this.name = 'InvalidPDFException';
  440. this.message = msg;
  441. }
  442. InvalidPDFException.prototype = new Error();
  443. InvalidPDFException.constructor = InvalidPDFException;
  444. return InvalidPDFException;
  445. }();
  446. var MissingPDFException = function MissingPDFExceptionClosure() {
  447. function MissingPDFException(msg) {
  448. this.name = 'MissingPDFException';
  449. this.message = msg;
  450. }
  451. MissingPDFException.prototype = new Error();
  452. MissingPDFException.constructor = MissingPDFException;
  453. return MissingPDFException;
  454. }();
  455. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  456. function UnexpectedResponseException(msg, status) {
  457. this.name = 'UnexpectedResponseException';
  458. this.message = msg;
  459. this.status = status;
  460. }
  461. UnexpectedResponseException.prototype = new Error();
  462. UnexpectedResponseException.constructor = UnexpectedResponseException;
  463. return UnexpectedResponseException;
  464. }();
  465. var NotImplementedException = function NotImplementedExceptionClosure() {
  466. function NotImplementedException(msg) {
  467. this.message = msg;
  468. }
  469. NotImplementedException.prototype = new Error();
  470. NotImplementedException.prototype.name = 'NotImplementedException';
  471. NotImplementedException.constructor = NotImplementedException;
  472. return NotImplementedException;
  473. }();
  474. var MissingDataException = function MissingDataExceptionClosure() {
  475. function MissingDataException(begin, end) {
  476. this.begin = begin;
  477. this.end = end;
  478. this.message = 'Missing data [' + begin + ', ' + end + ')';
  479. }
  480. MissingDataException.prototype = new Error();
  481. MissingDataException.prototype.name = 'MissingDataException';
  482. MissingDataException.constructor = MissingDataException;
  483. return MissingDataException;
  484. }();
  485. var XRefParseException = function XRefParseExceptionClosure() {
  486. function XRefParseException(msg) {
  487. this.message = msg;
  488. }
  489. XRefParseException.prototype = new Error();
  490. XRefParseException.prototype.name = 'XRefParseException';
  491. XRefParseException.constructor = XRefParseException;
  492. return XRefParseException;
  493. }();
  494. var NullCharactersRegExp = /\x00/g;
  495. function removeNullCharacters(str) {
  496. if (typeof str !== 'string') {
  497. warn('The argument for removeNullCharacters must be a string.');
  498. return str;
  499. }
  500. return str.replace(NullCharactersRegExp, '');
  501. }
  502. function bytesToString(bytes) {
  503. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  504. var length = bytes.length;
  505. var MAX_ARGUMENT_COUNT = 8192;
  506. if (length < MAX_ARGUMENT_COUNT) {
  507. return String.fromCharCode.apply(null, bytes);
  508. }
  509. var strBuf = [];
  510. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  511. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  512. var chunk = bytes.subarray(i, chunkEnd);
  513. strBuf.push(String.fromCharCode.apply(null, chunk));
  514. }
  515. return strBuf.join('');
  516. }
  517. function stringToBytes(str) {
  518. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  519. var length = str.length;
  520. var bytes = new Uint8Array(length);
  521. for (var i = 0; i < length; ++i) {
  522. bytes[i] = str.charCodeAt(i) & 0xFF;
  523. }
  524. return bytes;
  525. }
  526. function arrayByteLength(arr) {
  527. if (arr.length !== undefined) {
  528. return arr.length;
  529. }
  530. assert(arr.byteLength !== undefined);
  531. return arr.byteLength;
  532. }
  533. function arraysToBytes(arr) {
  534. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  535. return arr[0];
  536. }
  537. var resultLength = 0;
  538. var i, ii = arr.length;
  539. var item, itemLength;
  540. for (i = 0; i < ii; i++) {
  541. item = arr[i];
  542. itemLength = arrayByteLength(item);
  543. resultLength += itemLength;
  544. }
  545. var pos = 0;
  546. var data = new Uint8Array(resultLength);
  547. for (i = 0; i < ii; i++) {
  548. item = arr[i];
  549. if (!(item instanceof Uint8Array)) {
  550. if (typeof item === 'string') {
  551. item = stringToBytes(item);
  552. } else {
  553. item = new Uint8Array(item);
  554. }
  555. }
  556. itemLength = item.byteLength;
  557. data.set(item, pos);
  558. pos += itemLength;
  559. }
  560. return data;
  561. }
  562. function string32(value) {
  563. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  564. }
  565. function log2(x) {
  566. var n = 1, i = 0;
  567. while (x > n) {
  568. n <<= 1;
  569. i++;
  570. }
  571. return i;
  572. }
  573. function readInt8(data, start) {
  574. return data[start] << 24 >> 24;
  575. }
  576. function readUint16(data, offset) {
  577. return data[offset] << 8 | data[offset + 1];
  578. }
  579. function readUint32(data, offset) {
  580. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  581. }
  582. function isLittleEndian() {
  583. var buffer8 = new Uint8Array(2);
  584. buffer8[0] = 1;
  585. var buffer16 = new Uint16Array(buffer8.buffer);
  586. return buffer16[0] === 1;
  587. }
  588. function isEvalSupported() {
  589. try {
  590. new Function('');
  591. return true;
  592. } catch (e) {
  593. return false;
  594. }
  595. }
  596. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  597. function Uint32ArrayView(buffer, length) {
  598. this.buffer = buffer;
  599. this.byteLength = buffer.length;
  600. this.length = length === undefined ? this.byteLength >> 2 : length;
  601. ensureUint32ArrayViewProps(this.length);
  602. }
  603. Uint32ArrayView.prototype = Object.create(null);
  604. var uint32ArrayViewSetters = 0;
  605. function createUint32ArrayProp(index) {
  606. return {
  607. get: function () {
  608. var buffer = this.buffer, offset = index << 2;
  609. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  610. },
  611. set: function (value) {
  612. var buffer = this.buffer, offset = index << 2;
  613. buffer[offset] = value & 255;
  614. buffer[offset + 1] = value >> 8 & 255;
  615. buffer[offset + 2] = value >> 16 & 255;
  616. buffer[offset + 3] = value >>> 24 & 255;
  617. }
  618. };
  619. }
  620. function ensureUint32ArrayViewProps(length) {
  621. while (uint32ArrayViewSetters < length) {
  622. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  623. uint32ArrayViewSetters++;
  624. }
  625. }
  626. return Uint32ArrayView;
  627. }();
  628. exports.Uint32ArrayView = Uint32ArrayView;
  629. var IDENTITY_MATRIX = [
  630. 1,
  631. 0,
  632. 0,
  633. 1,
  634. 0,
  635. 0
  636. ];
  637. var Util = function UtilClosure() {
  638. function Util() {
  639. }
  640. var rgbBuf = [
  641. 'rgb(',
  642. 0,
  643. ',',
  644. 0,
  645. ',',
  646. 0,
  647. ')'
  648. ];
  649. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  650. rgbBuf[1] = r;
  651. rgbBuf[3] = g;
  652. rgbBuf[5] = b;
  653. return rgbBuf.join('');
  654. };
  655. Util.transform = function Util_transform(m1, m2) {
  656. return [
  657. m1[0] * m2[0] + m1[2] * m2[1],
  658. m1[1] * m2[0] + m1[3] * m2[1],
  659. m1[0] * m2[2] + m1[2] * m2[3],
  660. m1[1] * m2[2] + m1[3] * m2[3],
  661. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  662. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  663. ];
  664. };
  665. Util.applyTransform = function Util_applyTransform(p, m) {
  666. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  667. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  668. return [
  669. xt,
  670. yt
  671. ];
  672. };
  673. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  674. var d = m[0] * m[3] - m[1] * m[2];
  675. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  676. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  677. return [
  678. xt,
  679. yt
  680. ];
  681. };
  682. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  683. var p1 = Util.applyTransform(r, m);
  684. var p2 = Util.applyTransform(r.slice(2, 4), m);
  685. var p3 = Util.applyTransform([
  686. r[0],
  687. r[3]
  688. ], m);
  689. var p4 = Util.applyTransform([
  690. r[2],
  691. r[1]
  692. ], m);
  693. return [
  694. Math.min(p1[0], p2[0], p3[0], p4[0]),
  695. Math.min(p1[1], p2[1], p3[1], p4[1]),
  696. Math.max(p1[0], p2[0], p3[0], p4[0]),
  697. Math.max(p1[1], p2[1], p3[1], p4[1])
  698. ];
  699. };
  700. Util.inverseTransform = function Util_inverseTransform(m) {
  701. var d = m[0] * m[3] - m[1] * m[2];
  702. return [
  703. m[3] / d,
  704. -m[1] / d,
  705. -m[2] / d,
  706. m[0] / d,
  707. (m[2] * m[5] - m[4] * m[3]) / d,
  708. (m[4] * m[1] - m[5] * m[0]) / d
  709. ];
  710. };
  711. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  712. return [
  713. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  714. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  715. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  716. ];
  717. };
  718. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  719. var transpose = [
  720. m[0],
  721. m[2],
  722. m[1],
  723. m[3]
  724. ];
  725. var a = m[0] * transpose[0] + m[1] * transpose[2];
  726. var b = m[0] * transpose[1] + m[1] * transpose[3];
  727. var c = m[2] * transpose[0] + m[3] * transpose[2];
  728. var d = m[2] * transpose[1] + m[3] * transpose[3];
  729. var first = (a + d) / 2;
  730. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  731. var sx = first + second || 1;
  732. var sy = first - second || 1;
  733. return [
  734. Math.sqrt(sx),
  735. Math.sqrt(sy)
  736. ];
  737. };
  738. Util.normalizeRect = function Util_normalizeRect(rect) {
  739. var r = rect.slice(0);
  740. if (rect[0] > rect[2]) {
  741. r[0] = rect[2];
  742. r[2] = rect[0];
  743. }
  744. if (rect[1] > rect[3]) {
  745. r[1] = rect[3];
  746. r[3] = rect[1];
  747. }
  748. return r;
  749. };
  750. Util.intersect = function Util_intersect(rect1, rect2) {
  751. function compare(a, b) {
  752. return a - b;
  753. }
  754. var orderedX = [
  755. rect1[0],
  756. rect1[2],
  757. rect2[0],
  758. rect2[2]
  759. ].sort(compare), orderedY = [
  760. rect1[1],
  761. rect1[3],
  762. rect2[1],
  763. rect2[3]
  764. ].sort(compare), result = [];
  765. rect1 = Util.normalizeRect(rect1);
  766. rect2 = Util.normalizeRect(rect2);
  767. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  768. result[0] = orderedX[1];
  769. result[2] = orderedX[2];
  770. } else {
  771. return false;
  772. }
  773. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  774. result[1] = orderedY[1];
  775. result[3] = orderedY[2];
  776. } else {
  777. return false;
  778. }
  779. return result;
  780. };
  781. Util.sign = function Util_sign(num) {
  782. return num < 0 ? -1 : 1;
  783. };
  784. var ROMAN_NUMBER_MAP = [
  785. '',
  786. 'C',
  787. 'CC',
  788. 'CCC',
  789. 'CD',
  790. 'D',
  791. 'DC',
  792. 'DCC',
  793. 'DCCC',
  794. 'CM',
  795. '',
  796. 'X',
  797. 'XX',
  798. 'XXX',
  799. 'XL',
  800. 'L',
  801. 'LX',
  802. 'LXX',
  803. 'LXXX',
  804. 'XC',
  805. '',
  806. 'I',
  807. 'II',
  808. 'III',
  809. 'IV',
  810. 'V',
  811. 'VI',
  812. 'VII',
  813. 'VIII',
  814. 'IX'
  815. ];
  816. Util.toRoman = function Util_toRoman(number, lowerCase) {
  817. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  818. var pos, romanBuf = [];
  819. while (number >= 1000) {
  820. number -= 1000;
  821. romanBuf.push('M');
  822. }
  823. pos = number / 100 | 0;
  824. number %= 100;
  825. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  826. pos = number / 10 | 0;
  827. number %= 10;
  828. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  829. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  830. var romanStr = romanBuf.join('');
  831. return lowerCase ? romanStr.toLowerCase() : romanStr;
  832. };
  833. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  834. Array.prototype.push.apply(arr1, arr2);
  835. };
  836. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  837. Array.prototype.unshift.apply(arr1, arr2);
  838. };
  839. Util.extendObj = function extendObj(obj1, obj2) {
  840. for (var key in obj2) {
  841. obj1[key] = obj2[key];
  842. }
  843. };
  844. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  845. while (dict && !dict.has(name)) {
  846. dict = dict.get('Parent');
  847. }
  848. if (!dict) {
  849. return null;
  850. }
  851. return getArray ? dict.getArray(name) : dict.get(name);
  852. };
  853. Util.inherit = function Util_inherit(sub, base, prototype) {
  854. sub.prototype = Object.create(base.prototype);
  855. sub.prototype.constructor = sub;
  856. for (var prop in prototype) {
  857. sub.prototype[prop] = prototype[prop];
  858. }
  859. };
  860. Util.loadScript = function Util_loadScript(src, callback) {
  861. var script = document.createElement('script');
  862. var loaded = false;
  863. script.setAttribute('src', src);
  864. if (callback) {
  865. script.onload = function () {
  866. if (!loaded) {
  867. callback();
  868. }
  869. loaded = true;
  870. };
  871. }
  872. document.getElementsByTagName('head')[0].appendChild(script);
  873. };
  874. return Util;
  875. }();
  876. var PageViewport = function PageViewportClosure() {
  877. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  878. this.viewBox = viewBox;
  879. this.scale = scale;
  880. this.rotation = rotation;
  881. this.offsetX = offsetX;
  882. this.offsetY = offsetY;
  883. var centerX = (viewBox[2] + viewBox[0]) / 2;
  884. var centerY = (viewBox[3] + viewBox[1]) / 2;
  885. var rotateA, rotateB, rotateC, rotateD;
  886. rotation = rotation % 360;
  887. rotation = rotation < 0 ? rotation + 360 : rotation;
  888. switch (rotation) {
  889. case 180:
  890. rotateA = -1;
  891. rotateB = 0;
  892. rotateC = 0;
  893. rotateD = 1;
  894. break;
  895. case 90:
  896. rotateA = 0;
  897. rotateB = 1;
  898. rotateC = 1;
  899. rotateD = 0;
  900. break;
  901. case 270:
  902. rotateA = 0;
  903. rotateB = -1;
  904. rotateC = -1;
  905. rotateD = 0;
  906. break;
  907. default:
  908. rotateA = 1;
  909. rotateB = 0;
  910. rotateC = 0;
  911. rotateD = -1;
  912. break;
  913. }
  914. if (dontFlip) {
  915. rotateC = -rotateC;
  916. rotateD = -rotateD;
  917. }
  918. var offsetCanvasX, offsetCanvasY;
  919. var width, height;
  920. if (rotateA === 0) {
  921. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  922. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  923. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  924. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  925. } else {
  926. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  927. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  928. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  929. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  930. }
  931. this.transform = [
  932. rotateA * scale,
  933. rotateB * scale,
  934. rotateC * scale,
  935. rotateD * scale,
  936. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  937. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  938. ];
  939. this.width = width;
  940. this.height = height;
  941. this.fontScale = scale;
  942. }
  943. PageViewport.prototype = {
  944. clone: function PageViewPort_clone(args) {
  945. args = args || {};
  946. var scale = 'scale' in args ? args.scale : this.scale;
  947. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  948. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  949. },
  950. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  951. return Util.applyTransform([
  952. x,
  953. y
  954. ], this.transform);
  955. },
  956. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  957. var tl = Util.applyTransform([
  958. rect[0],
  959. rect[1]
  960. ], this.transform);
  961. var br = Util.applyTransform([
  962. rect[2],
  963. rect[3]
  964. ], this.transform);
  965. return [
  966. tl[0],
  967. tl[1],
  968. br[0],
  969. br[1]
  970. ];
  971. },
  972. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  973. return Util.applyInverseTransform([
  974. x,
  975. y
  976. ], this.transform);
  977. }
  978. };
  979. return PageViewport;
  980. }();
  981. var PDFStringTranslateTable = [
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0x2D8,
  1007. 0x2C7,
  1008. 0x2C6,
  1009. 0x2D9,
  1010. 0x2DD,
  1011. 0x2DB,
  1012. 0x2DA,
  1013. 0x2DC,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0,
  1110. 0x2022,
  1111. 0x2020,
  1112. 0x2021,
  1113. 0x2026,
  1114. 0x2014,
  1115. 0x2013,
  1116. 0x192,
  1117. 0x2044,
  1118. 0x2039,
  1119. 0x203A,
  1120. 0x2212,
  1121. 0x2030,
  1122. 0x201E,
  1123. 0x201C,
  1124. 0x201D,
  1125. 0x2018,
  1126. 0x2019,
  1127. 0x201A,
  1128. 0x2122,
  1129. 0xFB01,
  1130. 0xFB02,
  1131. 0x141,
  1132. 0x152,
  1133. 0x160,
  1134. 0x178,
  1135. 0x17D,
  1136. 0x131,
  1137. 0x142,
  1138. 0x153,
  1139. 0x161,
  1140. 0x17E,
  1141. 0,
  1142. 0x20AC
  1143. ];
  1144. function stringToPDFString(str) {
  1145. var i, n = str.length, strBuf = [];
  1146. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1147. for (i = 2; i < n; i += 2) {
  1148. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1149. }
  1150. } else {
  1151. for (i = 0; i < n; ++i) {
  1152. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1153. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1154. }
  1155. }
  1156. return strBuf.join('');
  1157. }
  1158. function stringToUTF8String(str) {
  1159. return decodeURIComponent(escape(str));
  1160. }
  1161. function utf8StringToString(str) {
  1162. return unescape(encodeURIComponent(str));
  1163. }
  1164. function isEmptyObj(obj) {
  1165. for (var key in obj) {
  1166. return false;
  1167. }
  1168. return true;
  1169. }
  1170. function isBool(v) {
  1171. return typeof v === 'boolean';
  1172. }
  1173. function isInt(v) {
  1174. return typeof v === 'number' && (v | 0) === v;
  1175. }
  1176. function isNum(v) {
  1177. return typeof v === 'number';
  1178. }
  1179. function isString(v) {
  1180. return typeof v === 'string';
  1181. }
  1182. function isArray(v) {
  1183. return v instanceof Array;
  1184. }
  1185. function isArrayBuffer(v) {
  1186. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1187. }
  1188. function isSpace(ch) {
  1189. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1190. }
  1191. function isNodeJS() {
  1192. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1193. return typeof process === 'object' && process + '' === '[object process]';
  1194. }
  1195. return false;
  1196. }
  1197. function createPromiseCapability() {
  1198. var capability = {};
  1199. capability.promise = new Promise(function (resolve, reject) {
  1200. capability.resolve = resolve;
  1201. capability.reject = reject;
  1202. });
  1203. return capability;
  1204. }
  1205. var StatTimer = function StatTimerClosure() {
  1206. function rpad(str, pad, length) {
  1207. while (str.length < length) {
  1208. str += pad;
  1209. }
  1210. return str;
  1211. }
  1212. function StatTimer() {
  1213. this.started = Object.create(null);
  1214. this.times = [];
  1215. this.enabled = true;
  1216. }
  1217. StatTimer.prototype = {
  1218. time: function StatTimer_time(name) {
  1219. if (!this.enabled) {
  1220. return;
  1221. }
  1222. if (name in this.started) {
  1223. warn('Timer is already running for ' + name);
  1224. }
  1225. this.started[name] = Date.now();
  1226. },
  1227. timeEnd: function StatTimer_timeEnd(name) {
  1228. if (!this.enabled) {
  1229. return;
  1230. }
  1231. if (!(name in this.started)) {
  1232. warn('Timer has not been started for ' + name);
  1233. }
  1234. this.times.push({
  1235. 'name': name,
  1236. 'start': this.started[name],
  1237. 'end': Date.now()
  1238. });
  1239. delete this.started[name];
  1240. },
  1241. toString: function StatTimer_toString() {
  1242. var i, ii;
  1243. var times = this.times;
  1244. var out = '';
  1245. var longest = 0;
  1246. for (i = 0, ii = times.length; i < ii; ++i) {
  1247. var name = times[i]['name'];
  1248. if (name.length > longest) {
  1249. longest = name.length;
  1250. }
  1251. }
  1252. for (i = 0, ii = times.length; i < ii; ++i) {
  1253. var span = times[i];
  1254. var duration = span.end - span.start;
  1255. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1256. }
  1257. return out;
  1258. }
  1259. };
  1260. return StatTimer;
  1261. }();
  1262. var createBlob = function createBlob(data, contentType) {
  1263. if (typeof Blob !== 'undefined') {
  1264. return new Blob([data], { type: contentType });
  1265. }
  1266. warn('The "Blob" constructor is not supported.');
  1267. };
  1268. var createObjectURL = function createObjectURLClosure() {
  1269. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1270. return function createObjectURL(data, contentType, forceDataSchema) {
  1271. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1272. var blob = createBlob(data, contentType);
  1273. return URL.createObjectURL(blob);
  1274. }
  1275. var buffer = 'data:' + contentType + ';base64,';
  1276. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1277. var b1 = data[i] & 0xFF;
  1278. var b2 = data[i + 1] & 0xFF;
  1279. var b3 = data[i + 2] & 0xFF;
  1280. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1281. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1282. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1283. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1284. }
  1285. return buffer;
  1286. };
  1287. }();
  1288. function MessageHandler(sourceName, targetName, comObj) {
  1289. this.sourceName = sourceName;
  1290. this.targetName = targetName;
  1291. this.comObj = comObj;
  1292. this.callbackIndex = 1;
  1293. this.postMessageTransfers = true;
  1294. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1295. var ah = this.actionHandler = Object.create(null);
  1296. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1297. var data = event.data;
  1298. if (data.targetName !== this.sourceName) {
  1299. return;
  1300. }
  1301. if (data.isReply) {
  1302. var callbackId = data.callbackId;
  1303. if (data.callbackId in callbacksCapabilities) {
  1304. var callback = callbacksCapabilities[callbackId];
  1305. delete callbacksCapabilities[callbackId];
  1306. if ('error' in data) {
  1307. callback.reject(data.error);
  1308. } else {
  1309. callback.resolve(data.data);
  1310. }
  1311. } else {
  1312. error('Cannot resolve callback ' + callbackId);
  1313. }
  1314. } else if (data.action in ah) {
  1315. var action = ah[data.action];
  1316. if (data.callbackId) {
  1317. var sourceName = this.sourceName;
  1318. var targetName = data.sourceName;
  1319. Promise.resolve().then(function () {
  1320. return action[0].call(action[1], data.data);
  1321. }).then(function (result) {
  1322. comObj.postMessage({
  1323. sourceName: sourceName,
  1324. targetName: targetName,
  1325. isReply: true,
  1326. callbackId: data.callbackId,
  1327. data: result
  1328. });
  1329. }, function (reason) {
  1330. if (reason instanceof Error) {
  1331. reason = reason + '';
  1332. }
  1333. comObj.postMessage({
  1334. sourceName: sourceName,
  1335. targetName: targetName,
  1336. isReply: true,
  1337. callbackId: data.callbackId,
  1338. error: reason
  1339. });
  1340. });
  1341. } else {
  1342. action[0].call(action[1], data.data);
  1343. }
  1344. } else {
  1345. error('Unknown action from worker: ' + data.action);
  1346. }
  1347. }.bind(this);
  1348. comObj.addEventListener('message', this._onComObjOnMessage);
  1349. }
  1350. MessageHandler.prototype = {
  1351. on: function messageHandlerOn(actionName, handler, scope) {
  1352. var ah = this.actionHandler;
  1353. if (ah[actionName]) {
  1354. error('There is already an actionName called "' + actionName + '"');
  1355. }
  1356. ah[actionName] = [
  1357. handler,
  1358. scope
  1359. ];
  1360. },
  1361. send: function messageHandlerSend(actionName, data, transfers) {
  1362. var message = {
  1363. sourceName: this.sourceName,
  1364. targetName: this.targetName,
  1365. action: actionName,
  1366. data: data
  1367. };
  1368. this.postMessage(message, transfers);
  1369. },
  1370. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1371. var callbackId = this.callbackIndex++;
  1372. var message = {
  1373. sourceName: this.sourceName,
  1374. targetName: this.targetName,
  1375. action: actionName,
  1376. data: data,
  1377. callbackId: callbackId
  1378. };
  1379. var capability = createPromiseCapability();
  1380. this.callbacksCapabilities[callbackId] = capability;
  1381. try {
  1382. this.postMessage(message, transfers);
  1383. } catch (e) {
  1384. capability.reject(e);
  1385. }
  1386. return capability.promise;
  1387. },
  1388. postMessage: function (message, transfers) {
  1389. if (transfers && this.postMessageTransfers) {
  1390. this.comObj.postMessage(message, transfers);
  1391. } else {
  1392. this.comObj.postMessage(message);
  1393. }
  1394. },
  1395. destroy: function () {
  1396. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1397. }
  1398. };
  1399. function loadJpegStream(id, imageUrl, objs) {
  1400. var img = new Image();
  1401. img.onload = function loadJpegStream_onloadClosure() {
  1402. objs.resolve(id, img);
  1403. };
  1404. img.onerror = function loadJpegStream_onerrorClosure() {
  1405. objs.resolve(id, null);
  1406. warn('Error during JPEG image loading');
  1407. };
  1408. img.src = imageUrl;
  1409. }
  1410. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1411. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1412. exports.OPS = OPS;
  1413. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1414. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1415. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1416. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1417. exports.AnnotationFlag = AnnotationFlag;
  1418. exports.AnnotationType = AnnotationType;
  1419. exports.FontType = FontType;
  1420. exports.ImageKind = ImageKind;
  1421. exports.CMapCompressionType = CMapCompressionType;
  1422. exports.InvalidPDFException = InvalidPDFException;
  1423. exports.MessageHandler = MessageHandler;
  1424. exports.MissingDataException = MissingDataException;
  1425. exports.MissingPDFException = MissingPDFException;
  1426. exports.NotImplementedException = NotImplementedException;
  1427. exports.PageViewport = PageViewport;
  1428. exports.PasswordException = PasswordException;
  1429. exports.PasswordResponses = PasswordResponses;
  1430. exports.StatTimer = StatTimer;
  1431. exports.StreamType = StreamType;
  1432. exports.TextRenderingMode = TextRenderingMode;
  1433. exports.UnexpectedResponseException = UnexpectedResponseException;
  1434. exports.UnknownErrorException = UnknownErrorException;
  1435. exports.Util = Util;
  1436. exports.XRefParseException = XRefParseException;
  1437. exports.arrayByteLength = arrayByteLength;
  1438. exports.arraysToBytes = arraysToBytes;
  1439. exports.assert = assert;
  1440. exports.bytesToString = bytesToString;
  1441. exports.createBlob = createBlob;
  1442. exports.createPromiseCapability = createPromiseCapability;
  1443. exports.createObjectURL = createObjectURL;
  1444. exports.deprecated = deprecated;
  1445. exports.error = error;
  1446. exports.getLookupTableFactory = getLookupTableFactory;
  1447. exports.getVerbosityLevel = getVerbosityLevel;
  1448. exports.globalScope = globalScope;
  1449. exports.info = info;
  1450. exports.isArray = isArray;
  1451. exports.isArrayBuffer = isArrayBuffer;
  1452. exports.isBool = isBool;
  1453. exports.isEmptyObj = isEmptyObj;
  1454. exports.isInt = isInt;
  1455. exports.isNum = isNum;
  1456. exports.isString = isString;
  1457. exports.isSpace = isSpace;
  1458. exports.isNodeJS = isNodeJS;
  1459. exports.isSameOrigin = isSameOrigin;
  1460. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1461. exports.isLittleEndian = isLittleEndian;
  1462. exports.isEvalSupported = isEvalSupported;
  1463. exports.loadJpegStream = loadJpegStream;
  1464. exports.log2 = log2;
  1465. exports.readInt8 = readInt8;
  1466. exports.readUint16 = readUint16;
  1467. exports.readUint32 = readUint32;
  1468. exports.removeNullCharacters = removeNullCharacters;
  1469. exports.setVerbosityLevel = setVerbosityLevel;
  1470. exports.shadow = shadow;
  1471. exports.string32 = string32;
  1472. exports.stringToBytes = stringToBytes;
  1473. exports.stringToPDFString = stringToPDFString;
  1474. exports.stringToUTF8String = stringToUTF8String;
  1475. exports.utf8StringToString = utf8StringToString;
  1476. exports.warn = warn;
  1477. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  1478. /***/ }),
  1479. /* 1 */
  1480. /***/ (function(module, exports, __w_pdfjs_require__) {
  1481. "use strict";
  1482. var sharedUtil = __w_pdfjs_require__(0);
  1483. var isArray = sharedUtil.isArray;
  1484. var EOF = {};
  1485. var Name = function NameClosure() {
  1486. function Name(name) {
  1487. this.name = name;
  1488. }
  1489. Name.prototype = {};
  1490. var nameCache = Object.create(null);
  1491. Name.get = function Name_get(name) {
  1492. var nameValue = nameCache[name];
  1493. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1494. };
  1495. return Name;
  1496. }();
  1497. var Cmd = function CmdClosure() {
  1498. function Cmd(cmd) {
  1499. this.cmd = cmd;
  1500. }
  1501. Cmd.prototype = {};
  1502. var cmdCache = Object.create(null);
  1503. Cmd.get = function Cmd_get(cmd) {
  1504. var cmdValue = cmdCache[cmd];
  1505. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1506. };
  1507. return Cmd;
  1508. }();
  1509. var Dict = function DictClosure() {
  1510. var nonSerializable = function nonSerializableClosure() {
  1511. return nonSerializable;
  1512. };
  1513. function Dict(xref) {
  1514. this.map = Object.create(null);
  1515. this.xref = xref;
  1516. this.objId = null;
  1517. this.suppressEncryption = false;
  1518. this.__nonSerializable__ = nonSerializable;
  1519. }
  1520. Dict.prototype = {
  1521. assignXref: function Dict_assignXref(newXref) {
  1522. this.xref = newXref;
  1523. },
  1524. get: function Dict_get(key1, key2, key3) {
  1525. var value;
  1526. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1527. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1528. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1529. }
  1530. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1531. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1532. }
  1533. value = this.map[key3] || null;
  1534. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1535. },
  1536. getAsync: function Dict_getAsync(key1, key2, key3) {
  1537. var value;
  1538. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1539. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1540. if (xref) {
  1541. return xref.fetchIfRefAsync(value, suppressEncryption);
  1542. }
  1543. return Promise.resolve(value);
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. if (xref) {
  1547. return xref.fetchIfRefAsync(value, suppressEncryption);
  1548. }
  1549. return Promise.resolve(value);
  1550. }
  1551. value = this.map[key3] || null;
  1552. if (xref) {
  1553. return xref.fetchIfRefAsync(value, suppressEncryption);
  1554. }
  1555. return Promise.resolve(value);
  1556. },
  1557. getArray: function Dict_getArray(key1, key2, key3) {
  1558. var value = this.get(key1, key2, key3);
  1559. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1560. if (!isArray(value) || !xref) {
  1561. return value;
  1562. }
  1563. value = value.slice();
  1564. for (var i = 0, ii = value.length; i < ii; i++) {
  1565. if (!isRef(value[i])) {
  1566. continue;
  1567. }
  1568. value[i] = xref.fetch(value[i], suppressEncryption);
  1569. }
  1570. return value;
  1571. },
  1572. getRaw: function Dict_getRaw(key) {
  1573. return this.map[key];
  1574. },
  1575. getKeys: function Dict_getKeys() {
  1576. return Object.keys(this.map);
  1577. },
  1578. set: function Dict_set(key, value) {
  1579. this.map[key] = value;
  1580. },
  1581. has: function Dict_has(key) {
  1582. return key in this.map;
  1583. },
  1584. forEach: function Dict_forEach(callback) {
  1585. for (var key in this.map) {
  1586. callback(key, this.get(key));
  1587. }
  1588. }
  1589. };
  1590. Dict.empty = new Dict(null);
  1591. Dict.merge = function Dict_merge(xref, dictArray) {
  1592. var mergedDict = new Dict(xref);
  1593. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1594. var dict = dictArray[i];
  1595. if (!isDict(dict)) {
  1596. continue;
  1597. }
  1598. for (var keyName in dict.map) {
  1599. if (mergedDict.map[keyName]) {
  1600. continue;
  1601. }
  1602. mergedDict.map[keyName] = dict.map[keyName];
  1603. }
  1604. }
  1605. return mergedDict;
  1606. };
  1607. return Dict;
  1608. }();
  1609. var Ref = function RefClosure() {
  1610. function Ref(num, gen) {
  1611. this.num = num;
  1612. this.gen = gen;
  1613. }
  1614. Ref.prototype = {
  1615. toString: function Ref_toString() {
  1616. var str = this.num + 'R';
  1617. if (this.gen !== 0) {
  1618. str += this.gen;
  1619. }
  1620. return str;
  1621. }
  1622. };
  1623. return Ref;
  1624. }();
  1625. var RefSet = function RefSetClosure() {
  1626. function RefSet() {
  1627. this.dict = Object.create(null);
  1628. }
  1629. RefSet.prototype = {
  1630. has: function RefSet_has(ref) {
  1631. return ref.toString() in this.dict;
  1632. },
  1633. put: function RefSet_put(ref) {
  1634. this.dict[ref.toString()] = true;
  1635. },
  1636. remove: function RefSet_remove(ref) {
  1637. delete this.dict[ref.toString()];
  1638. }
  1639. };
  1640. return RefSet;
  1641. }();
  1642. var RefSetCache = function RefSetCacheClosure() {
  1643. function RefSetCache() {
  1644. this.dict = Object.create(null);
  1645. }
  1646. RefSetCache.prototype = {
  1647. get: function RefSetCache_get(ref) {
  1648. return this.dict[ref.toString()];
  1649. },
  1650. has: function RefSetCache_has(ref) {
  1651. return ref.toString() in this.dict;
  1652. },
  1653. put: function RefSetCache_put(ref, obj) {
  1654. this.dict[ref.toString()] = obj;
  1655. },
  1656. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1657. this.dict[ref.toString()] = this.get(aliasRef);
  1658. },
  1659. forEach: function RefSetCache_forEach(fn, thisArg) {
  1660. for (var i in this.dict) {
  1661. fn.call(thisArg, this.dict[i]);
  1662. }
  1663. },
  1664. clear: function RefSetCache_clear() {
  1665. this.dict = Object.create(null);
  1666. }
  1667. };
  1668. return RefSetCache;
  1669. }();
  1670. function isEOF(v) {
  1671. return v === EOF;
  1672. }
  1673. function isName(v, name) {
  1674. return v instanceof Name && (name === undefined || v.name === name);
  1675. }
  1676. function isCmd(v, cmd) {
  1677. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1678. }
  1679. function isDict(v, type) {
  1680. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1681. }
  1682. function isRef(v) {
  1683. return v instanceof Ref;
  1684. }
  1685. function isRefsEqual(v1, v2) {
  1686. return v1.num === v2.num && v1.gen === v2.gen;
  1687. }
  1688. function isStream(v) {
  1689. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1690. }
  1691. exports.EOF = EOF;
  1692. exports.Cmd = Cmd;
  1693. exports.Dict = Dict;
  1694. exports.Name = Name;
  1695. exports.Ref = Ref;
  1696. exports.RefSet = RefSet;
  1697. exports.RefSetCache = RefSetCache;
  1698. exports.isEOF = isEOF;
  1699. exports.isCmd = isCmd;
  1700. exports.isDict = isDict;
  1701. exports.isName = isName;
  1702. exports.isRef = isRef;
  1703. exports.isRefsEqual = isRefsEqual;
  1704. exports.isStream = isStream;
  1705. /***/ }),
  1706. /* 2 */
  1707. /***/ (function(module, exports, __w_pdfjs_require__) {
  1708. "use strict";
  1709. var sharedUtil = __w_pdfjs_require__(0);
  1710. var corePrimitives = __w_pdfjs_require__(1);
  1711. var coreJbig2 = __w_pdfjs_require__(35);
  1712. var coreJpg = __w_pdfjs_require__(36);
  1713. var coreJpx = __w_pdfjs_require__(19);
  1714. var Util = sharedUtil.Util;
  1715. var error = sharedUtil.error;
  1716. var info = sharedUtil.info;
  1717. var isInt = sharedUtil.isInt;
  1718. var isArray = sharedUtil.isArray;
  1719. var createObjectURL = sharedUtil.createObjectURL;
  1720. var shadow = sharedUtil.shadow;
  1721. var isSpace = sharedUtil.isSpace;
  1722. var Dict = corePrimitives.Dict;
  1723. var isDict = corePrimitives.isDict;
  1724. var isStream = corePrimitives.isStream;
  1725. var Jbig2Image = coreJbig2.Jbig2Image;
  1726. var JpegImage = coreJpg.JpegImage;
  1727. var JpxImage = coreJpx.JpxImage;
  1728. var Stream = function StreamClosure() {
  1729. function Stream(arrayBuffer, start, length, dict) {
  1730. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1731. this.start = start || 0;
  1732. this.pos = this.start;
  1733. this.end = start + length || this.bytes.length;
  1734. this.dict = dict;
  1735. }
  1736. Stream.prototype = {
  1737. get length() {
  1738. return this.end - this.start;
  1739. },
  1740. get isEmpty() {
  1741. return this.length === 0;
  1742. },
  1743. getByte: function Stream_getByte() {
  1744. if (this.pos >= this.end) {
  1745. return -1;
  1746. }
  1747. return this.bytes[this.pos++];
  1748. },
  1749. getUint16: function Stream_getUint16() {
  1750. var b0 = this.getByte();
  1751. var b1 = this.getByte();
  1752. if (b0 === -1 || b1 === -1) {
  1753. return -1;
  1754. }
  1755. return (b0 << 8) + b1;
  1756. },
  1757. getInt32: function Stream_getInt32() {
  1758. var b0 = this.getByte();
  1759. var b1 = this.getByte();
  1760. var b2 = this.getByte();
  1761. var b3 = this.getByte();
  1762. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1763. },
  1764. getBytes: function Stream_getBytes(length) {
  1765. var bytes = this.bytes;
  1766. var pos = this.pos;
  1767. var strEnd = this.end;
  1768. if (!length) {
  1769. return bytes.subarray(pos, strEnd);
  1770. }
  1771. var end = pos + length;
  1772. if (end > strEnd) {
  1773. end = strEnd;
  1774. }
  1775. this.pos = end;
  1776. return bytes.subarray(pos, end);
  1777. },
  1778. peekByte: function Stream_peekByte() {
  1779. var peekedByte = this.getByte();
  1780. this.pos--;
  1781. return peekedByte;
  1782. },
  1783. peekBytes: function Stream_peekBytes(length) {
  1784. var bytes = this.getBytes(length);
  1785. this.pos -= bytes.length;
  1786. return bytes;
  1787. },
  1788. skip: function Stream_skip(n) {
  1789. if (!n) {
  1790. n = 1;
  1791. }
  1792. this.pos += n;
  1793. },
  1794. reset: function Stream_reset() {
  1795. this.pos = this.start;
  1796. },
  1797. moveStart: function Stream_moveStart() {
  1798. this.start = this.pos;
  1799. },
  1800. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1801. return new Stream(this.bytes.buffer, start, length, dict);
  1802. }
  1803. };
  1804. return Stream;
  1805. }();
  1806. var StringStream = function StringStreamClosure() {
  1807. function StringStream(str) {
  1808. var length = str.length;
  1809. var bytes = new Uint8Array(length);
  1810. for (var n = 0; n < length; ++n) {
  1811. bytes[n] = str.charCodeAt(n);
  1812. }
  1813. Stream.call(this, bytes);
  1814. }
  1815. StringStream.prototype = Stream.prototype;
  1816. return StringStream;
  1817. }();
  1818. var DecodeStream = function DecodeStreamClosure() {
  1819. var emptyBuffer = new Uint8Array(0);
  1820. function DecodeStream(maybeMinBufferLength) {
  1821. this.pos = 0;
  1822. this.bufferLength = 0;
  1823. this.eof = false;
  1824. this.buffer = emptyBuffer;
  1825. this.minBufferLength = 512;
  1826. if (maybeMinBufferLength) {
  1827. while (this.minBufferLength < maybeMinBufferLength) {
  1828. this.minBufferLength *= 2;
  1829. }
  1830. }
  1831. }
  1832. DecodeStream.prototype = {
  1833. get isEmpty() {
  1834. while (!this.eof && this.bufferLength === 0) {
  1835. this.readBlock();
  1836. }
  1837. return this.bufferLength === 0;
  1838. },
  1839. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1840. var buffer = this.buffer;
  1841. if (requested <= buffer.byteLength) {
  1842. return buffer;
  1843. }
  1844. var size = this.minBufferLength;
  1845. while (size < requested) {
  1846. size *= 2;
  1847. }
  1848. var buffer2 = new Uint8Array(size);
  1849. buffer2.set(buffer);
  1850. return this.buffer = buffer2;
  1851. },
  1852. getByte: function DecodeStream_getByte() {
  1853. var pos = this.pos;
  1854. while (this.bufferLength <= pos) {
  1855. if (this.eof) {
  1856. return -1;
  1857. }
  1858. this.readBlock();
  1859. }
  1860. return this.buffer[this.pos++];
  1861. },
  1862. getUint16: function DecodeStream_getUint16() {
  1863. var b0 = this.getByte();
  1864. var b1 = this.getByte();
  1865. if (b0 === -1 || b1 === -1) {
  1866. return -1;
  1867. }
  1868. return (b0 << 8) + b1;
  1869. },
  1870. getInt32: function DecodeStream_getInt32() {
  1871. var b0 = this.getByte();
  1872. var b1 = this.getByte();
  1873. var b2 = this.getByte();
  1874. var b3 = this.getByte();
  1875. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1876. },
  1877. getBytes: function DecodeStream_getBytes(length) {
  1878. var end, pos = this.pos;
  1879. if (length) {
  1880. this.ensureBuffer(pos + length);
  1881. end = pos + length;
  1882. while (!this.eof && this.bufferLength < end) {
  1883. this.readBlock();
  1884. }
  1885. var bufEnd = this.bufferLength;
  1886. if (end > bufEnd) {
  1887. end = bufEnd;
  1888. }
  1889. } else {
  1890. while (!this.eof) {
  1891. this.readBlock();
  1892. }
  1893. end = this.bufferLength;
  1894. }
  1895. this.pos = end;
  1896. return this.buffer.subarray(pos, end);
  1897. },
  1898. peekByte: function DecodeStream_peekByte() {
  1899. var peekedByte = this.getByte();
  1900. this.pos--;
  1901. return peekedByte;
  1902. },
  1903. peekBytes: function DecodeStream_peekBytes(length) {
  1904. var bytes = this.getBytes(length);
  1905. this.pos -= bytes.length;
  1906. return bytes;
  1907. },
  1908. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1909. var end = start + length;
  1910. while (this.bufferLength <= end && !this.eof) {
  1911. this.readBlock();
  1912. }
  1913. return new Stream(this.buffer, start, length, dict);
  1914. },
  1915. skip: function DecodeStream_skip(n) {
  1916. if (!n) {
  1917. n = 1;
  1918. }
  1919. this.pos += n;
  1920. },
  1921. reset: function DecodeStream_reset() {
  1922. this.pos = 0;
  1923. },
  1924. getBaseStreams: function DecodeStream_getBaseStreams() {
  1925. if (this.str && this.str.getBaseStreams) {
  1926. return this.str.getBaseStreams();
  1927. }
  1928. return [];
  1929. }
  1930. };
  1931. return DecodeStream;
  1932. }();
  1933. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1934. function StreamsSequenceStream(streams) {
  1935. this.streams = streams;
  1936. DecodeStream.call(this, null);
  1937. }
  1938. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1939. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1940. var streams = this.streams;
  1941. if (streams.length === 0) {
  1942. this.eof = true;
  1943. return;
  1944. }
  1945. var stream = streams.shift();
  1946. var chunk = stream.getBytes();
  1947. var bufferLength = this.bufferLength;
  1948. var newLength = bufferLength + chunk.length;
  1949. var buffer = this.ensureBuffer(newLength);
  1950. buffer.set(chunk, bufferLength);
  1951. this.bufferLength = newLength;
  1952. };
  1953. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1954. var baseStreams = [];
  1955. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1956. var stream = this.streams[i];
  1957. if (stream.getBaseStreams) {
  1958. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1959. }
  1960. }
  1961. return baseStreams;
  1962. };
  1963. return StreamsSequenceStream;
  1964. }();
  1965. var FlateStream = function FlateStreamClosure() {
  1966. var codeLenCodeMap = new Int32Array([
  1967. 16,
  1968. 17,
  1969. 18,
  1970. 0,
  1971. 8,
  1972. 7,
  1973. 9,
  1974. 6,
  1975. 10,
  1976. 5,
  1977. 11,
  1978. 4,
  1979. 12,
  1980. 3,
  1981. 13,
  1982. 2,
  1983. 14,
  1984. 1,
  1985. 15
  1986. ]);
  1987. var lengthDecode = new Int32Array([
  1988. 0x00003,
  1989. 0x00004,
  1990. 0x00005,
  1991. 0x00006,
  1992. 0x00007,
  1993. 0x00008,
  1994. 0x00009,
  1995. 0x0000a,
  1996. 0x1000b,
  1997. 0x1000d,
  1998. 0x1000f,
  1999. 0x10011,
  2000. 0x20013,
  2001. 0x20017,
  2002. 0x2001b,
  2003. 0x2001f,
  2004. 0x30023,
  2005. 0x3002b,
  2006. 0x30033,
  2007. 0x3003b,
  2008. 0x40043,
  2009. 0x40053,
  2010. 0x40063,
  2011. 0x40073,
  2012. 0x50083,
  2013. 0x500a3,
  2014. 0x500c3,
  2015. 0x500e3,
  2016. 0x00102,
  2017. 0x00102,
  2018. 0x00102
  2019. ]);
  2020. var distDecode = new Int32Array([
  2021. 0x00001,
  2022. 0x00002,
  2023. 0x00003,
  2024. 0x00004,
  2025. 0x10005,
  2026. 0x10007,
  2027. 0x20009,
  2028. 0x2000d,
  2029. 0x30011,
  2030. 0x30019,
  2031. 0x40021,
  2032. 0x40031,
  2033. 0x50041,
  2034. 0x50061,
  2035. 0x60081,
  2036. 0x600c1,
  2037. 0x70101,
  2038. 0x70181,
  2039. 0x80201,
  2040. 0x80301,
  2041. 0x90401,
  2042. 0x90601,
  2043. 0xa0801,
  2044. 0xa0c01,
  2045. 0xb1001,
  2046. 0xb1801,
  2047. 0xc2001,
  2048. 0xc3001,
  2049. 0xd4001,
  2050. 0xd6001
  2051. ]);
  2052. var fixedLitCodeTab = [
  2053. new Int32Array([
  2054. 0x70100,
  2055. 0x80050,
  2056. 0x80010,
  2057. 0x80118,
  2058. 0x70110,
  2059. 0x80070,
  2060. 0x80030,
  2061. 0x900c0,
  2062. 0x70108,
  2063. 0x80060,
  2064. 0x80020,
  2065. 0x900a0,
  2066. 0x80000,
  2067. 0x80080,
  2068. 0x80040,
  2069. 0x900e0,
  2070. 0x70104,
  2071. 0x80058,
  2072. 0x80018,
  2073. 0x90090,
  2074. 0x70114,
  2075. 0x80078,
  2076. 0x80038,
  2077. 0x900d0,
  2078. 0x7010c,
  2079. 0x80068,
  2080. 0x80028,
  2081. 0x900b0,
  2082. 0x80008,
  2083. 0x80088,
  2084. 0x80048,
  2085. 0x900f0,
  2086. 0x70102,
  2087. 0x80054,
  2088. 0x80014,
  2089. 0x8011c,
  2090. 0x70112,
  2091. 0x80074,
  2092. 0x80034,
  2093. 0x900c8,
  2094. 0x7010a,
  2095. 0x80064,
  2096. 0x80024,
  2097. 0x900a8,
  2098. 0x80004,
  2099. 0x80084,
  2100. 0x80044,
  2101. 0x900e8,
  2102. 0x70106,
  2103. 0x8005c,
  2104. 0x8001c,
  2105. 0x90098,
  2106. 0x70116,
  2107. 0x8007c,
  2108. 0x8003c,
  2109. 0x900d8,
  2110. 0x7010e,
  2111. 0x8006c,
  2112. 0x8002c,
  2113. 0x900b8,
  2114. 0x8000c,
  2115. 0x8008c,
  2116. 0x8004c,
  2117. 0x900f8,
  2118. 0x70101,
  2119. 0x80052,
  2120. 0x80012,
  2121. 0x8011a,
  2122. 0x70111,
  2123. 0x80072,
  2124. 0x80032,
  2125. 0x900c4,
  2126. 0x70109,
  2127. 0x80062,
  2128. 0x80022,
  2129. 0x900a4,
  2130. 0x80002,
  2131. 0x80082,
  2132. 0x80042,
  2133. 0x900e4,
  2134. 0x70105,
  2135. 0x8005a,
  2136. 0x8001a,
  2137. 0x90094,
  2138. 0x70115,
  2139. 0x8007a,
  2140. 0x8003a,
  2141. 0x900d4,
  2142. 0x7010d,
  2143. 0x8006a,
  2144. 0x8002a,
  2145. 0x900b4,
  2146. 0x8000a,
  2147. 0x8008a,
  2148. 0x8004a,
  2149. 0x900f4,
  2150. 0x70103,
  2151. 0x80056,
  2152. 0x80016,
  2153. 0x8011e,
  2154. 0x70113,
  2155. 0x80076,
  2156. 0x80036,
  2157. 0x900cc,
  2158. 0x7010b,
  2159. 0x80066,
  2160. 0x80026,
  2161. 0x900ac,
  2162. 0x80006,
  2163. 0x80086,
  2164. 0x80046,
  2165. 0x900ec,
  2166. 0x70107,
  2167. 0x8005e,
  2168. 0x8001e,
  2169. 0x9009c,
  2170. 0x70117,
  2171. 0x8007e,
  2172. 0x8003e,
  2173. 0x900dc,
  2174. 0x7010f,
  2175. 0x8006e,
  2176. 0x8002e,
  2177. 0x900bc,
  2178. 0x8000e,
  2179. 0x8008e,
  2180. 0x8004e,
  2181. 0x900fc,
  2182. 0x70100,
  2183. 0x80051,
  2184. 0x80011,
  2185. 0x80119,
  2186. 0x70110,
  2187. 0x80071,
  2188. 0x80031,
  2189. 0x900c2,
  2190. 0x70108,
  2191. 0x80061,
  2192. 0x80021,
  2193. 0x900a2,
  2194. 0x80001,
  2195. 0x80081,
  2196. 0x80041,
  2197. 0x900e2,
  2198. 0x70104,
  2199. 0x80059,
  2200. 0x80019,
  2201. 0x90092,
  2202. 0x70114,
  2203. 0x80079,
  2204. 0x80039,
  2205. 0x900d2,
  2206. 0x7010c,
  2207. 0x80069,
  2208. 0x80029,
  2209. 0x900b2,
  2210. 0x80009,
  2211. 0x80089,
  2212. 0x80049,
  2213. 0x900f2,
  2214. 0x70102,
  2215. 0x80055,
  2216. 0x80015,
  2217. 0x8011d,
  2218. 0x70112,
  2219. 0x80075,
  2220. 0x80035,
  2221. 0x900ca,
  2222. 0x7010a,
  2223. 0x80065,
  2224. 0x80025,
  2225. 0x900aa,
  2226. 0x80005,
  2227. 0x80085,
  2228. 0x80045,
  2229. 0x900ea,
  2230. 0x70106,
  2231. 0x8005d,
  2232. 0x8001d,
  2233. 0x9009a,
  2234. 0x70116,
  2235. 0x8007d,
  2236. 0x8003d,
  2237. 0x900da,
  2238. 0x7010e,
  2239. 0x8006d,
  2240. 0x8002d,
  2241. 0x900ba,
  2242. 0x8000d,
  2243. 0x8008d,
  2244. 0x8004d,
  2245. 0x900fa,
  2246. 0x70101,
  2247. 0x80053,
  2248. 0x80013,
  2249. 0x8011b,
  2250. 0x70111,
  2251. 0x80073,
  2252. 0x80033,
  2253. 0x900c6,
  2254. 0x70109,
  2255. 0x80063,
  2256. 0x80023,
  2257. 0x900a6,
  2258. 0x80003,
  2259. 0x80083,
  2260. 0x80043,
  2261. 0x900e6,
  2262. 0x70105,
  2263. 0x8005b,
  2264. 0x8001b,
  2265. 0x90096,
  2266. 0x70115,
  2267. 0x8007b,
  2268. 0x8003b,
  2269. 0x900d6,
  2270. 0x7010d,
  2271. 0x8006b,
  2272. 0x8002b,
  2273. 0x900b6,
  2274. 0x8000b,
  2275. 0x8008b,
  2276. 0x8004b,
  2277. 0x900f6,
  2278. 0x70103,
  2279. 0x80057,
  2280. 0x80017,
  2281. 0x8011f,
  2282. 0x70113,
  2283. 0x80077,
  2284. 0x80037,
  2285. 0x900ce,
  2286. 0x7010b,
  2287. 0x80067,
  2288. 0x80027,
  2289. 0x900ae,
  2290. 0x80007,
  2291. 0x80087,
  2292. 0x80047,
  2293. 0x900ee,
  2294. 0x70107,
  2295. 0x8005f,
  2296. 0x8001f,
  2297. 0x9009e,
  2298. 0x70117,
  2299. 0x8007f,
  2300. 0x8003f,
  2301. 0x900de,
  2302. 0x7010f,
  2303. 0x8006f,
  2304. 0x8002f,
  2305. 0x900be,
  2306. 0x8000f,
  2307. 0x8008f,
  2308. 0x8004f,
  2309. 0x900fe,
  2310. 0x70100,
  2311. 0x80050,
  2312. 0x80010,
  2313. 0x80118,
  2314. 0x70110,
  2315. 0x80070,
  2316. 0x80030,
  2317. 0x900c1,
  2318. 0x70108,
  2319. 0x80060,
  2320. 0x80020,
  2321. 0x900a1,
  2322. 0x80000,
  2323. 0x80080,
  2324. 0x80040,
  2325. 0x900e1,
  2326. 0x70104,
  2327. 0x80058,
  2328. 0x80018,
  2329. 0x90091,
  2330. 0x70114,
  2331. 0x80078,
  2332. 0x80038,
  2333. 0x900d1,
  2334. 0x7010c,
  2335. 0x80068,
  2336. 0x80028,
  2337. 0x900b1,
  2338. 0x80008,
  2339. 0x80088,
  2340. 0x80048,
  2341. 0x900f1,
  2342. 0x70102,
  2343. 0x80054,
  2344. 0x80014,
  2345. 0x8011c,
  2346. 0x70112,
  2347. 0x80074,
  2348. 0x80034,
  2349. 0x900c9,
  2350. 0x7010a,
  2351. 0x80064,
  2352. 0x80024,
  2353. 0x900a9,
  2354. 0x80004,
  2355. 0x80084,
  2356. 0x80044,
  2357. 0x900e9,
  2358. 0x70106,
  2359. 0x8005c,
  2360. 0x8001c,
  2361. 0x90099,
  2362. 0x70116,
  2363. 0x8007c,
  2364. 0x8003c,
  2365. 0x900d9,
  2366. 0x7010e,
  2367. 0x8006c,
  2368. 0x8002c,
  2369. 0x900b9,
  2370. 0x8000c,
  2371. 0x8008c,
  2372. 0x8004c,
  2373. 0x900f9,
  2374. 0x70101,
  2375. 0x80052,
  2376. 0x80012,
  2377. 0x8011a,
  2378. 0x70111,
  2379. 0x80072,
  2380. 0x80032,
  2381. 0x900c5,
  2382. 0x70109,
  2383. 0x80062,
  2384. 0x80022,
  2385. 0x900a5,
  2386. 0x80002,
  2387. 0x80082,
  2388. 0x80042,
  2389. 0x900e5,
  2390. 0x70105,
  2391. 0x8005a,
  2392. 0x8001a,
  2393. 0x90095,
  2394. 0x70115,
  2395. 0x8007a,
  2396. 0x8003a,
  2397. 0x900d5,
  2398. 0x7010d,
  2399. 0x8006a,
  2400. 0x8002a,
  2401. 0x900b5,
  2402. 0x8000a,
  2403. 0x8008a,
  2404. 0x8004a,
  2405. 0x900f5,
  2406. 0x70103,
  2407. 0x80056,
  2408. 0x80016,
  2409. 0x8011e,
  2410. 0x70113,
  2411. 0x80076,
  2412. 0x80036,
  2413. 0x900cd,
  2414. 0x7010b,
  2415. 0x80066,
  2416. 0x80026,
  2417. 0x900ad,
  2418. 0x80006,
  2419. 0x80086,
  2420. 0x80046,
  2421. 0x900ed,
  2422. 0x70107,
  2423. 0x8005e,
  2424. 0x8001e,
  2425. 0x9009d,
  2426. 0x70117,
  2427. 0x8007e,
  2428. 0x8003e,
  2429. 0x900dd,
  2430. 0x7010f,
  2431. 0x8006e,
  2432. 0x8002e,
  2433. 0x900bd,
  2434. 0x8000e,
  2435. 0x8008e,
  2436. 0x8004e,
  2437. 0x900fd,
  2438. 0x70100,
  2439. 0x80051,
  2440. 0x80011,
  2441. 0x80119,
  2442. 0x70110,
  2443. 0x80071,
  2444. 0x80031,
  2445. 0x900c3,
  2446. 0x70108,
  2447. 0x80061,
  2448. 0x80021,
  2449. 0x900a3,
  2450. 0x80001,
  2451. 0x80081,
  2452. 0x80041,
  2453. 0x900e3,
  2454. 0x70104,
  2455. 0x80059,
  2456. 0x80019,
  2457. 0x90093,
  2458. 0x70114,
  2459. 0x80079,
  2460. 0x80039,
  2461. 0x900d3,
  2462. 0x7010c,
  2463. 0x80069,
  2464. 0x80029,
  2465. 0x900b3,
  2466. 0x80009,
  2467. 0x80089,
  2468. 0x80049,
  2469. 0x900f3,
  2470. 0x70102,
  2471. 0x80055,
  2472. 0x80015,
  2473. 0x8011d,
  2474. 0x70112,
  2475. 0x80075,
  2476. 0x80035,
  2477. 0x900cb,
  2478. 0x7010a,
  2479. 0x80065,
  2480. 0x80025,
  2481. 0x900ab,
  2482. 0x80005,
  2483. 0x80085,
  2484. 0x80045,
  2485. 0x900eb,
  2486. 0x70106,
  2487. 0x8005d,
  2488. 0x8001d,
  2489. 0x9009b,
  2490. 0x70116,
  2491. 0x8007d,
  2492. 0x8003d,
  2493. 0x900db,
  2494. 0x7010e,
  2495. 0x8006d,
  2496. 0x8002d,
  2497. 0x900bb,
  2498. 0x8000d,
  2499. 0x8008d,
  2500. 0x8004d,
  2501. 0x900fb,
  2502. 0x70101,
  2503. 0x80053,
  2504. 0x80013,
  2505. 0x8011b,
  2506. 0x70111,
  2507. 0x80073,
  2508. 0x80033,
  2509. 0x900c7,
  2510. 0x70109,
  2511. 0x80063,
  2512. 0x80023,
  2513. 0x900a7,
  2514. 0x80003,
  2515. 0x80083,
  2516. 0x80043,
  2517. 0x900e7,
  2518. 0x70105,
  2519. 0x8005b,
  2520. 0x8001b,
  2521. 0x90097,
  2522. 0x70115,
  2523. 0x8007b,
  2524. 0x8003b,
  2525. 0x900d7,
  2526. 0x7010d,
  2527. 0x8006b,
  2528. 0x8002b,
  2529. 0x900b7,
  2530. 0x8000b,
  2531. 0x8008b,
  2532. 0x8004b,
  2533. 0x900f7,
  2534. 0x70103,
  2535. 0x80057,
  2536. 0x80017,
  2537. 0x8011f,
  2538. 0x70113,
  2539. 0x80077,
  2540. 0x80037,
  2541. 0x900cf,
  2542. 0x7010b,
  2543. 0x80067,
  2544. 0x80027,
  2545. 0x900af,
  2546. 0x80007,
  2547. 0x80087,
  2548. 0x80047,
  2549. 0x900ef,
  2550. 0x70107,
  2551. 0x8005f,
  2552. 0x8001f,
  2553. 0x9009f,
  2554. 0x70117,
  2555. 0x8007f,
  2556. 0x8003f,
  2557. 0x900df,
  2558. 0x7010f,
  2559. 0x8006f,
  2560. 0x8002f,
  2561. 0x900bf,
  2562. 0x8000f,
  2563. 0x8008f,
  2564. 0x8004f,
  2565. 0x900ff
  2566. ]),
  2567. 9
  2568. ];
  2569. var fixedDistCodeTab = [
  2570. new Int32Array([
  2571. 0x50000,
  2572. 0x50010,
  2573. 0x50008,
  2574. 0x50018,
  2575. 0x50004,
  2576. 0x50014,
  2577. 0x5000c,
  2578. 0x5001c,
  2579. 0x50002,
  2580. 0x50012,
  2581. 0x5000a,
  2582. 0x5001a,
  2583. 0x50006,
  2584. 0x50016,
  2585. 0x5000e,
  2586. 0x00000,
  2587. 0x50001,
  2588. 0x50011,
  2589. 0x50009,
  2590. 0x50019,
  2591. 0x50005,
  2592. 0x50015,
  2593. 0x5000d,
  2594. 0x5001d,
  2595. 0x50003,
  2596. 0x50013,
  2597. 0x5000b,
  2598. 0x5001b,
  2599. 0x50007,
  2600. 0x50017,
  2601. 0x5000f,
  2602. 0x00000
  2603. ]),
  2604. 5
  2605. ];
  2606. function FlateStream(str, maybeLength) {
  2607. this.str = str;
  2608. this.dict = str.dict;
  2609. var cmf = str.getByte();
  2610. var flg = str.getByte();
  2611. if (cmf === -1 || flg === -1) {
  2612. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2613. }
  2614. if ((cmf & 0x0f) !== 0x08) {
  2615. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2616. }
  2617. if (((cmf << 8) + flg) % 31 !== 0) {
  2618. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2619. }
  2620. if (flg & 0x20) {
  2621. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2622. }
  2623. this.codeSize = 0;
  2624. this.codeBuf = 0;
  2625. DecodeStream.call(this, maybeLength);
  2626. }
  2627. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2628. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2629. var str = this.str;
  2630. var codeSize = this.codeSize;
  2631. var codeBuf = this.codeBuf;
  2632. var b;
  2633. while (codeSize < bits) {
  2634. if ((b = str.getByte()) === -1) {
  2635. error('Bad encoding in flate stream');
  2636. }
  2637. codeBuf |= b << codeSize;
  2638. codeSize += 8;
  2639. }
  2640. b = codeBuf & (1 << bits) - 1;
  2641. this.codeBuf = codeBuf >> bits;
  2642. this.codeSize = codeSize -= bits;
  2643. return b;
  2644. };
  2645. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2646. var str = this.str;
  2647. var codes = table[0];
  2648. var maxLen = table[1];
  2649. var codeSize = this.codeSize;
  2650. var codeBuf = this.codeBuf;
  2651. var b;
  2652. while (codeSize < maxLen) {
  2653. if ((b = str.getByte()) === -1) {
  2654. break;
  2655. }
  2656. codeBuf |= b << codeSize;
  2657. codeSize += 8;
  2658. }
  2659. var code = codes[codeBuf & (1 << maxLen) - 1];
  2660. var codeLen = code >> 16;
  2661. var codeVal = code & 0xffff;
  2662. if (codeLen < 1 || codeSize < codeLen) {
  2663. error('Bad encoding in flate stream');
  2664. }
  2665. this.codeBuf = codeBuf >> codeLen;
  2666. this.codeSize = codeSize - codeLen;
  2667. return codeVal;
  2668. };
  2669. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2670. var n = lengths.length;
  2671. var maxLen = 0;
  2672. var i;
  2673. for (i = 0; i < n; ++i) {
  2674. if (lengths[i] > maxLen) {
  2675. maxLen = lengths[i];
  2676. }
  2677. }
  2678. var size = 1 << maxLen;
  2679. var codes = new Int32Array(size);
  2680. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2681. for (var val = 0; val < n; ++val) {
  2682. if (lengths[val] === len) {
  2683. var code2 = 0;
  2684. var t = code;
  2685. for (i = 0; i < len; ++i) {
  2686. code2 = code2 << 1 | t & 1;
  2687. t >>= 1;
  2688. }
  2689. for (i = code2; i < size; i += skip) {
  2690. codes[i] = len << 16 | val;
  2691. }
  2692. ++code;
  2693. }
  2694. }
  2695. }
  2696. return [
  2697. codes,
  2698. maxLen
  2699. ];
  2700. };
  2701. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2702. var buffer, len;
  2703. var str = this.str;
  2704. var hdr = this.getBits(3);
  2705. if (hdr & 1) {
  2706. this.eof = true;
  2707. }
  2708. hdr >>= 1;
  2709. if (hdr === 0) {
  2710. var b;
  2711. if ((b = str.getByte()) === -1) {
  2712. error('Bad block header in flate stream');
  2713. }
  2714. var blockLen = b;
  2715. if ((b = str.getByte()) === -1) {
  2716. error('Bad block header in flate stream');
  2717. }
  2718. blockLen |= b << 8;
  2719. if ((b = str.getByte()) === -1) {
  2720. error('Bad block header in flate stream');
  2721. }
  2722. var check = b;
  2723. if ((b = str.getByte()) === -1) {
  2724. error('Bad block header in flate stream');
  2725. }
  2726. check |= b << 8;
  2727. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2728. error('Bad uncompressed block length in flate stream');
  2729. }
  2730. this.codeBuf = 0;
  2731. this.codeSize = 0;
  2732. var bufferLength = this.bufferLength;
  2733. buffer = this.ensureBuffer(bufferLength + blockLen);
  2734. var end = bufferLength + blockLen;
  2735. this.bufferLength = end;
  2736. if (blockLen === 0) {
  2737. if (str.peekByte() === -1) {
  2738. this.eof = true;
  2739. }
  2740. } else {
  2741. for (var n = bufferLength; n < end; ++n) {
  2742. if ((b = str.getByte()) === -1) {
  2743. this.eof = true;
  2744. break;
  2745. }
  2746. buffer[n] = b;
  2747. }
  2748. }
  2749. return;
  2750. }
  2751. var litCodeTable;
  2752. var distCodeTable;
  2753. if (hdr === 1) {
  2754. litCodeTable = fixedLitCodeTab;
  2755. distCodeTable = fixedDistCodeTab;
  2756. } else if (hdr === 2) {
  2757. var numLitCodes = this.getBits(5) + 257;
  2758. var numDistCodes = this.getBits(5) + 1;
  2759. var numCodeLenCodes = this.getBits(4) + 4;
  2760. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2761. var i;
  2762. for (i = 0; i < numCodeLenCodes; ++i) {
  2763. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2764. }
  2765. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2766. len = 0;
  2767. i = 0;
  2768. var codes = numLitCodes + numDistCodes;
  2769. var codeLengths = new Uint8Array(codes);
  2770. var bitsLength, bitsOffset, what;
  2771. while (i < codes) {
  2772. var code = this.getCode(codeLenCodeTab);
  2773. if (code === 16) {
  2774. bitsLength = 2;
  2775. bitsOffset = 3;
  2776. what = len;
  2777. } else if (code === 17) {
  2778. bitsLength = 3;
  2779. bitsOffset = 3;
  2780. what = len = 0;
  2781. } else if (code === 18) {
  2782. bitsLength = 7;
  2783. bitsOffset = 11;
  2784. what = len = 0;
  2785. } else {
  2786. codeLengths[i++] = len = code;
  2787. continue;
  2788. }
  2789. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2790. while (repeatLength-- > 0) {
  2791. codeLengths[i++] = what;
  2792. }
  2793. }
  2794. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2795. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2796. } else {
  2797. error('Unknown block type in flate stream');
  2798. }
  2799. buffer = this.buffer;
  2800. var limit = buffer ? buffer.length : 0;
  2801. var pos = this.bufferLength;
  2802. while (true) {
  2803. var code1 = this.getCode(litCodeTable);
  2804. if (code1 < 256) {
  2805. if (pos + 1 >= limit) {
  2806. buffer = this.ensureBuffer(pos + 1);
  2807. limit = buffer.length;
  2808. }
  2809. buffer[pos++] = code1;
  2810. continue;
  2811. }
  2812. if (code1 === 256) {
  2813. this.bufferLength = pos;
  2814. return;
  2815. }
  2816. code1 -= 257;
  2817. code1 = lengthDecode[code1];
  2818. var code2 = code1 >> 16;
  2819. if (code2 > 0) {
  2820. code2 = this.getBits(code2);
  2821. }
  2822. len = (code1 & 0xffff) + code2;
  2823. code1 = this.getCode(distCodeTable);
  2824. code1 = distDecode[code1];
  2825. code2 = code1 >> 16;
  2826. if (code2 > 0) {
  2827. code2 = this.getBits(code2);
  2828. }
  2829. var dist = (code1 & 0xffff) + code2;
  2830. if (pos + len >= limit) {
  2831. buffer = this.ensureBuffer(pos + len);
  2832. limit = buffer.length;
  2833. }
  2834. for (var k = 0; k < len; ++k, ++pos) {
  2835. buffer[pos] = buffer[pos - dist];
  2836. }
  2837. }
  2838. };
  2839. return FlateStream;
  2840. }();
  2841. var PredictorStream = function PredictorStreamClosure() {
  2842. function PredictorStream(str, maybeLength, params) {
  2843. if (!isDict(params)) {
  2844. return str;
  2845. }
  2846. var predictor = this.predictor = params.get('Predictor') || 1;
  2847. if (predictor <= 1) {
  2848. return str;
  2849. }
  2850. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2851. error('Unsupported predictor: ' + predictor);
  2852. }
  2853. if (predictor === 2) {
  2854. this.readBlock = this.readBlockTiff;
  2855. } else {
  2856. this.readBlock = this.readBlockPng;
  2857. }
  2858. this.str = str;
  2859. this.dict = str.dict;
  2860. var colors = this.colors = params.get('Colors') || 1;
  2861. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2862. var columns = this.columns = params.get('Columns') || 1;
  2863. this.pixBytes = colors * bits + 7 >> 3;
  2864. this.rowBytes = columns * colors * bits + 7 >> 3;
  2865. DecodeStream.call(this, maybeLength);
  2866. return this;
  2867. }
  2868. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2869. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2870. var rowBytes = this.rowBytes;
  2871. var bufferLength = this.bufferLength;
  2872. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2873. var bits = this.bits;
  2874. var colors = this.colors;
  2875. var rawBytes = this.str.getBytes(rowBytes);
  2876. this.eof = !rawBytes.length;
  2877. if (this.eof) {
  2878. return;
  2879. }
  2880. var inbuf = 0, outbuf = 0;
  2881. var inbits = 0, outbits = 0;
  2882. var pos = bufferLength;
  2883. var i;
  2884. if (bits === 1 && colors === 1) {
  2885. for (i = 0; i < rowBytes; ++i) {
  2886. var c = rawBytes[i] ^ inbuf;
  2887. c ^= c >> 1;
  2888. c ^= c >> 2;
  2889. c ^= c >> 4;
  2890. inbuf = (c & 1) << 7;
  2891. buffer[pos++] = c;
  2892. }
  2893. } else if (bits === 8) {
  2894. for (i = 0; i < colors; ++i) {
  2895. buffer[pos++] = rawBytes[i];
  2896. }
  2897. for (; i < rowBytes; ++i) {
  2898. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2899. pos++;
  2900. }
  2901. } else {
  2902. var compArray = new Uint8Array(colors + 1);
  2903. var bitMask = (1 << bits) - 1;
  2904. var j = 0, k = bufferLength;
  2905. var columns = this.columns;
  2906. for (i = 0; i < columns; ++i) {
  2907. for (var kk = 0; kk < colors; ++kk) {
  2908. if (inbits < bits) {
  2909. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2910. inbits += 8;
  2911. }
  2912. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2913. inbits -= bits;
  2914. outbuf = outbuf << bits | compArray[kk];
  2915. outbits += bits;
  2916. if (outbits >= 8) {
  2917. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2918. outbits -= 8;
  2919. }
  2920. }
  2921. }
  2922. if (outbits > 0) {
  2923. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2924. }
  2925. }
  2926. this.bufferLength += rowBytes;
  2927. };
  2928. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2929. var rowBytes = this.rowBytes;
  2930. var pixBytes = this.pixBytes;
  2931. var predictor = this.str.getByte();
  2932. var rawBytes = this.str.getBytes(rowBytes);
  2933. this.eof = !rawBytes.length;
  2934. if (this.eof) {
  2935. return;
  2936. }
  2937. var bufferLength = this.bufferLength;
  2938. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2939. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2940. if (prevRow.length === 0) {
  2941. prevRow = new Uint8Array(rowBytes);
  2942. }
  2943. var i, j = bufferLength, up, c;
  2944. switch (predictor) {
  2945. case 0:
  2946. for (i = 0; i < rowBytes; ++i) {
  2947. buffer[j++] = rawBytes[i];
  2948. }
  2949. break;
  2950. case 1:
  2951. for (i = 0; i < pixBytes; ++i) {
  2952. buffer[j++] = rawBytes[i];
  2953. }
  2954. for (; i < rowBytes; ++i) {
  2955. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2956. j++;
  2957. }
  2958. break;
  2959. case 2:
  2960. for (i = 0; i < rowBytes; ++i) {
  2961. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2962. }
  2963. break;
  2964. case 3:
  2965. for (i = 0; i < pixBytes; ++i) {
  2966. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2967. }
  2968. for (; i < rowBytes; ++i) {
  2969. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2970. j++;
  2971. }
  2972. break;
  2973. case 4:
  2974. for (i = 0; i < pixBytes; ++i) {
  2975. up = prevRow[i];
  2976. c = rawBytes[i];
  2977. buffer[j++] = up + c;
  2978. }
  2979. for (; i < rowBytes; ++i) {
  2980. up = prevRow[i];
  2981. var upLeft = prevRow[i - pixBytes];
  2982. var left = buffer[j - pixBytes];
  2983. var p = left + up - upLeft;
  2984. var pa = p - left;
  2985. if (pa < 0) {
  2986. pa = -pa;
  2987. }
  2988. var pb = p - up;
  2989. if (pb < 0) {
  2990. pb = -pb;
  2991. }
  2992. var pc = p - upLeft;
  2993. if (pc < 0) {
  2994. pc = -pc;
  2995. }
  2996. c = rawBytes[i];
  2997. if (pa <= pb && pa <= pc) {
  2998. buffer[j++] = left + c;
  2999. } else if (pb <= pc) {
  3000. buffer[j++] = up + c;
  3001. } else {
  3002. buffer[j++] = upLeft + c;
  3003. }
  3004. }
  3005. break;
  3006. default:
  3007. error('Unsupported predictor: ' + predictor);
  3008. }
  3009. this.bufferLength += rowBytes;
  3010. };
  3011. return PredictorStream;
  3012. }();
  3013. var JpegStream = function JpegStreamClosure() {
  3014. function JpegStream(stream, maybeLength, dict, params) {
  3015. var ch;
  3016. while ((ch = stream.getByte()) !== -1) {
  3017. if (ch === 0xFF) {
  3018. stream.skip(-1);
  3019. break;
  3020. }
  3021. }
  3022. this.stream = stream;
  3023. this.maybeLength = maybeLength;
  3024. this.dict = dict;
  3025. this.params = params;
  3026. DecodeStream.call(this, maybeLength);
  3027. }
  3028. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3029. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3030. get: function JpegStream_bytes() {
  3031. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3032. },
  3033. configurable: true
  3034. });
  3035. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3036. if (this.bufferLength) {
  3037. return;
  3038. }
  3039. var jpegImage = new JpegImage();
  3040. var decodeArr = this.dict.getArray('Decode', 'D');
  3041. if (this.forceRGB && isArray(decodeArr)) {
  3042. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3043. var decodeArrLength = decodeArr.length;
  3044. var transform = new Int32Array(decodeArrLength);
  3045. var transformNeeded = false;
  3046. var maxValue = (1 << bitsPerComponent) - 1;
  3047. for (var i = 0; i < decodeArrLength; i += 2) {
  3048. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3049. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3050. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3051. transformNeeded = true;
  3052. }
  3053. }
  3054. if (transformNeeded) {
  3055. jpegImage.decodeTransform = transform;
  3056. }
  3057. }
  3058. if (isDict(this.params)) {
  3059. var colorTransform = this.params.get('ColorTransform');
  3060. if (isInt(colorTransform)) {
  3061. jpegImage.colorTransform = colorTransform;
  3062. }
  3063. }
  3064. jpegImage.parse(this.bytes);
  3065. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3066. this.buffer = data;
  3067. this.bufferLength = data.length;
  3068. this.eof = true;
  3069. };
  3070. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3071. this.ensureBuffer();
  3072. return this.buffer;
  3073. };
  3074. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3075. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3076. };
  3077. return JpegStream;
  3078. }();
  3079. var JpxStream = function JpxStreamClosure() {
  3080. function JpxStream(stream, maybeLength, dict, params) {
  3081. this.stream = stream;
  3082. this.maybeLength = maybeLength;
  3083. this.dict = dict;
  3084. this.params = params;
  3085. DecodeStream.call(this, maybeLength);
  3086. }
  3087. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3088. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3089. get: function JpxStream_bytes() {
  3090. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3091. },
  3092. configurable: true
  3093. });
  3094. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3095. if (this.bufferLength) {
  3096. return;
  3097. }
  3098. var jpxImage = new JpxImage();
  3099. jpxImage.parse(this.bytes);
  3100. var width = jpxImage.width;
  3101. var height = jpxImage.height;
  3102. var componentsCount = jpxImage.componentsCount;
  3103. var tileCount = jpxImage.tiles.length;
  3104. if (tileCount === 1) {
  3105. this.buffer = jpxImage.tiles[0].items;
  3106. } else {
  3107. var data = new Uint8Array(width * height * componentsCount);
  3108. for (var k = 0; k < tileCount; k++) {
  3109. var tileComponents = jpxImage.tiles[k];
  3110. var tileWidth = tileComponents.width;
  3111. var tileHeight = tileComponents.height;
  3112. var tileLeft = tileComponents.left;
  3113. var tileTop = tileComponents.top;
  3114. var src = tileComponents.items;
  3115. var srcPosition = 0;
  3116. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3117. var imgRowSize = width * componentsCount;
  3118. var tileRowSize = tileWidth * componentsCount;
  3119. for (var j = 0; j < tileHeight; j++) {
  3120. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3121. data.set(rowBytes, dataPosition);
  3122. srcPosition += tileRowSize;
  3123. dataPosition += imgRowSize;
  3124. }
  3125. }
  3126. this.buffer = data;
  3127. }
  3128. this.bufferLength = this.buffer.length;
  3129. this.eof = true;
  3130. };
  3131. return JpxStream;
  3132. }();
  3133. var Jbig2Stream = function Jbig2StreamClosure() {
  3134. function Jbig2Stream(stream, maybeLength, dict, params) {
  3135. this.stream = stream;
  3136. this.maybeLength = maybeLength;
  3137. this.dict = dict;
  3138. this.params = params;
  3139. DecodeStream.call(this, maybeLength);
  3140. }
  3141. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3142. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3143. get: function Jbig2Stream_bytes() {
  3144. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3145. },
  3146. configurable: true
  3147. });
  3148. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3149. if (this.bufferLength) {
  3150. return;
  3151. }
  3152. var jbig2Image = new Jbig2Image();
  3153. var chunks = [];
  3154. if (isDict(this.params)) {
  3155. var globalsStream = this.params.get('JBIG2Globals');
  3156. if (isStream(globalsStream)) {
  3157. var globals = globalsStream.getBytes();
  3158. chunks.push({
  3159. data: globals,
  3160. start: 0,
  3161. end: globals.length
  3162. });
  3163. }
  3164. }
  3165. chunks.push({
  3166. data: this.bytes,
  3167. start: 0,
  3168. end: this.bytes.length
  3169. });
  3170. var data = jbig2Image.parseChunks(chunks);
  3171. var dataLength = data.length;
  3172. for (var i = 0; i < dataLength; i++) {
  3173. data[i] ^= 0xFF;
  3174. }
  3175. this.buffer = data;
  3176. this.bufferLength = dataLength;
  3177. this.eof = true;
  3178. };
  3179. return Jbig2Stream;
  3180. }();
  3181. var DecryptStream = function DecryptStreamClosure() {
  3182. function DecryptStream(str, maybeLength, decrypt) {
  3183. this.str = str;
  3184. this.dict = str.dict;
  3185. this.decrypt = decrypt;
  3186. this.nextChunk = null;
  3187. this.initialized = false;
  3188. DecodeStream.call(this, maybeLength);
  3189. }
  3190. var chunkSize = 512;
  3191. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3192. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3193. var chunk;
  3194. if (this.initialized) {
  3195. chunk = this.nextChunk;
  3196. } else {
  3197. chunk = this.str.getBytes(chunkSize);
  3198. this.initialized = true;
  3199. }
  3200. if (!chunk || chunk.length === 0) {
  3201. this.eof = true;
  3202. return;
  3203. }
  3204. this.nextChunk = this.str.getBytes(chunkSize);
  3205. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3206. var decrypt = this.decrypt;
  3207. chunk = decrypt(chunk, !hasMoreData);
  3208. var bufferLength = this.bufferLength;
  3209. var i, n = chunk.length;
  3210. var buffer = this.ensureBuffer(bufferLength + n);
  3211. for (i = 0; i < n; i++) {
  3212. buffer[bufferLength++] = chunk[i];
  3213. }
  3214. this.bufferLength = bufferLength;
  3215. };
  3216. return DecryptStream;
  3217. }();
  3218. var Ascii85Stream = function Ascii85StreamClosure() {
  3219. function Ascii85Stream(str, maybeLength) {
  3220. this.str = str;
  3221. this.dict = str.dict;
  3222. this.input = new Uint8Array(5);
  3223. if (maybeLength) {
  3224. maybeLength = 0.8 * maybeLength;
  3225. }
  3226. DecodeStream.call(this, maybeLength);
  3227. }
  3228. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3229. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3230. var TILDA_CHAR = 0x7E;
  3231. var Z_LOWER_CHAR = 0x7A;
  3232. var EOF = -1;
  3233. var str = this.str;
  3234. var c = str.getByte();
  3235. while (isSpace(c)) {
  3236. c = str.getByte();
  3237. }
  3238. if (c === EOF || c === TILDA_CHAR) {
  3239. this.eof = true;
  3240. return;
  3241. }
  3242. var bufferLength = this.bufferLength, buffer;
  3243. var i;
  3244. if (c === Z_LOWER_CHAR) {
  3245. buffer = this.ensureBuffer(bufferLength + 4);
  3246. for (i = 0; i < 4; ++i) {
  3247. buffer[bufferLength + i] = 0;
  3248. }
  3249. this.bufferLength += 4;
  3250. } else {
  3251. var input = this.input;
  3252. input[0] = c;
  3253. for (i = 1; i < 5; ++i) {
  3254. c = str.getByte();
  3255. while (isSpace(c)) {
  3256. c = str.getByte();
  3257. }
  3258. input[i] = c;
  3259. if (c === EOF || c === TILDA_CHAR) {
  3260. break;
  3261. }
  3262. }
  3263. buffer = this.ensureBuffer(bufferLength + i - 1);
  3264. this.bufferLength += i - 1;
  3265. if (i < 5) {
  3266. for (; i < 5; ++i) {
  3267. input[i] = 0x21 + 84;
  3268. }
  3269. this.eof = true;
  3270. }
  3271. var t = 0;
  3272. for (i = 0; i < 5; ++i) {
  3273. t = t * 85 + (input[i] - 0x21);
  3274. }
  3275. for (i = 3; i >= 0; --i) {
  3276. buffer[bufferLength + i] = t & 0xFF;
  3277. t >>= 8;
  3278. }
  3279. }
  3280. };
  3281. return Ascii85Stream;
  3282. }();
  3283. var AsciiHexStream = function AsciiHexStreamClosure() {
  3284. function AsciiHexStream(str, maybeLength) {
  3285. this.str = str;
  3286. this.dict = str.dict;
  3287. this.firstDigit = -1;
  3288. if (maybeLength) {
  3289. maybeLength = 0.5 * maybeLength;
  3290. }
  3291. DecodeStream.call(this, maybeLength);
  3292. }
  3293. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3294. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3295. var UPSTREAM_BLOCK_SIZE = 8000;
  3296. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3297. if (!bytes.length) {
  3298. this.eof = true;
  3299. return;
  3300. }
  3301. var maxDecodeLength = bytes.length + 1 >> 1;
  3302. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3303. var bufferLength = this.bufferLength;
  3304. var firstDigit = this.firstDigit;
  3305. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3306. var ch = bytes[i], digit;
  3307. if (ch >= 0x30 && ch <= 0x39) {
  3308. digit = ch & 0x0F;
  3309. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3310. digit = (ch & 0x0F) + 9;
  3311. } else if (ch === 0x3E) {
  3312. this.eof = true;
  3313. break;
  3314. } else {
  3315. continue;
  3316. }
  3317. if (firstDigit < 0) {
  3318. firstDigit = digit;
  3319. } else {
  3320. buffer[bufferLength++] = firstDigit << 4 | digit;
  3321. firstDigit = -1;
  3322. }
  3323. }
  3324. if (firstDigit >= 0 && this.eof) {
  3325. buffer[bufferLength++] = firstDigit << 4;
  3326. firstDigit = -1;
  3327. }
  3328. this.firstDigit = firstDigit;
  3329. this.bufferLength = bufferLength;
  3330. };
  3331. return AsciiHexStream;
  3332. }();
  3333. var RunLengthStream = function RunLengthStreamClosure() {
  3334. function RunLengthStream(str, maybeLength) {
  3335. this.str = str;
  3336. this.dict = str.dict;
  3337. DecodeStream.call(this, maybeLength);
  3338. }
  3339. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3340. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3341. var repeatHeader = this.str.getBytes(2);
  3342. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3343. this.eof = true;
  3344. return;
  3345. }
  3346. var buffer;
  3347. var bufferLength = this.bufferLength;
  3348. var n = repeatHeader[0];
  3349. if (n < 128) {
  3350. buffer = this.ensureBuffer(bufferLength + n + 1);
  3351. buffer[bufferLength++] = repeatHeader[1];
  3352. if (n > 0) {
  3353. var source = this.str.getBytes(n);
  3354. buffer.set(source, bufferLength);
  3355. bufferLength += n;
  3356. }
  3357. } else {
  3358. n = 257 - n;
  3359. var b = repeatHeader[1];
  3360. buffer = this.ensureBuffer(bufferLength + n + 1);
  3361. for (var i = 0; i < n; i++) {
  3362. buffer[bufferLength++] = b;
  3363. }
  3364. }
  3365. this.bufferLength = bufferLength;
  3366. };
  3367. return RunLengthStream;
  3368. }();
  3369. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3370. var ccittEOL = -2;
  3371. var ccittEOF = -1;
  3372. var twoDimPass = 0;
  3373. var twoDimHoriz = 1;
  3374. var twoDimVert0 = 2;
  3375. var twoDimVertR1 = 3;
  3376. var twoDimVertL1 = 4;
  3377. var twoDimVertR2 = 5;
  3378. var twoDimVertL2 = 6;
  3379. var twoDimVertR3 = 7;
  3380. var twoDimVertL3 = 8;
  3381. var twoDimTable = [
  3382. [
  3383. -1,
  3384. -1
  3385. ],
  3386. [
  3387. -1,
  3388. -1
  3389. ],
  3390. [
  3391. 7,
  3392. twoDimVertL3
  3393. ],
  3394. [
  3395. 7,
  3396. twoDimVertR3
  3397. ],
  3398. [
  3399. 6,
  3400. twoDimVertL2
  3401. ],
  3402. [
  3403. 6,
  3404. twoDimVertL2
  3405. ],
  3406. [
  3407. 6,
  3408. twoDimVertR2
  3409. ],
  3410. [
  3411. 6,
  3412. twoDimVertR2
  3413. ],
  3414. [
  3415. 4,
  3416. twoDimPass
  3417. ],
  3418. [
  3419. 4,
  3420. twoDimPass
  3421. ],
  3422. [
  3423. 4,
  3424. twoDimPass
  3425. ],
  3426. [
  3427. 4,
  3428. twoDimPass
  3429. ],
  3430. [
  3431. 4,
  3432. twoDimPass
  3433. ],
  3434. [
  3435. 4,
  3436. twoDimPass
  3437. ],
  3438. [
  3439. 4,
  3440. twoDimPass
  3441. ],
  3442. [
  3443. 4,
  3444. twoDimPass
  3445. ],
  3446. [
  3447. 3,
  3448. twoDimHoriz
  3449. ],
  3450. [
  3451. 3,
  3452. twoDimHoriz
  3453. ],
  3454. [
  3455. 3,
  3456. twoDimHoriz
  3457. ],
  3458. [
  3459. 3,
  3460. twoDimHoriz
  3461. ],
  3462. [
  3463. 3,
  3464. twoDimHoriz
  3465. ],
  3466. [
  3467. 3,
  3468. twoDimHoriz
  3469. ],
  3470. [
  3471. 3,
  3472. twoDimHoriz
  3473. ],
  3474. [
  3475. 3,
  3476. twoDimHoriz
  3477. ],
  3478. [
  3479. 3,
  3480. twoDimHoriz
  3481. ],
  3482. [
  3483. 3,
  3484. twoDimHoriz
  3485. ],
  3486. [
  3487. 3,
  3488. twoDimHoriz
  3489. ],
  3490. [
  3491. 3,
  3492. twoDimHoriz
  3493. ],
  3494. [
  3495. 3,
  3496. twoDimHoriz
  3497. ],
  3498. [
  3499. 3,
  3500. twoDimHoriz
  3501. ],
  3502. [
  3503. 3,
  3504. twoDimHoriz
  3505. ],
  3506. [
  3507. 3,
  3508. twoDimHoriz
  3509. ],
  3510. [
  3511. 3,
  3512. twoDimVertL1
  3513. ],
  3514. [
  3515. 3,
  3516. twoDimVertL1
  3517. ],
  3518. [
  3519. 3,
  3520. twoDimVertL1
  3521. ],
  3522. [
  3523. 3,
  3524. twoDimVertL1
  3525. ],
  3526. [
  3527. 3,
  3528. twoDimVertL1
  3529. ],
  3530. [
  3531. 3,
  3532. twoDimVertL1
  3533. ],
  3534. [
  3535. 3,
  3536. twoDimVertL1
  3537. ],
  3538. [
  3539. 3,
  3540. twoDimVertL1
  3541. ],
  3542. [
  3543. 3,
  3544. twoDimVertL1
  3545. ],
  3546. [
  3547. 3,
  3548. twoDimVertL1
  3549. ],
  3550. [
  3551. 3,
  3552. twoDimVertL1
  3553. ],
  3554. [
  3555. 3,
  3556. twoDimVertL1
  3557. ],
  3558. [
  3559. 3,
  3560. twoDimVertL1
  3561. ],
  3562. [
  3563. 3,
  3564. twoDimVertL1
  3565. ],
  3566. [
  3567. 3,
  3568. twoDimVertL1
  3569. ],
  3570. [
  3571. 3,
  3572. twoDimVertL1
  3573. ],
  3574. [
  3575. 3,
  3576. twoDimVertR1
  3577. ],
  3578. [
  3579. 3,
  3580. twoDimVertR1
  3581. ],
  3582. [
  3583. 3,
  3584. twoDimVertR1
  3585. ],
  3586. [
  3587. 3,
  3588. twoDimVertR1
  3589. ],
  3590. [
  3591. 3,
  3592. twoDimVertR1
  3593. ],
  3594. [
  3595. 3,
  3596. twoDimVertR1
  3597. ],
  3598. [
  3599. 3,
  3600. twoDimVertR1
  3601. ],
  3602. [
  3603. 3,
  3604. twoDimVertR1
  3605. ],
  3606. [
  3607. 3,
  3608. twoDimVertR1
  3609. ],
  3610. [
  3611. 3,
  3612. twoDimVertR1
  3613. ],
  3614. [
  3615. 3,
  3616. twoDimVertR1
  3617. ],
  3618. [
  3619. 3,
  3620. twoDimVertR1
  3621. ],
  3622. [
  3623. 3,
  3624. twoDimVertR1
  3625. ],
  3626. [
  3627. 3,
  3628. twoDimVertR1
  3629. ],
  3630. [
  3631. 3,
  3632. twoDimVertR1
  3633. ],
  3634. [
  3635. 3,
  3636. twoDimVertR1
  3637. ],
  3638. [
  3639. 1,
  3640. twoDimVert0
  3641. ],
  3642. [
  3643. 1,
  3644. twoDimVert0
  3645. ],
  3646. [
  3647. 1,
  3648. twoDimVert0
  3649. ],
  3650. [
  3651. 1,
  3652. twoDimVert0
  3653. ],
  3654. [
  3655. 1,
  3656. twoDimVert0
  3657. ],
  3658. [
  3659. 1,
  3660. twoDimVert0
  3661. ],
  3662. [
  3663. 1,
  3664. twoDimVert0
  3665. ],
  3666. [
  3667. 1,
  3668. twoDimVert0
  3669. ],
  3670. [
  3671. 1,
  3672. twoDimVert0
  3673. ],
  3674. [
  3675. 1,
  3676. twoDimVert0
  3677. ],
  3678. [
  3679. 1,
  3680. twoDimVert0
  3681. ],
  3682. [
  3683. 1,
  3684. twoDimVert0
  3685. ],
  3686. [
  3687. 1,
  3688. twoDimVert0
  3689. ],
  3690. [
  3691. 1,
  3692. twoDimVert0
  3693. ],
  3694. [
  3695. 1,
  3696. twoDimVert0
  3697. ],
  3698. [
  3699. 1,
  3700. twoDimVert0
  3701. ],
  3702. [
  3703. 1,
  3704. twoDimVert0
  3705. ],
  3706. [
  3707. 1,
  3708. twoDimVert0
  3709. ],
  3710. [
  3711. 1,
  3712. twoDimVert0
  3713. ],
  3714. [
  3715. 1,
  3716. twoDimVert0
  3717. ],
  3718. [
  3719. 1,
  3720. twoDimVert0
  3721. ],
  3722. [
  3723. 1,
  3724. twoDimVert0
  3725. ],
  3726. [
  3727. 1,
  3728. twoDimVert0
  3729. ],
  3730. [
  3731. 1,
  3732. twoDimVert0
  3733. ],
  3734. [
  3735. 1,
  3736. twoDimVert0
  3737. ],
  3738. [
  3739. 1,
  3740. twoDimVert0
  3741. ],
  3742. [
  3743. 1,
  3744. twoDimVert0
  3745. ],
  3746. [
  3747. 1,
  3748. twoDimVert0
  3749. ],
  3750. [
  3751. 1,
  3752. twoDimVert0
  3753. ],
  3754. [
  3755. 1,
  3756. twoDimVert0
  3757. ],
  3758. [
  3759. 1,
  3760. twoDimVert0
  3761. ],
  3762. [
  3763. 1,
  3764. twoDimVert0
  3765. ],
  3766. [
  3767. 1,
  3768. twoDimVert0
  3769. ],
  3770. [
  3771. 1,
  3772. twoDimVert0
  3773. ],
  3774. [
  3775. 1,
  3776. twoDimVert0
  3777. ],
  3778. [
  3779. 1,
  3780. twoDimVert0
  3781. ],
  3782. [
  3783. 1,
  3784. twoDimVert0
  3785. ],
  3786. [
  3787. 1,
  3788. twoDimVert0
  3789. ],
  3790. [
  3791. 1,
  3792. twoDimVert0
  3793. ],
  3794. [
  3795. 1,
  3796. twoDimVert0
  3797. ],
  3798. [
  3799. 1,
  3800. twoDimVert0
  3801. ],
  3802. [
  3803. 1,
  3804. twoDimVert0
  3805. ],
  3806. [
  3807. 1,
  3808. twoDimVert0
  3809. ],
  3810. [
  3811. 1,
  3812. twoDimVert0
  3813. ],
  3814. [
  3815. 1,
  3816. twoDimVert0
  3817. ],
  3818. [
  3819. 1,
  3820. twoDimVert0
  3821. ],
  3822. [
  3823. 1,
  3824. twoDimVert0
  3825. ],
  3826. [
  3827. 1,
  3828. twoDimVert0
  3829. ],
  3830. [
  3831. 1,
  3832. twoDimVert0
  3833. ],
  3834. [
  3835. 1,
  3836. twoDimVert0
  3837. ],
  3838. [
  3839. 1,
  3840. twoDimVert0
  3841. ],
  3842. [
  3843. 1,
  3844. twoDimVert0
  3845. ],
  3846. [
  3847. 1,
  3848. twoDimVert0
  3849. ],
  3850. [
  3851. 1,
  3852. twoDimVert0
  3853. ],
  3854. [
  3855. 1,
  3856. twoDimVert0
  3857. ],
  3858. [
  3859. 1,
  3860. twoDimVert0
  3861. ],
  3862. [
  3863. 1,
  3864. twoDimVert0
  3865. ],
  3866. [
  3867. 1,
  3868. twoDimVert0
  3869. ],
  3870. [
  3871. 1,
  3872. twoDimVert0
  3873. ],
  3874. [
  3875. 1,
  3876. twoDimVert0
  3877. ],
  3878. [
  3879. 1,
  3880. twoDimVert0
  3881. ],
  3882. [
  3883. 1,
  3884. twoDimVert0
  3885. ],
  3886. [
  3887. 1,
  3888. twoDimVert0
  3889. ],
  3890. [
  3891. 1,
  3892. twoDimVert0
  3893. ]
  3894. ];
  3895. var whiteTable1 = [
  3896. [
  3897. -1,
  3898. -1
  3899. ],
  3900. [
  3901. 12,
  3902. ccittEOL
  3903. ],
  3904. [
  3905. -1,
  3906. -1
  3907. ],
  3908. [
  3909. -1,
  3910. -1
  3911. ],
  3912. [
  3913. -1,
  3914. -1
  3915. ],
  3916. [
  3917. -1,
  3918. -1
  3919. ],
  3920. [
  3921. -1,
  3922. -1
  3923. ],
  3924. [
  3925. -1,
  3926. -1
  3927. ],
  3928. [
  3929. -1,
  3930. -1
  3931. ],
  3932. [
  3933. -1,
  3934. -1
  3935. ],
  3936. [
  3937. -1,
  3938. -1
  3939. ],
  3940. [
  3941. -1,
  3942. -1
  3943. ],
  3944. [
  3945. -1,
  3946. -1
  3947. ],
  3948. [
  3949. -1,
  3950. -1
  3951. ],
  3952. [
  3953. -1,
  3954. -1
  3955. ],
  3956. [
  3957. -1,
  3958. -1
  3959. ],
  3960. [
  3961. 11,
  3962. 1792
  3963. ],
  3964. [
  3965. 11,
  3966. 1792
  3967. ],
  3968. [
  3969. 12,
  3970. 1984
  3971. ],
  3972. [
  3973. 12,
  3974. 2048
  3975. ],
  3976. [
  3977. 12,
  3978. 2112
  3979. ],
  3980. [
  3981. 12,
  3982. 2176
  3983. ],
  3984. [
  3985. 12,
  3986. 2240
  3987. ],
  3988. [
  3989. 12,
  3990. 2304
  3991. ],
  3992. [
  3993. 11,
  3994. 1856
  3995. ],
  3996. [
  3997. 11,
  3998. 1856
  3999. ],
  4000. [
  4001. 11,
  4002. 1920
  4003. ],
  4004. [
  4005. 11,
  4006. 1920
  4007. ],
  4008. [
  4009. 12,
  4010. 2368
  4011. ],
  4012. [
  4013. 12,
  4014. 2432
  4015. ],
  4016. [
  4017. 12,
  4018. 2496
  4019. ],
  4020. [
  4021. 12,
  4022. 2560
  4023. ]
  4024. ];
  4025. var whiteTable2 = [
  4026. [
  4027. -1,
  4028. -1
  4029. ],
  4030. [
  4031. -1,
  4032. -1
  4033. ],
  4034. [
  4035. -1,
  4036. -1
  4037. ],
  4038. [
  4039. -1,
  4040. -1
  4041. ],
  4042. [
  4043. 8,
  4044. 29
  4045. ],
  4046. [
  4047. 8,
  4048. 29
  4049. ],
  4050. [
  4051. 8,
  4052. 30
  4053. ],
  4054. [
  4055. 8,
  4056. 30
  4057. ],
  4058. [
  4059. 8,
  4060. 45
  4061. ],
  4062. [
  4063. 8,
  4064. 45
  4065. ],
  4066. [
  4067. 8,
  4068. 46
  4069. ],
  4070. [
  4071. 8,
  4072. 46
  4073. ],
  4074. [
  4075. 7,
  4076. 22
  4077. ],
  4078. [
  4079. 7,
  4080. 22
  4081. ],
  4082. [
  4083. 7,
  4084. 22
  4085. ],
  4086. [
  4087. 7,
  4088. 22
  4089. ],
  4090. [
  4091. 7,
  4092. 23
  4093. ],
  4094. [
  4095. 7,
  4096. 23
  4097. ],
  4098. [
  4099. 7,
  4100. 23
  4101. ],
  4102. [
  4103. 7,
  4104. 23
  4105. ],
  4106. [
  4107. 8,
  4108. 47
  4109. ],
  4110. [
  4111. 8,
  4112. 47
  4113. ],
  4114. [
  4115. 8,
  4116. 48
  4117. ],
  4118. [
  4119. 8,
  4120. 48
  4121. ],
  4122. [
  4123. 6,
  4124. 13
  4125. ],
  4126. [
  4127. 6,
  4128. 13
  4129. ],
  4130. [
  4131. 6,
  4132. 13
  4133. ],
  4134. [
  4135. 6,
  4136. 13
  4137. ],
  4138. [
  4139. 6,
  4140. 13
  4141. ],
  4142. [
  4143. 6,
  4144. 13
  4145. ],
  4146. [
  4147. 6,
  4148. 13
  4149. ],
  4150. [
  4151. 6,
  4152. 13
  4153. ],
  4154. [
  4155. 7,
  4156. 20
  4157. ],
  4158. [
  4159. 7,
  4160. 20
  4161. ],
  4162. [
  4163. 7,
  4164. 20
  4165. ],
  4166. [
  4167. 7,
  4168. 20
  4169. ],
  4170. [
  4171. 8,
  4172. 33
  4173. ],
  4174. [
  4175. 8,
  4176. 33
  4177. ],
  4178. [
  4179. 8,
  4180. 34
  4181. ],
  4182. [
  4183. 8,
  4184. 34
  4185. ],
  4186. [
  4187. 8,
  4188. 35
  4189. ],
  4190. [
  4191. 8,
  4192. 35
  4193. ],
  4194. [
  4195. 8,
  4196. 36
  4197. ],
  4198. [
  4199. 8,
  4200. 36
  4201. ],
  4202. [
  4203. 8,
  4204. 37
  4205. ],
  4206. [
  4207. 8,
  4208. 37
  4209. ],
  4210. [
  4211. 8,
  4212. 38
  4213. ],
  4214. [
  4215. 8,
  4216. 38
  4217. ],
  4218. [
  4219. 7,
  4220. 19
  4221. ],
  4222. [
  4223. 7,
  4224. 19
  4225. ],
  4226. [
  4227. 7,
  4228. 19
  4229. ],
  4230. [
  4231. 7,
  4232. 19
  4233. ],
  4234. [
  4235. 8,
  4236. 31
  4237. ],
  4238. [
  4239. 8,
  4240. 31
  4241. ],
  4242. [
  4243. 8,
  4244. 32
  4245. ],
  4246. [
  4247. 8,
  4248. 32
  4249. ],
  4250. [
  4251. 6,
  4252. 1
  4253. ],
  4254. [
  4255. 6,
  4256. 1
  4257. ],
  4258. [
  4259. 6,
  4260. 1
  4261. ],
  4262. [
  4263. 6,
  4264. 1
  4265. ],
  4266. [
  4267. 6,
  4268. 1
  4269. ],
  4270. [
  4271. 6,
  4272. 1
  4273. ],
  4274. [
  4275. 6,
  4276. 1
  4277. ],
  4278. [
  4279. 6,
  4280. 1
  4281. ],
  4282. [
  4283. 6,
  4284. 12
  4285. ],
  4286. [
  4287. 6,
  4288. 12
  4289. ],
  4290. [
  4291. 6,
  4292. 12
  4293. ],
  4294. [
  4295. 6,
  4296. 12
  4297. ],
  4298. [
  4299. 6,
  4300. 12
  4301. ],
  4302. [
  4303. 6,
  4304. 12
  4305. ],
  4306. [
  4307. 6,
  4308. 12
  4309. ],
  4310. [
  4311. 6,
  4312. 12
  4313. ],
  4314. [
  4315. 8,
  4316. 53
  4317. ],
  4318. [
  4319. 8,
  4320. 53
  4321. ],
  4322. [
  4323. 8,
  4324. 54
  4325. ],
  4326. [
  4327. 8,
  4328. 54
  4329. ],
  4330. [
  4331. 7,
  4332. 26
  4333. ],
  4334. [
  4335. 7,
  4336. 26
  4337. ],
  4338. [
  4339. 7,
  4340. 26
  4341. ],
  4342. [
  4343. 7,
  4344. 26
  4345. ],
  4346. [
  4347. 8,
  4348. 39
  4349. ],
  4350. [
  4351. 8,
  4352. 39
  4353. ],
  4354. [
  4355. 8,
  4356. 40
  4357. ],
  4358. [
  4359. 8,
  4360. 40
  4361. ],
  4362. [
  4363. 8,
  4364. 41
  4365. ],
  4366. [
  4367. 8,
  4368. 41
  4369. ],
  4370. [
  4371. 8,
  4372. 42
  4373. ],
  4374. [
  4375. 8,
  4376. 42
  4377. ],
  4378. [
  4379. 8,
  4380. 43
  4381. ],
  4382. [
  4383. 8,
  4384. 43
  4385. ],
  4386. [
  4387. 8,
  4388. 44
  4389. ],
  4390. [
  4391. 8,
  4392. 44
  4393. ],
  4394. [
  4395. 7,
  4396. 21
  4397. ],
  4398. [
  4399. 7,
  4400. 21
  4401. ],
  4402. [
  4403. 7,
  4404. 21
  4405. ],
  4406. [
  4407. 7,
  4408. 21
  4409. ],
  4410. [
  4411. 7,
  4412. 28
  4413. ],
  4414. [
  4415. 7,
  4416. 28
  4417. ],
  4418. [
  4419. 7,
  4420. 28
  4421. ],
  4422. [
  4423. 7,
  4424. 28
  4425. ],
  4426. [
  4427. 8,
  4428. 61
  4429. ],
  4430. [
  4431. 8,
  4432. 61
  4433. ],
  4434. [
  4435. 8,
  4436. 62
  4437. ],
  4438. [
  4439. 8,
  4440. 62
  4441. ],
  4442. [
  4443. 8,
  4444. 63
  4445. ],
  4446. [
  4447. 8,
  4448. 63
  4449. ],
  4450. [
  4451. 8,
  4452. 0
  4453. ],
  4454. [
  4455. 8,
  4456. 0
  4457. ],
  4458. [
  4459. 8,
  4460. 320
  4461. ],
  4462. [
  4463. 8,
  4464. 320
  4465. ],
  4466. [
  4467. 8,
  4468. 384
  4469. ],
  4470. [
  4471. 8,
  4472. 384
  4473. ],
  4474. [
  4475. 5,
  4476. 10
  4477. ],
  4478. [
  4479. 5,
  4480. 10
  4481. ],
  4482. [
  4483. 5,
  4484. 10
  4485. ],
  4486. [
  4487. 5,
  4488. 10
  4489. ],
  4490. [
  4491. 5,
  4492. 10
  4493. ],
  4494. [
  4495. 5,
  4496. 10
  4497. ],
  4498. [
  4499. 5,
  4500. 10
  4501. ],
  4502. [
  4503. 5,
  4504. 10
  4505. ],
  4506. [
  4507. 5,
  4508. 10
  4509. ],
  4510. [
  4511. 5,
  4512. 10
  4513. ],
  4514. [
  4515. 5,
  4516. 10
  4517. ],
  4518. [
  4519. 5,
  4520. 10
  4521. ],
  4522. [
  4523. 5,
  4524. 10
  4525. ],
  4526. [
  4527. 5,
  4528. 10
  4529. ],
  4530. [
  4531. 5,
  4532. 10
  4533. ],
  4534. [
  4535. 5,
  4536. 10
  4537. ],
  4538. [
  4539. 5,
  4540. 11
  4541. ],
  4542. [
  4543. 5,
  4544. 11
  4545. ],
  4546. [
  4547. 5,
  4548. 11
  4549. ],
  4550. [
  4551. 5,
  4552. 11
  4553. ],
  4554. [
  4555. 5,
  4556. 11
  4557. ],
  4558. [
  4559. 5,
  4560. 11
  4561. ],
  4562. [
  4563. 5,
  4564. 11
  4565. ],
  4566. [
  4567. 5,
  4568. 11
  4569. ],
  4570. [
  4571. 5,
  4572. 11
  4573. ],
  4574. [
  4575. 5,
  4576. 11
  4577. ],
  4578. [
  4579. 5,
  4580. 11
  4581. ],
  4582. [
  4583. 5,
  4584. 11
  4585. ],
  4586. [
  4587. 5,
  4588. 11
  4589. ],
  4590. [
  4591. 5,
  4592. 11
  4593. ],
  4594. [
  4595. 5,
  4596. 11
  4597. ],
  4598. [
  4599. 5,
  4600. 11
  4601. ],
  4602. [
  4603. 7,
  4604. 27
  4605. ],
  4606. [
  4607. 7,
  4608. 27
  4609. ],
  4610. [
  4611. 7,
  4612. 27
  4613. ],
  4614. [
  4615. 7,
  4616. 27
  4617. ],
  4618. [
  4619. 8,
  4620. 59
  4621. ],
  4622. [
  4623. 8,
  4624. 59
  4625. ],
  4626. [
  4627. 8,
  4628. 60
  4629. ],
  4630. [
  4631. 8,
  4632. 60
  4633. ],
  4634. [
  4635. 9,
  4636. 1472
  4637. ],
  4638. [
  4639. 9,
  4640. 1536
  4641. ],
  4642. [
  4643. 9,
  4644. 1600
  4645. ],
  4646. [
  4647. 9,
  4648. 1728
  4649. ],
  4650. [
  4651. 7,
  4652. 18
  4653. ],
  4654. [
  4655. 7,
  4656. 18
  4657. ],
  4658. [
  4659. 7,
  4660. 18
  4661. ],
  4662. [
  4663. 7,
  4664. 18
  4665. ],
  4666. [
  4667. 7,
  4668. 24
  4669. ],
  4670. [
  4671. 7,
  4672. 24
  4673. ],
  4674. [
  4675. 7,
  4676. 24
  4677. ],
  4678. [
  4679. 7,
  4680. 24
  4681. ],
  4682. [
  4683. 8,
  4684. 49
  4685. ],
  4686. [
  4687. 8,
  4688. 49
  4689. ],
  4690. [
  4691. 8,
  4692. 50
  4693. ],
  4694. [
  4695. 8,
  4696. 50
  4697. ],
  4698. [
  4699. 8,
  4700. 51
  4701. ],
  4702. [
  4703. 8,
  4704. 51
  4705. ],
  4706. [
  4707. 8,
  4708. 52
  4709. ],
  4710. [
  4711. 8,
  4712. 52
  4713. ],
  4714. [
  4715. 7,
  4716. 25
  4717. ],
  4718. [
  4719. 7,
  4720. 25
  4721. ],
  4722. [
  4723. 7,
  4724. 25
  4725. ],
  4726. [
  4727. 7,
  4728. 25
  4729. ],
  4730. [
  4731. 8,
  4732. 55
  4733. ],
  4734. [
  4735. 8,
  4736. 55
  4737. ],
  4738. [
  4739. 8,
  4740. 56
  4741. ],
  4742. [
  4743. 8,
  4744. 56
  4745. ],
  4746. [
  4747. 8,
  4748. 57
  4749. ],
  4750. [
  4751. 8,
  4752. 57
  4753. ],
  4754. [
  4755. 8,
  4756. 58
  4757. ],
  4758. [
  4759. 8,
  4760. 58
  4761. ],
  4762. [
  4763. 6,
  4764. 192
  4765. ],
  4766. [
  4767. 6,
  4768. 192
  4769. ],
  4770. [
  4771. 6,
  4772. 192
  4773. ],
  4774. [
  4775. 6,
  4776. 192
  4777. ],
  4778. [
  4779. 6,
  4780. 192
  4781. ],
  4782. [
  4783. 6,
  4784. 192
  4785. ],
  4786. [
  4787. 6,
  4788. 192
  4789. ],
  4790. [
  4791. 6,
  4792. 192
  4793. ],
  4794. [
  4795. 6,
  4796. 1664
  4797. ],
  4798. [
  4799. 6,
  4800. 1664
  4801. ],
  4802. [
  4803. 6,
  4804. 1664
  4805. ],
  4806. [
  4807. 6,
  4808. 1664
  4809. ],
  4810. [
  4811. 6,
  4812. 1664
  4813. ],
  4814. [
  4815. 6,
  4816. 1664
  4817. ],
  4818. [
  4819. 6,
  4820. 1664
  4821. ],
  4822. [
  4823. 6,
  4824. 1664
  4825. ],
  4826. [
  4827. 8,
  4828. 448
  4829. ],
  4830. [
  4831. 8,
  4832. 448
  4833. ],
  4834. [
  4835. 8,
  4836. 512
  4837. ],
  4838. [
  4839. 8,
  4840. 512
  4841. ],
  4842. [
  4843. 9,
  4844. 704
  4845. ],
  4846. [
  4847. 9,
  4848. 768
  4849. ],
  4850. [
  4851. 8,
  4852. 640
  4853. ],
  4854. [
  4855. 8,
  4856. 640
  4857. ],
  4858. [
  4859. 8,
  4860. 576
  4861. ],
  4862. [
  4863. 8,
  4864. 576
  4865. ],
  4866. [
  4867. 9,
  4868. 832
  4869. ],
  4870. [
  4871. 9,
  4872. 896
  4873. ],
  4874. [
  4875. 9,
  4876. 960
  4877. ],
  4878. [
  4879. 9,
  4880. 1024
  4881. ],
  4882. [
  4883. 9,
  4884. 1088
  4885. ],
  4886. [
  4887. 9,
  4888. 1152
  4889. ],
  4890. [
  4891. 9,
  4892. 1216
  4893. ],
  4894. [
  4895. 9,
  4896. 1280
  4897. ],
  4898. [
  4899. 9,
  4900. 1344
  4901. ],
  4902. [
  4903. 9,
  4904. 1408
  4905. ],
  4906. [
  4907. 7,
  4908. 256
  4909. ],
  4910. [
  4911. 7,
  4912. 256
  4913. ],
  4914. [
  4915. 7,
  4916. 256
  4917. ],
  4918. [
  4919. 7,
  4920. 256
  4921. ],
  4922. [
  4923. 4,
  4924. 2
  4925. ],
  4926. [
  4927. 4,
  4928. 2
  4929. ],
  4930. [
  4931. 4,
  4932. 2
  4933. ],
  4934. [
  4935. 4,
  4936. 2
  4937. ],
  4938. [
  4939. 4,
  4940. 2
  4941. ],
  4942. [
  4943. 4,
  4944. 2
  4945. ],
  4946. [
  4947. 4,
  4948. 2
  4949. ],
  4950. [
  4951. 4,
  4952. 2
  4953. ],
  4954. [
  4955. 4,
  4956. 2
  4957. ],
  4958. [
  4959. 4,
  4960. 2
  4961. ],
  4962. [
  4963. 4,
  4964. 2
  4965. ],
  4966. [
  4967. 4,
  4968. 2
  4969. ],
  4970. [
  4971. 4,
  4972. 2
  4973. ],
  4974. [
  4975. 4,
  4976. 2
  4977. ],
  4978. [
  4979. 4,
  4980. 2
  4981. ],
  4982. [
  4983. 4,
  4984. 2
  4985. ],
  4986. [
  4987. 4,
  4988. 2
  4989. ],
  4990. [
  4991. 4,
  4992. 2
  4993. ],
  4994. [
  4995. 4,
  4996. 2
  4997. ],
  4998. [
  4999. 4,
  5000. 2
  5001. ],
  5002. [
  5003. 4,
  5004. 2
  5005. ],
  5006. [
  5007. 4,
  5008. 2
  5009. ],
  5010. [
  5011. 4,
  5012. 2
  5013. ],
  5014. [
  5015. 4,
  5016. 2
  5017. ],
  5018. [
  5019. 4,
  5020. 2
  5021. ],
  5022. [
  5023. 4,
  5024. 2
  5025. ],
  5026. [
  5027. 4,
  5028. 2
  5029. ],
  5030. [
  5031. 4,
  5032. 2
  5033. ],
  5034. [
  5035. 4,
  5036. 2
  5037. ],
  5038. [
  5039. 4,
  5040. 2
  5041. ],
  5042. [
  5043. 4,
  5044. 2
  5045. ],
  5046. [
  5047. 4,
  5048. 2
  5049. ],
  5050. [
  5051. 4,
  5052. 3
  5053. ],
  5054. [
  5055. 4,
  5056. 3
  5057. ],
  5058. [
  5059. 4,
  5060. 3
  5061. ],
  5062. [
  5063. 4,
  5064. 3
  5065. ],
  5066. [
  5067. 4,
  5068. 3
  5069. ],
  5070. [
  5071. 4,
  5072. 3
  5073. ],
  5074. [
  5075. 4,
  5076. 3
  5077. ],
  5078. [
  5079. 4,
  5080. 3
  5081. ],
  5082. [
  5083. 4,
  5084. 3
  5085. ],
  5086. [
  5087. 4,
  5088. 3
  5089. ],
  5090. [
  5091. 4,
  5092. 3
  5093. ],
  5094. [
  5095. 4,
  5096. 3
  5097. ],
  5098. [
  5099. 4,
  5100. 3
  5101. ],
  5102. [
  5103. 4,
  5104. 3
  5105. ],
  5106. [
  5107. 4,
  5108. 3
  5109. ],
  5110. [
  5111. 4,
  5112. 3
  5113. ],
  5114. [
  5115. 4,
  5116. 3
  5117. ],
  5118. [
  5119. 4,
  5120. 3
  5121. ],
  5122. [
  5123. 4,
  5124. 3
  5125. ],
  5126. [
  5127. 4,
  5128. 3
  5129. ],
  5130. [
  5131. 4,
  5132. 3
  5133. ],
  5134. [
  5135. 4,
  5136. 3
  5137. ],
  5138. [
  5139. 4,
  5140. 3
  5141. ],
  5142. [
  5143. 4,
  5144. 3
  5145. ],
  5146. [
  5147. 4,
  5148. 3
  5149. ],
  5150. [
  5151. 4,
  5152. 3
  5153. ],
  5154. [
  5155. 4,
  5156. 3
  5157. ],
  5158. [
  5159. 4,
  5160. 3
  5161. ],
  5162. [
  5163. 4,
  5164. 3
  5165. ],
  5166. [
  5167. 4,
  5168. 3
  5169. ],
  5170. [
  5171. 4,
  5172. 3
  5173. ],
  5174. [
  5175. 4,
  5176. 3
  5177. ],
  5178. [
  5179. 5,
  5180. 128
  5181. ],
  5182. [
  5183. 5,
  5184. 128
  5185. ],
  5186. [
  5187. 5,
  5188. 128
  5189. ],
  5190. [
  5191. 5,
  5192. 128
  5193. ],
  5194. [
  5195. 5,
  5196. 128
  5197. ],
  5198. [
  5199. 5,
  5200. 128
  5201. ],
  5202. [
  5203. 5,
  5204. 128
  5205. ],
  5206. [
  5207. 5,
  5208. 128
  5209. ],
  5210. [
  5211. 5,
  5212. 128
  5213. ],
  5214. [
  5215. 5,
  5216. 128
  5217. ],
  5218. [
  5219. 5,
  5220. 128
  5221. ],
  5222. [
  5223. 5,
  5224. 128
  5225. ],
  5226. [
  5227. 5,
  5228. 128
  5229. ],
  5230. [
  5231. 5,
  5232. 128
  5233. ],
  5234. [
  5235. 5,
  5236. 128
  5237. ],
  5238. [
  5239. 5,
  5240. 128
  5241. ],
  5242. [
  5243. 5,
  5244. 8
  5245. ],
  5246. [
  5247. 5,
  5248. 8
  5249. ],
  5250. [
  5251. 5,
  5252. 8
  5253. ],
  5254. [
  5255. 5,
  5256. 8
  5257. ],
  5258. [
  5259. 5,
  5260. 8
  5261. ],
  5262. [
  5263. 5,
  5264. 8
  5265. ],
  5266. [
  5267. 5,
  5268. 8
  5269. ],
  5270. [
  5271. 5,
  5272. 8
  5273. ],
  5274. [
  5275. 5,
  5276. 8
  5277. ],
  5278. [
  5279. 5,
  5280. 8
  5281. ],
  5282. [
  5283. 5,
  5284. 8
  5285. ],
  5286. [
  5287. 5,
  5288. 8
  5289. ],
  5290. [
  5291. 5,
  5292. 8
  5293. ],
  5294. [
  5295. 5,
  5296. 8
  5297. ],
  5298. [
  5299. 5,
  5300. 8
  5301. ],
  5302. [
  5303. 5,
  5304. 8
  5305. ],
  5306. [
  5307. 5,
  5308. 9
  5309. ],
  5310. [
  5311. 5,
  5312. 9
  5313. ],
  5314. [
  5315. 5,
  5316. 9
  5317. ],
  5318. [
  5319. 5,
  5320. 9
  5321. ],
  5322. [
  5323. 5,
  5324. 9
  5325. ],
  5326. [
  5327. 5,
  5328. 9
  5329. ],
  5330. [
  5331. 5,
  5332. 9
  5333. ],
  5334. [
  5335. 5,
  5336. 9
  5337. ],
  5338. [
  5339. 5,
  5340. 9
  5341. ],
  5342. [
  5343. 5,
  5344. 9
  5345. ],
  5346. [
  5347. 5,
  5348. 9
  5349. ],
  5350. [
  5351. 5,
  5352. 9
  5353. ],
  5354. [
  5355. 5,
  5356. 9
  5357. ],
  5358. [
  5359. 5,
  5360. 9
  5361. ],
  5362. [
  5363. 5,
  5364. 9
  5365. ],
  5366. [
  5367. 5,
  5368. 9
  5369. ],
  5370. [
  5371. 6,
  5372. 16
  5373. ],
  5374. [
  5375. 6,
  5376. 16
  5377. ],
  5378. [
  5379. 6,
  5380. 16
  5381. ],
  5382. [
  5383. 6,
  5384. 16
  5385. ],
  5386. [
  5387. 6,
  5388. 16
  5389. ],
  5390. [
  5391. 6,
  5392. 16
  5393. ],
  5394. [
  5395. 6,
  5396. 16
  5397. ],
  5398. [
  5399. 6,
  5400. 16
  5401. ],
  5402. [
  5403. 6,
  5404. 17
  5405. ],
  5406. [
  5407. 6,
  5408. 17
  5409. ],
  5410. [
  5411. 6,
  5412. 17
  5413. ],
  5414. [
  5415. 6,
  5416. 17
  5417. ],
  5418. [
  5419. 6,
  5420. 17
  5421. ],
  5422. [
  5423. 6,
  5424. 17
  5425. ],
  5426. [
  5427. 6,
  5428. 17
  5429. ],
  5430. [
  5431. 6,
  5432. 17
  5433. ],
  5434. [
  5435. 4,
  5436. 4
  5437. ],
  5438. [
  5439. 4,
  5440. 4
  5441. ],
  5442. [
  5443. 4,
  5444. 4
  5445. ],
  5446. [
  5447. 4,
  5448. 4
  5449. ],
  5450. [
  5451. 4,
  5452. 4
  5453. ],
  5454. [
  5455. 4,
  5456. 4
  5457. ],
  5458. [
  5459. 4,
  5460. 4
  5461. ],
  5462. [
  5463. 4,
  5464. 4
  5465. ],
  5466. [
  5467. 4,
  5468. 4
  5469. ],
  5470. [
  5471. 4,
  5472. 4
  5473. ],
  5474. [
  5475. 4,
  5476. 4
  5477. ],
  5478. [
  5479. 4,
  5480. 4
  5481. ],
  5482. [
  5483. 4,
  5484. 4
  5485. ],
  5486. [
  5487. 4,
  5488. 4
  5489. ],
  5490. [
  5491. 4,
  5492. 4
  5493. ],
  5494. [
  5495. 4,
  5496. 4
  5497. ],
  5498. [
  5499. 4,
  5500. 4
  5501. ],
  5502. [
  5503. 4,
  5504. 4
  5505. ],
  5506. [
  5507. 4,
  5508. 4
  5509. ],
  5510. [
  5511. 4,
  5512. 4
  5513. ],
  5514. [
  5515. 4,
  5516. 4
  5517. ],
  5518. [
  5519. 4,
  5520. 4
  5521. ],
  5522. [
  5523. 4,
  5524. 4
  5525. ],
  5526. [
  5527. 4,
  5528. 4
  5529. ],
  5530. [
  5531. 4,
  5532. 4
  5533. ],
  5534. [
  5535. 4,
  5536. 4
  5537. ],
  5538. [
  5539. 4,
  5540. 4
  5541. ],
  5542. [
  5543. 4,
  5544. 4
  5545. ],
  5546. [
  5547. 4,
  5548. 4
  5549. ],
  5550. [
  5551. 4,
  5552. 4
  5553. ],
  5554. [
  5555. 4,
  5556. 4
  5557. ],
  5558. [
  5559. 4,
  5560. 4
  5561. ],
  5562. [
  5563. 4,
  5564. 5
  5565. ],
  5566. [
  5567. 4,
  5568. 5
  5569. ],
  5570. [
  5571. 4,
  5572. 5
  5573. ],
  5574. [
  5575. 4,
  5576. 5
  5577. ],
  5578. [
  5579. 4,
  5580. 5
  5581. ],
  5582. [
  5583. 4,
  5584. 5
  5585. ],
  5586. [
  5587. 4,
  5588. 5
  5589. ],
  5590. [
  5591. 4,
  5592. 5
  5593. ],
  5594. [
  5595. 4,
  5596. 5
  5597. ],
  5598. [
  5599. 4,
  5600. 5
  5601. ],
  5602. [
  5603. 4,
  5604. 5
  5605. ],
  5606. [
  5607. 4,
  5608. 5
  5609. ],
  5610. [
  5611. 4,
  5612. 5
  5613. ],
  5614. [
  5615. 4,
  5616. 5
  5617. ],
  5618. [
  5619. 4,
  5620. 5
  5621. ],
  5622. [
  5623. 4,
  5624. 5
  5625. ],
  5626. [
  5627. 4,
  5628. 5
  5629. ],
  5630. [
  5631. 4,
  5632. 5
  5633. ],
  5634. [
  5635. 4,
  5636. 5
  5637. ],
  5638. [
  5639. 4,
  5640. 5
  5641. ],
  5642. [
  5643. 4,
  5644. 5
  5645. ],
  5646. [
  5647. 4,
  5648. 5
  5649. ],
  5650. [
  5651. 4,
  5652. 5
  5653. ],
  5654. [
  5655. 4,
  5656. 5
  5657. ],
  5658. [
  5659. 4,
  5660. 5
  5661. ],
  5662. [
  5663. 4,
  5664. 5
  5665. ],
  5666. [
  5667. 4,
  5668. 5
  5669. ],
  5670. [
  5671. 4,
  5672. 5
  5673. ],
  5674. [
  5675. 4,
  5676. 5
  5677. ],
  5678. [
  5679. 4,
  5680. 5
  5681. ],
  5682. [
  5683. 4,
  5684. 5
  5685. ],
  5686. [
  5687. 4,
  5688. 5
  5689. ],
  5690. [
  5691. 6,
  5692. 14
  5693. ],
  5694. [
  5695. 6,
  5696. 14
  5697. ],
  5698. [
  5699. 6,
  5700. 14
  5701. ],
  5702. [
  5703. 6,
  5704. 14
  5705. ],
  5706. [
  5707. 6,
  5708. 14
  5709. ],
  5710. [
  5711. 6,
  5712. 14
  5713. ],
  5714. [
  5715. 6,
  5716. 14
  5717. ],
  5718. [
  5719. 6,
  5720. 14
  5721. ],
  5722. [
  5723. 6,
  5724. 15
  5725. ],
  5726. [
  5727. 6,
  5728. 15
  5729. ],
  5730. [
  5731. 6,
  5732. 15
  5733. ],
  5734. [
  5735. 6,
  5736. 15
  5737. ],
  5738. [
  5739. 6,
  5740. 15
  5741. ],
  5742. [
  5743. 6,
  5744. 15
  5745. ],
  5746. [
  5747. 6,
  5748. 15
  5749. ],
  5750. [
  5751. 6,
  5752. 15
  5753. ],
  5754. [
  5755. 5,
  5756. 64
  5757. ],
  5758. [
  5759. 5,
  5760. 64
  5761. ],
  5762. [
  5763. 5,
  5764. 64
  5765. ],
  5766. [
  5767. 5,
  5768. 64
  5769. ],
  5770. [
  5771. 5,
  5772. 64
  5773. ],
  5774. [
  5775. 5,
  5776. 64
  5777. ],
  5778. [
  5779. 5,
  5780. 64
  5781. ],
  5782. [
  5783. 5,
  5784. 64
  5785. ],
  5786. [
  5787. 5,
  5788. 64
  5789. ],
  5790. [
  5791. 5,
  5792. 64
  5793. ],
  5794. [
  5795. 5,
  5796. 64
  5797. ],
  5798. [
  5799. 5,
  5800. 64
  5801. ],
  5802. [
  5803. 5,
  5804. 64
  5805. ],
  5806. [
  5807. 5,
  5808. 64
  5809. ],
  5810. [
  5811. 5,
  5812. 64
  5813. ],
  5814. [
  5815. 5,
  5816. 64
  5817. ],
  5818. [
  5819. 4,
  5820. 6
  5821. ],
  5822. [
  5823. 4,
  5824. 6
  5825. ],
  5826. [
  5827. 4,
  5828. 6
  5829. ],
  5830. [
  5831. 4,
  5832. 6
  5833. ],
  5834. [
  5835. 4,
  5836. 6
  5837. ],
  5838. [
  5839. 4,
  5840. 6
  5841. ],
  5842. [
  5843. 4,
  5844. 6
  5845. ],
  5846. [
  5847. 4,
  5848. 6
  5849. ],
  5850. [
  5851. 4,
  5852. 6
  5853. ],
  5854. [
  5855. 4,
  5856. 6
  5857. ],
  5858. [
  5859. 4,
  5860. 6
  5861. ],
  5862. [
  5863. 4,
  5864. 6
  5865. ],
  5866. [
  5867. 4,
  5868. 6
  5869. ],
  5870. [
  5871. 4,
  5872. 6
  5873. ],
  5874. [
  5875. 4,
  5876. 6
  5877. ],
  5878. [
  5879. 4,
  5880. 6
  5881. ],
  5882. [
  5883. 4,
  5884. 6
  5885. ],
  5886. [
  5887. 4,
  5888. 6
  5889. ],
  5890. [
  5891. 4,
  5892. 6
  5893. ],
  5894. [
  5895. 4,
  5896. 6
  5897. ],
  5898. [
  5899. 4,
  5900. 6
  5901. ],
  5902. [
  5903. 4,
  5904. 6
  5905. ],
  5906. [
  5907. 4,
  5908. 6
  5909. ],
  5910. [
  5911. 4,
  5912. 6
  5913. ],
  5914. [
  5915. 4,
  5916. 6
  5917. ],
  5918. [
  5919. 4,
  5920. 6
  5921. ],
  5922. [
  5923. 4,
  5924. 6
  5925. ],
  5926. [
  5927. 4,
  5928. 6
  5929. ],
  5930. [
  5931. 4,
  5932. 6
  5933. ],
  5934. [
  5935. 4,
  5936. 6
  5937. ],
  5938. [
  5939. 4,
  5940. 6
  5941. ],
  5942. [
  5943. 4,
  5944. 6
  5945. ],
  5946. [
  5947. 4,
  5948. 7
  5949. ],
  5950. [
  5951. 4,
  5952. 7
  5953. ],
  5954. [
  5955. 4,
  5956. 7
  5957. ],
  5958. [
  5959. 4,
  5960. 7
  5961. ],
  5962. [
  5963. 4,
  5964. 7
  5965. ],
  5966. [
  5967. 4,
  5968. 7
  5969. ],
  5970. [
  5971. 4,
  5972. 7
  5973. ],
  5974. [
  5975. 4,
  5976. 7
  5977. ],
  5978. [
  5979. 4,
  5980. 7
  5981. ],
  5982. [
  5983. 4,
  5984. 7
  5985. ],
  5986. [
  5987. 4,
  5988. 7
  5989. ],
  5990. [
  5991. 4,
  5992. 7
  5993. ],
  5994. [
  5995. 4,
  5996. 7
  5997. ],
  5998. [
  5999. 4,
  6000. 7
  6001. ],
  6002. [
  6003. 4,
  6004. 7
  6005. ],
  6006. [
  6007. 4,
  6008. 7
  6009. ],
  6010. [
  6011. 4,
  6012. 7
  6013. ],
  6014. [
  6015. 4,
  6016. 7
  6017. ],
  6018. [
  6019. 4,
  6020. 7
  6021. ],
  6022. [
  6023. 4,
  6024. 7
  6025. ],
  6026. [
  6027. 4,
  6028. 7
  6029. ],
  6030. [
  6031. 4,
  6032. 7
  6033. ],
  6034. [
  6035. 4,
  6036. 7
  6037. ],
  6038. [
  6039. 4,
  6040. 7
  6041. ],
  6042. [
  6043. 4,
  6044. 7
  6045. ],
  6046. [
  6047. 4,
  6048. 7
  6049. ],
  6050. [
  6051. 4,
  6052. 7
  6053. ],
  6054. [
  6055. 4,
  6056. 7
  6057. ],
  6058. [
  6059. 4,
  6060. 7
  6061. ],
  6062. [
  6063. 4,
  6064. 7
  6065. ],
  6066. [
  6067. 4,
  6068. 7
  6069. ],
  6070. [
  6071. 4,
  6072. 7
  6073. ]
  6074. ];
  6075. var blackTable1 = [
  6076. [
  6077. -1,
  6078. -1
  6079. ],
  6080. [
  6081. -1,
  6082. -1
  6083. ],
  6084. [
  6085. 12,
  6086. ccittEOL
  6087. ],
  6088. [
  6089. 12,
  6090. ccittEOL
  6091. ],
  6092. [
  6093. -1,
  6094. -1
  6095. ],
  6096. [
  6097. -1,
  6098. -1
  6099. ],
  6100. [
  6101. -1,
  6102. -1
  6103. ],
  6104. [
  6105. -1,
  6106. -1
  6107. ],
  6108. [
  6109. -1,
  6110. -1
  6111. ],
  6112. [
  6113. -1,
  6114. -1
  6115. ],
  6116. [
  6117. -1,
  6118. -1
  6119. ],
  6120. [
  6121. -1,
  6122. -1
  6123. ],
  6124. [
  6125. -1,
  6126. -1
  6127. ],
  6128. [
  6129. -1,
  6130. -1
  6131. ],
  6132. [
  6133. -1,
  6134. -1
  6135. ],
  6136. [
  6137. -1,
  6138. -1
  6139. ],
  6140. [
  6141. -1,
  6142. -1
  6143. ],
  6144. [
  6145. -1,
  6146. -1
  6147. ],
  6148. [
  6149. -1,
  6150. -1
  6151. ],
  6152. [
  6153. -1,
  6154. -1
  6155. ],
  6156. [
  6157. -1,
  6158. -1
  6159. ],
  6160. [
  6161. -1,
  6162. -1
  6163. ],
  6164. [
  6165. -1,
  6166. -1
  6167. ],
  6168. [
  6169. -1,
  6170. -1
  6171. ],
  6172. [
  6173. -1,
  6174. -1
  6175. ],
  6176. [
  6177. -1,
  6178. -1
  6179. ],
  6180. [
  6181. -1,
  6182. -1
  6183. ],
  6184. [
  6185. -1,
  6186. -1
  6187. ],
  6188. [
  6189. -1,
  6190. -1
  6191. ],
  6192. [
  6193. -1,
  6194. -1
  6195. ],
  6196. [
  6197. -1,
  6198. -1
  6199. ],
  6200. [
  6201. -1,
  6202. -1
  6203. ],
  6204. [
  6205. 11,
  6206. 1792
  6207. ],
  6208. [
  6209. 11,
  6210. 1792
  6211. ],
  6212. [
  6213. 11,
  6214. 1792
  6215. ],
  6216. [
  6217. 11,
  6218. 1792
  6219. ],
  6220. [
  6221. 12,
  6222. 1984
  6223. ],
  6224. [
  6225. 12,
  6226. 1984
  6227. ],
  6228. [
  6229. 12,
  6230. 2048
  6231. ],
  6232. [
  6233. 12,
  6234. 2048
  6235. ],
  6236. [
  6237. 12,
  6238. 2112
  6239. ],
  6240. [
  6241. 12,
  6242. 2112
  6243. ],
  6244. [
  6245. 12,
  6246. 2176
  6247. ],
  6248. [
  6249. 12,
  6250. 2176
  6251. ],
  6252. [
  6253. 12,
  6254. 2240
  6255. ],
  6256. [
  6257. 12,
  6258. 2240
  6259. ],
  6260. [
  6261. 12,
  6262. 2304
  6263. ],
  6264. [
  6265. 12,
  6266. 2304
  6267. ],
  6268. [
  6269. 11,
  6270. 1856
  6271. ],
  6272. [
  6273. 11,
  6274. 1856
  6275. ],
  6276. [
  6277. 11,
  6278. 1856
  6279. ],
  6280. [
  6281. 11,
  6282. 1856
  6283. ],
  6284. [
  6285. 11,
  6286. 1920
  6287. ],
  6288. [
  6289. 11,
  6290. 1920
  6291. ],
  6292. [
  6293. 11,
  6294. 1920
  6295. ],
  6296. [
  6297. 11,
  6298. 1920
  6299. ],
  6300. [
  6301. 12,
  6302. 2368
  6303. ],
  6304. [
  6305. 12,
  6306. 2368
  6307. ],
  6308. [
  6309. 12,
  6310. 2432
  6311. ],
  6312. [
  6313. 12,
  6314. 2432
  6315. ],
  6316. [
  6317. 12,
  6318. 2496
  6319. ],
  6320. [
  6321. 12,
  6322. 2496
  6323. ],
  6324. [
  6325. 12,
  6326. 2560
  6327. ],
  6328. [
  6329. 12,
  6330. 2560
  6331. ],
  6332. [
  6333. 10,
  6334. 18
  6335. ],
  6336. [
  6337. 10,
  6338. 18
  6339. ],
  6340. [
  6341. 10,
  6342. 18
  6343. ],
  6344. [
  6345. 10,
  6346. 18
  6347. ],
  6348. [
  6349. 10,
  6350. 18
  6351. ],
  6352. [
  6353. 10,
  6354. 18
  6355. ],
  6356. [
  6357. 10,
  6358. 18
  6359. ],
  6360. [
  6361. 10,
  6362. 18
  6363. ],
  6364. [
  6365. 12,
  6366. 52
  6367. ],
  6368. [
  6369. 12,
  6370. 52
  6371. ],
  6372. [
  6373. 13,
  6374. 640
  6375. ],
  6376. [
  6377. 13,
  6378. 704
  6379. ],
  6380. [
  6381. 13,
  6382. 768
  6383. ],
  6384. [
  6385. 13,
  6386. 832
  6387. ],
  6388. [
  6389. 12,
  6390. 55
  6391. ],
  6392. [
  6393. 12,
  6394. 55
  6395. ],
  6396. [
  6397. 12,
  6398. 56
  6399. ],
  6400. [
  6401. 12,
  6402. 56
  6403. ],
  6404. [
  6405. 13,
  6406. 1280
  6407. ],
  6408. [
  6409. 13,
  6410. 1344
  6411. ],
  6412. [
  6413. 13,
  6414. 1408
  6415. ],
  6416. [
  6417. 13,
  6418. 1472
  6419. ],
  6420. [
  6421. 12,
  6422. 59
  6423. ],
  6424. [
  6425. 12,
  6426. 59
  6427. ],
  6428. [
  6429. 12,
  6430. 60
  6431. ],
  6432. [
  6433. 12,
  6434. 60
  6435. ],
  6436. [
  6437. 13,
  6438. 1536
  6439. ],
  6440. [
  6441. 13,
  6442. 1600
  6443. ],
  6444. [
  6445. 11,
  6446. 24
  6447. ],
  6448. [
  6449. 11,
  6450. 24
  6451. ],
  6452. [
  6453. 11,
  6454. 24
  6455. ],
  6456. [
  6457. 11,
  6458. 24
  6459. ],
  6460. [
  6461. 11,
  6462. 25
  6463. ],
  6464. [
  6465. 11,
  6466. 25
  6467. ],
  6468. [
  6469. 11,
  6470. 25
  6471. ],
  6472. [
  6473. 11,
  6474. 25
  6475. ],
  6476. [
  6477. 13,
  6478. 1664
  6479. ],
  6480. [
  6481. 13,
  6482. 1728
  6483. ],
  6484. [
  6485. 12,
  6486. 320
  6487. ],
  6488. [
  6489. 12,
  6490. 320
  6491. ],
  6492. [
  6493. 12,
  6494. 384
  6495. ],
  6496. [
  6497. 12,
  6498. 384
  6499. ],
  6500. [
  6501. 12,
  6502. 448
  6503. ],
  6504. [
  6505. 12,
  6506. 448
  6507. ],
  6508. [
  6509. 13,
  6510. 512
  6511. ],
  6512. [
  6513. 13,
  6514. 576
  6515. ],
  6516. [
  6517. 12,
  6518. 53
  6519. ],
  6520. [
  6521. 12,
  6522. 53
  6523. ],
  6524. [
  6525. 12,
  6526. 54
  6527. ],
  6528. [
  6529. 12,
  6530. 54
  6531. ],
  6532. [
  6533. 13,
  6534. 896
  6535. ],
  6536. [
  6537. 13,
  6538. 960
  6539. ],
  6540. [
  6541. 13,
  6542. 1024
  6543. ],
  6544. [
  6545. 13,
  6546. 1088
  6547. ],
  6548. [
  6549. 13,
  6550. 1152
  6551. ],
  6552. [
  6553. 13,
  6554. 1216
  6555. ],
  6556. [
  6557. 10,
  6558. 64
  6559. ],
  6560. [
  6561. 10,
  6562. 64
  6563. ],
  6564. [
  6565. 10,
  6566. 64
  6567. ],
  6568. [
  6569. 10,
  6570. 64
  6571. ],
  6572. [
  6573. 10,
  6574. 64
  6575. ],
  6576. [
  6577. 10,
  6578. 64
  6579. ],
  6580. [
  6581. 10,
  6582. 64
  6583. ],
  6584. [
  6585. 10,
  6586. 64
  6587. ]
  6588. ];
  6589. var blackTable2 = [
  6590. [
  6591. 8,
  6592. 13
  6593. ],
  6594. [
  6595. 8,
  6596. 13
  6597. ],
  6598. [
  6599. 8,
  6600. 13
  6601. ],
  6602. [
  6603. 8,
  6604. 13
  6605. ],
  6606. [
  6607. 8,
  6608. 13
  6609. ],
  6610. [
  6611. 8,
  6612. 13
  6613. ],
  6614. [
  6615. 8,
  6616. 13
  6617. ],
  6618. [
  6619. 8,
  6620. 13
  6621. ],
  6622. [
  6623. 8,
  6624. 13
  6625. ],
  6626. [
  6627. 8,
  6628. 13
  6629. ],
  6630. [
  6631. 8,
  6632. 13
  6633. ],
  6634. [
  6635. 8,
  6636. 13
  6637. ],
  6638. [
  6639. 8,
  6640. 13
  6641. ],
  6642. [
  6643. 8,
  6644. 13
  6645. ],
  6646. [
  6647. 8,
  6648. 13
  6649. ],
  6650. [
  6651. 8,
  6652. 13
  6653. ],
  6654. [
  6655. 11,
  6656. 23
  6657. ],
  6658. [
  6659. 11,
  6660. 23
  6661. ],
  6662. [
  6663. 12,
  6664. 50
  6665. ],
  6666. [
  6667. 12,
  6668. 51
  6669. ],
  6670. [
  6671. 12,
  6672. 44
  6673. ],
  6674. [
  6675. 12,
  6676. 45
  6677. ],
  6678. [
  6679. 12,
  6680. 46
  6681. ],
  6682. [
  6683. 12,
  6684. 47
  6685. ],
  6686. [
  6687. 12,
  6688. 57
  6689. ],
  6690. [
  6691. 12,
  6692. 58
  6693. ],
  6694. [
  6695. 12,
  6696. 61
  6697. ],
  6698. [
  6699. 12,
  6700. 256
  6701. ],
  6702. [
  6703. 10,
  6704. 16
  6705. ],
  6706. [
  6707. 10,
  6708. 16
  6709. ],
  6710. [
  6711. 10,
  6712. 16
  6713. ],
  6714. [
  6715. 10,
  6716. 16
  6717. ],
  6718. [
  6719. 10,
  6720. 17
  6721. ],
  6722. [
  6723. 10,
  6724. 17
  6725. ],
  6726. [
  6727. 10,
  6728. 17
  6729. ],
  6730. [
  6731. 10,
  6732. 17
  6733. ],
  6734. [
  6735. 12,
  6736. 48
  6737. ],
  6738. [
  6739. 12,
  6740. 49
  6741. ],
  6742. [
  6743. 12,
  6744. 62
  6745. ],
  6746. [
  6747. 12,
  6748. 63
  6749. ],
  6750. [
  6751. 12,
  6752. 30
  6753. ],
  6754. [
  6755. 12,
  6756. 31
  6757. ],
  6758. [
  6759. 12,
  6760. 32
  6761. ],
  6762. [
  6763. 12,
  6764. 33
  6765. ],
  6766. [
  6767. 12,
  6768. 40
  6769. ],
  6770. [
  6771. 12,
  6772. 41
  6773. ],
  6774. [
  6775. 11,
  6776. 22
  6777. ],
  6778. [
  6779. 11,
  6780. 22
  6781. ],
  6782. [
  6783. 8,
  6784. 14
  6785. ],
  6786. [
  6787. 8,
  6788. 14
  6789. ],
  6790. [
  6791. 8,
  6792. 14
  6793. ],
  6794. [
  6795. 8,
  6796. 14
  6797. ],
  6798. [
  6799. 8,
  6800. 14
  6801. ],
  6802. [
  6803. 8,
  6804. 14
  6805. ],
  6806. [
  6807. 8,
  6808. 14
  6809. ],
  6810. [
  6811. 8,
  6812. 14
  6813. ],
  6814. [
  6815. 8,
  6816. 14
  6817. ],
  6818. [
  6819. 8,
  6820. 14
  6821. ],
  6822. [
  6823. 8,
  6824. 14
  6825. ],
  6826. [
  6827. 8,
  6828. 14
  6829. ],
  6830. [
  6831. 8,
  6832. 14
  6833. ],
  6834. [
  6835. 8,
  6836. 14
  6837. ],
  6838. [
  6839. 8,
  6840. 14
  6841. ],
  6842. [
  6843. 8,
  6844. 14
  6845. ],
  6846. [
  6847. 7,
  6848. 10
  6849. ],
  6850. [
  6851. 7,
  6852. 10
  6853. ],
  6854. [
  6855. 7,
  6856. 10
  6857. ],
  6858. [
  6859. 7,
  6860. 10
  6861. ],
  6862. [
  6863. 7,
  6864. 10
  6865. ],
  6866. [
  6867. 7,
  6868. 10
  6869. ],
  6870. [
  6871. 7,
  6872. 10
  6873. ],
  6874. [
  6875. 7,
  6876. 10
  6877. ],
  6878. [
  6879. 7,
  6880. 10
  6881. ],
  6882. [
  6883. 7,
  6884. 10
  6885. ],
  6886. [
  6887. 7,
  6888. 10
  6889. ],
  6890. [
  6891. 7,
  6892. 10
  6893. ],
  6894. [
  6895. 7,
  6896. 10
  6897. ],
  6898. [
  6899. 7,
  6900. 10
  6901. ],
  6902. [
  6903. 7,
  6904. 10
  6905. ],
  6906. [
  6907. 7,
  6908. 10
  6909. ],
  6910. [
  6911. 7,
  6912. 10
  6913. ],
  6914. [
  6915. 7,
  6916. 10
  6917. ],
  6918. [
  6919. 7,
  6920. 10
  6921. ],
  6922. [
  6923. 7,
  6924. 10
  6925. ],
  6926. [
  6927. 7,
  6928. 10
  6929. ],
  6930. [
  6931. 7,
  6932. 10
  6933. ],
  6934. [
  6935. 7,
  6936. 10
  6937. ],
  6938. [
  6939. 7,
  6940. 10
  6941. ],
  6942. [
  6943. 7,
  6944. 10
  6945. ],
  6946. [
  6947. 7,
  6948. 10
  6949. ],
  6950. [
  6951. 7,
  6952. 10
  6953. ],
  6954. [
  6955. 7,
  6956. 10
  6957. ],
  6958. [
  6959. 7,
  6960. 10
  6961. ],
  6962. [
  6963. 7,
  6964. 10
  6965. ],
  6966. [
  6967. 7,
  6968. 10
  6969. ],
  6970. [
  6971. 7,
  6972. 10
  6973. ],
  6974. [
  6975. 7,
  6976. 11
  6977. ],
  6978. [
  6979. 7,
  6980. 11
  6981. ],
  6982. [
  6983. 7,
  6984. 11
  6985. ],
  6986. [
  6987. 7,
  6988. 11
  6989. ],
  6990. [
  6991. 7,
  6992. 11
  6993. ],
  6994. [
  6995. 7,
  6996. 11
  6997. ],
  6998. [
  6999. 7,
  7000. 11
  7001. ],
  7002. [
  7003. 7,
  7004. 11
  7005. ],
  7006. [
  7007. 7,
  7008. 11
  7009. ],
  7010. [
  7011. 7,
  7012. 11
  7013. ],
  7014. [
  7015. 7,
  7016. 11
  7017. ],
  7018. [
  7019. 7,
  7020. 11
  7021. ],
  7022. [
  7023. 7,
  7024. 11
  7025. ],
  7026. [
  7027. 7,
  7028. 11
  7029. ],
  7030. [
  7031. 7,
  7032. 11
  7033. ],
  7034. [
  7035. 7,
  7036. 11
  7037. ],
  7038. [
  7039. 7,
  7040. 11
  7041. ],
  7042. [
  7043. 7,
  7044. 11
  7045. ],
  7046. [
  7047. 7,
  7048. 11
  7049. ],
  7050. [
  7051. 7,
  7052. 11
  7053. ],
  7054. [
  7055. 7,
  7056. 11
  7057. ],
  7058. [
  7059. 7,
  7060. 11
  7061. ],
  7062. [
  7063. 7,
  7064. 11
  7065. ],
  7066. [
  7067. 7,
  7068. 11
  7069. ],
  7070. [
  7071. 7,
  7072. 11
  7073. ],
  7074. [
  7075. 7,
  7076. 11
  7077. ],
  7078. [
  7079. 7,
  7080. 11
  7081. ],
  7082. [
  7083. 7,
  7084. 11
  7085. ],
  7086. [
  7087. 7,
  7088. 11
  7089. ],
  7090. [
  7091. 7,
  7092. 11
  7093. ],
  7094. [
  7095. 7,
  7096. 11
  7097. ],
  7098. [
  7099. 7,
  7100. 11
  7101. ],
  7102. [
  7103. 9,
  7104. 15
  7105. ],
  7106. [
  7107. 9,
  7108. 15
  7109. ],
  7110. [
  7111. 9,
  7112. 15
  7113. ],
  7114. [
  7115. 9,
  7116. 15
  7117. ],
  7118. [
  7119. 9,
  7120. 15
  7121. ],
  7122. [
  7123. 9,
  7124. 15
  7125. ],
  7126. [
  7127. 9,
  7128. 15
  7129. ],
  7130. [
  7131. 9,
  7132. 15
  7133. ],
  7134. [
  7135. 12,
  7136. 128
  7137. ],
  7138. [
  7139. 12,
  7140. 192
  7141. ],
  7142. [
  7143. 12,
  7144. 26
  7145. ],
  7146. [
  7147. 12,
  7148. 27
  7149. ],
  7150. [
  7151. 12,
  7152. 28
  7153. ],
  7154. [
  7155. 12,
  7156. 29
  7157. ],
  7158. [
  7159. 11,
  7160. 19
  7161. ],
  7162. [
  7163. 11,
  7164. 19
  7165. ],
  7166. [
  7167. 11,
  7168. 20
  7169. ],
  7170. [
  7171. 11,
  7172. 20
  7173. ],
  7174. [
  7175. 12,
  7176. 34
  7177. ],
  7178. [
  7179. 12,
  7180. 35
  7181. ],
  7182. [
  7183. 12,
  7184. 36
  7185. ],
  7186. [
  7187. 12,
  7188. 37
  7189. ],
  7190. [
  7191. 12,
  7192. 38
  7193. ],
  7194. [
  7195. 12,
  7196. 39
  7197. ],
  7198. [
  7199. 11,
  7200. 21
  7201. ],
  7202. [
  7203. 11,
  7204. 21
  7205. ],
  7206. [
  7207. 12,
  7208. 42
  7209. ],
  7210. [
  7211. 12,
  7212. 43
  7213. ],
  7214. [
  7215. 10,
  7216. 0
  7217. ],
  7218. [
  7219. 10,
  7220. 0
  7221. ],
  7222. [
  7223. 10,
  7224. 0
  7225. ],
  7226. [
  7227. 10,
  7228. 0
  7229. ],
  7230. [
  7231. 7,
  7232. 12
  7233. ],
  7234. [
  7235. 7,
  7236. 12
  7237. ],
  7238. [
  7239. 7,
  7240. 12
  7241. ],
  7242. [
  7243. 7,
  7244. 12
  7245. ],
  7246. [
  7247. 7,
  7248. 12
  7249. ],
  7250. [
  7251. 7,
  7252. 12
  7253. ],
  7254. [
  7255. 7,
  7256. 12
  7257. ],
  7258. [
  7259. 7,
  7260. 12
  7261. ],
  7262. [
  7263. 7,
  7264. 12
  7265. ],
  7266. [
  7267. 7,
  7268. 12
  7269. ],
  7270. [
  7271. 7,
  7272. 12
  7273. ],
  7274. [
  7275. 7,
  7276. 12
  7277. ],
  7278. [
  7279. 7,
  7280. 12
  7281. ],
  7282. [
  7283. 7,
  7284. 12
  7285. ],
  7286. [
  7287. 7,
  7288. 12
  7289. ],
  7290. [
  7291. 7,
  7292. 12
  7293. ],
  7294. [
  7295. 7,
  7296. 12
  7297. ],
  7298. [
  7299. 7,
  7300. 12
  7301. ],
  7302. [
  7303. 7,
  7304. 12
  7305. ],
  7306. [
  7307. 7,
  7308. 12
  7309. ],
  7310. [
  7311. 7,
  7312. 12
  7313. ],
  7314. [
  7315. 7,
  7316. 12
  7317. ],
  7318. [
  7319. 7,
  7320. 12
  7321. ],
  7322. [
  7323. 7,
  7324. 12
  7325. ],
  7326. [
  7327. 7,
  7328. 12
  7329. ],
  7330. [
  7331. 7,
  7332. 12
  7333. ],
  7334. [
  7335. 7,
  7336. 12
  7337. ],
  7338. [
  7339. 7,
  7340. 12
  7341. ],
  7342. [
  7343. 7,
  7344. 12
  7345. ],
  7346. [
  7347. 7,
  7348. 12
  7349. ],
  7350. [
  7351. 7,
  7352. 12
  7353. ],
  7354. [
  7355. 7,
  7356. 12
  7357. ]
  7358. ];
  7359. var blackTable3 = [
  7360. [
  7361. -1,
  7362. -1
  7363. ],
  7364. [
  7365. -1,
  7366. -1
  7367. ],
  7368. [
  7369. -1,
  7370. -1
  7371. ],
  7372. [
  7373. -1,
  7374. -1
  7375. ],
  7376. [
  7377. 6,
  7378. 9
  7379. ],
  7380. [
  7381. 6,
  7382. 8
  7383. ],
  7384. [
  7385. 5,
  7386. 7
  7387. ],
  7388. [
  7389. 5,
  7390. 7
  7391. ],
  7392. [
  7393. 4,
  7394. 6
  7395. ],
  7396. [
  7397. 4,
  7398. 6
  7399. ],
  7400. [
  7401. 4,
  7402. 6
  7403. ],
  7404. [
  7405. 4,
  7406. 6
  7407. ],
  7408. [
  7409. 4,
  7410. 5
  7411. ],
  7412. [
  7413. 4,
  7414. 5
  7415. ],
  7416. [
  7417. 4,
  7418. 5
  7419. ],
  7420. [
  7421. 4,
  7422. 5
  7423. ],
  7424. [
  7425. 3,
  7426. 1
  7427. ],
  7428. [
  7429. 3,
  7430. 1
  7431. ],
  7432. [
  7433. 3,
  7434. 1
  7435. ],
  7436. [
  7437. 3,
  7438. 1
  7439. ],
  7440. [
  7441. 3,
  7442. 1
  7443. ],
  7444. [
  7445. 3,
  7446. 1
  7447. ],
  7448. [
  7449. 3,
  7450. 1
  7451. ],
  7452. [
  7453. 3,
  7454. 1
  7455. ],
  7456. [
  7457. 3,
  7458. 4
  7459. ],
  7460. [
  7461. 3,
  7462. 4
  7463. ],
  7464. [
  7465. 3,
  7466. 4
  7467. ],
  7468. [
  7469. 3,
  7470. 4
  7471. ],
  7472. [
  7473. 3,
  7474. 4
  7475. ],
  7476. [
  7477. 3,
  7478. 4
  7479. ],
  7480. [
  7481. 3,
  7482. 4
  7483. ],
  7484. [
  7485. 3,
  7486. 4
  7487. ],
  7488. [
  7489. 2,
  7490. 3
  7491. ],
  7492. [
  7493. 2,
  7494. 3
  7495. ],
  7496. [
  7497. 2,
  7498. 3
  7499. ],
  7500. [
  7501. 2,
  7502. 3
  7503. ],
  7504. [
  7505. 2,
  7506. 3
  7507. ],
  7508. [
  7509. 2,
  7510. 3
  7511. ],
  7512. [
  7513. 2,
  7514. 3
  7515. ],
  7516. [
  7517. 2,
  7518. 3
  7519. ],
  7520. [
  7521. 2,
  7522. 3
  7523. ],
  7524. [
  7525. 2,
  7526. 3
  7527. ],
  7528. [
  7529. 2,
  7530. 3
  7531. ],
  7532. [
  7533. 2,
  7534. 3
  7535. ],
  7536. [
  7537. 2,
  7538. 3
  7539. ],
  7540. [
  7541. 2,
  7542. 3
  7543. ],
  7544. [
  7545. 2,
  7546. 3
  7547. ],
  7548. [
  7549. 2,
  7550. 3
  7551. ],
  7552. [
  7553. 2,
  7554. 2
  7555. ],
  7556. [
  7557. 2,
  7558. 2
  7559. ],
  7560. [
  7561. 2,
  7562. 2
  7563. ],
  7564. [
  7565. 2,
  7566. 2
  7567. ],
  7568. [
  7569. 2,
  7570. 2
  7571. ],
  7572. [
  7573. 2,
  7574. 2
  7575. ],
  7576. [
  7577. 2,
  7578. 2
  7579. ],
  7580. [
  7581. 2,
  7582. 2
  7583. ],
  7584. [
  7585. 2,
  7586. 2
  7587. ],
  7588. [
  7589. 2,
  7590. 2
  7591. ],
  7592. [
  7593. 2,
  7594. 2
  7595. ],
  7596. [
  7597. 2,
  7598. 2
  7599. ],
  7600. [
  7601. 2,
  7602. 2
  7603. ],
  7604. [
  7605. 2,
  7606. 2
  7607. ],
  7608. [
  7609. 2,
  7610. 2
  7611. ],
  7612. [
  7613. 2,
  7614. 2
  7615. ]
  7616. ];
  7617. function CCITTFaxStream(str, maybeLength, params) {
  7618. this.str = str;
  7619. this.dict = str.dict;
  7620. params = params || Dict.empty;
  7621. this.encoding = params.get('K') || 0;
  7622. this.eoline = params.get('EndOfLine') || false;
  7623. this.byteAlign = params.get('EncodedByteAlign') || false;
  7624. this.columns = params.get('Columns') || 1728;
  7625. this.rows = params.get('Rows') || 0;
  7626. var eoblock = params.get('EndOfBlock');
  7627. if (eoblock === null || eoblock === undefined) {
  7628. eoblock = true;
  7629. }
  7630. this.eoblock = eoblock;
  7631. this.black = params.get('BlackIs1') || false;
  7632. this.codingLine = new Uint32Array(this.columns + 1);
  7633. this.refLine = new Uint32Array(this.columns + 2);
  7634. this.codingLine[0] = this.columns;
  7635. this.codingPos = 0;
  7636. this.row = 0;
  7637. this.nextLine2D = this.encoding < 0;
  7638. this.inputBits = 0;
  7639. this.inputBuf = 0;
  7640. this.outputBits = 0;
  7641. var code1;
  7642. while ((code1 = this.lookBits(12)) === 0) {
  7643. this.eatBits(1);
  7644. }
  7645. if (code1 === 1) {
  7646. this.eatBits(12);
  7647. }
  7648. if (this.encoding > 0) {
  7649. this.nextLine2D = !this.lookBits(1);
  7650. this.eatBits(1);
  7651. }
  7652. DecodeStream.call(this, maybeLength);
  7653. }
  7654. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7655. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7656. while (!this.eof) {
  7657. var c = this.lookChar();
  7658. this.ensureBuffer(this.bufferLength + 1);
  7659. this.buffer[this.bufferLength++] = c;
  7660. }
  7661. };
  7662. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7663. var codingLine = this.codingLine;
  7664. var codingPos = this.codingPos;
  7665. if (a1 > codingLine[codingPos]) {
  7666. if (a1 > this.columns) {
  7667. info('row is wrong length');
  7668. this.err = true;
  7669. a1 = this.columns;
  7670. }
  7671. if (codingPos & 1 ^ blackPixels) {
  7672. ++codingPos;
  7673. }
  7674. codingLine[codingPos] = a1;
  7675. }
  7676. this.codingPos = codingPos;
  7677. };
  7678. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7679. var codingLine = this.codingLine;
  7680. var codingPos = this.codingPos;
  7681. if (a1 > codingLine[codingPos]) {
  7682. if (a1 > this.columns) {
  7683. info('row is wrong length');
  7684. this.err = true;
  7685. a1 = this.columns;
  7686. }
  7687. if (codingPos & 1 ^ blackPixels) {
  7688. ++codingPos;
  7689. }
  7690. codingLine[codingPos] = a1;
  7691. } else if (a1 < codingLine[codingPos]) {
  7692. if (a1 < 0) {
  7693. info('invalid code');
  7694. this.err = true;
  7695. a1 = 0;
  7696. }
  7697. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7698. --codingPos;
  7699. }
  7700. codingLine[codingPos] = a1;
  7701. }
  7702. this.codingPos = codingPos;
  7703. };
  7704. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7705. var refLine = this.refLine;
  7706. var codingLine = this.codingLine;
  7707. var columns = this.columns;
  7708. var refPos, blackPixels, bits, i;
  7709. if (this.outputBits === 0) {
  7710. if (this.eof) {
  7711. return null;
  7712. }
  7713. this.err = false;
  7714. var code1, code2, code3;
  7715. if (this.nextLine2D) {
  7716. for (i = 0; codingLine[i] < columns; ++i) {
  7717. refLine[i] = codingLine[i];
  7718. }
  7719. refLine[i++] = columns;
  7720. refLine[i] = columns;
  7721. codingLine[0] = 0;
  7722. this.codingPos = 0;
  7723. refPos = 0;
  7724. blackPixels = 0;
  7725. while (codingLine[this.codingPos] < columns) {
  7726. code1 = this.getTwoDimCode();
  7727. switch (code1) {
  7728. case twoDimPass:
  7729. this.addPixels(refLine[refPos + 1], blackPixels);
  7730. if (refLine[refPos + 1] < columns) {
  7731. refPos += 2;
  7732. }
  7733. break;
  7734. case twoDimHoriz:
  7735. code1 = code2 = 0;
  7736. if (blackPixels) {
  7737. do {
  7738. code1 += code3 = this.getBlackCode();
  7739. } while (code3 >= 64);
  7740. do {
  7741. code2 += code3 = this.getWhiteCode();
  7742. } while (code3 >= 64);
  7743. } else {
  7744. do {
  7745. code1 += code3 = this.getWhiteCode();
  7746. } while (code3 >= 64);
  7747. do {
  7748. code2 += code3 = this.getBlackCode();
  7749. } while (code3 >= 64);
  7750. }
  7751. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7752. if (codingLine[this.codingPos] < columns) {
  7753. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7754. }
  7755. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7756. refPos += 2;
  7757. }
  7758. break;
  7759. case twoDimVertR3:
  7760. this.addPixels(refLine[refPos] + 3, blackPixels);
  7761. blackPixels ^= 1;
  7762. if (codingLine[this.codingPos] < columns) {
  7763. ++refPos;
  7764. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7765. refPos += 2;
  7766. }
  7767. }
  7768. break;
  7769. case twoDimVertR2:
  7770. this.addPixels(refLine[refPos] + 2, blackPixels);
  7771. blackPixels ^= 1;
  7772. if (codingLine[this.codingPos] < columns) {
  7773. ++refPos;
  7774. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7775. refPos += 2;
  7776. }
  7777. }
  7778. break;
  7779. case twoDimVertR1:
  7780. this.addPixels(refLine[refPos] + 1, blackPixels);
  7781. blackPixels ^= 1;
  7782. if (codingLine[this.codingPos] < columns) {
  7783. ++refPos;
  7784. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7785. refPos += 2;
  7786. }
  7787. }
  7788. break;
  7789. case twoDimVert0:
  7790. this.addPixels(refLine[refPos], blackPixels);
  7791. blackPixels ^= 1;
  7792. if (codingLine[this.codingPos] < columns) {
  7793. ++refPos;
  7794. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7795. refPos += 2;
  7796. }
  7797. }
  7798. break;
  7799. case twoDimVertL3:
  7800. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7801. blackPixels ^= 1;
  7802. if (codingLine[this.codingPos] < columns) {
  7803. if (refPos > 0) {
  7804. --refPos;
  7805. } else {
  7806. ++refPos;
  7807. }
  7808. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7809. refPos += 2;
  7810. }
  7811. }
  7812. break;
  7813. case twoDimVertL2:
  7814. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7815. blackPixels ^= 1;
  7816. if (codingLine[this.codingPos] < columns) {
  7817. if (refPos > 0) {
  7818. --refPos;
  7819. } else {
  7820. ++refPos;
  7821. }
  7822. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7823. refPos += 2;
  7824. }
  7825. }
  7826. break;
  7827. case twoDimVertL1:
  7828. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7829. blackPixels ^= 1;
  7830. if (codingLine[this.codingPos] < columns) {
  7831. if (refPos > 0) {
  7832. --refPos;
  7833. } else {
  7834. ++refPos;
  7835. }
  7836. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7837. refPos += 2;
  7838. }
  7839. }
  7840. break;
  7841. case ccittEOF:
  7842. this.addPixels(columns, 0);
  7843. this.eof = true;
  7844. break;
  7845. default:
  7846. info('bad 2d code');
  7847. this.addPixels(columns, 0);
  7848. this.err = true;
  7849. }
  7850. }
  7851. } else {
  7852. codingLine[0] = 0;
  7853. this.codingPos = 0;
  7854. blackPixels = 0;
  7855. while (codingLine[this.codingPos] < columns) {
  7856. code1 = 0;
  7857. if (blackPixels) {
  7858. do {
  7859. code1 += code3 = this.getBlackCode();
  7860. } while (code3 >= 64);
  7861. } else {
  7862. do {
  7863. code1 += code3 = this.getWhiteCode();
  7864. } while (code3 >= 64);
  7865. }
  7866. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7867. blackPixels ^= 1;
  7868. }
  7869. }
  7870. var gotEOL = false;
  7871. if (this.byteAlign) {
  7872. this.inputBits &= ~7;
  7873. }
  7874. if (!this.eoblock && this.row === this.rows - 1) {
  7875. this.eof = true;
  7876. } else {
  7877. code1 = this.lookBits(12);
  7878. if (this.eoline) {
  7879. while (code1 !== ccittEOF && code1 !== 1) {
  7880. this.eatBits(1);
  7881. code1 = this.lookBits(12);
  7882. }
  7883. } else {
  7884. while (code1 === 0) {
  7885. this.eatBits(1);
  7886. code1 = this.lookBits(12);
  7887. }
  7888. }
  7889. if (code1 === 1) {
  7890. this.eatBits(12);
  7891. gotEOL = true;
  7892. } else if (code1 === ccittEOF) {
  7893. this.eof = true;
  7894. }
  7895. }
  7896. if (!this.eof && this.encoding > 0) {
  7897. this.nextLine2D = !this.lookBits(1);
  7898. this.eatBits(1);
  7899. }
  7900. if (this.eoblock && gotEOL && this.byteAlign) {
  7901. code1 = this.lookBits(12);
  7902. if (code1 === 1) {
  7903. this.eatBits(12);
  7904. if (this.encoding > 0) {
  7905. this.lookBits(1);
  7906. this.eatBits(1);
  7907. }
  7908. if (this.encoding >= 0) {
  7909. for (i = 0; i < 4; ++i) {
  7910. code1 = this.lookBits(12);
  7911. if (code1 !== 1) {
  7912. info('bad rtc code: ' + code1);
  7913. }
  7914. this.eatBits(12);
  7915. if (this.encoding > 0) {
  7916. this.lookBits(1);
  7917. this.eatBits(1);
  7918. }
  7919. }
  7920. }
  7921. this.eof = true;
  7922. }
  7923. } else if (this.err && this.eoline) {
  7924. while (true) {
  7925. code1 = this.lookBits(13);
  7926. if (code1 === ccittEOF) {
  7927. this.eof = true;
  7928. return null;
  7929. }
  7930. if (code1 >> 1 === 1) {
  7931. break;
  7932. }
  7933. this.eatBits(1);
  7934. }
  7935. this.eatBits(12);
  7936. if (this.encoding > 0) {
  7937. this.eatBits(1);
  7938. this.nextLine2D = !(code1 & 1);
  7939. }
  7940. }
  7941. if (codingLine[0] > 0) {
  7942. this.outputBits = codingLine[this.codingPos = 0];
  7943. } else {
  7944. this.outputBits = codingLine[this.codingPos = 1];
  7945. }
  7946. this.row++;
  7947. }
  7948. var c;
  7949. if (this.outputBits >= 8) {
  7950. c = this.codingPos & 1 ? 0 : 0xFF;
  7951. this.outputBits -= 8;
  7952. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7953. this.codingPos++;
  7954. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7955. }
  7956. } else {
  7957. bits = 8;
  7958. c = 0;
  7959. do {
  7960. if (this.outputBits > bits) {
  7961. c <<= bits;
  7962. if (!(this.codingPos & 1)) {
  7963. c |= 0xFF >> 8 - bits;
  7964. }
  7965. this.outputBits -= bits;
  7966. bits = 0;
  7967. } else {
  7968. c <<= this.outputBits;
  7969. if (!(this.codingPos & 1)) {
  7970. c |= 0xFF >> 8 - this.outputBits;
  7971. }
  7972. bits -= this.outputBits;
  7973. this.outputBits = 0;
  7974. if (codingLine[this.codingPos] < columns) {
  7975. this.codingPos++;
  7976. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7977. } else if (bits > 0) {
  7978. c <<= bits;
  7979. bits = 0;
  7980. }
  7981. }
  7982. } while (bits);
  7983. }
  7984. if (this.black) {
  7985. c ^= 0xFF;
  7986. }
  7987. return c;
  7988. };
  7989. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  7990. var limitValue = limit || 0;
  7991. for (var i = start; i <= end; ++i) {
  7992. var code = this.lookBits(i);
  7993. if (code === ccittEOF) {
  7994. return [
  7995. true,
  7996. 1,
  7997. false
  7998. ];
  7999. }
  8000. if (i < end) {
  8001. code <<= end - i;
  8002. }
  8003. if (!limitValue || code >= limitValue) {
  8004. var p = table[code - limitValue];
  8005. if (p[0] === i) {
  8006. this.eatBits(i);
  8007. return [
  8008. true,
  8009. p[1],
  8010. true
  8011. ];
  8012. }
  8013. }
  8014. }
  8015. return [
  8016. false,
  8017. 0,
  8018. false
  8019. ];
  8020. };
  8021. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8022. var code = 0;
  8023. var p;
  8024. if (this.eoblock) {
  8025. code = this.lookBits(7);
  8026. p = twoDimTable[code];
  8027. if (p && p[0] > 0) {
  8028. this.eatBits(p[0]);
  8029. return p[1];
  8030. }
  8031. } else {
  8032. var result = this.findTableCode(1, 7, twoDimTable);
  8033. if (result[0] && result[2]) {
  8034. return result[1];
  8035. }
  8036. }
  8037. info('Bad two dim code');
  8038. return ccittEOF;
  8039. };
  8040. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8041. var code = 0;
  8042. var p;
  8043. if (this.eoblock) {
  8044. code = this.lookBits(12);
  8045. if (code === ccittEOF) {
  8046. return 1;
  8047. }
  8048. if (code >> 5 === 0) {
  8049. p = whiteTable1[code];
  8050. } else {
  8051. p = whiteTable2[code >> 3];
  8052. }
  8053. if (p[0] > 0) {
  8054. this.eatBits(p[0]);
  8055. return p[1];
  8056. }
  8057. } else {
  8058. var result = this.findTableCode(1, 9, whiteTable2);
  8059. if (result[0]) {
  8060. return result[1];
  8061. }
  8062. result = this.findTableCode(11, 12, whiteTable1);
  8063. if (result[0]) {
  8064. return result[1];
  8065. }
  8066. }
  8067. info('bad white code');
  8068. this.eatBits(1);
  8069. return 1;
  8070. };
  8071. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8072. var code, p;
  8073. if (this.eoblock) {
  8074. code = this.lookBits(13);
  8075. if (code === ccittEOF) {
  8076. return 1;
  8077. }
  8078. if (code >> 7 === 0) {
  8079. p = blackTable1[code];
  8080. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8081. p = blackTable2[(code >> 1) - 64];
  8082. } else {
  8083. p = blackTable3[code >> 7];
  8084. }
  8085. if (p[0] > 0) {
  8086. this.eatBits(p[0]);
  8087. return p[1];
  8088. }
  8089. } else {
  8090. var result = this.findTableCode(2, 6, blackTable3);
  8091. if (result[0]) {
  8092. return result[1];
  8093. }
  8094. result = this.findTableCode(7, 12, blackTable2, 64);
  8095. if (result[0]) {
  8096. return result[1];
  8097. }
  8098. result = this.findTableCode(10, 13, blackTable1);
  8099. if (result[0]) {
  8100. return result[1];
  8101. }
  8102. }
  8103. info('bad black code');
  8104. this.eatBits(1);
  8105. return 1;
  8106. };
  8107. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8108. var c;
  8109. while (this.inputBits < n) {
  8110. if ((c = this.str.getByte()) === -1) {
  8111. if (this.inputBits === 0) {
  8112. return ccittEOF;
  8113. }
  8114. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8115. }
  8116. this.inputBuf = this.inputBuf << 8 | c;
  8117. this.inputBits += 8;
  8118. }
  8119. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8120. };
  8121. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8122. if ((this.inputBits -= n) < 0) {
  8123. this.inputBits = 0;
  8124. }
  8125. };
  8126. return CCITTFaxStream;
  8127. }();
  8128. var LZWStream = function LZWStreamClosure() {
  8129. function LZWStream(str, maybeLength, earlyChange) {
  8130. this.str = str;
  8131. this.dict = str.dict;
  8132. this.cachedData = 0;
  8133. this.bitsCached = 0;
  8134. var maxLzwDictionarySize = 4096;
  8135. var lzwState = {
  8136. earlyChange: earlyChange,
  8137. codeLength: 9,
  8138. nextCode: 258,
  8139. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8140. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8141. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8142. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8143. currentSequenceLength: 0
  8144. };
  8145. for (var i = 0; i < 256; ++i) {
  8146. lzwState.dictionaryValues[i] = i;
  8147. lzwState.dictionaryLengths[i] = 1;
  8148. }
  8149. this.lzwState = lzwState;
  8150. DecodeStream.call(this, maybeLength);
  8151. }
  8152. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8153. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8154. var bitsCached = this.bitsCached;
  8155. var cachedData = this.cachedData;
  8156. while (bitsCached < n) {
  8157. var c = this.str.getByte();
  8158. if (c === -1) {
  8159. this.eof = true;
  8160. return null;
  8161. }
  8162. cachedData = cachedData << 8 | c;
  8163. bitsCached += 8;
  8164. }
  8165. this.bitsCached = bitsCached -= n;
  8166. this.cachedData = cachedData;
  8167. this.lastCode = null;
  8168. return cachedData >>> bitsCached & (1 << n) - 1;
  8169. };
  8170. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8171. var blockSize = 512;
  8172. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8173. var i, j, q;
  8174. var lzwState = this.lzwState;
  8175. if (!lzwState) {
  8176. return;
  8177. }
  8178. var earlyChange = lzwState.earlyChange;
  8179. var nextCode = lzwState.nextCode;
  8180. var dictionaryValues = lzwState.dictionaryValues;
  8181. var dictionaryLengths = lzwState.dictionaryLengths;
  8182. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8183. var codeLength = lzwState.codeLength;
  8184. var prevCode = lzwState.prevCode;
  8185. var currentSequence = lzwState.currentSequence;
  8186. var currentSequenceLength = lzwState.currentSequenceLength;
  8187. var decodedLength = 0;
  8188. var currentBufferLength = this.bufferLength;
  8189. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8190. for (i = 0; i < blockSize; i++) {
  8191. var code = this.readBits(codeLength);
  8192. var hasPrev = currentSequenceLength > 0;
  8193. if (code < 256) {
  8194. currentSequence[0] = code;
  8195. currentSequenceLength = 1;
  8196. } else if (code >= 258) {
  8197. if (code < nextCode) {
  8198. currentSequenceLength = dictionaryLengths[code];
  8199. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8200. currentSequence[j] = dictionaryValues[q];
  8201. q = dictionaryPrevCodes[q];
  8202. }
  8203. } else {
  8204. currentSequence[currentSequenceLength++] = currentSequence[0];
  8205. }
  8206. } else if (code === 256) {
  8207. codeLength = 9;
  8208. nextCode = 258;
  8209. currentSequenceLength = 0;
  8210. continue;
  8211. } else {
  8212. this.eof = true;
  8213. delete this.lzwState;
  8214. break;
  8215. }
  8216. if (hasPrev) {
  8217. dictionaryPrevCodes[nextCode] = prevCode;
  8218. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8219. dictionaryValues[nextCode] = currentSequence[0];
  8220. nextCode++;
  8221. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8222. }
  8223. prevCode = code;
  8224. decodedLength += currentSequenceLength;
  8225. if (estimatedDecodedSize < decodedLength) {
  8226. do {
  8227. estimatedDecodedSize += decodedSizeDelta;
  8228. } while (estimatedDecodedSize < decodedLength);
  8229. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8230. }
  8231. for (j = 0; j < currentSequenceLength; j++) {
  8232. buffer[currentBufferLength++] = currentSequence[j];
  8233. }
  8234. }
  8235. lzwState.nextCode = nextCode;
  8236. lzwState.codeLength = codeLength;
  8237. lzwState.prevCode = prevCode;
  8238. lzwState.currentSequenceLength = currentSequenceLength;
  8239. this.bufferLength = currentBufferLength;
  8240. };
  8241. return LZWStream;
  8242. }();
  8243. var NullStream = function NullStreamClosure() {
  8244. function NullStream() {
  8245. Stream.call(this, new Uint8Array(0));
  8246. }
  8247. NullStream.prototype = Stream.prototype;
  8248. return NullStream;
  8249. }();
  8250. exports.Ascii85Stream = Ascii85Stream;
  8251. exports.AsciiHexStream = AsciiHexStream;
  8252. exports.CCITTFaxStream = CCITTFaxStream;
  8253. exports.DecryptStream = DecryptStream;
  8254. exports.DecodeStream = DecodeStream;
  8255. exports.FlateStream = FlateStream;
  8256. exports.Jbig2Stream = Jbig2Stream;
  8257. exports.JpegStream = JpegStream;
  8258. exports.JpxStream = JpxStream;
  8259. exports.NullStream = NullStream;
  8260. exports.PredictorStream = PredictorStream;
  8261. exports.RunLengthStream = RunLengthStream;
  8262. exports.Stream = Stream;
  8263. exports.StreamsSequenceStream = StreamsSequenceStream;
  8264. exports.StringStream = StringStream;
  8265. exports.LZWStream = LZWStream;
  8266. /***/ }),
  8267. /* 3 */
  8268. /***/ (function(module, exports, __w_pdfjs_require__) {
  8269. "use strict";
  8270. var sharedUtil = __w_pdfjs_require__(0);
  8271. var assert = sharedUtil.assert;
  8272. var removeNullCharacters = sharedUtil.removeNullCharacters;
  8273. var warn = sharedUtil.warn;
  8274. var deprecated = sharedUtil.deprecated;
  8275. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  8276. var stringToBytes = sharedUtil.stringToBytes;
  8277. var CMapCompressionType = sharedUtil.CMapCompressionType;
  8278. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  8279. function DOMCanvasFactory() {
  8280. }
  8281. DOMCanvasFactory.prototype = {
  8282. create: function DOMCanvasFactory_create(width, height) {
  8283. assert(width > 0 && height > 0, 'invalid canvas size');
  8284. var canvas = document.createElement('canvas');
  8285. var context = canvas.getContext('2d');
  8286. canvas.width = width;
  8287. canvas.height = height;
  8288. return {
  8289. canvas: canvas,
  8290. context: context
  8291. };
  8292. },
  8293. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  8294. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8295. assert(width > 0 && height > 0, 'invalid canvas size');
  8296. canvasAndContextPair.canvas.width = width;
  8297. canvasAndContextPair.canvas.height = height;
  8298. },
  8299. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  8300. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8301. canvasAndContextPair.canvas.width = 0;
  8302. canvasAndContextPair.canvas.height = 0;
  8303. canvasAndContextPair.canvas = null;
  8304. canvasAndContextPair.context = null;
  8305. }
  8306. };
  8307. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  8308. function DOMCMapReaderFactory(params) {
  8309. this.baseUrl = params.baseUrl || null;
  8310. this.isCompressed = params.isCompressed || false;
  8311. }
  8312. DOMCMapReaderFactory.prototype = {
  8313. fetch: function (params) {
  8314. if (!params.name) {
  8315. return Promise.reject(new Error('CMap name must be specified.'));
  8316. }
  8317. return new Promise(function (resolve, reject) {
  8318. var url = this.baseUrl + params.name;
  8319. var request = new XMLHttpRequest();
  8320. if (this.isCompressed) {
  8321. url += '.bcmap';
  8322. request.responseType = 'arraybuffer';
  8323. }
  8324. request.onreadystatechange = function () {
  8325. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  8326. var data;
  8327. if (this.isCompressed && request.response) {
  8328. data = new Uint8Array(request.response);
  8329. } else if (!this.isCompressed && request.responseText) {
  8330. data = stringToBytes(request.responseText);
  8331. }
  8332. if (data) {
  8333. resolve({
  8334. cMapData: data,
  8335. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  8336. });
  8337. return;
  8338. }
  8339. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  8340. }
  8341. }.bind(this);
  8342. request.open('GET', url, true);
  8343. request.send(null);
  8344. }.bind(this));
  8345. }
  8346. };
  8347. return DOMCMapReaderFactory;
  8348. }();
  8349. var CustomStyle = function CustomStyleClosure() {
  8350. var prefixes = [
  8351. 'ms',
  8352. 'Moz',
  8353. 'Webkit',
  8354. 'O'
  8355. ];
  8356. var _cache = Object.create(null);
  8357. function CustomStyle() {
  8358. }
  8359. CustomStyle.getProp = function get(propName, element) {
  8360. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  8361. return _cache[propName];
  8362. }
  8363. element = element || document.documentElement;
  8364. var style = element.style, prefixed, uPropName;
  8365. if (typeof style[propName] === 'string') {
  8366. return _cache[propName] = propName;
  8367. }
  8368. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  8369. for (var i = 0, l = prefixes.length; i < l; i++) {
  8370. prefixed = prefixes[i] + uPropName;
  8371. if (typeof style[prefixed] === 'string') {
  8372. return _cache[propName] = prefixed;
  8373. }
  8374. }
  8375. return _cache[propName] = 'undefined';
  8376. };
  8377. CustomStyle.setProp = function set(propName, element, str) {
  8378. var prop = this.getProp(propName);
  8379. if (prop !== 'undefined') {
  8380. element.style[prop] = str;
  8381. }
  8382. };
  8383. return CustomStyle;
  8384. }();
  8385. var hasCanvasTypedArrays;
  8386. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  8387. var canvas = document.createElement('canvas');
  8388. canvas.width = canvas.height = 1;
  8389. var ctx = canvas.getContext('2d');
  8390. var imageData = ctx.createImageData(1, 1);
  8391. return typeof imageData.data.buffer !== 'undefined';
  8392. };
  8393. var LinkTarget = {
  8394. NONE: 0,
  8395. SELF: 1,
  8396. BLANK: 2,
  8397. PARENT: 3,
  8398. TOP: 4
  8399. };
  8400. var LinkTargetStringMap = [
  8401. '',
  8402. '_self',
  8403. '_blank',
  8404. '_parent',
  8405. '_top'
  8406. ];
  8407. function addLinkAttributes(link, params) {
  8408. var url = params && params.url;
  8409. link.href = link.title = url ? removeNullCharacters(url) : '';
  8410. if (url) {
  8411. var target = params.target;
  8412. if (typeof target === 'undefined') {
  8413. target = getDefaultSetting('externalLinkTarget');
  8414. }
  8415. link.target = LinkTargetStringMap[target];
  8416. var rel = params.rel;
  8417. if (typeof rel === 'undefined') {
  8418. rel = getDefaultSetting('externalLinkRel');
  8419. }
  8420. link.rel = rel;
  8421. }
  8422. }
  8423. function getFilenameFromUrl(url) {
  8424. var anchor = url.indexOf('#');
  8425. var query = url.indexOf('?');
  8426. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  8427. return url.substring(url.lastIndexOf('/', end) + 1, end);
  8428. }
  8429. function getDefaultSetting(id) {
  8430. var globalSettings = sharedUtil.globalScope.PDFJS;
  8431. switch (id) {
  8432. case 'pdfBug':
  8433. return globalSettings ? globalSettings.pdfBug : false;
  8434. case 'disableAutoFetch':
  8435. return globalSettings ? globalSettings.disableAutoFetch : false;
  8436. case 'disableStream':
  8437. return globalSettings ? globalSettings.disableStream : false;
  8438. case 'disableRange':
  8439. return globalSettings ? globalSettings.disableRange : false;
  8440. case 'disableFontFace':
  8441. return globalSettings ? globalSettings.disableFontFace : false;
  8442. case 'disableCreateObjectURL':
  8443. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  8444. case 'disableWebGL':
  8445. return globalSettings ? globalSettings.disableWebGL : true;
  8446. case 'cMapUrl':
  8447. return globalSettings ? globalSettings.cMapUrl : null;
  8448. case 'cMapPacked':
  8449. return globalSettings ? globalSettings.cMapPacked : false;
  8450. case 'postMessageTransfers':
  8451. return globalSettings ? globalSettings.postMessageTransfers : true;
  8452. case 'workerPort':
  8453. return globalSettings ? globalSettings.workerPort : null;
  8454. case 'workerSrc':
  8455. return globalSettings ? globalSettings.workerSrc : null;
  8456. case 'disableWorker':
  8457. return globalSettings ? globalSettings.disableWorker : false;
  8458. case 'maxImageSize':
  8459. return globalSettings ? globalSettings.maxImageSize : -1;
  8460. case 'imageResourcesPath':
  8461. return globalSettings ? globalSettings.imageResourcesPath : '';
  8462. case 'isEvalSupported':
  8463. return globalSettings ? globalSettings.isEvalSupported : true;
  8464. case 'externalLinkTarget':
  8465. if (!globalSettings) {
  8466. return LinkTarget.NONE;
  8467. }
  8468. switch (globalSettings.externalLinkTarget) {
  8469. case LinkTarget.NONE:
  8470. case LinkTarget.SELF:
  8471. case LinkTarget.BLANK:
  8472. case LinkTarget.PARENT:
  8473. case LinkTarget.TOP:
  8474. return globalSettings.externalLinkTarget;
  8475. }
  8476. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  8477. globalSettings.externalLinkTarget = LinkTarget.NONE;
  8478. return LinkTarget.NONE;
  8479. case 'externalLinkRel':
  8480. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  8481. case 'enableStats':
  8482. return !!(globalSettings && globalSettings.enableStats);
  8483. default:
  8484. throw new Error('Unknown default setting: ' + id);
  8485. }
  8486. }
  8487. function isExternalLinkTargetSet() {
  8488. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  8489. switch (externalLinkTarget) {
  8490. case LinkTarget.NONE:
  8491. return false;
  8492. case LinkTarget.SELF:
  8493. case LinkTarget.BLANK:
  8494. case LinkTarget.PARENT:
  8495. case LinkTarget.TOP:
  8496. return true;
  8497. }
  8498. }
  8499. function isValidUrl(url, allowRelative) {
  8500. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  8501. var baseUrl = allowRelative ? 'http://example.com' : null;
  8502. return createValidAbsoluteUrl(url, baseUrl) !== null;
  8503. }
  8504. exports.CustomStyle = CustomStyle;
  8505. exports.addLinkAttributes = addLinkAttributes;
  8506. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  8507. exports.isValidUrl = isValidUrl;
  8508. exports.getFilenameFromUrl = getFilenameFromUrl;
  8509. exports.LinkTarget = LinkTarget;
  8510. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  8511. exports.getDefaultSetting = getDefaultSetting;
  8512. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  8513. exports.DOMCanvasFactory = DOMCanvasFactory;
  8514. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  8515. /***/ }),
  8516. /* 4 */
  8517. /***/ (function(module, exports, __w_pdfjs_require__) {
  8518. "use strict";
  8519. var sharedUtil = __w_pdfjs_require__(0);
  8520. var corePrimitives = __w_pdfjs_require__(1);
  8521. var coreFunction = __w_pdfjs_require__(7);
  8522. var error = sharedUtil.error;
  8523. var info = sharedUtil.info;
  8524. var isArray = sharedUtil.isArray;
  8525. var isString = sharedUtil.isString;
  8526. var shadow = sharedUtil.shadow;
  8527. var warn = sharedUtil.warn;
  8528. var isDict = corePrimitives.isDict;
  8529. var isName = corePrimitives.isName;
  8530. var isStream = corePrimitives.isStream;
  8531. var PDFFunction = coreFunction.PDFFunction;
  8532. var ColorSpace = function ColorSpaceClosure() {
  8533. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8534. var COMPONENTS = 3;
  8535. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8536. var xRatio = w1 / w2;
  8537. var yRatio = h1 / h2;
  8538. var i, j, py, newIndex = 0, oldIndex;
  8539. var xScaled = new Uint16Array(w2);
  8540. var w1Scanline = w1 * COMPONENTS;
  8541. for (i = 0; i < w2; i++) {
  8542. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8543. }
  8544. for (i = 0; i < h2; i++) {
  8545. py = Math.floor(i * yRatio) * w1Scanline;
  8546. for (j = 0; j < w2; j++) {
  8547. oldIndex = py + xScaled[j];
  8548. dest[newIndex++] = src[oldIndex++];
  8549. dest[newIndex++] = src[oldIndex++];
  8550. dest[newIndex++] = src[oldIndex++];
  8551. newIndex += alpha01;
  8552. }
  8553. }
  8554. }
  8555. function ColorSpace() {
  8556. error('should not call ColorSpace constructor');
  8557. }
  8558. ColorSpace.prototype = {
  8559. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8560. var rgb = new Uint8Array(3);
  8561. this.getRgbItem(src, srcOffset, rgb, 0);
  8562. return rgb;
  8563. },
  8564. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8565. error('Should not call ColorSpace.getRgbItem');
  8566. },
  8567. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8568. error('Should not call ColorSpace.getRgbBuffer');
  8569. },
  8570. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8571. error('Should not call ColorSpace.getOutputLength');
  8572. },
  8573. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8574. return false;
  8575. },
  8576. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8577. var count = originalWidth * originalHeight;
  8578. var rgbBuf = null;
  8579. var numComponentColors = 1 << bpc;
  8580. var needsResizing = originalHeight !== height || originalWidth !== width;
  8581. var i, ii;
  8582. if (this.isPassthrough(bpc)) {
  8583. rgbBuf = comps;
  8584. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8585. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8586. var key;
  8587. for (i = 0; i < numComponentColors; i++) {
  8588. allColors[i] = i;
  8589. }
  8590. var colorMap = new Uint8Array(numComponentColors * 3);
  8591. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8592. var destPos, rgbPos;
  8593. if (!needsResizing) {
  8594. destPos = 0;
  8595. for (i = 0; i < count; ++i) {
  8596. key = comps[i] * 3;
  8597. dest[destPos++] = colorMap[key];
  8598. dest[destPos++] = colorMap[key + 1];
  8599. dest[destPos++] = colorMap[key + 2];
  8600. destPos += alpha01;
  8601. }
  8602. } else {
  8603. rgbBuf = new Uint8Array(count * 3);
  8604. rgbPos = 0;
  8605. for (i = 0; i < count; ++i) {
  8606. key = comps[i] * 3;
  8607. rgbBuf[rgbPos++] = colorMap[key];
  8608. rgbBuf[rgbPos++] = colorMap[key + 1];
  8609. rgbBuf[rgbPos++] = colorMap[key + 2];
  8610. }
  8611. }
  8612. } else {
  8613. if (!needsResizing) {
  8614. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8615. } else {
  8616. rgbBuf = new Uint8Array(count * 3);
  8617. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8618. }
  8619. }
  8620. if (rgbBuf) {
  8621. if (needsResizing) {
  8622. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8623. } else {
  8624. rgbPos = 0;
  8625. destPos = 0;
  8626. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8627. dest[destPos++] = rgbBuf[rgbPos++];
  8628. dest[destPos++] = rgbBuf[rgbPos++];
  8629. dest[destPos++] = rgbBuf[rgbPos++];
  8630. destPos += alpha01;
  8631. }
  8632. }
  8633. }
  8634. },
  8635. usesZeroToOneRange: true
  8636. };
  8637. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8638. var IR = ColorSpace.parseToIR(cs, xref, res);
  8639. if (IR instanceof AlternateCS) {
  8640. return IR;
  8641. }
  8642. return ColorSpace.fromIR(IR);
  8643. };
  8644. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8645. var name = isArray(IR) ? IR[0] : IR;
  8646. var whitePoint, blackPoint, gamma;
  8647. switch (name) {
  8648. case 'DeviceGrayCS':
  8649. return this.singletons.gray;
  8650. case 'DeviceRgbCS':
  8651. return this.singletons.rgb;
  8652. case 'DeviceCmykCS':
  8653. return this.singletons.cmyk;
  8654. case 'CalGrayCS':
  8655. whitePoint = IR[1];
  8656. blackPoint = IR[2];
  8657. gamma = IR[3];
  8658. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8659. case 'CalRGBCS':
  8660. whitePoint = IR[1];
  8661. blackPoint = IR[2];
  8662. gamma = IR[3];
  8663. var matrix = IR[4];
  8664. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8665. case 'PatternCS':
  8666. var basePatternCS = IR[1];
  8667. if (basePatternCS) {
  8668. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8669. }
  8670. return new PatternCS(basePatternCS);
  8671. case 'IndexedCS':
  8672. var baseIndexedCS = IR[1];
  8673. var hiVal = IR[2];
  8674. var lookup = IR[3];
  8675. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8676. case 'AlternateCS':
  8677. var numComps = IR[1];
  8678. var alt = IR[2];
  8679. var tintFnIR = IR[3];
  8680. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8681. case 'LabCS':
  8682. whitePoint = IR[1];
  8683. blackPoint = IR[2];
  8684. var range = IR[3];
  8685. return new LabCS(whitePoint, blackPoint, range);
  8686. default:
  8687. error('Unknown name ' + name);
  8688. }
  8689. return null;
  8690. };
  8691. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8692. if (isName(cs)) {
  8693. var colorSpaces = res.get('ColorSpace');
  8694. if (isDict(colorSpaces)) {
  8695. var refcs = colorSpaces.get(cs.name);
  8696. if (refcs) {
  8697. cs = refcs;
  8698. }
  8699. }
  8700. }
  8701. cs = xref.fetchIfRef(cs);
  8702. if (isName(cs)) {
  8703. switch (cs.name) {
  8704. case 'DeviceGray':
  8705. case 'G':
  8706. return 'DeviceGrayCS';
  8707. case 'DeviceRGB':
  8708. case 'RGB':
  8709. return 'DeviceRgbCS';
  8710. case 'DeviceCMYK':
  8711. case 'CMYK':
  8712. return 'DeviceCmykCS';
  8713. case 'Pattern':
  8714. return [
  8715. 'PatternCS',
  8716. null
  8717. ];
  8718. default:
  8719. error('unrecognized colorspace ' + cs.name);
  8720. }
  8721. } else if (isArray(cs)) {
  8722. var mode = xref.fetchIfRef(cs[0]).name;
  8723. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8724. switch (mode) {
  8725. case 'DeviceGray':
  8726. case 'G':
  8727. return 'DeviceGrayCS';
  8728. case 'DeviceRGB':
  8729. case 'RGB':
  8730. return 'DeviceRgbCS';
  8731. case 'DeviceCMYK':
  8732. case 'CMYK':
  8733. return 'DeviceCmykCS';
  8734. case 'CalGray':
  8735. params = xref.fetchIfRef(cs[1]);
  8736. whitePoint = params.getArray('WhitePoint');
  8737. blackPoint = params.getArray('BlackPoint');
  8738. gamma = params.get('Gamma');
  8739. return [
  8740. 'CalGrayCS',
  8741. whitePoint,
  8742. blackPoint,
  8743. gamma
  8744. ];
  8745. case 'CalRGB':
  8746. params = xref.fetchIfRef(cs[1]);
  8747. whitePoint = params.getArray('WhitePoint');
  8748. blackPoint = params.getArray('BlackPoint');
  8749. gamma = params.getArray('Gamma');
  8750. var matrix = params.getArray('Matrix');
  8751. return [
  8752. 'CalRGBCS',
  8753. whitePoint,
  8754. blackPoint,
  8755. gamma,
  8756. matrix
  8757. ];
  8758. case 'ICCBased':
  8759. var stream = xref.fetchIfRef(cs[1]);
  8760. var dict = stream.dict;
  8761. numComps = dict.get('N');
  8762. alt = dict.get('Alternate');
  8763. if (alt) {
  8764. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8765. var altCS = ColorSpace.fromIR(altIR);
  8766. if (altCS.numComps === numComps) {
  8767. return altIR;
  8768. }
  8769. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8770. }
  8771. if (numComps === 1) {
  8772. return 'DeviceGrayCS';
  8773. } else if (numComps === 3) {
  8774. return 'DeviceRgbCS';
  8775. } else if (numComps === 4) {
  8776. return 'DeviceCmykCS';
  8777. }
  8778. break;
  8779. case 'Pattern':
  8780. var basePatternCS = cs[1] || null;
  8781. if (basePatternCS) {
  8782. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8783. }
  8784. return [
  8785. 'PatternCS',
  8786. basePatternCS
  8787. ];
  8788. case 'Indexed':
  8789. case 'I':
  8790. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8791. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8792. var lookup = xref.fetchIfRef(cs[3]);
  8793. if (isStream(lookup)) {
  8794. lookup = lookup.getBytes();
  8795. }
  8796. return [
  8797. 'IndexedCS',
  8798. baseIndexedCS,
  8799. hiVal,
  8800. lookup
  8801. ];
  8802. case 'Separation':
  8803. case 'DeviceN':
  8804. var name = xref.fetchIfRef(cs[1]);
  8805. numComps = isArray(name) ? name.length : 1;
  8806. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8807. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8808. return [
  8809. 'AlternateCS',
  8810. numComps,
  8811. alt,
  8812. tintFnIR
  8813. ];
  8814. case 'Lab':
  8815. params = xref.fetchIfRef(cs[1]);
  8816. whitePoint = params.getArray('WhitePoint');
  8817. blackPoint = params.getArray('BlackPoint');
  8818. var range = params.getArray('Range');
  8819. return [
  8820. 'LabCS',
  8821. whitePoint,
  8822. blackPoint,
  8823. range
  8824. ];
  8825. default:
  8826. error('unimplemented color space object "' + mode + '"');
  8827. }
  8828. } else {
  8829. error('unrecognized color space object: "' + cs + '"');
  8830. }
  8831. return null;
  8832. };
  8833. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8834. if (!isArray(decode)) {
  8835. return true;
  8836. }
  8837. if (n * 2 !== decode.length) {
  8838. warn('The decode map is not the correct length');
  8839. return true;
  8840. }
  8841. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8842. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8843. return false;
  8844. }
  8845. }
  8846. return true;
  8847. };
  8848. ColorSpace.singletons = {
  8849. get gray() {
  8850. return shadow(this, 'gray', new DeviceGrayCS());
  8851. },
  8852. get rgb() {
  8853. return shadow(this, 'rgb', new DeviceRgbCS());
  8854. },
  8855. get cmyk() {
  8856. return shadow(this, 'cmyk', new DeviceCmykCS());
  8857. }
  8858. };
  8859. return ColorSpace;
  8860. }();
  8861. var AlternateCS = function AlternateCSClosure() {
  8862. function AlternateCS(numComps, base, tintFn) {
  8863. this.name = 'Alternate';
  8864. this.numComps = numComps;
  8865. this.defaultColor = new Float32Array(numComps);
  8866. for (var i = 0; i < numComps; ++i) {
  8867. this.defaultColor[i] = 1;
  8868. }
  8869. this.base = base;
  8870. this.tintFn = tintFn;
  8871. this.tmpBuf = new Float32Array(base.numComps);
  8872. }
  8873. AlternateCS.prototype = {
  8874. getRgb: ColorSpace.prototype.getRgb,
  8875. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8876. var tmpBuf = this.tmpBuf;
  8877. this.tintFn(src, srcOffset, tmpBuf, 0);
  8878. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8879. },
  8880. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8881. var tintFn = this.tintFn;
  8882. var base = this.base;
  8883. var scale = 1 / ((1 << bits) - 1);
  8884. var baseNumComps = base.numComps;
  8885. var usesZeroToOneRange = base.usesZeroToOneRange;
  8886. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8887. var pos = isPassthrough ? destOffset : 0;
  8888. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8889. var numComps = this.numComps;
  8890. var scaled = new Float32Array(numComps);
  8891. var tinted = new Float32Array(baseNumComps);
  8892. var i, j;
  8893. for (i = 0; i < count; i++) {
  8894. for (j = 0; j < numComps; j++) {
  8895. scaled[j] = src[srcOffset++] * scale;
  8896. }
  8897. tintFn(scaled, 0, tinted, 0);
  8898. if (usesZeroToOneRange) {
  8899. for (j = 0; j < baseNumComps; j++) {
  8900. baseBuf[pos++] = tinted[j] * 255;
  8901. }
  8902. } else {
  8903. base.getRgbItem(tinted, 0, baseBuf, pos);
  8904. pos += baseNumComps;
  8905. }
  8906. }
  8907. if (!isPassthrough) {
  8908. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8909. }
  8910. },
  8911. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8912. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8913. },
  8914. isPassthrough: ColorSpace.prototype.isPassthrough,
  8915. fillRgb: ColorSpace.prototype.fillRgb,
  8916. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8917. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8918. },
  8919. usesZeroToOneRange: true
  8920. };
  8921. return AlternateCS;
  8922. }();
  8923. var PatternCS = function PatternCSClosure() {
  8924. function PatternCS(baseCS) {
  8925. this.name = 'Pattern';
  8926. this.base = baseCS;
  8927. }
  8928. PatternCS.prototype = {};
  8929. return PatternCS;
  8930. }();
  8931. var IndexedCS = function IndexedCSClosure() {
  8932. function IndexedCS(base, highVal, lookup) {
  8933. this.name = 'Indexed';
  8934. this.numComps = 1;
  8935. this.defaultColor = new Uint8Array(this.numComps);
  8936. this.base = base;
  8937. this.highVal = highVal;
  8938. var baseNumComps = base.numComps;
  8939. var length = baseNumComps * highVal;
  8940. if (isStream(lookup)) {
  8941. this.lookup = new Uint8Array(length);
  8942. var bytes = lookup.getBytes(length);
  8943. this.lookup.set(bytes);
  8944. } else if (isString(lookup)) {
  8945. this.lookup = new Uint8Array(length);
  8946. for (var i = 0; i < length; ++i) {
  8947. this.lookup[i] = lookup.charCodeAt(i);
  8948. }
  8949. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8950. this.lookup = lookup;
  8951. } else {
  8952. error('Unrecognized lookup table: ' + lookup);
  8953. }
  8954. }
  8955. IndexedCS.prototype = {
  8956. getRgb: ColorSpace.prototype.getRgb,
  8957. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8958. var numComps = this.base.numComps;
  8959. var start = src[srcOffset] * numComps;
  8960. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8961. },
  8962. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8963. var base = this.base;
  8964. var numComps = base.numComps;
  8965. var outputDelta = base.getOutputLength(numComps, alpha01);
  8966. var lookup = this.lookup;
  8967. for (var i = 0; i < count; ++i) {
  8968. var lookupPos = src[srcOffset++] * numComps;
  8969. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8970. destOffset += outputDelta;
  8971. }
  8972. },
  8973. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8974. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8975. },
  8976. isPassthrough: ColorSpace.prototype.isPassthrough,
  8977. fillRgb: ColorSpace.prototype.fillRgb,
  8978. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8979. return true;
  8980. },
  8981. usesZeroToOneRange: true
  8982. };
  8983. return IndexedCS;
  8984. }();
  8985. var DeviceGrayCS = function DeviceGrayCSClosure() {
  8986. function DeviceGrayCS() {
  8987. this.name = 'DeviceGray';
  8988. this.numComps = 1;
  8989. this.defaultColor = new Float32Array(this.numComps);
  8990. }
  8991. DeviceGrayCS.prototype = {
  8992. getRgb: ColorSpace.prototype.getRgb,
  8993. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8994. var c = src[srcOffset] * 255 | 0;
  8995. c = c < 0 ? 0 : c > 255 ? 255 : c;
  8996. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  8997. },
  8998. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8999. var scale = 255 / ((1 << bits) - 1);
  9000. var j = srcOffset, q = destOffset;
  9001. for (var i = 0; i < count; ++i) {
  9002. var c = scale * src[j++] | 0;
  9003. dest[q++] = c;
  9004. dest[q++] = c;
  9005. dest[q++] = c;
  9006. q += alpha01;
  9007. }
  9008. },
  9009. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9010. return inputLength * (3 + alpha01);
  9011. },
  9012. isPassthrough: ColorSpace.prototype.isPassthrough,
  9013. fillRgb: ColorSpace.prototype.fillRgb,
  9014. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9015. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9016. },
  9017. usesZeroToOneRange: true
  9018. };
  9019. return DeviceGrayCS;
  9020. }();
  9021. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9022. function DeviceRgbCS() {
  9023. this.name = 'DeviceRGB';
  9024. this.numComps = 3;
  9025. this.defaultColor = new Float32Array(this.numComps);
  9026. }
  9027. DeviceRgbCS.prototype = {
  9028. getRgb: ColorSpace.prototype.getRgb,
  9029. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9030. var r = src[srcOffset] * 255 | 0;
  9031. var g = src[srcOffset + 1] * 255 | 0;
  9032. var b = src[srcOffset + 2] * 255 | 0;
  9033. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9034. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9035. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9036. },
  9037. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9038. if (bits === 8 && alpha01 === 0) {
  9039. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9040. return;
  9041. }
  9042. var scale = 255 / ((1 << bits) - 1);
  9043. var j = srcOffset, q = destOffset;
  9044. for (var i = 0; i < count; ++i) {
  9045. dest[q++] = scale * src[j++] | 0;
  9046. dest[q++] = scale * src[j++] | 0;
  9047. dest[q++] = scale * src[j++] | 0;
  9048. q += alpha01;
  9049. }
  9050. },
  9051. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9052. return inputLength * (3 + alpha01) / 3 | 0;
  9053. },
  9054. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9055. return bits === 8;
  9056. },
  9057. fillRgb: ColorSpace.prototype.fillRgb,
  9058. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9059. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9060. },
  9061. usesZeroToOneRange: true
  9062. };
  9063. return DeviceRgbCS;
  9064. }();
  9065. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9066. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9067. var c = src[srcOffset + 0] * srcScale;
  9068. var m = src[srcOffset + 1] * srcScale;
  9069. var y = src[srcOffset + 2] * srcScale;
  9070. var k = src[srcOffset + 3] * srcScale;
  9071. 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;
  9072. 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;
  9073. 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;
  9074. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9075. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9076. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9077. }
  9078. function DeviceCmykCS() {
  9079. this.name = 'DeviceCMYK';
  9080. this.numComps = 4;
  9081. this.defaultColor = new Float32Array(this.numComps);
  9082. this.defaultColor[3] = 1;
  9083. }
  9084. DeviceCmykCS.prototype = {
  9085. getRgb: ColorSpace.prototype.getRgb,
  9086. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9087. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9088. },
  9089. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9090. var scale = 1 / ((1 << bits) - 1);
  9091. for (var i = 0; i < count; i++) {
  9092. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9093. srcOffset += 4;
  9094. destOffset += 3 + alpha01;
  9095. }
  9096. },
  9097. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9098. return inputLength / 4 * (3 + alpha01) | 0;
  9099. },
  9100. isPassthrough: ColorSpace.prototype.isPassthrough,
  9101. fillRgb: ColorSpace.prototype.fillRgb,
  9102. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9103. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9104. },
  9105. usesZeroToOneRange: true
  9106. };
  9107. return DeviceCmykCS;
  9108. }();
  9109. var CalGrayCS = function CalGrayCSClosure() {
  9110. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9111. this.name = 'CalGray';
  9112. this.numComps = 1;
  9113. this.defaultColor = new Float32Array(this.numComps);
  9114. if (!whitePoint) {
  9115. error('WhitePoint missing - required for color space CalGray');
  9116. }
  9117. blackPoint = blackPoint || [
  9118. 0,
  9119. 0,
  9120. 0
  9121. ];
  9122. gamma = gamma || 1;
  9123. this.XW = whitePoint[0];
  9124. this.YW = whitePoint[1];
  9125. this.ZW = whitePoint[2];
  9126. this.XB = blackPoint[0];
  9127. this.YB = blackPoint[1];
  9128. this.ZB = blackPoint[2];
  9129. this.G = gamma;
  9130. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9131. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9132. }
  9133. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9134. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9135. this.XB = this.YB = this.ZB = 0;
  9136. }
  9137. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9138. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9139. }
  9140. if (this.G < 1) {
  9141. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9142. this.G = 1;
  9143. }
  9144. }
  9145. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9146. var A = src[srcOffset] * scale;
  9147. var AG = Math.pow(A, cs.G);
  9148. var L = cs.YW * AG;
  9149. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9150. dest[destOffset] = val;
  9151. dest[destOffset + 1] = val;
  9152. dest[destOffset + 2] = val;
  9153. }
  9154. CalGrayCS.prototype = {
  9155. getRgb: ColorSpace.prototype.getRgb,
  9156. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9157. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9158. },
  9159. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9160. var scale = 1 / ((1 << bits) - 1);
  9161. for (var i = 0; i < count; ++i) {
  9162. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9163. srcOffset += 1;
  9164. destOffset += 3 + alpha01;
  9165. }
  9166. },
  9167. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9168. return inputLength * (3 + alpha01);
  9169. },
  9170. isPassthrough: ColorSpace.prototype.isPassthrough,
  9171. fillRgb: ColorSpace.prototype.fillRgb,
  9172. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9173. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9174. },
  9175. usesZeroToOneRange: true
  9176. };
  9177. return CalGrayCS;
  9178. }();
  9179. var CalRGBCS = function CalRGBCSClosure() {
  9180. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9181. 0.8951,
  9182. 0.2664,
  9183. -0.1614,
  9184. -0.7502,
  9185. 1.7135,
  9186. 0.0367,
  9187. 0.0389,
  9188. -0.0685,
  9189. 1.0296
  9190. ]);
  9191. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9192. 0.9869929,
  9193. -0.1470543,
  9194. 0.1599627,
  9195. 0.4323053,
  9196. 0.5183603,
  9197. 0.0492912,
  9198. -0.0085287,
  9199. 0.0400428,
  9200. 0.9684867
  9201. ]);
  9202. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9203. 3.2404542,
  9204. -1.5371385,
  9205. -0.4985314,
  9206. -0.9692660,
  9207. 1.8760108,
  9208. 0.0415560,
  9209. 0.0556434,
  9210. -0.2040259,
  9211. 1.0572252
  9212. ]);
  9213. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9214. 1,
  9215. 1,
  9216. 1
  9217. ]);
  9218. var tempNormalizeMatrix = new Float32Array(3);
  9219. var tempConvertMatrix1 = new Float32Array(3);
  9220. var tempConvertMatrix2 = new Float32Array(3);
  9221. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9222. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9223. this.name = 'CalRGB';
  9224. this.numComps = 3;
  9225. this.defaultColor = new Float32Array(this.numComps);
  9226. if (!whitePoint) {
  9227. error('WhitePoint missing - required for color space CalRGB');
  9228. }
  9229. blackPoint = blackPoint || new Float32Array(3);
  9230. gamma = gamma || new Float32Array([
  9231. 1,
  9232. 1,
  9233. 1
  9234. ]);
  9235. matrix = matrix || new Float32Array([
  9236. 1,
  9237. 0,
  9238. 0,
  9239. 0,
  9240. 1,
  9241. 0,
  9242. 0,
  9243. 0,
  9244. 1
  9245. ]);
  9246. var XW = whitePoint[0];
  9247. var YW = whitePoint[1];
  9248. var ZW = whitePoint[2];
  9249. this.whitePoint = whitePoint;
  9250. var XB = blackPoint[0];
  9251. var YB = blackPoint[1];
  9252. var ZB = blackPoint[2];
  9253. this.blackPoint = blackPoint;
  9254. this.GR = gamma[0];
  9255. this.GG = gamma[1];
  9256. this.GB = gamma[2];
  9257. this.MXA = matrix[0];
  9258. this.MYA = matrix[1];
  9259. this.MZA = matrix[2];
  9260. this.MXB = matrix[3];
  9261. this.MYB = matrix[4];
  9262. this.MZB = matrix[5];
  9263. this.MXC = matrix[6];
  9264. this.MYC = matrix[7];
  9265. this.MZC = matrix[8];
  9266. if (XW < 0 || ZW < 0 || YW !== 1) {
  9267. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9268. }
  9269. if (XB < 0 || YB < 0 || ZB < 0) {
  9270. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9271. this.blackPoint = new Float32Array(3);
  9272. }
  9273. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9274. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9275. this.GR = this.GG = this.GB = 1;
  9276. }
  9277. 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) {
  9278. 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');
  9279. this.MXA = this.MYB = this.MZC = 1;
  9280. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9281. }
  9282. }
  9283. function matrixProduct(a, b, result) {
  9284. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9285. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9286. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9287. }
  9288. function convertToFlat(sourceWhitePoint, LMS, result) {
  9289. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9290. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9291. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9292. }
  9293. function convertToD65(sourceWhitePoint, LMS, result) {
  9294. var D65X = 0.95047;
  9295. var D65Y = 1;
  9296. var D65Z = 1.08883;
  9297. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9298. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9299. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9300. }
  9301. function sRGBTransferFunction(color) {
  9302. if (color <= 0.0031308) {
  9303. return adjustToRange(0, 1, 12.92 * color);
  9304. }
  9305. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9306. }
  9307. function adjustToRange(min, max, value) {
  9308. return Math.max(min, Math.min(max, value));
  9309. }
  9310. function decodeL(L) {
  9311. if (L < 0) {
  9312. return -decodeL(-L);
  9313. }
  9314. if (L > 8.0) {
  9315. return Math.pow((L + 16) / 116, 3);
  9316. }
  9317. return L * DECODE_L_CONSTANT;
  9318. }
  9319. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9320. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9321. result[0] = XYZ_Flat[0];
  9322. result[1] = XYZ_Flat[1];
  9323. result[2] = XYZ_Flat[2];
  9324. return;
  9325. }
  9326. var zeroDecodeL = decodeL(0);
  9327. var X_DST = zeroDecodeL;
  9328. var X_SRC = decodeL(sourceBlackPoint[0]);
  9329. var Y_DST = zeroDecodeL;
  9330. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9331. var Z_DST = zeroDecodeL;
  9332. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9333. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9334. var X_Offset = 1 - X_Scale;
  9335. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9336. var Y_Offset = 1 - Y_Scale;
  9337. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9338. var Z_Offset = 1 - Z_Scale;
  9339. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9340. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9341. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9342. }
  9343. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9344. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9345. result[0] = XYZ_In[0];
  9346. result[1] = XYZ_In[1];
  9347. result[2] = XYZ_In[2];
  9348. return;
  9349. }
  9350. var LMS = result;
  9351. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9352. var LMS_Flat = tempNormalizeMatrix;
  9353. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9354. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9355. }
  9356. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9357. var LMS = result;
  9358. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9359. var LMS_D65 = tempNormalizeMatrix;
  9360. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9361. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9362. }
  9363. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9364. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9365. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9366. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9367. var AGR = Math.pow(A, cs.GR);
  9368. var BGG = Math.pow(B, cs.GG);
  9369. var CGB = Math.pow(C, cs.GB);
  9370. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9371. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9372. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9373. var XYZ = tempConvertMatrix1;
  9374. XYZ[0] = X;
  9375. XYZ[1] = Y;
  9376. XYZ[2] = Z;
  9377. var XYZ_Flat = tempConvertMatrix2;
  9378. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9379. var XYZ_Black = tempConvertMatrix1;
  9380. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9381. var XYZ_D65 = tempConvertMatrix2;
  9382. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9383. var SRGB = tempConvertMatrix1;
  9384. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9385. var sR = sRGBTransferFunction(SRGB[0]);
  9386. var sG = sRGBTransferFunction(SRGB[1]);
  9387. var sB = sRGBTransferFunction(SRGB[2]);
  9388. dest[destOffset] = Math.round(sR * 255);
  9389. dest[destOffset + 1] = Math.round(sG * 255);
  9390. dest[destOffset + 2] = Math.round(sB * 255);
  9391. }
  9392. CalRGBCS.prototype = {
  9393. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9394. var rgb = new Uint8Array(3);
  9395. this.getRgbItem(src, srcOffset, rgb, 0);
  9396. return rgb;
  9397. },
  9398. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9399. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9400. },
  9401. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9402. var scale = 1 / ((1 << bits) - 1);
  9403. for (var i = 0; i < count; ++i) {
  9404. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9405. srcOffset += 3;
  9406. destOffset += 3 + alpha01;
  9407. }
  9408. },
  9409. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9410. return inputLength * (3 + alpha01) / 3 | 0;
  9411. },
  9412. isPassthrough: ColorSpace.prototype.isPassthrough,
  9413. fillRgb: ColorSpace.prototype.fillRgb,
  9414. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9415. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9416. },
  9417. usesZeroToOneRange: true
  9418. };
  9419. return CalRGBCS;
  9420. }();
  9421. var LabCS = function LabCSClosure() {
  9422. function LabCS(whitePoint, blackPoint, range) {
  9423. this.name = 'Lab';
  9424. this.numComps = 3;
  9425. this.defaultColor = new Float32Array(this.numComps);
  9426. if (!whitePoint) {
  9427. error('WhitePoint missing - required for color space Lab');
  9428. }
  9429. blackPoint = blackPoint || [
  9430. 0,
  9431. 0,
  9432. 0
  9433. ];
  9434. range = range || [
  9435. -100,
  9436. 100,
  9437. -100,
  9438. 100
  9439. ];
  9440. this.XW = whitePoint[0];
  9441. this.YW = whitePoint[1];
  9442. this.ZW = whitePoint[2];
  9443. this.amin = range[0];
  9444. this.amax = range[1];
  9445. this.bmin = range[2];
  9446. this.bmax = range[3];
  9447. this.XB = blackPoint[0];
  9448. this.YB = blackPoint[1];
  9449. this.ZB = blackPoint[2];
  9450. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9451. error('Invalid WhitePoint components, no fallback available');
  9452. }
  9453. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9454. info('Invalid BlackPoint, falling back to default');
  9455. this.XB = this.YB = this.ZB = 0;
  9456. }
  9457. if (this.amin > this.amax || this.bmin > this.bmax) {
  9458. info('Invalid Range, falling back to defaults');
  9459. this.amin = -100;
  9460. this.amax = 100;
  9461. this.bmin = -100;
  9462. this.bmax = 100;
  9463. }
  9464. }
  9465. function fn_g(x) {
  9466. var result;
  9467. if (x >= 6 / 29) {
  9468. result = x * x * x;
  9469. } else {
  9470. result = 108 / 841 * (x - 4 / 29);
  9471. }
  9472. return result;
  9473. }
  9474. function decode(value, high1, low2, high2) {
  9475. return low2 + value * (high2 - low2) / high1;
  9476. }
  9477. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9478. var Ls = src[srcOffset];
  9479. var as = src[srcOffset + 1];
  9480. var bs = src[srcOffset + 2];
  9481. if (maxVal !== false) {
  9482. Ls = decode(Ls, maxVal, 0, 100);
  9483. as = decode(as, maxVal, cs.amin, cs.amax);
  9484. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9485. }
  9486. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9487. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9488. var M = (Ls + 16) / 116;
  9489. var L = M + as / 500;
  9490. var N = M - bs / 200;
  9491. var X = cs.XW * fn_g(L);
  9492. var Y = cs.YW * fn_g(M);
  9493. var Z = cs.ZW * fn_g(N);
  9494. var r, g, b;
  9495. if (cs.ZW < 1) {
  9496. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9497. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9498. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9499. } else {
  9500. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9501. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9502. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9503. }
  9504. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9505. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9506. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9507. }
  9508. LabCS.prototype = {
  9509. getRgb: ColorSpace.prototype.getRgb,
  9510. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9511. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9512. },
  9513. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9514. var maxVal = (1 << bits) - 1;
  9515. for (var i = 0; i < count; i++) {
  9516. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9517. srcOffset += 3;
  9518. destOffset += 3 + alpha01;
  9519. }
  9520. },
  9521. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9522. return inputLength * (3 + alpha01) / 3 | 0;
  9523. },
  9524. isPassthrough: ColorSpace.prototype.isPassthrough,
  9525. fillRgb: ColorSpace.prototype.fillRgb,
  9526. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9527. return true;
  9528. },
  9529. usesZeroToOneRange: false
  9530. };
  9531. return LabCS;
  9532. }();
  9533. exports.ColorSpace = ColorSpace;
  9534. /***/ }),
  9535. /* 5 */
  9536. /***/ (function(module, exports, __w_pdfjs_require__) {
  9537. "use strict";
  9538. var ExpertEncoding = [
  9539. '',
  9540. '',
  9541. '',
  9542. '',
  9543. '',
  9544. '',
  9545. '',
  9546. '',
  9547. '',
  9548. '',
  9549. '',
  9550. '',
  9551. '',
  9552. '',
  9553. '',
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. '',
  9570. '',
  9571. 'space',
  9572. 'exclamsmall',
  9573. 'Hungarumlautsmall',
  9574. '',
  9575. 'dollaroldstyle',
  9576. 'dollarsuperior',
  9577. 'ampersandsmall',
  9578. 'Acutesmall',
  9579. 'parenleftsuperior',
  9580. 'parenrightsuperior',
  9581. 'twodotenleader',
  9582. 'onedotenleader',
  9583. 'comma',
  9584. 'hyphen',
  9585. 'period',
  9586. 'fraction',
  9587. 'zerooldstyle',
  9588. 'oneoldstyle',
  9589. 'twooldstyle',
  9590. 'threeoldstyle',
  9591. 'fouroldstyle',
  9592. 'fiveoldstyle',
  9593. 'sixoldstyle',
  9594. 'sevenoldstyle',
  9595. 'eightoldstyle',
  9596. 'nineoldstyle',
  9597. 'colon',
  9598. 'semicolon',
  9599. 'commasuperior',
  9600. 'threequartersemdash',
  9601. 'periodsuperior',
  9602. 'questionsmall',
  9603. '',
  9604. 'asuperior',
  9605. 'bsuperior',
  9606. 'centsuperior',
  9607. 'dsuperior',
  9608. 'esuperior',
  9609. '',
  9610. '',
  9611. 'isuperior',
  9612. '',
  9613. '',
  9614. 'lsuperior',
  9615. 'msuperior',
  9616. 'nsuperior',
  9617. 'osuperior',
  9618. '',
  9619. '',
  9620. 'rsuperior',
  9621. 'ssuperior',
  9622. 'tsuperior',
  9623. '',
  9624. 'ff',
  9625. 'fi',
  9626. 'fl',
  9627. 'ffi',
  9628. 'ffl',
  9629. 'parenleftinferior',
  9630. '',
  9631. 'parenrightinferior',
  9632. 'Circumflexsmall',
  9633. 'hyphensuperior',
  9634. 'Gravesmall',
  9635. 'Asmall',
  9636. 'Bsmall',
  9637. 'Csmall',
  9638. 'Dsmall',
  9639. 'Esmall',
  9640. 'Fsmall',
  9641. 'Gsmall',
  9642. 'Hsmall',
  9643. 'Ismall',
  9644. 'Jsmall',
  9645. 'Ksmall',
  9646. 'Lsmall',
  9647. 'Msmall',
  9648. 'Nsmall',
  9649. 'Osmall',
  9650. 'Psmall',
  9651. 'Qsmall',
  9652. 'Rsmall',
  9653. 'Ssmall',
  9654. 'Tsmall',
  9655. 'Usmall',
  9656. 'Vsmall',
  9657. 'Wsmall',
  9658. 'Xsmall',
  9659. 'Ysmall',
  9660. 'Zsmall',
  9661. 'colonmonetary',
  9662. 'onefitted',
  9663. 'rupiah',
  9664. 'Tildesmall',
  9665. '',
  9666. '',
  9667. '',
  9668. '',
  9669. '',
  9670. '',
  9671. '',
  9672. '',
  9673. '',
  9674. '',
  9675. '',
  9676. '',
  9677. '',
  9678. '',
  9679. '',
  9680. '',
  9681. '',
  9682. '',
  9683. '',
  9684. '',
  9685. '',
  9686. '',
  9687. '',
  9688. '',
  9689. '',
  9690. '',
  9691. '',
  9692. '',
  9693. '',
  9694. '',
  9695. '',
  9696. '',
  9697. '',
  9698. '',
  9699. 'exclamdownsmall',
  9700. 'centoldstyle',
  9701. 'Lslashsmall',
  9702. '',
  9703. '',
  9704. 'Scaronsmall',
  9705. 'Zcaronsmall',
  9706. 'Dieresissmall',
  9707. 'Brevesmall',
  9708. 'Caronsmall',
  9709. '',
  9710. 'Dotaccentsmall',
  9711. '',
  9712. '',
  9713. 'Macronsmall',
  9714. '',
  9715. '',
  9716. 'figuredash',
  9717. 'hypheninferior',
  9718. '',
  9719. '',
  9720. 'Ogoneksmall',
  9721. 'Ringsmall',
  9722. 'Cedillasmall',
  9723. '',
  9724. '',
  9725. '',
  9726. 'onequarter',
  9727. 'onehalf',
  9728. 'threequarters',
  9729. 'questiondownsmall',
  9730. 'oneeighth',
  9731. 'threeeighths',
  9732. 'fiveeighths',
  9733. 'seveneighths',
  9734. 'onethird',
  9735. 'twothirds',
  9736. '',
  9737. '',
  9738. 'zerosuperior',
  9739. 'onesuperior',
  9740. 'twosuperior',
  9741. 'threesuperior',
  9742. 'foursuperior',
  9743. 'fivesuperior',
  9744. 'sixsuperior',
  9745. 'sevensuperior',
  9746. 'eightsuperior',
  9747. 'ninesuperior',
  9748. 'zeroinferior',
  9749. 'oneinferior',
  9750. 'twoinferior',
  9751. 'threeinferior',
  9752. 'fourinferior',
  9753. 'fiveinferior',
  9754. 'sixinferior',
  9755. 'seveninferior',
  9756. 'eightinferior',
  9757. 'nineinferior',
  9758. 'centinferior',
  9759. 'dollarinferior',
  9760. 'periodinferior',
  9761. 'commainferior',
  9762. 'Agravesmall',
  9763. 'Aacutesmall',
  9764. 'Acircumflexsmall',
  9765. 'Atildesmall',
  9766. 'Adieresissmall',
  9767. 'Aringsmall',
  9768. 'AEsmall',
  9769. 'Ccedillasmall',
  9770. 'Egravesmall',
  9771. 'Eacutesmall',
  9772. 'Ecircumflexsmall',
  9773. 'Edieresissmall',
  9774. 'Igravesmall',
  9775. 'Iacutesmall',
  9776. 'Icircumflexsmall',
  9777. 'Idieresissmall',
  9778. 'Ethsmall',
  9779. 'Ntildesmall',
  9780. 'Ogravesmall',
  9781. 'Oacutesmall',
  9782. 'Ocircumflexsmall',
  9783. 'Otildesmall',
  9784. 'Odieresissmall',
  9785. 'OEsmall',
  9786. 'Oslashsmall',
  9787. 'Ugravesmall',
  9788. 'Uacutesmall',
  9789. 'Ucircumflexsmall',
  9790. 'Udieresissmall',
  9791. 'Yacutesmall',
  9792. 'Thornsmall',
  9793. 'Ydieresissmall'
  9794. ];
  9795. var MacExpertEncoding = [
  9796. '',
  9797. '',
  9798. '',
  9799. '',
  9800. '',
  9801. '',
  9802. '',
  9803. '',
  9804. '',
  9805. '',
  9806. '',
  9807. '',
  9808. '',
  9809. '',
  9810. '',
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. '',
  9827. '',
  9828. 'space',
  9829. 'exclamsmall',
  9830. 'Hungarumlautsmall',
  9831. 'centoldstyle',
  9832. 'dollaroldstyle',
  9833. 'dollarsuperior',
  9834. 'ampersandsmall',
  9835. 'Acutesmall',
  9836. 'parenleftsuperior',
  9837. 'parenrightsuperior',
  9838. 'twodotenleader',
  9839. 'onedotenleader',
  9840. 'comma',
  9841. 'hyphen',
  9842. 'period',
  9843. 'fraction',
  9844. 'zerooldstyle',
  9845. 'oneoldstyle',
  9846. 'twooldstyle',
  9847. 'threeoldstyle',
  9848. 'fouroldstyle',
  9849. 'fiveoldstyle',
  9850. 'sixoldstyle',
  9851. 'sevenoldstyle',
  9852. 'eightoldstyle',
  9853. 'nineoldstyle',
  9854. 'colon',
  9855. 'semicolon',
  9856. '',
  9857. 'threequartersemdash',
  9858. '',
  9859. 'questionsmall',
  9860. '',
  9861. '',
  9862. '',
  9863. '',
  9864. 'Ethsmall',
  9865. '',
  9866. '',
  9867. 'onequarter',
  9868. 'onehalf',
  9869. 'threequarters',
  9870. 'oneeighth',
  9871. 'threeeighths',
  9872. 'fiveeighths',
  9873. 'seveneighths',
  9874. 'onethird',
  9875. 'twothirds',
  9876. '',
  9877. '',
  9878. '',
  9879. '',
  9880. '',
  9881. '',
  9882. 'ff',
  9883. 'fi',
  9884. 'fl',
  9885. 'ffi',
  9886. 'ffl',
  9887. 'parenleftinferior',
  9888. '',
  9889. 'parenrightinferior',
  9890. 'Circumflexsmall',
  9891. 'hypheninferior',
  9892. 'Gravesmall',
  9893. 'Asmall',
  9894. 'Bsmall',
  9895. 'Csmall',
  9896. 'Dsmall',
  9897. 'Esmall',
  9898. 'Fsmall',
  9899. 'Gsmall',
  9900. 'Hsmall',
  9901. 'Ismall',
  9902. 'Jsmall',
  9903. 'Ksmall',
  9904. 'Lsmall',
  9905. 'Msmall',
  9906. 'Nsmall',
  9907. 'Osmall',
  9908. 'Psmall',
  9909. 'Qsmall',
  9910. 'Rsmall',
  9911. 'Ssmall',
  9912. 'Tsmall',
  9913. 'Usmall',
  9914. 'Vsmall',
  9915. 'Wsmall',
  9916. 'Xsmall',
  9917. 'Ysmall',
  9918. 'Zsmall',
  9919. 'colonmonetary',
  9920. 'onefitted',
  9921. 'rupiah',
  9922. 'Tildesmall',
  9923. '',
  9924. '',
  9925. 'asuperior',
  9926. 'centsuperior',
  9927. '',
  9928. '',
  9929. '',
  9930. '',
  9931. 'Aacutesmall',
  9932. 'Agravesmall',
  9933. 'Acircumflexsmall',
  9934. 'Adieresissmall',
  9935. 'Atildesmall',
  9936. 'Aringsmall',
  9937. 'Ccedillasmall',
  9938. 'Eacutesmall',
  9939. 'Egravesmall',
  9940. 'Ecircumflexsmall',
  9941. 'Edieresissmall',
  9942. 'Iacutesmall',
  9943. 'Igravesmall',
  9944. 'Icircumflexsmall',
  9945. 'Idieresissmall',
  9946. 'Ntildesmall',
  9947. 'Oacutesmall',
  9948. 'Ogravesmall',
  9949. 'Ocircumflexsmall',
  9950. 'Odieresissmall',
  9951. 'Otildesmall',
  9952. 'Uacutesmall',
  9953. 'Ugravesmall',
  9954. 'Ucircumflexsmall',
  9955. 'Udieresissmall',
  9956. '',
  9957. 'eightsuperior',
  9958. 'fourinferior',
  9959. 'threeinferior',
  9960. 'sixinferior',
  9961. 'eightinferior',
  9962. 'seveninferior',
  9963. 'Scaronsmall',
  9964. '',
  9965. 'centinferior',
  9966. 'twoinferior',
  9967. '',
  9968. 'Dieresissmall',
  9969. '',
  9970. 'Caronsmall',
  9971. 'osuperior',
  9972. 'fiveinferior',
  9973. '',
  9974. 'commainferior',
  9975. 'periodinferior',
  9976. 'Yacutesmall',
  9977. '',
  9978. 'dollarinferior',
  9979. '',
  9980. 'Thornsmall',
  9981. '',
  9982. 'nineinferior',
  9983. 'zeroinferior',
  9984. 'Zcaronsmall',
  9985. 'AEsmall',
  9986. 'Oslashsmall',
  9987. 'questiondownsmall',
  9988. 'oneinferior',
  9989. 'Lslashsmall',
  9990. '',
  9991. '',
  9992. '',
  9993. '',
  9994. '',
  9995. '',
  9996. 'Cedillasmall',
  9997. '',
  9998. '',
  9999. '',
  10000. '',
  10001. '',
  10002. 'OEsmall',
  10003. 'figuredash',
  10004. 'hyphensuperior',
  10005. '',
  10006. '',
  10007. '',
  10008. '',
  10009. 'exclamdownsmall',
  10010. '',
  10011. 'Ydieresissmall',
  10012. '',
  10013. 'onesuperior',
  10014. 'twosuperior',
  10015. 'threesuperior',
  10016. 'foursuperior',
  10017. 'fivesuperior',
  10018. 'sixsuperior',
  10019. 'sevensuperior',
  10020. 'ninesuperior',
  10021. 'zerosuperior',
  10022. '',
  10023. 'esuperior',
  10024. 'rsuperior',
  10025. 'tsuperior',
  10026. '',
  10027. '',
  10028. 'isuperior',
  10029. 'ssuperior',
  10030. 'dsuperior',
  10031. '',
  10032. '',
  10033. '',
  10034. '',
  10035. '',
  10036. 'lsuperior',
  10037. 'Ogoneksmall',
  10038. 'Brevesmall',
  10039. 'Macronsmall',
  10040. 'bsuperior',
  10041. 'nsuperior',
  10042. 'msuperior',
  10043. 'commasuperior',
  10044. 'periodsuperior',
  10045. 'Dotaccentsmall',
  10046. 'Ringsmall'
  10047. ];
  10048. var MacRomanEncoding = [
  10049. '',
  10050. '',
  10051. '',
  10052. '',
  10053. '',
  10054. '',
  10055. '',
  10056. '',
  10057. '',
  10058. '',
  10059. '',
  10060. '',
  10061. '',
  10062. '',
  10063. '',
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. '',
  10080. '',
  10081. 'space',
  10082. 'exclam',
  10083. 'quotedbl',
  10084. 'numbersign',
  10085. 'dollar',
  10086. 'percent',
  10087. 'ampersand',
  10088. 'quotesingle',
  10089. 'parenleft',
  10090. 'parenright',
  10091. 'asterisk',
  10092. 'plus',
  10093. 'comma',
  10094. 'hyphen',
  10095. 'period',
  10096. 'slash',
  10097. 'zero',
  10098. 'one',
  10099. 'two',
  10100. 'three',
  10101. 'four',
  10102. 'five',
  10103. 'six',
  10104. 'seven',
  10105. 'eight',
  10106. 'nine',
  10107. 'colon',
  10108. 'semicolon',
  10109. 'less',
  10110. 'equal',
  10111. 'greater',
  10112. 'question',
  10113. 'at',
  10114. 'A',
  10115. 'B',
  10116. 'C',
  10117. 'D',
  10118. 'E',
  10119. 'F',
  10120. 'G',
  10121. 'H',
  10122. 'I',
  10123. 'J',
  10124. 'K',
  10125. 'L',
  10126. 'M',
  10127. 'N',
  10128. 'O',
  10129. 'P',
  10130. 'Q',
  10131. 'R',
  10132. 'S',
  10133. 'T',
  10134. 'U',
  10135. 'V',
  10136. 'W',
  10137. 'X',
  10138. 'Y',
  10139. 'Z',
  10140. 'bracketleft',
  10141. 'backslash',
  10142. 'bracketright',
  10143. 'asciicircum',
  10144. 'underscore',
  10145. 'grave',
  10146. 'a',
  10147. 'b',
  10148. 'c',
  10149. 'd',
  10150. 'e',
  10151. 'f',
  10152. 'g',
  10153. 'h',
  10154. 'i',
  10155. 'j',
  10156. 'k',
  10157. 'l',
  10158. 'm',
  10159. 'n',
  10160. 'o',
  10161. 'p',
  10162. 'q',
  10163. 'r',
  10164. 's',
  10165. 't',
  10166. 'u',
  10167. 'v',
  10168. 'w',
  10169. 'x',
  10170. 'y',
  10171. 'z',
  10172. 'braceleft',
  10173. 'bar',
  10174. 'braceright',
  10175. 'asciitilde',
  10176. '',
  10177. 'Adieresis',
  10178. 'Aring',
  10179. 'Ccedilla',
  10180. 'Eacute',
  10181. 'Ntilde',
  10182. 'Odieresis',
  10183. 'Udieresis',
  10184. 'aacute',
  10185. 'agrave',
  10186. 'acircumflex',
  10187. 'adieresis',
  10188. 'atilde',
  10189. 'aring',
  10190. 'ccedilla',
  10191. 'eacute',
  10192. 'egrave',
  10193. 'ecircumflex',
  10194. 'edieresis',
  10195. 'iacute',
  10196. 'igrave',
  10197. 'icircumflex',
  10198. 'idieresis',
  10199. 'ntilde',
  10200. 'oacute',
  10201. 'ograve',
  10202. 'ocircumflex',
  10203. 'odieresis',
  10204. 'otilde',
  10205. 'uacute',
  10206. 'ugrave',
  10207. 'ucircumflex',
  10208. 'udieresis',
  10209. 'dagger',
  10210. 'degree',
  10211. 'cent',
  10212. 'sterling',
  10213. 'section',
  10214. 'bullet',
  10215. 'paragraph',
  10216. 'germandbls',
  10217. 'registered',
  10218. 'copyright',
  10219. 'trademark',
  10220. 'acute',
  10221. 'dieresis',
  10222. 'notequal',
  10223. 'AE',
  10224. 'Oslash',
  10225. 'infinity',
  10226. 'plusminus',
  10227. 'lessequal',
  10228. 'greaterequal',
  10229. 'yen',
  10230. 'mu',
  10231. 'partialdiff',
  10232. 'summation',
  10233. 'product',
  10234. 'pi',
  10235. 'integral',
  10236. 'ordfeminine',
  10237. 'ordmasculine',
  10238. 'Omega',
  10239. 'ae',
  10240. 'oslash',
  10241. 'questiondown',
  10242. 'exclamdown',
  10243. 'logicalnot',
  10244. 'radical',
  10245. 'florin',
  10246. 'approxequal',
  10247. 'Delta',
  10248. 'guillemotleft',
  10249. 'guillemotright',
  10250. 'ellipsis',
  10251. 'space',
  10252. 'Agrave',
  10253. 'Atilde',
  10254. 'Otilde',
  10255. 'OE',
  10256. 'oe',
  10257. 'endash',
  10258. 'emdash',
  10259. 'quotedblleft',
  10260. 'quotedblright',
  10261. 'quoteleft',
  10262. 'quoteright',
  10263. 'divide',
  10264. 'lozenge',
  10265. 'ydieresis',
  10266. 'Ydieresis',
  10267. 'fraction',
  10268. 'currency',
  10269. 'guilsinglleft',
  10270. 'guilsinglright',
  10271. 'fi',
  10272. 'fl',
  10273. 'daggerdbl',
  10274. 'periodcentered',
  10275. 'quotesinglbase',
  10276. 'quotedblbase',
  10277. 'perthousand',
  10278. 'Acircumflex',
  10279. 'Ecircumflex',
  10280. 'Aacute',
  10281. 'Edieresis',
  10282. 'Egrave',
  10283. 'Iacute',
  10284. 'Icircumflex',
  10285. 'Idieresis',
  10286. 'Igrave',
  10287. 'Oacute',
  10288. 'Ocircumflex',
  10289. 'apple',
  10290. 'Ograve',
  10291. 'Uacute',
  10292. 'Ucircumflex',
  10293. 'Ugrave',
  10294. 'dotlessi',
  10295. 'circumflex',
  10296. 'tilde',
  10297. 'macron',
  10298. 'breve',
  10299. 'dotaccent',
  10300. 'ring',
  10301. 'cedilla',
  10302. 'hungarumlaut',
  10303. 'ogonek',
  10304. 'caron'
  10305. ];
  10306. var StandardEncoding = [
  10307. '',
  10308. '',
  10309. '',
  10310. '',
  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. 'space',
  10340. 'exclam',
  10341. 'quotedbl',
  10342. 'numbersign',
  10343. 'dollar',
  10344. 'percent',
  10345. 'ampersand',
  10346. 'quoteright',
  10347. 'parenleft',
  10348. 'parenright',
  10349. 'asterisk',
  10350. 'plus',
  10351. 'comma',
  10352. 'hyphen',
  10353. 'period',
  10354. 'slash',
  10355. 'zero',
  10356. 'one',
  10357. 'two',
  10358. 'three',
  10359. 'four',
  10360. 'five',
  10361. 'six',
  10362. 'seven',
  10363. 'eight',
  10364. 'nine',
  10365. 'colon',
  10366. 'semicolon',
  10367. 'less',
  10368. 'equal',
  10369. 'greater',
  10370. 'question',
  10371. 'at',
  10372. 'A',
  10373. 'B',
  10374. 'C',
  10375. 'D',
  10376. 'E',
  10377. 'F',
  10378. 'G',
  10379. 'H',
  10380. 'I',
  10381. 'J',
  10382. 'K',
  10383. 'L',
  10384. 'M',
  10385. 'N',
  10386. 'O',
  10387. 'P',
  10388. 'Q',
  10389. 'R',
  10390. 'S',
  10391. 'T',
  10392. 'U',
  10393. 'V',
  10394. 'W',
  10395. 'X',
  10396. 'Y',
  10397. 'Z',
  10398. 'bracketleft',
  10399. 'backslash',
  10400. 'bracketright',
  10401. 'asciicircum',
  10402. 'underscore',
  10403. 'quoteleft',
  10404. 'a',
  10405. 'b',
  10406. 'c',
  10407. 'd',
  10408. 'e',
  10409. 'f',
  10410. 'g',
  10411. 'h',
  10412. 'i',
  10413. 'j',
  10414. 'k',
  10415. 'l',
  10416. 'm',
  10417. 'n',
  10418. 'o',
  10419. 'p',
  10420. 'q',
  10421. 'r',
  10422. 's',
  10423. 't',
  10424. 'u',
  10425. 'v',
  10426. 'w',
  10427. 'x',
  10428. 'y',
  10429. 'z',
  10430. 'braceleft',
  10431. 'bar',
  10432. 'braceright',
  10433. 'asciitilde',
  10434. '',
  10435. '',
  10436. '',
  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. 'exclamdown',
  10469. 'cent',
  10470. 'sterling',
  10471. 'fraction',
  10472. 'yen',
  10473. 'florin',
  10474. 'section',
  10475. 'currency',
  10476. 'quotesingle',
  10477. 'quotedblleft',
  10478. 'guillemotleft',
  10479. 'guilsinglleft',
  10480. 'guilsinglright',
  10481. 'fi',
  10482. 'fl',
  10483. '',
  10484. 'endash',
  10485. 'dagger',
  10486. 'daggerdbl',
  10487. 'periodcentered',
  10488. '',
  10489. 'paragraph',
  10490. 'bullet',
  10491. 'quotesinglbase',
  10492. 'quotedblbase',
  10493. 'quotedblright',
  10494. 'guillemotright',
  10495. 'ellipsis',
  10496. 'perthousand',
  10497. '',
  10498. 'questiondown',
  10499. '',
  10500. 'grave',
  10501. 'acute',
  10502. 'circumflex',
  10503. 'tilde',
  10504. 'macron',
  10505. 'breve',
  10506. 'dotaccent',
  10507. 'dieresis',
  10508. '',
  10509. 'ring',
  10510. 'cedilla',
  10511. '',
  10512. 'hungarumlaut',
  10513. 'ogonek',
  10514. 'caron',
  10515. 'emdash',
  10516. '',
  10517. '',
  10518. '',
  10519. '',
  10520. '',
  10521. '',
  10522. '',
  10523. '',
  10524. '',
  10525. '',
  10526. '',
  10527. '',
  10528. '',
  10529. '',
  10530. '',
  10531. '',
  10532. 'AE',
  10533. '',
  10534. 'ordfeminine',
  10535. '',
  10536. '',
  10537. '',
  10538. '',
  10539. 'Lslash',
  10540. 'Oslash',
  10541. 'OE',
  10542. 'ordmasculine',
  10543. '',
  10544. '',
  10545. '',
  10546. '',
  10547. '',
  10548. 'ae',
  10549. '',
  10550. '',
  10551. '',
  10552. 'dotlessi',
  10553. '',
  10554. '',
  10555. 'lslash',
  10556. 'oslash',
  10557. 'oe',
  10558. 'germandbls'
  10559. ];
  10560. var WinAnsiEncoding = [
  10561. '',
  10562. '',
  10563. '',
  10564. '',
  10565. '',
  10566. '',
  10567. '',
  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. 'space',
  10594. 'exclam',
  10595. 'quotedbl',
  10596. 'numbersign',
  10597. 'dollar',
  10598. 'percent',
  10599. 'ampersand',
  10600. 'quotesingle',
  10601. 'parenleft',
  10602. 'parenright',
  10603. 'asterisk',
  10604. 'plus',
  10605. 'comma',
  10606. 'hyphen',
  10607. 'period',
  10608. 'slash',
  10609. 'zero',
  10610. 'one',
  10611. 'two',
  10612. 'three',
  10613. 'four',
  10614. 'five',
  10615. 'six',
  10616. 'seven',
  10617. 'eight',
  10618. 'nine',
  10619. 'colon',
  10620. 'semicolon',
  10621. 'less',
  10622. 'equal',
  10623. 'greater',
  10624. 'question',
  10625. 'at',
  10626. 'A',
  10627. 'B',
  10628. 'C',
  10629. 'D',
  10630. 'E',
  10631. 'F',
  10632. 'G',
  10633. 'H',
  10634. 'I',
  10635. 'J',
  10636. 'K',
  10637. 'L',
  10638. 'M',
  10639. 'N',
  10640. 'O',
  10641. 'P',
  10642. 'Q',
  10643. 'R',
  10644. 'S',
  10645. 'T',
  10646. 'U',
  10647. 'V',
  10648. 'W',
  10649. 'X',
  10650. 'Y',
  10651. 'Z',
  10652. 'bracketleft',
  10653. 'backslash',
  10654. 'bracketright',
  10655. 'asciicircum',
  10656. 'underscore',
  10657. 'grave',
  10658. 'a',
  10659. 'b',
  10660. 'c',
  10661. 'd',
  10662. 'e',
  10663. 'f',
  10664. 'g',
  10665. 'h',
  10666. 'i',
  10667. 'j',
  10668. 'k',
  10669. 'l',
  10670. 'm',
  10671. 'n',
  10672. 'o',
  10673. 'p',
  10674. 'q',
  10675. 'r',
  10676. 's',
  10677. 't',
  10678. 'u',
  10679. 'v',
  10680. 'w',
  10681. 'x',
  10682. 'y',
  10683. 'z',
  10684. 'braceleft',
  10685. 'bar',
  10686. 'braceright',
  10687. 'asciitilde',
  10688. 'bullet',
  10689. 'Euro',
  10690. 'bullet',
  10691. 'quotesinglbase',
  10692. 'florin',
  10693. 'quotedblbase',
  10694. 'ellipsis',
  10695. 'dagger',
  10696. 'daggerdbl',
  10697. 'circumflex',
  10698. 'perthousand',
  10699. 'Scaron',
  10700. 'guilsinglleft',
  10701. 'OE',
  10702. 'bullet',
  10703. 'Zcaron',
  10704. 'bullet',
  10705. 'bullet',
  10706. 'quoteleft',
  10707. 'quoteright',
  10708. 'quotedblleft',
  10709. 'quotedblright',
  10710. 'bullet',
  10711. 'endash',
  10712. 'emdash',
  10713. 'tilde',
  10714. 'trademark',
  10715. 'scaron',
  10716. 'guilsinglright',
  10717. 'oe',
  10718. 'bullet',
  10719. 'zcaron',
  10720. 'Ydieresis',
  10721. 'space',
  10722. 'exclamdown',
  10723. 'cent',
  10724. 'sterling',
  10725. 'currency',
  10726. 'yen',
  10727. 'brokenbar',
  10728. 'section',
  10729. 'dieresis',
  10730. 'copyright',
  10731. 'ordfeminine',
  10732. 'guillemotleft',
  10733. 'logicalnot',
  10734. 'hyphen',
  10735. 'registered',
  10736. 'macron',
  10737. 'degree',
  10738. 'plusminus',
  10739. 'twosuperior',
  10740. 'threesuperior',
  10741. 'acute',
  10742. 'mu',
  10743. 'paragraph',
  10744. 'periodcentered',
  10745. 'cedilla',
  10746. 'onesuperior',
  10747. 'ordmasculine',
  10748. 'guillemotright',
  10749. 'onequarter',
  10750. 'onehalf',
  10751. 'threequarters',
  10752. 'questiondown',
  10753. 'Agrave',
  10754. 'Aacute',
  10755. 'Acircumflex',
  10756. 'Atilde',
  10757. 'Adieresis',
  10758. 'Aring',
  10759. 'AE',
  10760. 'Ccedilla',
  10761. 'Egrave',
  10762. 'Eacute',
  10763. 'Ecircumflex',
  10764. 'Edieresis',
  10765. 'Igrave',
  10766. 'Iacute',
  10767. 'Icircumflex',
  10768. 'Idieresis',
  10769. 'Eth',
  10770. 'Ntilde',
  10771. 'Ograve',
  10772. 'Oacute',
  10773. 'Ocircumflex',
  10774. 'Otilde',
  10775. 'Odieresis',
  10776. 'multiply',
  10777. 'Oslash',
  10778. 'Ugrave',
  10779. 'Uacute',
  10780. 'Ucircumflex',
  10781. 'Udieresis',
  10782. 'Yacute',
  10783. 'Thorn',
  10784. 'germandbls',
  10785. 'agrave',
  10786. 'aacute',
  10787. 'acircumflex',
  10788. 'atilde',
  10789. 'adieresis',
  10790. 'aring',
  10791. 'ae',
  10792. 'ccedilla',
  10793. 'egrave',
  10794. 'eacute',
  10795. 'ecircumflex',
  10796. 'edieresis',
  10797. 'igrave',
  10798. 'iacute',
  10799. 'icircumflex',
  10800. 'idieresis',
  10801. 'eth',
  10802. 'ntilde',
  10803. 'ograve',
  10804. 'oacute',
  10805. 'ocircumflex',
  10806. 'otilde',
  10807. 'odieresis',
  10808. 'divide',
  10809. 'oslash',
  10810. 'ugrave',
  10811. 'uacute',
  10812. 'ucircumflex',
  10813. 'udieresis',
  10814. 'yacute',
  10815. 'thorn',
  10816. 'ydieresis'
  10817. ];
  10818. var SymbolSetEncoding = [
  10819. '',
  10820. '',
  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. 'space',
  10852. 'exclam',
  10853. 'universal',
  10854. 'numbersign',
  10855. 'existential',
  10856. 'percent',
  10857. 'ampersand',
  10858. 'suchthat',
  10859. 'parenleft',
  10860. 'parenright',
  10861. 'asteriskmath',
  10862. 'plus',
  10863. 'comma',
  10864. 'minus',
  10865. 'period',
  10866. 'slash',
  10867. 'zero',
  10868. 'one',
  10869. 'two',
  10870. 'three',
  10871. 'four',
  10872. 'five',
  10873. 'six',
  10874. 'seven',
  10875. 'eight',
  10876. 'nine',
  10877. 'colon',
  10878. 'semicolon',
  10879. 'less',
  10880. 'equal',
  10881. 'greater',
  10882. 'question',
  10883. 'congruent',
  10884. 'Alpha',
  10885. 'Beta',
  10886. 'Chi',
  10887. 'Delta',
  10888. 'Epsilon',
  10889. 'Phi',
  10890. 'Gamma',
  10891. 'Eta',
  10892. 'Iota',
  10893. 'theta1',
  10894. 'Kappa',
  10895. 'Lambda',
  10896. 'Mu',
  10897. 'Nu',
  10898. 'Omicron',
  10899. 'Pi',
  10900. 'Theta',
  10901. 'Rho',
  10902. 'Sigma',
  10903. 'Tau',
  10904. 'Upsilon',
  10905. 'sigma1',
  10906. 'Omega',
  10907. 'Xi',
  10908. 'Psi',
  10909. 'Zeta',
  10910. 'bracketleft',
  10911. 'therefore',
  10912. 'bracketright',
  10913. 'perpendicular',
  10914. 'underscore',
  10915. 'radicalex',
  10916. 'alpha',
  10917. 'beta',
  10918. 'chi',
  10919. 'delta',
  10920. 'epsilon',
  10921. 'phi',
  10922. 'gamma',
  10923. 'eta',
  10924. 'iota',
  10925. 'phi1',
  10926. 'kappa',
  10927. 'lambda',
  10928. 'mu',
  10929. 'nu',
  10930. 'omicron',
  10931. 'pi',
  10932. 'theta',
  10933. 'rho',
  10934. 'sigma',
  10935. 'tau',
  10936. 'upsilon',
  10937. 'omega1',
  10938. 'omega',
  10939. 'xi',
  10940. 'psi',
  10941. 'zeta',
  10942. 'braceleft',
  10943. 'bar',
  10944. 'braceright',
  10945. 'similar',
  10946. '',
  10947. '',
  10948. '',
  10949. '',
  10950. '',
  10951. '',
  10952. '',
  10953. '',
  10954. '',
  10955. '',
  10956. '',
  10957. '',
  10958. '',
  10959. '',
  10960. '',
  10961. '',
  10962. '',
  10963. '',
  10964. '',
  10965. '',
  10966. '',
  10967. '',
  10968. '',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. '',
  10978. '',
  10979. 'Euro',
  10980. 'Upsilon1',
  10981. 'minute',
  10982. 'lessequal',
  10983. 'fraction',
  10984. 'infinity',
  10985. 'florin',
  10986. 'club',
  10987. 'diamond',
  10988. 'heart',
  10989. 'spade',
  10990. 'arrowboth',
  10991. 'arrowleft',
  10992. 'arrowup',
  10993. 'arrowright',
  10994. 'arrowdown',
  10995. 'degree',
  10996. 'plusminus',
  10997. 'second',
  10998. 'greaterequal',
  10999. 'multiply',
  11000. 'proportional',
  11001. 'partialdiff',
  11002. 'bullet',
  11003. 'divide',
  11004. 'notequal',
  11005. 'equivalence',
  11006. 'approxequal',
  11007. 'ellipsis',
  11008. 'arrowvertex',
  11009. 'arrowhorizex',
  11010. 'carriagereturn',
  11011. 'aleph',
  11012. 'Ifraktur',
  11013. 'Rfraktur',
  11014. 'weierstrass',
  11015. 'circlemultiply',
  11016. 'circleplus',
  11017. 'emptyset',
  11018. 'intersection',
  11019. 'union',
  11020. 'propersuperset',
  11021. 'reflexsuperset',
  11022. 'notsubset',
  11023. 'propersubset',
  11024. 'reflexsubset',
  11025. 'element',
  11026. 'notelement',
  11027. 'angle',
  11028. 'gradient',
  11029. 'registerserif',
  11030. 'copyrightserif',
  11031. 'trademarkserif',
  11032. 'product',
  11033. 'radical',
  11034. 'dotmath',
  11035. 'logicalnot',
  11036. 'logicaland',
  11037. 'logicalor',
  11038. 'arrowdblboth',
  11039. 'arrowdblleft',
  11040. 'arrowdblup',
  11041. 'arrowdblright',
  11042. 'arrowdbldown',
  11043. 'lozenge',
  11044. 'angleleft',
  11045. 'registersans',
  11046. 'copyrightsans',
  11047. 'trademarksans',
  11048. 'summation',
  11049. 'parenlefttp',
  11050. 'parenleftex',
  11051. 'parenleftbt',
  11052. 'bracketlefttp',
  11053. 'bracketleftex',
  11054. 'bracketleftbt',
  11055. 'bracelefttp',
  11056. 'braceleftmid',
  11057. 'braceleftbt',
  11058. 'braceex',
  11059. '',
  11060. 'angleright',
  11061. 'integral',
  11062. 'integraltp',
  11063. 'integralex',
  11064. 'integralbt',
  11065. 'parenrighttp',
  11066. 'parenrightex',
  11067. 'parenrightbt',
  11068. 'bracketrighttp',
  11069. 'bracketrightex',
  11070. 'bracketrightbt',
  11071. 'bracerighttp',
  11072. 'bracerightmid',
  11073. 'bracerightbt'
  11074. ];
  11075. var ZapfDingbatsEncoding = [
  11076. '',
  11077. '',
  11078. '',
  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. 'space',
  11109. 'a1',
  11110. 'a2',
  11111. 'a202',
  11112. 'a3',
  11113. 'a4',
  11114. 'a5',
  11115. 'a119',
  11116. 'a118',
  11117. 'a117',
  11118. 'a11',
  11119. 'a12',
  11120. 'a13',
  11121. 'a14',
  11122. 'a15',
  11123. 'a16',
  11124. 'a105',
  11125. 'a17',
  11126. 'a18',
  11127. 'a19',
  11128. 'a20',
  11129. 'a21',
  11130. 'a22',
  11131. 'a23',
  11132. 'a24',
  11133. 'a25',
  11134. 'a26',
  11135. 'a27',
  11136. 'a28',
  11137. 'a6',
  11138. 'a7',
  11139. 'a8',
  11140. 'a9',
  11141. 'a10',
  11142. 'a29',
  11143. 'a30',
  11144. 'a31',
  11145. 'a32',
  11146. 'a33',
  11147. 'a34',
  11148. 'a35',
  11149. 'a36',
  11150. 'a37',
  11151. 'a38',
  11152. 'a39',
  11153. 'a40',
  11154. 'a41',
  11155. 'a42',
  11156. 'a43',
  11157. 'a44',
  11158. 'a45',
  11159. 'a46',
  11160. 'a47',
  11161. 'a48',
  11162. 'a49',
  11163. 'a50',
  11164. 'a51',
  11165. 'a52',
  11166. 'a53',
  11167. 'a54',
  11168. 'a55',
  11169. 'a56',
  11170. 'a57',
  11171. 'a58',
  11172. 'a59',
  11173. 'a60',
  11174. 'a61',
  11175. 'a62',
  11176. 'a63',
  11177. 'a64',
  11178. 'a65',
  11179. 'a66',
  11180. 'a67',
  11181. 'a68',
  11182. 'a69',
  11183. 'a70',
  11184. 'a71',
  11185. 'a72',
  11186. 'a73',
  11187. 'a74',
  11188. 'a203',
  11189. 'a75',
  11190. 'a204',
  11191. 'a76',
  11192. 'a77',
  11193. 'a78',
  11194. 'a79',
  11195. 'a81',
  11196. 'a82',
  11197. 'a83',
  11198. 'a84',
  11199. 'a97',
  11200. 'a98',
  11201. 'a99',
  11202. 'a100',
  11203. '',
  11204. 'a89',
  11205. 'a90',
  11206. 'a93',
  11207. 'a94',
  11208. 'a91',
  11209. 'a92',
  11210. 'a205',
  11211. 'a85',
  11212. 'a206',
  11213. 'a86',
  11214. 'a87',
  11215. 'a88',
  11216. 'a95',
  11217. 'a96',
  11218. '',
  11219. '',
  11220. '',
  11221. '',
  11222. '',
  11223. '',
  11224. '',
  11225. '',
  11226. '',
  11227. '',
  11228. '',
  11229. '',
  11230. '',
  11231. '',
  11232. '',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. 'a101',
  11238. 'a102',
  11239. 'a103',
  11240. 'a104',
  11241. 'a106',
  11242. 'a107',
  11243. 'a108',
  11244. 'a112',
  11245. 'a111',
  11246. 'a110',
  11247. 'a109',
  11248. 'a120',
  11249. 'a121',
  11250. 'a122',
  11251. 'a123',
  11252. 'a124',
  11253. 'a125',
  11254. 'a126',
  11255. 'a127',
  11256. 'a128',
  11257. 'a129',
  11258. 'a130',
  11259. 'a131',
  11260. 'a132',
  11261. 'a133',
  11262. 'a134',
  11263. 'a135',
  11264. 'a136',
  11265. 'a137',
  11266. 'a138',
  11267. 'a139',
  11268. 'a140',
  11269. 'a141',
  11270. 'a142',
  11271. 'a143',
  11272. 'a144',
  11273. 'a145',
  11274. 'a146',
  11275. 'a147',
  11276. 'a148',
  11277. 'a149',
  11278. 'a150',
  11279. 'a151',
  11280. 'a152',
  11281. 'a153',
  11282. 'a154',
  11283. 'a155',
  11284. 'a156',
  11285. 'a157',
  11286. 'a158',
  11287. 'a159',
  11288. 'a160',
  11289. 'a161',
  11290. 'a163',
  11291. 'a164',
  11292. 'a196',
  11293. 'a165',
  11294. 'a192',
  11295. 'a166',
  11296. 'a167',
  11297. 'a168',
  11298. 'a169',
  11299. 'a170',
  11300. 'a171',
  11301. 'a172',
  11302. 'a173',
  11303. 'a162',
  11304. 'a174',
  11305. 'a175',
  11306. 'a176',
  11307. 'a177',
  11308. 'a178',
  11309. 'a179',
  11310. 'a193',
  11311. 'a180',
  11312. 'a199',
  11313. 'a181',
  11314. 'a200',
  11315. 'a182',
  11316. '',
  11317. 'a201',
  11318. 'a183',
  11319. 'a184',
  11320. 'a197',
  11321. 'a185',
  11322. 'a194',
  11323. 'a198',
  11324. 'a186',
  11325. 'a195',
  11326. 'a187',
  11327. 'a188',
  11328. 'a189',
  11329. 'a190',
  11330. 'a191'
  11331. ];
  11332. function getEncoding(encodingName) {
  11333. switch (encodingName) {
  11334. case 'WinAnsiEncoding':
  11335. return WinAnsiEncoding;
  11336. case 'StandardEncoding':
  11337. return StandardEncoding;
  11338. case 'MacRomanEncoding':
  11339. return MacRomanEncoding;
  11340. case 'SymbolSetEncoding':
  11341. return SymbolSetEncoding;
  11342. case 'ZapfDingbatsEncoding':
  11343. return ZapfDingbatsEncoding;
  11344. case 'ExpertEncoding':
  11345. return ExpertEncoding;
  11346. case 'MacExpertEncoding':
  11347. return MacExpertEncoding;
  11348. default:
  11349. return null;
  11350. }
  11351. }
  11352. exports.WinAnsiEncoding = WinAnsiEncoding;
  11353. exports.StandardEncoding = StandardEncoding;
  11354. exports.MacRomanEncoding = MacRomanEncoding;
  11355. exports.SymbolSetEncoding = SymbolSetEncoding;
  11356. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11357. exports.ExpertEncoding = ExpertEncoding;
  11358. exports.getEncoding = getEncoding;
  11359. /***/ }),
  11360. /* 6 */
  11361. /***/ (function(module, exports, __w_pdfjs_require__) {
  11362. "use strict";
  11363. var sharedUtil = __w_pdfjs_require__(0);
  11364. var corePrimitives = __w_pdfjs_require__(1);
  11365. var coreStream = __w_pdfjs_require__(2);
  11366. var MissingDataException = sharedUtil.MissingDataException;
  11367. var StreamType = sharedUtil.StreamType;
  11368. var assert = sharedUtil.assert;
  11369. var error = sharedUtil.error;
  11370. var info = sharedUtil.info;
  11371. var isArray = sharedUtil.isArray;
  11372. var isInt = sharedUtil.isInt;
  11373. var isNum = sharedUtil.isNum;
  11374. var isString = sharedUtil.isString;
  11375. var warn = sharedUtil.warn;
  11376. var EOF = corePrimitives.EOF;
  11377. var Cmd = corePrimitives.Cmd;
  11378. var Dict = corePrimitives.Dict;
  11379. var Name = corePrimitives.Name;
  11380. var Ref = corePrimitives.Ref;
  11381. var isEOF = corePrimitives.isEOF;
  11382. var isCmd = corePrimitives.isCmd;
  11383. var isDict = corePrimitives.isDict;
  11384. var isName = corePrimitives.isName;
  11385. var Ascii85Stream = coreStream.Ascii85Stream;
  11386. var AsciiHexStream = coreStream.AsciiHexStream;
  11387. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11388. var FlateStream = coreStream.FlateStream;
  11389. var Jbig2Stream = coreStream.Jbig2Stream;
  11390. var JpegStream = coreStream.JpegStream;
  11391. var JpxStream = coreStream.JpxStream;
  11392. var LZWStream = coreStream.LZWStream;
  11393. var NullStream = coreStream.NullStream;
  11394. var PredictorStream = coreStream.PredictorStream;
  11395. var RunLengthStream = coreStream.RunLengthStream;
  11396. var MAX_LENGTH_TO_CACHE = 1000;
  11397. var Parser = function ParserClosure() {
  11398. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11399. this.lexer = lexer;
  11400. this.allowStreams = allowStreams;
  11401. this.xref = xref;
  11402. this.recoveryMode = recoveryMode || false;
  11403. this.imageCache = Object.create(null);
  11404. this.refill();
  11405. }
  11406. Parser.prototype = {
  11407. refill: function Parser_refill() {
  11408. this.buf1 = this.lexer.getObj();
  11409. this.buf2 = this.lexer.getObj();
  11410. },
  11411. shift: function Parser_shift() {
  11412. if (isCmd(this.buf2, 'ID')) {
  11413. this.buf1 = this.buf2;
  11414. this.buf2 = null;
  11415. } else {
  11416. this.buf1 = this.buf2;
  11417. this.buf2 = this.lexer.getObj();
  11418. }
  11419. },
  11420. tryShift: function Parser_tryShift() {
  11421. try {
  11422. this.shift();
  11423. return true;
  11424. } catch (e) {
  11425. if (e instanceof MissingDataException) {
  11426. throw e;
  11427. }
  11428. return false;
  11429. }
  11430. },
  11431. getObj: function Parser_getObj(cipherTransform) {
  11432. var buf1 = this.buf1;
  11433. this.shift();
  11434. if (buf1 instanceof Cmd) {
  11435. switch (buf1.cmd) {
  11436. case 'BI':
  11437. return this.makeInlineImage(cipherTransform);
  11438. case '[':
  11439. var array = [];
  11440. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11441. array.push(this.getObj(cipherTransform));
  11442. }
  11443. if (isEOF(this.buf1)) {
  11444. if (!this.recoveryMode) {
  11445. error('End of file inside array');
  11446. }
  11447. return array;
  11448. }
  11449. this.shift();
  11450. return array;
  11451. case '<<':
  11452. var dict = new Dict(this.xref);
  11453. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11454. if (!isName(this.buf1)) {
  11455. info('Malformed dictionary: key must be a name object');
  11456. this.shift();
  11457. continue;
  11458. }
  11459. var key = this.buf1.name;
  11460. this.shift();
  11461. if (isEOF(this.buf1)) {
  11462. break;
  11463. }
  11464. dict.set(key, this.getObj(cipherTransform));
  11465. }
  11466. if (isEOF(this.buf1)) {
  11467. if (!this.recoveryMode) {
  11468. error('End of file inside dictionary');
  11469. }
  11470. return dict;
  11471. }
  11472. if (isCmd(this.buf2, 'stream')) {
  11473. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11474. }
  11475. this.shift();
  11476. return dict;
  11477. default:
  11478. return buf1;
  11479. }
  11480. }
  11481. if (isInt(buf1)) {
  11482. var num = buf1;
  11483. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11484. var ref = new Ref(num, this.buf1);
  11485. this.shift();
  11486. this.shift();
  11487. return ref;
  11488. }
  11489. return num;
  11490. }
  11491. if (isString(buf1)) {
  11492. var str = buf1;
  11493. if (cipherTransform) {
  11494. str = cipherTransform.decryptString(str);
  11495. }
  11496. return str;
  11497. }
  11498. return buf1;
  11499. },
  11500. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11501. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11502. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11503. while ((ch = stream.getByte()) !== -1) {
  11504. if (state === 0) {
  11505. state = ch === E ? 1 : 0;
  11506. } else if (state === 1) {
  11507. state = ch === I ? 2 : 0;
  11508. } else {
  11509. assert(state === 2);
  11510. if (ch === SPACE || ch === LF || ch === CR) {
  11511. n = 5;
  11512. followingBytes = stream.peekBytes(n);
  11513. for (i = 0; i < n; i++) {
  11514. ch = followingBytes[i];
  11515. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11516. state = 0;
  11517. break;
  11518. }
  11519. }
  11520. if (state === 2) {
  11521. break;
  11522. }
  11523. } else {
  11524. state = 0;
  11525. }
  11526. }
  11527. }
  11528. return stream.pos - 4 - startPos;
  11529. },
  11530. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11531. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11532. while ((b = stream.getByte()) !== -1) {
  11533. if (b !== 0xFF) {
  11534. continue;
  11535. }
  11536. switch (stream.getByte()) {
  11537. case 0x00:
  11538. break;
  11539. case 0xFF:
  11540. stream.skip(-1);
  11541. break;
  11542. case 0xD9:
  11543. foundEOI = true;
  11544. break;
  11545. case 0xC0:
  11546. case 0xC1:
  11547. case 0xC2:
  11548. case 0xC3:
  11549. case 0xC5:
  11550. case 0xC6:
  11551. case 0xC7:
  11552. case 0xC9:
  11553. case 0xCA:
  11554. case 0xCB:
  11555. case 0xCD:
  11556. case 0xCE:
  11557. case 0xCF:
  11558. case 0xC4:
  11559. case 0xCC:
  11560. case 0xDA:
  11561. case 0xDB:
  11562. case 0xDC:
  11563. case 0xDD:
  11564. case 0xDE:
  11565. case 0xDF:
  11566. case 0xE0:
  11567. case 0xE1:
  11568. case 0xE2:
  11569. case 0xE3:
  11570. case 0xE4:
  11571. case 0xE5:
  11572. case 0xE6:
  11573. case 0xE7:
  11574. case 0xE8:
  11575. case 0xE9:
  11576. case 0xEA:
  11577. case 0xEB:
  11578. case 0xEC:
  11579. case 0xED:
  11580. case 0xEE:
  11581. case 0xEF:
  11582. case 0xFE:
  11583. markerLength = stream.getUint16();
  11584. if (markerLength > 2) {
  11585. stream.skip(markerLength - 2);
  11586. } else {
  11587. stream.skip(-2);
  11588. }
  11589. break;
  11590. }
  11591. if (foundEOI) {
  11592. break;
  11593. }
  11594. }
  11595. length = stream.pos - startPos;
  11596. if (b === -1) {
  11597. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11598. stream.skip(-length);
  11599. return this.findDefaultInlineStreamEnd(stream);
  11600. }
  11601. this.inlineStreamSkipEI(stream);
  11602. return length;
  11603. },
  11604. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11605. var TILDE = 0x7E, GT = 0x3E;
  11606. var startPos = stream.pos, ch, length;
  11607. while ((ch = stream.getByte()) !== -1) {
  11608. if (ch === TILDE && stream.peekByte() === GT) {
  11609. stream.skip();
  11610. break;
  11611. }
  11612. }
  11613. length = stream.pos - startPos;
  11614. if (ch === -1) {
  11615. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11616. stream.skip(-length);
  11617. return this.findDefaultInlineStreamEnd(stream);
  11618. }
  11619. this.inlineStreamSkipEI(stream);
  11620. return length;
  11621. },
  11622. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11623. var GT = 0x3E;
  11624. var startPos = stream.pos, ch, length;
  11625. while ((ch = stream.getByte()) !== -1) {
  11626. if (ch === GT) {
  11627. break;
  11628. }
  11629. }
  11630. length = stream.pos - startPos;
  11631. if (ch === -1) {
  11632. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11633. stream.skip(-length);
  11634. return this.findDefaultInlineStreamEnd(stream);
  11635. }
  11636. this.inlineStreamSkipEI(stream);
  11637. return length;
  11638. },
  11639. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11640. var E = 0x45, I = 0x49;
  11641. var state = 0, ch;
  11642. while ((ch = stream.getByte()) !== -1) {
  11643. if (state === 0) {
  11644. state = ch === E ? 1 : 0;
  11645. } else if (state === 1) {
  11646. state = ch === I ? 2 : 0;
  11647. } else if (state === 2) {
  11648. break;
  11649. }
  11650. }
  11651. },
  11652. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11653. var lexer = this.lexer;
  11654. var stream = lexer.stream;
  11655. var dict = new Dict(this.xref);
  11656. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11657. if (!isName(this.buf1)) {
  11658. error('Dictionary key must be a name object');
  11659. }
  11660. var key = this.buf1.name;
  11661. this.shift();
  11662. if (isEOF(this.buf1)) {
  11663. break;
  11664. }
  11665. dict.set(key, this.getObj(cipherTransform));
  11666. }
  11667. var filter = dict.get('Filter', 'F'), filterName;
  11668. if (isName(filter)) {
  11669. filterName = filter.name;
  11670. } else if (isArray(filter)) {
  11671. var filterZero = this.xref.fetchIfRef(filter[0]);
  11672. if (isName(filterZero)) {
  11673. filterName = filterZero.name;
  11674. }
  11675. }
  11676. var startPos = stream.pos, length, i, ii;
  11677. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11678. length = this.findDCTDecodeInlineStreamEnd(stream);
  11679. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11680. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11681. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11682. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11683. } else {
  11684. length = this.findDefaultInlineStreamEnd(stream);
  11685. }
  11686. var imageStream = stream.makeSubStream(startPos, length, dict);
  11687. var adler32;
  11688. if (length < MAX_LENGTH_TO_CACHE) {
  11689. var imageBytes = imageStream.getBytes();
  11690. imageStream.reset();
  11691. var a = 1;
  11692. var b = 0;
  11693. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11694. a += imageBytes[i] & 0xff;
  11695. b += a;
  11696. }
  11697. adler32 = b % 65521 << 16 | a % 65521;
  11698. if (this.imageCache.adler32 === adler32) {
  11699. this.buf2 = Cmd.get('EI');
  11700. this.shift();
  11701. this.imageCache[adler32].reset();
  11702. return this.imageCache[adler32];
  11703. }
  11704. }
  11705. if (cipherTransform) {
  11706. imageStream = cipherTransform.createStream(imageStream, length);
  11707. }
  11708. imageStream = this.filter(imageStream, dict, length);
  11709. imageStream.dict = dict;
  11710. if (adler32 !== undefined) {
  11711. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11712. this.imageCache[adler32] = imageStream;
  11713. }
  11714. this.buf2 = Cmd.get('EI');
  11715. this.shift();
  11716. return imageStream;
  11717. },
  11718. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11719. var lexer = this.lexer;
  11720. var stream = lexer.stream;
  11721. lexer.skipToNextLine();
  11722. var pos = stream.pos - 1;
  11723. var length = dict.get('Length');
  11724. if (!isInt(length)) {
  11725. info('Bad ' + length + ' attribute in stream');
  11726. length = 0;
  11727. }
  11728. stream.pos = pos + length;
  11729. lexer.nextChar();
  11730. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11731. this.shift();
  11732. } else {
  11733. stream.pos = pos;
  11734. var SCAN_BLOCK_SIZE = 2048;
  11735. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11736. var ENDSTREAM_SIGNATURE = [
  11737. 0x65,
  11738. 0x6E,
  11739. 0x64,
  11740. 0x73,
  11741. 0x74,
  11742. 0x72,
  11743. 0x65,
  11744. 0x61,
  11745. 0x6D
  11746. ];
  11747. var skipped = 0, found = false, i, j;
  11748. while (stream.pos < stream.end) {
  11749. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11750. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11751. if (scanLength <= 0) {
  11752. break;
  11753. }
  11754. found = false;
  11755. i = 0;
  11756. while (i < scanLength) {
  11757. j = 0;
  11758. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11759. j++;
  11760. }
  11761. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11762. found = true;
  11763. break;
  11764. }
  11765. i++;
  11766. }
  11767. if (found) {
  11768. skipped += i;
  11769. stream.pos += i;
  11770. break;
  11771. }
  11772. skipped += scanLength;
  11773. stream.pos += scanLength;
  11774. }
  11775. if (!found) {
  11776. error('Missing endstream');
  11777. }
  11778. length = skipped;
  11779. lexer.nextChar();
  11780. this.shift();
  11781. this.shift();
  11782. }
  11783. this.shift();
  11784. stream = stream.makeSubStream(pos, length, dict);
  11785. if (cipherTransform) {
  11786. stream = cipherTransform.createStream(stream, length);
  11787. }
  11788. stream = this.filter(stream, dict, length);
  11789. stream.dict = dict;
  11790. return stream;
  11791. },
  11792. filter: function Parser_filter(stream, dict, length) {
  11793. var filter = dict.get('Filter', 'F');
  11794. var params = dict.get('DecodeParms', 'DP');
  11795. if (isName(filter)) {
  11796. if (isArray(params)) {
  11797. params = this.xref.fetchIfRef(params[0]);
  11798. }
  11799. return this.makeFilter(stream, filter.name, length, params);
  11800. }
  11801. var maybeLength = length;
  11802. if (isArray(filter)) {
  11803. var filterArray = filter;
  11804. var paramsArray = params;
  11805. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11806. filter = this.xref.fetchIfRef(filterArray[i]);
  11807. if (!isName(filter)) {
  11808. error('Bad filter name: ' + filter);
  11809. }
  11810. params = null;
  11811. if (isArray(paramsArray) && i in paramsArray) {
  11812. params = this.xref.fetchIfRef(paramsArray[i]);
  11813. }
  11814. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11815. maybeLength = null;
  11816. }
  11817. }
  11818. return stream;
  11819. },
  11820. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11821. if (maybeLength === 0) {
  11822. warn('Empty "' + name + '" stream.');
  11823. return new NullStream(stream);
  11824. }
  11825. try {
  11826. var xrefStreamStats = this.xref.stats.streamTypes;
  11827. if (name === 'FlateDecode' || name === 'Fl') {
  11828. xrefStreamStats[StreamType.FLATE] = true;
  11829. if (params) {
  11830. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11831. }
  11832. return new FlateStream(stream, maybeLength);
  11833. }
  11834. if (name === 'LZWDecode' || name === 'LZW') {
  11835. xrefStreamStats[StreamType.LZW] = true;
  11836. var earlyChange = 1;
  11837. if (params) {
  11838. if (params.has('EarlyChange')) {
  11839. earlyChange = params.get('EarlyChange');
  11840. }
  11841. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11842. }
  11843. return new LZWStream(stream, maybeLength, earlyChange);
  11844. }
  11845. if (name === 'DCTDecode' || name === 'DCT') {
  11846. xrefStreamStats[StreamType.DCT] = true;
  11847. return new JpegStream(stream, maybeLength, stream.dict, params);
  11848. }
  11849. if (name === 'JPXDecode' || name === 'JPX') {
  11850. xrefStreamStats[StreamType.JPX] = true;
  11851. return new JpxStream(stream, maybeLength, stream.dict, params);
  11852. }
  11853. if (name === 'ASCII85Decode' || name === 'A85') {
  11854. xrefStreamStats[StreamType.A85] = true;
  11855. return new Ascii85Stream(stream, maybeLength);
  11856. }
  11857. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11858. xrefStreamStats[StreamType.AHX] = true;
  11859. return new AsciiHexStream(stream, maybeLength);
  11860. }
  11861. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11862. xrefStreamStats[StreamType.CCF] = true;
  11863. return new CCITTFaxStream(stream, maybeLength, params);
  11864. }
  11865. if (name === 'RunLengthDecode' || name === 'RL') {
  11866. xrefStreamStats[StreamType.RL] = true;
  11867. return new RunLengthStream(stream, maybeLength);
  11868. }
  11869. if (name === 'JBIG2Decode') {
  11870. xrefStreamStats[StreamType.JBIG] = true;
  11871. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11872. }
  11873. warn('filter "' + name + '" not supported yet');
  11874. return stream;
  11875. } catch (ex) {
  11876. if (ex instanceof MissingDataException) {
  11877. throw ex;
  11878. }
  11879. warn('Invalid stream: \"' + ex + '\"');
  11880. return new NullStream(stream);
  11881. }
  11882. }
  11883. };
  11884. return Parser;
  11885. }();
  11886. var Lexer = function LexerClosure() {
  11887. function Lexer(stream, knownCommands) {
  11888. this.stream = stream;
  11889. this.nextChar();
  11890. this.strBuf = [];
  11891. this.knownCommands = knownCommands;
  11892. }
  11893. var specialChars = [
  11894. 1,
  11895. 0,
  11896. 0,
  11897. 0,
  11898. 0,
  11899. 0,
  11900. 0,
  11901. 0,
  11902. 0,
  11903. 1,
  11904. 1,
  11905. 0,
  11906. 1,
  11907. 1,
  11908. 0,
  11909. 0,
  11910. 0,
  11911. 0,
  11912. 0,
  11913. 0,
  11914. 0,
  11915. 0,
  11916. 0,
  11917. 0,
  11918. 0,
  11919. 0,
  11920. 0,
  11921. 0,
  11922. 0,
  11923. 0,
  11924. 0,
  11925. 0,
  11926. 1,
  11927. 0,
  11928. 0,
  11929. 0,
  11930. 0,
  11931. 2,
  11932. 0,
  11933. 0,
  11934. 2,
  11935. 2,
  11936. 0,
  11937. 0,
  11938. 0,
  11939. 0,
  11940. 0,
  11941. 2,
  11942. 0,
  11943. 0,
  11944. 0,
  11945. 0,
  11946. 0,
  11947. 0,
  11948. 0,
  11949. 0,
  11950. 0,
  11951. 0,
  11952. 0,
  11953. 0,
  11954. 2,
  11955. 0,
  11956. 2,
  11957. 0,
  11958. 0,
  11959. 0,
  11960. 0,
  11961. 0,
  11962. 0,
  11963. 0,
  11964. 0,
  11965. 0,
  11966. 0,
  11967. 0,
  11968. 0,
  11969. 0,
  11970. 0,
  11971. 0,
  11972. 0,
  11973. 0,
  11974. 0,
  11975. 0,
  11976. 0,
  11977. 0,
  11978. 0,
  11979. 0,
  11980. 0,
  11981. 0,
  11982. 0,
  11983. 0,
  11984. 0,
  11985. 2,
  11986. 0,
  11987. 2,
  11988. 0,
  11989. 0,
  11990. 0,
  11991. 0,
  11992. 0,
  11993. 0,
  11994. 0,
  11995. 0,
  11996. 0,
  11997. 0,
  11998. 0,
  11999. 0,
  12000. 0,
  12001. 0,
  12002. 0,
  12003. 0,
  12004. 0,
  12005. 0,
  12006. 0,
  12007. 0,
  12008. 0,
  12009. 0,
  12010. 0,
  12011. 0,
  12012. 0,
  12013. 0,
  12014. 0,
  12015. 0,
  12016. 0,
  12017. 2,
  12018. 0,
  12019. 2,
  12020. 0,
  12021. 0,
  12022. 0,
  12023. 0,
  12024. 0,
  12025. 0,
  12026. 0,
  12027. 0,
  12028. 0,
  12029. 0,
  12030. 0,
  12031. 0,
  12032. 0,
  12033. 0,
  12034. 0,
  12035. 0,
  12036. 0,
  12037. 0,
  12038. 0,
  12039. 0,
  12040. 0,
  12041. 0,
  12042. 0,
  12043. 0,
  12044. 0,
  12045. 0,
  12046. 0,
  12047. 0,
  12048. 0,
  12049. 0,
  12050. 0,
  12051. 0,
  12052. 0,
  12053. 0,
  12054. 0,
  12055. 0,
  12056. 0,
  12057. 0,
  12058. 0,
  12059. 0,
  12060. 0,
  12061. 0,
  12062. 0,
  12063. 0,
  12064. 0,
  12065. 0,
  12066. 0,
  12067. 0,
  12068. 0,
  12069. 0,
  12070. 0,
  12071. 0,
  12072. 0,
  12073. 0,
  12074. 0,
  12075. 0,
  12076. 0,
  12077. 0,
  12078. 0,
  12079. 0,
  12080. 0,
  12081. 0,
  12082. 0,
  12083. 0,
  12084. 0,
  12085. 0,
  12086. 0,
  12087. 0,
  12088. 0,
  12089. 0,
  12090. 0,
  12091. 0,
  12092. 0,
  12093. 0,
  12094. 0,
  12095. 0,
  12096. 0,
  12097. 0,
  12098. 0,
  12099. 0,
  12100. 0,
  12101. 0,
  12102. 0,
  12103. 0,
  12104. 0,
  12105. 0,
  12106. 0,
  12107. 0,
  12108. 0,
  12109. 0,
  12110. 0,
  12111. 0,
  12112. 0,
  12113. 0,
  12114. 0,
  12115. 0,
  12116. 0,
  12117. 0,
  12118. 0,
  12119. 0,
  12120. 0,
  12121. 0,
  12122. 0,
  12123. 0,
  12124. 0,
  12125. 0,
  12126. 0,
  12127. 0,
  12128. 0,
  12129. 0,
  12130. 0,
  12131. 0,
  12132. 0,
  12133. 0,
  12134. 0,
  12135. 0,
  12136. 0,
  12137. 0,
  12138. 0,
  12139. 0,
  12140. 0,
  12141. 0,
  12142. 0,
  12143. 0,
  12144. 0,
  12145. 0,
  12146. 0,
  12147. 0,
  12148. 0,
  12149. 0
  12150. ];
  12151. function toHexDigit(ch) {
  12152. if (ch >= 0x30 && ch <= 0x39) {
  12153. return ch & 0x0F;
  12154. }
  12155. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12156. return (ch & 0x0F) + 9;
  12157. }
  12158. return -1;
  12159. }
  12160. Lexer.prototype = {
  12161. nextChar: function Lexer_nextChar() {
  12162. return this.currentChar = this.stream.getByte();
  12163. },
  12164. peekChar: function Lexer_peekChar() {
  12165. return this.stream.peekByte();
  12166. },
  12167. getNumber: function Lexer_getNumber() {
  12168. var ch = this.currentChar;
  12169. var eNotation = false;
  12170. var divideBy = 0;
  12171. var sign = 1;
  12172. if (ch === 0x2D) {
  12173. sign = -1;
  12174. ch = this.nextChar();
  12175. if (ch === 0x2D) {
  12176. ch = this.nextChar();
  12177. }
  12178. } else if (ch === 0x2B) {
  12179. ch = this.nextChar();
  12180. }
  12181. if (ch === 0x2E) {
  12182. divideBy = 10;
  12183. ch = this.nextChar();
  12184. }
  12185. if (ch < 0x30 || ch > 0x39) {
  12186. error('Invalid number: ' + String.fromCharCode(ch));
  12187. return 0;
  12188. }
  12189. var baseValue = ch - 0x30;
  12190. var powerValue = 0;
  12191. var powerValueSign = 1;
  12192. while ((ch = this.nextChar()) >= 0) {
  12193. if (0x30 <= ch && ch <= 0x39) {
  12194. var currentDigit = ch - 0x30;
  12195. if (eNotation) {
  12196. powerValue = powerValue * 10 + currentDigit;
  12197. } else {
  12198. if (divideBy !== 0) {
  12199. divideBy *= 10;
  12200. }
  12201. baseValue = baseValue * 10 + currentDigit;
  12202. }
  12203. } else if (ch === 0x2E) {
  12204. if (divideBy === 0) {
  12205. divideBy = 1;
  12206. } else {
  12207. break;
  12208. }
  12209. } else if (ch === 0x2D) {
  12210. warn('Badly formatted number');
  12211. } else if (ch === 0x45 || ch === 0x65) {
  12212. ch = this.peekChar();
  12213. if (ch === 0x2B || ch === 0x2D) {
  12214. powerValueSign = ch === 0x2D ? -1 : 1;
  12215. this.nextChar();
  12216. } else if (ch < 0x30 || ch > 0x39) {
  12217. break;
  12218. }
  12219. eNotation = true;
  12220. } else {
  12221. break;
  12222. }
  12223. }
  12224. if (divideBy !== 0) {
  12225. baseValue /= divideBy;
  12226. }
  12227. if (eNotation) {
  12228. baseValue *= Math.pow(10, powerValueSign * powerValue);
  12229. }
  12230. return sign * baseValue;
  12231. },
  12232. getString: function Lexer_getString() {
  12233. var numParen = 1;
  12234. var done = false;
  12235. var strBuf = this.strBuf;
  12236. strBuf.length = 0;
  12237. var ch = this.nextChar();
  12238. while (true) {
  12239. var charBuffered = false;
  12240. switch (ch | 0) {
  12241. case -1:
  12242. warn('Unterminated string');
  12243. done = true;
  12244. break;
  12245. case 0x28:
  12246. ++numParen;
  12247. strBuf.push('(');
  12248. break;
  12249. case 0x29:
  12250. if (--numParen === 0) {
  12251. this.nextChar();
  12252. done = true;
  12253. } else {
  12254. strBuf.push(')');
  12255. }
  12256. break;
  12257. case 0x5C:
  12258. ch = this.nextChar();
  12259. switch (ch) {
  12260. case -1:
  12261. warn('Unterminated string');
  12262. done = true;
  12263. break;
  12264. case 0x6E:
  12265. strBuf.push('\n');
  12266. break;
  12267. case 0x72:
  12268. strBuf.push('\r');
  12269. break;
  12270. case 0x74:
  12271. strBuf.push('\t');
  12272. break;
  12273. case 0x62:
  12274. strBuf.push('\b');
  12275. break;
  12276. case 0x66:
  12277. strBuf.push('\f');
  12278. break;
  12279. case 0x5C:
  12280. case 0x28:
  12281. case 0x29:
  12282. strBuf.push(String.fromCharCode(ch));
  12283. break;
  12284. case 0x30:
  12285. case 0x31:
  12286. case 0x32:
  12287. case 0x33:
  12288. case 0x34:
  12289. case 0x35:
  12290. case 0x36:
  12291. case 0x37:
  12292. var x = ch & 0x0F;
  12293. ch = this.nextChar();
  12294. charBuffered = true;
  12295. if (ch >= 0x30 && ch <= 0x37) {
  12296. x = (x << 3) + (ch & 0x0F);
  12297. ch = this.nextChar();
  12298. if (ch >= 0x30 && ch <= 0x37) {
  12299. charBuffered = false;
  12300. x = (x << 3) + (ch & 0x0F);
  12301. }
  12302. }
  12303. strBuf.push(String.fromCharCode(x));
  12304. break;
  12305. case 0x0D:
  12306. if (this.peekChar() === 0x0A) {
  12307. this.nextChar();
  12308. }
  12309. break;
  12310. case 0x0A:
  12311. break;
  12312. default:
  12313. strBuf.push(String.fromCharCode(ch));
  12314. break;
  12315. }
  12316. break;
  12317. default:
  12318. strBuf.push(String.fromCharCode(ch));
  12319. break;
  12320. }
  12321. if (done) {
  12322. break;
  12323. }
  12324. if (!charBuffered) {
  12325. ch = this.nextChar();
  12326. }
  12327. }
  12328. return strBuf.join('');
  12329. },
  12330. getName: function Lexer_getName() {
  12331. var ch, previousCh;
  12332. var strBuf = this.strBuf;
  12333. strBuf.length = 0;
  12334. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12335. if (ch === 0x23) {
  12336. ch = this.nextChar();
  12337. if (specialChars[ch]) {
  12338. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12339. strBuf.push('#');
  12340. break;
  12341. }
  12342. var x = toHexDigit(ch);
  12343. if (x !== -1) {
  12344. previousCh = ch;
  12345. ch = this.nextChar();
  12346. var x2 = toHexDigit(ch);
  12347. if (x2 === -1) {
  12348. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12349. strBuf.push('#', String.fromCharCode(previousCh));
  12350. if (specialChars[ch]) {
  12351. break;
  12352. }
  12353. strBuf.push(String.fromCharCode(ch));
  12354. continue;
  12355. }
  12356. strBuf.push(String.fromCharCode(x << 4 | x2));
  12357. } else {
  12358. strBuf.push('#', String.fromCharCode(ch));
  12359. }
  12360. } else {
  12361. strBuf.push(String.fromCharCode(ch));
  12362. }
  12363. }
  12364. if (strBuf.length > 127) {
  12365. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12366. }
  12367. return Name.get(strBuf.join(''));
  12368. },
  12369. getHexString: function Lexer_getHexString() {
  12370. var strBuf = this.strBuf;
  12371. strBuf.length = 0;
  12372. var ch = this.currentChar;
  12373. var isFirstHex = true;
  12374. var firstDigit;
  12375. var secondDigit;
  12376. while (true) {
  12377. if (ch < 0) {
  12378. warn('Unterminated hex string');
  12379. break;
  12380. } else if (ch === 0x3E) {
  12381. this.nextChar();
  12382. break;
  12383. } else if (specialChars[ch] === 1) {
  12384. ch = this.nextChar();
  12385. continue;
  12386. } else {
  12387. if (isFirstHex) {
  12388. firstDigit = toHexDigit(ch);
  12389. if (firstDigit === -1) {
  12390. warn('Ignoring invalid character "' + ch + '" in hex string');
  12391. ch = this.nextChar();
  12392. continue;
  12393. }
  12394. } else {
  12395. secondDigit = toHexDigit(ch);
  12396. if (secondDigit === -1) {
  12397. warn('Ignoring invalid character "' + ch + '" in hex string');
  12398. ch = this.nextChar();
  12399. continue;
  12400. }
  12401. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12402. }
  12403. isFirstHex = !isFirstHex;
  12404. ch = this.nextChar();
  12405. }
  12406. }
  12407. return strBuf.join('');
  12408. },
  12409. getObj: function Lexer_getObj() {
  12410. var comment = false;
  12411. var ch = this.currentChar;
  12412. while (true) {
  12413. if (ch < 0) {
  12414. return EOF;
  12415. }
  12416. if (comment) {
  12417. if (ch === 0x0A || ch === 0x0D) {
  12418. comment = false;
  12419. }
  12420. } else if (ch === 0x25) {
  12421. comment = true;
  12422. } else if (specialChars[ch] !== 1) {
  12423. break;
  12424. }
  12425. ch = this.nextChar();
  12426. }
  12427. switch (ch | 0) {
  12428. case 0x30:
  12429. case 0x31:
  12430. case 0x32:
  12431. case 0x33:
  12432. case 0x34:
  12433. case 0x35:
  12434. case 0x36:
  12435. case 0x37:
  12436. case 0x38:
  12437. case 0x39:
  12438. case 0x2B:
  12439. case 0x2D:
  12440. case 0x2E:
  12441. return this.getNumber();
  12442. case 0x28:
  12443. return this.getString();
  12444. case 0x2F:
  12445. return this.getName();
  12446. case 0x5B:
  12447. this.nextChar();
  12448. return Cmd.get('[');
  12449. case 0x5D:
  12450. this.nextChar();
  12451. return Cmd.get(']');
  12452. case 0x3C:
  12453. ch = this.nextChar();
  12454. if (ch === 0x3C) {
  12455. this.nextChar();
  12456. return Cmd.get('<<');
  12457. }
  12458. return this.getHexString();
  12459. case 0x3E:
  12460. ch = this.nextChar();
  12461. if (ch === 0x3E) {
  12462. this.nextChar();
  12463. return Cmd.get('>>');
  12464. }
  12465. return Cmd.get('>');
  12466. case 0x7B:
  12467. this.nextChar();
  12468. return Cmd.get('{');
  12469. case 0x7D:
  12470. this.nextChar();
  12471. return Cmd.get('}');
  12472. case 0x29:
  12473. this.nextChar();
  12474. error('Illegal character: ' + ch);
  12475. break;
  12476. }
  12477. var str = String.fromCharCode(ch);
  12478. var knownCommands = this.knownCommands;
  12479. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12480. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12481. var possibleCommand = str + String.fromCharCode(ch);
  12482. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12483. break;
  12484. }
  12485. if (str.length === 128) {
  12486. error('Command token too long: ' + str.length);
  12487. }
  12488. str = possibleCommand;
  12489. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12490. }
  12491. if (str === 'true') {
  12492. return true;
  12493. }
  12494. if (str === 'false') {
  12495. return false;
  12496. }
  12497. if (str === 'null') {
  12498. return null;
  12499. }
  12500. return Cmd.get(str);
  12501. },
  12502. skipToNextLine: function Lexer_skipToNextLine() {
  12503. var ch = this.currentChar;
  12504. while (ch >= 0) {
  12505. if (ch === 0x0D) {
  12506. ch = this.nextChar();
  12507. if (ch === 0x0A) {
  12508. this.nextChar();
  12509. }
  12510. break;
  12511. } else if (ch === 0x0A) {
  12512. this.nextChar();
  12513. break;
  12514. }
  12515. ch = this.nextChar();
  12516. }
  12517. }
  12518. };
  12519. return Lexer;
  12520. }();
  12521. var Linearization = {
  12522. create: function LinearizationCreate(stream) {
  12523. function getInt(name, allowZeroValue) {
  12524. var obj = linDict.get(name);
  12525. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12526. return obj;
  12527. }
  12528. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12529. }
  12530. function getHints() {
  12531. var hints = linDict.get('H'), hintsLength, item;
  12532. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12533. for (var index = 0; index < hintsLength; index++) {
  12534. if (!(isInt(item = hints[index]) && item > 0)) {
  12535. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12536. }
  12537. }
  12538. return hints;
  12539. }
  12540. throw new Error('Hint array in the linearization dictionary is invalid.');
  12541. }
  12542. var parser = new Parser(new Lexer(stream), false, null);
  12543. var obj1 = parser.getObj();
  12544. var obj2 = parser.getObj();
  12545. var obj3 = parser.getObj();
  12546. var linDict = parser.getObj();
  12547. var obj, length;
  12548. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12549. return null;
  12550. } else if ((length = getInt('L')) !== stream.length) {
  12551. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12552. }
  12553. return {
  12554. length: length,
  12555. hints: getHints(),
  12556. objectNumberFirst: getInt('O'),
  12557. endFirst: getInt('E'),
  12558. numPages: getInt('N'),
  12559. mainXRefEntriesOffset: getInt('T'),
  12560. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12561. };
  12562. }
  12563. };
  12564. exports.Lexer = Lexer;
  12565. exports.Linearization = Linearization;
  12566. exports.Parser = Parser;
  12567. /***/ }),
  12568. /* 7 */
  12569. /***/ (function(module, exports, __w_pdfjs_require__) {
  12570. "use strict";
  12571. var sharedUtil = __w_pdfjs_require__(0);
  12572. var corePrimitives = __w_pdfjs_require__(1);
  12573. var corePsParser = __w_pdfjs_require__(42);
  12574. var error = sharedUtil.error;
  12575. var info = sharedUtil.info;
  12576. var isArray = sharedUtil.isArray;
  12577. var isBool = sharedUtil.isBool;
  12578. var isDict = corePrimitives.isDict;
  12579. var isStream = corePrimitives.isStream;
  12580. var PostScriptLexer = corePsParser.PostScriptLexer;
  12581. var PostScriptParser = corePsParser.PostScriptParser;
  12582. var PDFFunction = function PDFFunctionClosure() {
  12583. var CONSTRUCT_SAMPLED = 0;
  12584. var CONSTRUCT_INTERPOLATED = 2;
  12585. var CONSTRUCT_STICHED = 3;
  12586. var CONSTRUCT_POSTSCRIPT = 4;
  12587. return {
  12588. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12589. var i, ii;
  12590. var length = 1;
  12591. for (i = 0, ii = size.length; i < ii; i++) {
  12592. length *= size[i];
  12593. }
  12594. length *= outputSize;
  12595. var array = new Array(length);
  12596. var codeSize = 0;
  12597. var codeBuf = 0;
  12598. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12599. var strBytes = str.getBytes((length * bps + 7) / 8);
  12600. var strIdx = 0;
  12601. for (i = 0; i < length; i++) {
  12602. while (codeSize < bps) {
  12603. codeBuf <<= 8;
  12604. codeBuf |= strBytes[strIdx++];
  12605. codeSize += 8;
  12606. }
  12607. codeSize -= bps;
  12608. array[i] = (codeBuf >> codeSize) * sampleMul;
  12609. codeBuf &= (1 << codeSize) - 1;
  12610. }
  12611. return array;
  12612. },
  12613. getIR: function PDFFunction_getIR(xref, fn) {
  12614. var dict = fn.dict;
  12615. if (!dict) {
  12616. dict = fn;
  12617. }
  12618. var types = [
  12619. this.constructSampled,
  12620. null,
  12621. this.constructInterpolated,
  12622. this.constructStiched,
  12623. this.constructPostScript
  12624. ];
  12625. var typeNum = dict.get('FunctionType');
  12626. var typeFn = types[typeNum];
  12627. if (!typeFn) {
  12628. error('Unknown type of function');
  12629. }
  12630. return typeFn.call(this, fn, dict, xref);
  12631. },
  12632. fromIR: function PDFFunction_fromIR(IR) {
  12633. var type = IR[0];
  12634. switch (type) {
  12635. case CONSTRUCT_SAMPLED:
  12636. return this.constructSampledFromIR(IR);
  12637. case CONSTRUCT_INTERPOLATED:
  12638. return this.constructInterpolatedFromIR(IR);
  12639. case CONSTRUCT_STICHED:
  12640. return this.constructStichedFromIR(IR);
  12641. default:
  12642. return this.constructPostScriptFromIR(IR);
  12643. }
  12644. },
  12645. parse: function PDFFunction_parse(xref, fn) {
  12646. var IR = this.getIR(xref, fn);
  12647. return this.fromIR(IR);
  12648. },
  12649. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12650. if (!isArray(fnObj)) {
  12651. return this.parse(xref, fnObj);
  12652. }
  12653. var fnArray = [];
  12654. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12655. var obj = xref.fetchIfRef(fnObj[j]);
  12656. fnArray.push(PDFFunction.parse(xref, obj));
  12657. }
  12658. return function (src, srcOffset, dest, destOffset) {
  12659. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12660. fnArray[i](src, srcOffset, dest, destOffset + i);
  12661. }
  12662. };
  12663. },
  12664. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12665. function toMultiArray(arr) {
  12666. var inputLength = arr.length;
  12667. var out = [];
  12668. var index = 0;
  12669. for (var i = 0; i < inputLength; i += 2) {
  12670. out[index] = [
  12671. arr[i],
  12672. arr[i + 1]
  12673. ];
  12674. ++index;
  12675. }
  12676. return out;
  12677. }
  12678. var domain = dict.getArray('Domain');
  12679. var range = dict.getArray('Range');
  12680. if (!domain || !range) {
  12681. error('No domain or range');
  12682. }
  12683. var inputSize = domain.length / 2;
  12684. var outputSize = range.length / 2;
  12685. domain = toMultiArray(domain);
  12686. range = toMultiArray(range);
  12687. var size = dict.get('Size');
  12688. var bps = dict.get('BitsPerSample');
  12689. var order = dict.get('Order') || 1;
  12690. if (order !== 1) {
  12691. info('No support for cubic spline interpolation: ' + order);
  12692. }
  12693. var encode = dict.getArray('Encode');
  12694. if (!encode) {
  12695. encode = [];
  12696. for (var i = 0; i < inputSize; ++i) {
  12697. encode.push(0);
  12698. encode.push(size[i] - 1);
  12699. }
  12700. }
  12701. encode = toMultiArray(encode);
  12702. var decode = dict.getArray('Decode');
  12703. if (!decode) {
  12704. decode = range;
  12705. } else {
  12706. decode = toMultiArray(decode);
  12707. }
  12708. var samples = this.getSampleArray(size, outputSize, bps, str);
  12709. return [
  12710. CONSTRUCT_SAMPLED,
  12711. inputSize,
  12712. domain,
  12713. encode,
  12714. decode,
  12715. samples,
  12716. size,
  12717. outputSize,
  12718. Math.pow(2, bps) - 1,
  12719. range
  12720. ];
  12721. },
  12722. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12723. function interpolate(x, xmin, xmax, ymin, ymax) {
  12724. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12725. }
  12726. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12727. var m = IR[1];
  12728. var domain = IR[2];
  12729. var encode = IR[3];
  12730. var decode = IR[4];
  12731. var samples = IR[5];
  12732. var size = IR[6];
  12733. var n = IR[7];
  12734. var range = IR[9];
  12735. var cubeVertices = 1 << m;
  12736. var cubeN = new Float64Array(cubeVertices);
  12737. var cubeVertex = new Uint32Array(cubeVertices);
  12738. var i, j;
  12739. for (j = 0; j < cubeVertices; j++) {
  12740. cubeN[j] = 1;
  12741. }
  12742. var k = n, pos = 1;
  12743. for (i = 0; i < m; ++i) {
  12744. var domain_2i = domain[i][0];
  12745. var domain_2i_1 = domain[i][1];
  12746. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12747. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12748. var size_i = size[i];
  12749. e = Math.min(Math.max(e, 0), size_i - 1);
  12750. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12751. var n0 = e0 + 1 - e;
  12752. var n1 = e - e0;
  12753. var offset0 = e0 * k;
  12754. var offset1 = offset0 + k;
  12755. for (j = 0; j < cubeVertices; j++) {
  12756. if (j & pos) {
  12757. cubeN[j] *= n1;
  12758. cubeVertex[j] += offset1;
  12759. } else {
  12760. cubeN[j] *= n0;
  12761. cubeVertex[j] += offset0;
  12762. }
  12763. }
  12764. k *= size_i;
  12765. pos <<= 1;
  12766. }
  12767. for (j = 0; j < n; ++j) {
  12768. var rj = 0;
  12769. for (i = 0; i < cubeVertices; i++) {
  12770. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12771. }
  12772. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12773. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12774. }
  12775. };
  12776. },
  12777. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12778. var c0 = dict.getArray('C0') || [0];
  12779. var c1 = dict.getArray('C1') || [1];
  12780. var n = dict.get('N');
  12781. if (!isArray(c0) || !isArray(c1)) {
  12782. error('Illegal dictionary for interpolated function');
  12783. }
  12784. var length = c0.length;
  12785. var diff = [];
  12786. for (var i = 0; i < length; ++i) {
  12787. diff.push(c1[i] - c0[i]);
  12788. }
  12789. return [
  12790. CONSTRUCT_INTERPOLATED,
  12791. c0,
  12792. diff,
  12793. n
  12794. ];
  12795. },
  12796. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12797. var c0 = IR[1];
  12798. var diff = IR[2];
  12799. var n = IR[3];
  12800. var length = diff.length;
  12801. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12802. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12803. for (var j = 0; j < length; ++j) {
  12804. dest[destOffset + j] = c0[j] + x * diff[j];
  12805. }
  12806. };
  12807. },
  12808. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12809. var domain = dict.getArray('Domain');
  12810. if (!domain) {
  12811. error('No domain');
  12812. }
  12813. var inputSize = domain.length / 2;
  12814. if (inputSize !== 1) {
  12815. error('Bad domain for stiched function');
  12816. }
  12817. var fnRefs = dict.get('Functions');
  12818. var fns = [];
  12819. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12820. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12821. }
  12822. var bounds = dict.getArray('Bounds');
  12823. var encode = dict.getArray('Encode');
  12824. return [
  12825. CONSTRUCT_STICHED,
  12826. domain,
  12827. bounds,
  12828. encode,
  12829. fns
  12830. ];
  12831. },
  12832. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12833. var domain = IR[1];
  12834. var bounds = IR[2];
  12835. var encode = IR[3];
  12836. var fnsIR = IR[4];
  12837. var fns = [];
  12838. var tmpBuf = new Float32Array(1);
  12839. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12840. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12841. }
  12842. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12843. var clip = function constructStichedFromIRClip(v, min, max) {
  12844. if (v > max) {
  12845. v = max;
  12846. } else if (v < min) {
  12847. v = min;
  12848. }
  12849. return v;
  12850. };
  12851. var v = clip(src[srcOffset], domain[0], domain[1]);
  12852. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12853. if (v < bounds[i]) {
  12854. break;
  12855. }
  12856. }
  12857. var dmin = domain[0];
  12858. if (i > 0) {
  12859. dmin = bounds[i - 1];
  12860. }
  12861. var dmax = domain[1];
  12862. if (i < bounds.length) {
  12863. dmax = bounds[i];
  12864. }
  12865. var rmin = encode[2 * i];
  12866. var rmax = encode[2 * i + 1];
  12867. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12868. fns[i](tmpBuf, 0, dest, destOffset);
  12869. };
  12870. },
  12871. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12872. var domain = dict.getArray('Domain');
  12873. var range = dict.getArray('Range');
  12874. if (!domain) {
  12875. error('No domain.');
  12876. }
  12877. if (!range) {
  12878. error('No range.');
  12879. }
  12880. var lexer = new PostScriptLexer(fn);
  12881. var parser = new PostScriptParser(lexer);
  12882. var code = parser.parse();
  12883. return [
  12884. CONSTRUCT_POSTSCRIPT,
  12885. domain,
  12886. range,
  12887. code
  12888. ];
  12889. },
  12890. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12891. var domain = IR[1];
  12892. var range = IR[2];
  12893. var code = IR[3];
  12894. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12895. if (compiled) {
  12896. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12897. }
  12898. info('Unable to compile PS function');
  12899. var numOutputs = range.length >> 1;
  12900. var numInputs = domain.length >> 1;
  12901. var evaluator = new PostScriptEvaluator(code);
  12902. var cache = Object.create(null);
  12903. var MAX_CACHE_SIZE = 2048 * 4;
  12904. var cache_available = MAX_CACHE_SIZE;
  12905. var tmpBuf = new Float32Array(numInputs);
  12906. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12907. var i, value;
  12908. var key = '';
  12909. var input = tmpBuf;
  12910. for (i = 0; i < numInputs; i++) {
  12911. value = src[srcOffset + i];
  12912. input[i] = value;
  12913. key += value + '_';
  12914. }
  12915. var cachedValue = cache[key];
  12916. if (cachedValue !== undefined) {
  12917. dest.set(cachedValue, destOffset);
  12918. return;
  12919. }
  12920. var output = new Float32Array(numOutputs);
  12921. var stack = evaluator.execute(input);
  12922. var stackIndex = stack.length - numOutputs;
  12923. for (i = 0; i < numOutputs; i++) {
  12924. value = stack[stackIndex + i];
  12925. var bound = range[i * 2];
  12926. if (value < bound) {
  12927. value = bound;
  12928. } else {
  12929. bound = range[i * 2 + 1];
  12930. if (value > bound) {
  12931. value = bound;
  12932. }
  12933. }
  12934. output[i] = value;
  12935. }
  12936. if (cache_available > 0) {
  12937. cache_available--;
  12938. cache[key] = output;
  12939. }
  12940. dest.set(output, destOffset);
  12941. };
  12942. }
  12943. };
  12944. }();
  12945. function isPDFFunction(v) {
  12946. var fnDict;
  12947. if (typeof v !== 'object') {
  12948. return false;
  12949. } else if (isDict(v)) {
  12950. fnDict = v;
  12951. } else if (isStream(v)) {
  12952. fnDict = v.dict;
  12953. } else {
  12954. return false;
  12955. }
  12956. return fnDict.has('FunctionType');
  12957. }
  12958. var PostScriptStack = function PostScriptStackClosure() {
  12959. var MAX_STACK_SIZE = 100;
  12960. function PostScriptStack(initialStack) {
  12961. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12962. }
  12963. PostScriptStack.prototype = {
  12964. push: function PostScriptStack_push(value) {
  12965. if (this.stack.length >= MAX_STACK_SIZE) {
  12966. error('PostScript function stack overflow.');
  12967. }
  12968. this.stack.push(value);
  12969. },
  12970. pop: function PostScriptStack_pop() {
  12971. if (this.stack.length <= 0) {
  12972. error('PostScript function stack underflow.');
  12973. }
  12974. return this.stack.pop();
  12975. },
  12976. copy: function PostScriptStack_copy(n) {
  12977. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12978. error('PostScript function stack overflow.');
  12979. }
  12980. var stack = this.stack;
  12981. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12982. stack.push(stack[i]);
  12983. }
  12984. },
  12985. index: function PostScriptStack_index(n) {
  12986. this.push(this.stack[this.stack.length - n - 1]);
  12987. },
  12988. roll: function PostScriptStack_roll(n, p) {
  12989. var stack = this.stack;
  12990. var l = stack.length - n;
  12991. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  12992. for (i = l, j = r; i < j; i++, j--) {
  12993. t = stack[i];
  12994. stack[i] = stack[j];
  12995. stack[j] = t;
  12996. }
  12997. for (i = l, j = c - 1; i < j; i++, j--) {
  12998. t = stack[i];
  12999. stack[i] = stack[j];
  13000. stack[j] = t;
  13001. }
  13002. for (i = c, j = r; i < j; i++, j--) {
  13003. t = stack[i];
  13004. stack[i] = stack[j];
  13005. stack[j] = t;
  13006. }
  13007. }
  13008. };
  13009. return PostScriptStack;
  13010. }();
  13011. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13012. function PostScriptEvaluator(operators) {
  13013. this.operators = operators;
  13014. }
  13015. PostScriptEvaluator.prototype = {
  13016. execute: function PostScriptEvaluator_execute(initialStack) {
  13017. var stack = new PostScriptStack(initialStack);
  13018. var counter = 0;
  13019. var operators = this.operators;
  13020. var length = operators.length;
  13021. var operator, a, b;
  13022. while (counter < length) {
  13023. operator = operators[counter++];
  13024. if (typeof operator === 'number') {
  13025. stack.push(operator);
  13026. continue;
  13027. }
  13028. switch (operator) {
  13029. case 'jz':
  13030. b = stack.pop();
  13031. a = stack.pop();
  13032. if (!a) {
  13033. counter = b;
  13034. }
  13035. break;
  13036. case 'j':
  13037. a = stack.pop();
  13038. counter = a;
  13039. break;
  13040. case 'abs':
  13041. a = stack.pop();
  13042. stack.push(Math.abs(a));
  13043. break;
  13044. case 'add':
  13045. b = stack.pop();
  13046. a = stack.pop();
  13047. stack.push(a + b);
  13048. break;
  13049. case 'and':
  13050. b = stack.pop();
  13051. a = stack.pop();
  13052. if (isBool(a) && isBool(b)) {
  13053. stack.push(a && b);
  13054. } else {
  13055. stack.push(a & b);
  13056. }
  13057. break;
  13058. case 'atan':
  13059. a = stack.pop();
  13060. stack.push(Math.atan(a));
  13061. break;
  13062. case 'bitshift':
  13063. b = stack.pop();
  13064. a = stack.pop();
  13065. if (a > 0) {
  13066. stack.push(a << b);
  13067. } else {
  13068. stack.push(a >> b);
  13069. }
  13070. break;
  13071. case 'ceiling':
  13072. a = stack.pop();
  13073. stack.push(Math.ceil(a));
  13074. break;
  13075. case 'copy':
  13076. a = stack.pop();
  13077. stack.copy(a);
  13078. break;
  13079. case 'cos':
  13080. a = stack.pop();
  13081. stack.push(Math.cos(a));
  13082. break;
  13083. case 'cvi':
  13084. a = stack.pop() | 0;
  13085. stack.push(a);
  13086. break;
  13087. case 'cvr':
  13088. break;
  13089. case 'div':
  13090. b = stack.pop();
  13091. a = stack.pop();
  13092. stack.push(a / b);
  13093. break;
  13094. case 'dup':
  13095. stack.copy(1);
  13096. break;
  13097. case 'eq':
  13098. b = stack.pop();
  13099. a = stack.pop();
  13100. stack.push(a === b);
  13101. break;
  13102. case 'exch':
  13103. stack.roll(2, 1);
  13104. break;
  13105. case 'exp':
  13106. b = stack.pop();
  13107. a = stack.pop();
  13108. stack.push(Math.pow(a, b));
  13109. break;
  13110. case 'false':
  13111. stack.push(false);
  13112. break;
  13113. case 'floor':
  13114. a = stack.pop();
  13115. stack.push(Math.floor(a));
  13116. break;
  13117. case 'ge':
  13118. b = stack.pop();
  13119. a = stack.pop();
  13120. stack.push(a >= b);
  13121. break;
  13122. case 'gt':
  13123. b = stack.pop();
  13124. a = stack.pop();
  13125. stack.push(a > b);
  13126. break;
  13127. case 'idiv':
  13128. b = stack.pop();
  13129. a = stack.pop();
  13130. stack.push(a / b | 0);
  13131. break;
  13132. case 'index':
  13133. a = stack.pop();
  13134. stack.index(a);
  13135. break;
  13136. case 'le':
  13137. b = stack.pop();
  13138. a = stack.pop();
  13139. stack.push(a <= b);
  13140. break;
  13141. case 'ln':
  13142. a = stack.pop();
  13143. stack.push(Math.log(a));
  13144. break;
  13145. case 'log':
  13146. a = stack.pop();
  13147. stack.push(Math.log(a) / Math.LN10);
  13148. break;
  13149. case 'lt':
  13150. b = stack.pop();
  13151. a = stack.pop();
  13152. stack.push(a < b);
  13153. break;
  13154. case 'mod':
  13155. b = stack.pop();
  13156. a = stack.pop();
  13157. stack.push(a % b);
  13158. break;
  13159. case 'mul':
  13160. b = stack.pop();
  13161. a = stack.pop();
  13162. stack.push(a * b);
  13163. break;
  13164. case 'ne':
  13165. b = stack.pop();
  13166. a = stack.pop();
  13167. stack.push(a !== b);
  13168. break;
  13169. case 'neg':
  13170. a = stack.pop();
  13171. stack.push(-a);
  13172. break;
  13173. case 'not':
  13174. a = stack.pop();
  13175. if (isBool(a)) {
  13176. stack.push(!a);
  13177. } else {
  13178. stack.push(~a);
  13179. }
  13180. break;
  13181. case 'or':
  13182. b = stack.pop();
  13183. a = stack.pop();
  13184. if (isBool(a) && isBool(b)) {
  13185. stack.push(a || b);
  13186. } else {
  13187. stack.push(a | b);
  13188. }
  13189. break;
  13190. case 'pop':
  13191. stack.pop();
  13192. break;
  13193. case 'roll':
  13194. b = stack.pop();
  13195. a = stack.pop();
  13196. stack.roll(a, b);
  13197. break;
  13198. case 'round':
  13199. a = stack.pop();
  13200. stack.push(Math.round(a));
  13201. break;
  13202. case 'sin':
  13203. a = stack.pop();
  13204. stack.push(Math.sin(a));
  13205. break;
  13206. case 'sqrt':
  13207. a = stack.pop();
  13208. stack.push(Math.sqrt(a));
  13209. break;
  13210. case 'sub':
  13211. b = stack.pop();
  13212. a = stack.pop();
  13213. stack.push(a - b);
  13214. break;
  13215. case 'true':
  13216. stack.push(true);
  13217. break;
  13218. case 'truncate':
  13219. a = stack.pop();
  13220. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13221. stack.push(a);
  13222. break;
  13223. case 'xor':
  13224. b = stack.pop();
  13225. a = stack.pop();
  13226. if (isBool(a) && isBool(b)) {
  13227. stack.push(a !== b);
  13228. } else {
  13229. stack.push(a ^ b);
  13230. }
  13231. break;
  13232. default:
  13233. error('Unknown operator ' + operator);
  13234. break;
  13235. }
  13236. }
  13237. return stack.stack;
  13238. }
  13239. };
  13240. return PostScriptEvaluator;
  13241. }();
  13242. var PostScriptCompiler = function PostScriptCompilerClosure() {
  13243. function AstNode(type) {
  13244. this.type = type;
  13245. }
  13246. AstNode.prototype.visit = function (visitor) {
  13247. throw new Error('abstract method');
  13248. };
  13249. function AstArgument(index, min, max) {
  13250. AstNode.call(this, 'args');
  13251. this.index = index;
  13252. this.min = min;
  13253. this.max = max;
  13254. }
  13255. AstArgument.prototype = Object.create(AstNode.prototype);
  13256. AstArgument.prototype.visit = function (visitor) {
  13257. visitor.visitArgument(this);
  13258. };
  13259. function AstLiteral(number) {
  13260. AstNode.call(this, 'literal');
  13261. this.number = number;
  13262. this.min = number;
  13263. this.max = number;
  13264. }
  13265. AstLiteral.prototype = Object.create(AstNode.prototype);
  13266. AstLiteral.prototype.visit = function (visitor) {
  13267. visitor.visitLiteral(this);
  13268. };
  13269. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13270. AstNode.call(this, 'binary');
  13271. this.op = op;
  13272. this.arg1 = arg1;
  13273. this.arg2 = arg2;
  13274. this.min = min;
  13275. this.max = max;
  13276. }
  13277. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13278. AstBinaryOperation.prototype.visit = function (visitor) {
  13279. visitor.visitBinaryOperation(this);
  13280. };
  13281. function AstMin(arg, max) {
  13282. AstNode.call(this, 'max');
  13283. this.arg = arg;
  13284. this.min = arg.min;
  13285. this.max = max;
  13286. }
  13287. AstMin.prototype = Object.create(AstNode.prototype);
  13288. AstMin.prototype.visit = function (visitor) {
  13289. visitor.visitMin(this);
  13290. };
  13291. function AstVariable(index, min, max) {
  13292. AstNode.call(this, 'var');
  13293. this.index = index;
  13294. this.min = min;
  13295. this.max = max;
  13296. }
  13297. AstVariable.prototype = Object.create(AstNode.prototype);
  13298. AstVariable.prototype.visit = function (visitor) {
  13299. visitor.visitVariable(this);
  13300. };
  13301. function AstVariableDefinition(variable, arg) {
  13302. AstNode.call(this, 'definition');
  13303. this.variable = variable;
  13304. this.arg = arg;
  13305. }
  13306. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13307. AstVariableDefinition.prototype.visit = function (visitor) {
  13308. visitor.visitVariableDefinition(this);
  13309. };
  13310. function ExpressionBuilderVisitor() {
  13311. this.parts = [];
  13312. }
  13313. ExpressionBuilderVisitor.prototype = {
  13314. visitArgument: function (arg) {
  13315. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13316. },
  13317. visitVariable: function (variable) {
  13318. this.parts.push('v', variable.index);
  13319. },
  13320. visitLiteral: function (literal) {
  13321. this.parts.push(literal.number);
  13322. },
  13323. visitBinaryOperation: function (operation) {
  13324. this.parts.push('(');
  13325. operation.arg1.visit(this);
  13326. this.parts.push(' ', operation.op, ' ');
  13327. operation.arg2.visit(this);
  13328. this.parts.push(')');
  13329. },
  13330. visitVariableDefinition: function (definition) {
  13331. this.parts.push('var ');
  13332. definition.variable.visit(this);
  13333. this.parts.push(' = ');
  13334. definition.arg.visit(this);
  13335. this.parts.push(';');
  13336. },
  13337. visitMin: function (max) {
  13338. this.parts.push('Math.min(');
  13339. max.arg.visit(this);
  13340. this.parts.push(', ', max.max, ')');
  13341. },
  13342. toString: function () {
  13343. return this.parts.join('');
  13344. }
  13345. };
  13346. function buildAddOperation(num1, num2) {
  13347. if (num2.type === 'literal' && num2.number === 0) {
  13348. return num1;
  13349. }
  13350. if (num1.type === 'literal' && num1.number === 0) {
  13351. return num2;
  13352. }
  13353. if (num2.type === 'literal' && num1.type === 'literal') {
  13354. return new AstLiteral(num1.number + num2.number);
  13355. }
  13356. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13357. }
  13358. function buildMulOperation(num1, num2) {
  13359. if (num2.type === 'literal') {
  13360. if (num2.number === 0) {
  13361. return new AstLiteral(0);
  13362. } else if (num2.number === 1) {
  13363. return num1;
  13364. } else if (num1.type === 'literal') {
  13365. return new AstLiteral(num1.number * num2.number);
  13366. }
  13367. }
  13368. if (num1.type === 'literal') {
  13369. if (num1.number === 0) {
  13370. return new AstLiteral(0);
  13371. } else if (num1.number === 1) {
  13372. return num2;
  13373. }
  13374. }
  13375. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13376. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13377. return new AstBinaryOperation('*', num1, num2, min, max);
  13378. }
  13379. function buildSubOperation(num1, num2) {
  13380. if (num2.type === 'literal') {
  13381. if (num2.number === 0) {
  13382. return num1;
  13383. } else if (num1.type === 'literal') {
  13384. return new AstLiteral(num1.number - num2.number);
  13385. }
  13386. }
  13387. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13388. return num2.arg2;
  13389. }
  13390. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13391. }
  13392. function buildMinOperation(num1, max) {
  13393. if (num1.min >= max) {
  13394. return new AstLiteral(max);
  13395. } else if (num1.max <= max) {
  13396. return num1;
  13397. }
  13398. return new AstMin(num1, max);
  13399. }
  13400. function PostScriptCompiler() {
  13401. }
  13402. PostScriptCompiler.prototype = {
  13403. compile: function PostScriptCompiler_compile(code, domain, range) {
  13404. var stack = [];
  13405. var i, ii;
  13406. var instructions = [];
  13407. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13408. var lastRegister = 0;
  13409. var n, j;
  13410. var num1, num2, ast1, ast2, tmpVar, item;
  13411. for (i = 0; i < inputSize; i++) {
  13412. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13413. }
  13414. for (i = 0, ii = code.length; i < ii; i++) {
  13415. item = code[i];
  13416. if (typeof item === 'number') {
  13417. stack.push(new AstLiteral(item));
  13418. continue;
  13419. }
  13420. switch (item) {
  13421. case 'add':
  13422. if (stack.length < 2) {
  13423. return null;
  13424. }
  13425. num2 = stack.pop();
  13426. num1 = stack.pop();
  13427. stack.push(buildAddOperation(num1, num2));
  13428. break;
  13429. case 'cvr':
  13430. if (stack.length < 1) {
  13431. return null;
  13432. }
  13433. break;
  13434. case 'mul':
  13435. if (stack.length < 2) {
  13436. return null;
  13437. }
  13438. num2 = stack.pop();
  13439. num1 = stack.pop();
  13440. stack.push(buildMulOperation(num1, num2));
  13441. break;
  13442. case 'sub':
  13443. if (stack.length < 2) {
  13444. return null;
  13445. }
  13446. num2 = stack.pop();
  13447. num1 = stack.pop();
  13448. stack.push(buildSubOperation(num1, num2));
  13449. break;
  13450. case 'exch':
  13451. if (stack.length < 2) {
  13452. return null;
  13453. }
  13454. ast1 = stack.pop();
  13455. ast2 = stack.pop();
  13456. stack.push(ast1, ast2);
  13457. break;
  13458. case 'pop':
  13459. if (stack.length < 1) {
  13460. return null;
  13461. }
  13462. stack.pop();
  13463. break;
  13464. case 'index':
  13465. if (stack.length < 1) {
  13466. return null;
  13467. }
  13468. num1 = stack.pop();
  13469. if (num1.type !== 'literal') {
  13470. return null;
  13471. }
  13472. n = num1.number;
  13473. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13474. return null;
  13475. }
  13476. ast1 = stack[stack.length - n - 1];
  13477. if (ast1.type === 'literal' || ast1.type === 'var') {
  13478. stack.push(ast1);
  13479. break;
  13480. }
  13481. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13482. stack[stack.length - n - 1] = tmpVar;
  13483. stack.push(tmpVar);
  13484. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13485. break;
  13486. case 'dup':
  13487. if (stack.length < 1) {
  13488. return null;
  13489. }
  13490. 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]) {
  13491. num1 = stack.pop();
  13492. stack.push(buildMinOperation(num1, code[i + 1]));
  13493. i += 6;
  13494. break;
  13495. }
  13496. ast1 = stack[stack.length - 1];
  13497. if (ast1.type === 'literal' || ast1.type === 'var') {
  13498. stack.push(ast1);
  13499. break;
  13500. }
  13501. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13502. stack[stack.length - 1] = tmpVar;
  13503. stack.push(tmpVar);
  13504. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13505. break;
  13506. case 'roll':
  13507. if (stack.length < 2) {
  13508. return null;
  13509. }
  13510. num2 = stack.pop();
  13511. num1 = stack.pop();
  13512. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13513. return null;
  13514. }
  13515. j = num2.number;
  13516. n = num1.number;
  13517. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13518. return null;
  13519. }
  13520. j = (j % n + n) % n;
  13521. if (j === 0) {
  13522. break;
  13523. }
  13524. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13525. break;
  13526. default:
  13527. return null;
  13528. }
  13529. }
  13530. if (stack.length !== outputSize) {
  13531. return null;
  13532. }
  13533. var result = [];
  13534. instructions.forEach(function (instruction) {
  13535. var statementBuilder = new ExpressionBuilderVisitor();
  13536. instruction.visit(statementBuilder);
  13537. result.push(statementBuilder.toString());
  13538. });
  13539. stack.forEach(function (expr, i) {
  13540. var statementBuilder = new ExpressionBuilderVisitor();
  13541. expr.visit(statementBuilder);
  13542. var min = range[i * 2], max = range[i * 2 + 1];
  13543. var out = [statementBuilder.toString()];
  13544. if (min > expr.min) {
  13545. out.unshift('Math.max(', min, ', ');
  13546. out.push(')');
  13547. }
  13548. if (max < expr.max) {
  13549. out.unshift('Math.min(', max, ', ');
  13550. out.push(')');
  13551. }
  13552. out.unshift('dest[destOffset + ', i, '] = ');
  13553. out.push(';');
  13554. result.push(out.join(''));
  13555. });
  13556. return result.join('\n');
  13557. }
  13558. };
  13559. return PostScriptCompiler;
  13560. }();
  13561. exports.isPDFFunction = isPDFFunction;
  13562. exports.PDFFunction = PDFFunction;
  13563. exports.PostScriptEvaluator = PostScriptEvaluator;
  13564. exports.PostScriptCompiler = PostScriptCompiler;
  13565. /***/ }),
  13566. /* 8 */
  13567. /***/ (function(module, exports, __w_pdfjs_require__) {
  13568. "use strict";
  13569. var sharedUtil = __w_pdfjs_require__(0);
  13570. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13571. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13572. t['A'] = 0x0041;
  13573. t['AE'] = 0x00C6;
  13574. t['AEacute'] = 0x01FC;
  13575. t['AEmacron'] = 0x01E2;
  13576. t['AEsmall'] = 0xF7E6;
  13577. t['Aacute'] = 0x00C1;
  13578. t['Aacutesmall'] = 0xF7E1;
  13579. t['Abreve'] = 0x0102;
  13580. t['Abreveacute'] = 0x1EAE;
  13581. t['Abrevecyrillic'] = 0x04D0;
  13582. t['Abrevedotbelow'] = 0x1EB6;
  13583. t['Abrevegrave'] = 0x1EB0;
  13584. t['Abrevehookabove'] = 0x1EB2;
  13585. t['Abrevetilde'] = 0x1EB4;
  13586. t['Acaron'] = 0x01CD;
  13587. t['Acircle'] = 0x24B6;
  13588. t['Acircumflex'] = 0x00C2;
  13589. t['Acircumflexacute'] = 0x1EA4;
  13590. t['Acircumflexdotbelow'] = 0x1EAC;
  13591. t['Acircumflexgrave'] = 0x1EA6;
  13592. t['Acircumflexhookabove'] = 0x1EA8;
  13593. t['Acircumflexsmall'] = 0xF7E2;
  13594. t['Acircumflextilde'] = 0x1EAA;
  13595. t['Acute'] = 0xF6C9;
  13596. t['Acutesmall'] = 0xF7B4;
  13597. t['Acyrillic'] = 0x0410;
  13598. t['Adblgrave'] = 0x0200;
  13599. t['Adieresis'] = 0x00C4;
  13600. t['Adieresiscyrillic'] = 0x04D2;
  13601. t['Adieresismacron'] = 0x01DE;
  13602. t['Adieresissmall'] = 0xF7E4;
  13603. t['Adotbelow'] = 0x1EA0;
  13604. t['Adotmacron'] = 0x01E0;
  13605. t['Agrave'] = 0x00C0;
  13606. t['Agravesmall'] = 0xF7E0;
  13607. t['Ahookabove'] = 0x1EA2;
  13608. t['Aiecyrillic'] = 0x04D4;
  13609. t['Ainvertedbreve'] = 0x0202;
  13610. t['Alpha'] = 0x0391;
  13611. t['Alphatonos'] = 0x0386;
  13612. t['Amacron'] = 0x0100;
  13613. t['Amonospace'] = 0xFF21;
  13614. t['Aogonek'] = 0x0104;
  13615. t['Aring'] = 0x00C5;
  13616. t['Aringacute'] = 0x01FA;
  13617. t['Aringbelow'] = 0x1E00;
  13618. t['Aringsmall'] = 0xF7E5;
  13619. t['Asmall'] = 0xF761;
  13620. t['Atilde'] = 0x00C3;
  13621. t['Atildesmall'] = 0xF7E3;
  13622. t['Aybarmenian'] = 0x0531;
  13623. t['B'] = 0x0042;
  13624. t['Bcircle'] = 0x24B7;
  13625. t['Bdotaccent'] = 0x1E02;
  13626. t['Bdotbelow'] = 0x1E04;
  13627. t['Becyrillic'] = 0x0411;
  13628. t['Benarmenian'] = 0x0532;
  13629. t['Beta'] = 0x0392;
  13630. t['Bhook'] = 0x0181;
  13631. t['Blinebelow'] = 0x1E06;
  13632. t['Bmonospace'] = 0xFF22;
  13633. t['Brevesmall'] = 0xF6F4;
  13634. t['Bsmall'] = 0xF762;
  13635. t['Btopbar'] = 0x0182;
  13636. t['C'] = 0x0043;
  13637. t['Caarmenian'] = 0x053E;
  13638. t['Cacute'] = 0x0106;
  13639. t['Caron'] = 0xF6CA;
  13640. t['Caronsmall'] = 0xF6F5;
  13641. t['Ccaron'] = 0x010C;
  13642. t['Ccedilla'] = 0x00C7;
  13643. t['Ccedillaacute'] = 0x1E08;
  13644. t['Ccedillasmall'] = 0xF7E7;
  13645. t['Ccircle'] = 0x24B8;
  13646. t['Ccircumflex'] = 0x0108;
  13647. t['Cdot'] = 0x010A;
  13648. t['Cdotaccent'] = 0x010A;
  13649. t['Cedillasmall'] = 0xF7B8;
  13650. t['Chaarmenian'] = 0x0549;
  13651. t['Cheabkhasiancyrillic'] = 0x04BC;
  13652. t['Checyrillic'] = 0x0427;
  13653. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13654. t['Chedescendercyrillic'] = 0x04B6;
  13655. t['Chedieresiscyrillic'] = 0x04F4;
  13656. t['Cheharmenian'] = 0x0543;
  13657. t['Chekhakassiancyrillic'] = 0x04CB;
  13658. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13659. t['Chi'] = 0x03A7;
  13660. t['Chook'] = 0x0187;
  13661. t['Circumflexsmall'] = 0xF6F6;
  13662. t['Cmonospace'] = 0xFF23;
  13663. t['Coarmenian'] = 0x0551;
  13664. t['Csmall'] = 0xF763;
  13665. t['D'] = 0x0044;
  13666. t['DZ'] = 0x01F1;
  13667. t['DZcaron'] = 0x01C4;
  13668. t['Daarmenian'] = 0x0534;
  13669. t['Dafrican'] = 0x0189;
  13670. t['Dcaron'] = 0x010E;
  13671. t['Dcedilla'] = 0x1E10;
  13672. t['Dcircle'] = 0x24B9;
  13673. t['Dcircumflexbelow'] = 0x1E12;
  13674. t['Dcroat'] = 0x0110;
  13675. t['Ddotaccent'] = 0x1E0A;
  13676. t['Ddotbelow'] = 0x1E0C;
  13677. t['Decyrillic'] = 0x0414;
  13678. t['Deicoptic'] = 0x03EE;
  13679. t['Delta'] = 0x2206;
  13680. t['Deltagreek'] = 0x0394;
  13681. t['Dhook'] = 0x018A;
  13682. t['Dieresis'] = 0xF6CB;
  13683. t['DieresisAcute'] = 0xF6CC;
  13684. t['DieresisGrave'] = 0xF6CD;
  13685. t['Dieresissmall'] = 0xF7A8;
  13686. t['Digammagreek'] = 0x03DC;
  13687. t['Djecyrillic'] = 0x0402;
  13688. t['Dlinebelow'] = 0x1E0E;
  13689. t['Dmonospace'] = 0xFF24;
  13690. t['Dotaccentsmall'] = 0xF6F7;
  13691. t['Dslash'] = 0x0110;
  13692. t['Dsmall'] = 0xF764;
  13693. t['Dtopbar'] = 0x018B;
  13694. t['Dz'] = 0x01F2;
  13695. t['Dzcaron'] = 0x01C5;
  13696. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13697. t['Dzecyrillic'] = 0x0405;
  13698. t['Dzhecyrillic'] = 0x040F;
  13699. t['E'] = 0x0045;
  13700. t['Eacute'] = 0x00C9;
  13701. t['Eacutesmall'] = 0xF7E9;
  13702. t['Ebreve'] = 0x0114;
  13703. t['Ecaron'] = 0x011A;
  13704. t['Ecedillabreve'] = 0x1E1C;
  13705. t['Echarmenian'] = 0x0535;
  13706. t['Ecircle'] = 0x24BA;
  13707. t['Ecircumflex'] = 0x00CA;
  13708. t['Ecircumflexacute'] = 0x1EBE;
  13709. t['Ecircumflexbelow'] = 0x1E18;
  13710. t['Ecircumflexdotbelow'] = 0x1EC6;
  13711. t['Ecircumflexgrave'] = 0x1EC0;
  13712. t['Ecircumflexhookabove'] = 0x1EC2;
  13713. t['Ecircumflexsmall'] = 0xF7EA;
  13714. t['Ecircumflextilde'] = 0x1EC4;
  13715. t['Ecyrillic'] = 0x0404;
  13716. t['Edblgrave'] = 0x0204;
  13717. t['Edieresis'] = 0x00CB;
  13718. t['Edieresissmall'] = 0xF7EB;
  13719. t['Edot'] = 0x0116;
  13720. t['Edotaccent'] = 0x0116;
  13721. t['Edotbelow'] = 0x1EB8;
  13722. t['Efcyrillic'] = 0x0424;
  13723. t['Egrave'] = 0x00C8;
  13724. t['Egravesmall'] = 0xF7E8;
  13725. t['Eharmenian'] = 0x0537;
  13726. t['Ehookabove'] = 0x1EBA;
  13727. t['Eightroman'] = 0x2167;
  13728. t['Einvertedbreve'] = 0x0206;
  13729. t['Eiotifiedcyrillic'] = 0x0464;
  13730. t['Elcyrillic'] = 0x041B;
  13731. t['Elevenroman'] = 0x216A;
  13732. t['Emacron'] = 0x0112;
  13733. t['Emacronacute'] = 0x1E16;
  13734. t['Emacrongrave'] = 0x1E14;
  13735. t['Emcyrillic'] = 0x041C;
  13736. t['Emonospace'] = 0xFF25;
  13737. t['Encyrillic'] = 0x041D;
  13738. t['Endescendercyrillic'] = 0x04A2;
  13739. t['Eng'] = 0x014A;
  13740. t['Enghecyrillic'] = 0x04A4;
  13741. t['Enhookcyrillic'] = 0x04C7;
  13742. t['Eogonek'] = 0x0118;
  13743. t['Eopen'] = 0x0190;
  13744. t['Epsilon'] = 0x0395;
  13745. t['Epsilontonos'] = 0x0388;
  13746. t['Ercyrillic'] = 0x0420;
  13747. t['Ereversed'] = 0x018E;
  13748. t['Ereversedcyrillic'] = 0x042D;
  13749. t['Escyrillic'] = 0x0421;
  13750. t['Esdescendercyrillic'] = 0x04AA;
  13751. t['Esh'] = 0x01A9;
  13752. t['Esmall'] = 0xF765;
  13753. t['Eta'] = 0x0397;
  13754. t['Etarmenian'] = 0x0538;
  13755. t['Etatonos'] = 0x0389;
  13756. t['Eth'] = 0x00D0;
  13757. t['Ethsmall'] = 0xF7F0;
  13758. t['Etilde'] = 0x1EBC;
  13759. t['Etildebelow'] = 0x1E1A;
  13760. t['Euro'] = 0x20AC;
  13761. t['Ezh'] = 0x01B7;
  13762. t['Ezhcaron'] = 0x01EE;
  13763. t['Ezhreversed'] = 0x01B8;
  13764. t['F'] = 0x0046;
  13765. t['Fcircle'] = 0x24BB;
  13766. t['Fdotaccent'] = 0x1E1E;
  13767. t['Feharmenian'] = 0x0556;
  13768. t['Feicoptic'] = 0x03E4;
  13769. t['Fhook'] = 0x0191;
  13770. t['Fitacyrillic'] = 0x0472;
  13771. t['Fiveroman'] = 0x2164;
  13772. t['Fmonospace'] = 0xFF26;
  13773. t['Fourroman'] = 0x2163;
  13774. t['Fsmall'] = 0xF766;
  13775. t['G'] = 0x0047;
  13776. t['GBsquare'] = 0x3387;
  13777. t['Gacute'] = 0x01F4;
  13778. t['Gamma'] = 0x0393;
  13779. t['Gammaafrican'] = 0x0194;
  13780. t['Gangiacoptic'] = 0x03EA;
  13781. t['Gbreve'] = 0x011E;
  13782. t['Gcaron'] = 0x01E6;
  13783. t['Gcedilla'] = 0x0122;
  13784. t['Gcircle'] = 0x24BC;
  13785. t['Gcircumflex'] = 0x011C;
  13786. t['Gcommaaccent'] = 0x0122;
  13787. t['Gdot'] = 0x0120;
  13788. t['Gdotaccent'] = 0x0120;
  13789. t['Gecyrillic'] = 0x0413;
  13790. t['Ghadarmenian'] = 0x0542;
  13791. t['Ghemiddlehookcyrillic'] = 0x0494;
  13792. t['Ghestrokecyrillic'] = 0x0492;
  13793. t['Gheupturncyrillic'] = 0x0490;
  13794. t['Ghook'] = 0x0193;
  13795. t['Gimarmenian'] = 0x0533;
  13796. t['Gjecyrillic'] = 0x0403;
  13797. t['Gmacron'] = 0x1E20;
  13798. t['Gmonospace'] = 0xFF27;
  13799. t['Grave'] = 0xF6CE;
  13800. t['Gravesmall'] = 0xF760;
  13801. t['Gsmall'] = 0xF767;
  13802. t['Gsmallhook'] = 0x029B;
  13803. t['Gstroke'] = 0x01E4;
  13804. t['H'] = 0x0048;
  13805. t['H18533'] = 0x25CF;
  13806. t['H18543'] = 0x25AA;
  13807. t['H18551'] = 0x25AB;
  13808. t['H22073'] = 0x25A1;
  13809. t['HPsquare'] = 0x33CB;
  13810. t['Haabkhasiancyrillic'] = 0x04A8;
  13811. t['Hadescendercyrillic'] = 0x04B2;
  13812. t['Hardsigncyrillic'] = 0x042A;
  13813. t['Hbar'] = 0x0126;
  13814. t['Hbrevebelow'] = 0x1E2A;
  13815. t['Hcedilla'] = 0x1E28;
  13816. t['Hcircle'] = 0x24BD;
  13817. t['Hcircumflex'] = 0x0124;
  13818. t['Hdieresis'] = 0x1E26;
  13819. t['Hdotaccent'] = 0x1E22;
  13820. t['Hdotbelow'] = 0x1E24;
  13821. t['Hmonospace'] = 0xFF28;
  13822. t['Hoarmenian'] = 0x0540;
  13823. t['Horicoptic'] = 0x03E8;
  13824. t['Hsmall'] = 0xF768;
  13825. t['Hungarumlaut'] = 0xF6CF;
  13826. t['Hungarumlautsmall'] = 0xF6F8;
  13827. t['Hzsquare'] = 0x3390;
  13828. t['I'] = 0x0049;
  13829. t['IAcyrillic'] = 0x042F;
  13830. t['IJ'] = 0x0132;
  13831. t['IUcyrillic'] = 0x042E;
  13832. t['Iacute'] = 0x00CD;
  13833. t['Iacutesmall'] = 0xF7ED;
  13834. t['Ibreve'] = 0x012C;
  13835. t['Icaron'] = 0x01CF;
  13836. t['Icircle'] = 0x24BE;
  13837. t['Icircumflex'] = 0x00CE;
  13838. t['Icircumflexsmall'] = 0xF7EE;
  13839. t['Icyrillic'] = 0x0406;
  13840. t['Idblgrave'] = 0x0208;
  13841. t['Idieresis'] = 0x00CF;
  13842. t['Idieresisacute'] = 0x1E2E;
  13843. t['Idieresiscyrillic'] = 0x04E4;
  13844. t['Idieresissmall'] = 0xF7EF;
  13845. t['Idot'] = 0x0130;
  13846. t['Idotaccent'] = 0x0130;
  13847. t['Idotbelow'] = 0x1ECA;
  13848. t['Iebrevecyrillic'] = 0x04D6;
  13849. t['Iecyrillic'] = 0x0415;
  13850. t['Ifraktur'] = 0x2111;
  13851. t['Igrave'] = 0x00CC;
  13852. t['Igravesmall'] = 0xF7EC;
  13853. t['Ihookabove'] = 0x1EC8;
  13854. t['Iicyrillic'] = 0x0418;
  13855. t['Iinvertedbreve'] = 0x020A;
  13856. t['Iishortcyrillic'] = 0x0419;
  13857. t['Imacron'] = 0x012A;
  13858. t['Imacroncyrillic'] = 0x04E2;
  13859. t['Imonospace'] = 0xFF29;
  13860. t['Iniarmenian'] = 0x053B;
  13861. t['Iocyrillic'] = 0x0401;
  13862. t['Iogonek'] = 0x012E;
  13863. t['Iota'] = 0x0399;
  13864. t['Iotaafrican'] = 0x0196;
  13865. t['Iotadieresis'] = 0x03AA;
  13866. t['Iotatonos'] = 0x038A;
  13867. t['Ismall'] = 0xF769;
  13868. t['Istroke'] = 0x0197;
  13869. t['Itilde'] = 0x0128;
  13870. t['Itildebelow'] = 0x1E2C;
  13871. t['Izhitsacyrillic'] = 0x0474;
  13872. t['Izhitsadblgravecyrillic'] = 0x0476;
  13873. t['J'] = 0x004A;
  13874. t['Jaarmenian'] = 0x0541;
  13875. t['Jcircle'] = 0x24BF;
  13876. t['Jcircumflex'] = 0x0134;
  13877. t['Jecyrillic'] = 0x0408;
  13878. t['Jheharmenian'] = 0x054B;
  13879. t['Jmonospace'] = 0xFF2A;
  13880. t['Jsmall'] = 0xF76A;
  13881. t['K'] = 0x004B;
  13882. t['KBsquare'] = 0x3385;
  13883. t['KKsquare'] = 0x33CD;
  13884. t['Kabashkircyrillic'] = 0x04A0;
  13885. t['Kacute'] = 0x1E30;
  13886. t['Kacyrillic'] = 0x041A;
  13887. t['Kadescendercyrillic'] = 0x049A;
  13888. t['Kahookcyrillic'] = 0x04C3;
  13889. t['Kappa'] = 0x039A;
  13890. t['Kastrokecyrillic'] = 0x049E;
  13891. t['Kaverticalstrokecyrillic'] = 0x049C;
  13892. t['Kcaron'] = 0x01E8;
  13893. t['Kcedilla'] = 0x0136;
  13894. t['Kcircle'] = 0x24C0;
  13895. t['Kcommaaccent'] = 0x0136;
  13896. t['Kdotbelow'] = 0x1E32;
  13897. t['Keharmenian'] = 0x0554;
  13898. t['Kenarmenian'] = 0x053F;
  13899. t['Khacyrillic'] = 0x0425;
  13900. t['Kheicoptic'] = 0x03E6;
  13901. t['Khook'] = 0x0198;
  13902. t['Kjecyrillic'] = 0x040C;
  13903. t['Klinebelow'] = 0x1E34;
  13904. t['Kmonospace'] = 0xFF2B;
  13905. t['Koppacyrillic'] = 0x0480;
  13906. t['Koppagreek'] = 0x03DE;
  13907. t['Ksicyrillic'] = 0x046E;
  13908. t['Ksmall'] = 0xF76B;
  13909. t['L'] = 0x004C;
  13910. t['LJ'] = 0x01C7;
  13911. t['LL'] = 0xF6BF;
  13912. t['Lacute'] = 0x0139;
  13913. t['Lambda'] = 0x039B;
  13914. t['Lcaron'] = 0x013D;
  13915. t['Lcedilla'] = 0x013B;
  13916. t['Lcircle'] = 0x24C1;
  13917. t['Lcircumflexbelow'] = 0x1E3C;
  13918. t['Lcommaaccent'] = 0x013B;
  13919. t['Ldot'] = 0x013F;
  13920. t['Ldotaccent'] = 0x013F;
  13921. t['Ldotbelow'] = 0x1E36;
  13922. t['Ldotbelowmacron'] = 0x1E38;
  13923. t['Liwnarmenian'] = 0x053C;
  13924. t['Lj'] = 0x01C8;
  13925. t['Ljecyrillic'] = 0x0409;
  13926. t['Llinebelow'] = 0x1E3A;
  13927. t['Lmonospace'] = 0xFF2C;
  13928. t['Lslash'] = 0x0141;
  13929. t['Lslashsmall'] = 0xF6F9;
  13930. t['Lsmall'] = 0xF76C;
  13931. t['M'] = 0x004D;
  13932. t['MBsquare'] = 0x3386;
  13933. t['Macron'] = 0xF6D0;
  13934. t['Macronsmall'] = 0xF7AF;
  13935. t['Macute'] = 0x1E3E;
  13936. t['Mcircle'] = 0x24C2;
  13937. t['Mdotaccent'] = 0x1E40;
  13938. t['Mdotbelow'] = 0x1E42;
  13939. t['Menarmenian'] = 0x0544;
  13940. t['Mmonospace'] = 0xFF2D;
  13941. t['Msmall'] = 0xF76D;
  13942. t['Mturned'] = 0x019C;
  13943. t['Mu'] = 0x039C;
  13944. t['N'] = 0x004E;
  13945. t['NJ'] = 0x01CA;
  13946. t['Nacute'] = 0x0143;
  13947. t['Ncaron'] = 0x0147;
  13948. t['Ncedilla'] = 0x0145;
  13949. t['Ncircle'] = 0x24C3;
  13950. t['Ncircumflexbelow'] = 0x1E4A;
  13951. t['Ncommaaccent'] = 0x0145;
  13952. t['Ndotaccent'] = 0x1E44;
  13953. t['Ndotbelow'] = 0x1E46;
  13954. t['Nhookleft'] = 0x019D;
  13955. t['Nineroman'] = 0x2168;
  13956. t['Nj'] = 0x01CB;
  13957. t['Njecyrillic'] = 0x040A;
  13958. t['Nlinebelow'] = 0x1E48;
  13959. t['Nmonospace'] = 0xFF2E;
  13960. t['Nowarmenian'] = 0x0546;
  13961. t['Nsmall'] = 0xF76E;
  13962. t['Ntilde'] = 0x00D1;
  13963. t['Ntildesmall'] = 0xF7F1;
  13964. t['Nu'] = 0x039D;
  13965. t['O'] = 0x004F;
  13966. t['OE'] = 0x0152;
  13967. t['OEsmall'] = 0xF6FA;
  13968. t['Oacute'] = 0x00D3;
  13969. t['Oacutesmall'] = 0xF7F3;
  13970. t['Obarredcyrillic'] = 0x04E8;
  13971. t['Obarreddieresiscyrillic'] = 0x04EA;
  13972. t['Obreve'] = 0x014E;
  13973. t['Ocaron'] = 0x01D1;
  13974. t['Ocenteredtilde'] = 0x019F;
  13975. t['Ocircle'] = 0x24C4;
  13976. t['Ocircumflex'] = 0x00D4;
  13977. t['Ocircumflexacute'] = 0x1ED0;
  13978. t['Ocircumflexdotbelow'] = 0x1ED8;
  13979. t['Ocircumflexgrave'] = 0x1ED2;
  13980. t['Ocircumflexhookabove'] = 0x1ED4;
  13981. t['Ocircumflexsmall'] = 0xF7F4;
  13982. t['Ocircumflextilde'] = 0x1ED6;
  13983. t['Ocyrillic'] = 0x041E;
  13984. t['Odblacute'] = 0x0150;
  13985. t['Odblgrave'] = 0x020C;
  13986. t['Odieresis'] = 0x00D6;
  13987. t['Odieresiscyrillic'] = 0x04E6;
  13988. t['Odieresissmall'] = 0xF7F6;
  13989. t['Odotbelow'] = 0x1ECC;
  13990. t['Ogoneksmall'] = 0xF6FB;
  13991. t['Ograve'] = 0x00D2;
  13992. t['Ogravesmall'] = 0xF7F2;
  13993. t['Oharmenian'] = 0x0555;
  13994. t['Ohm'] = 0x2126;
  13995. t['Ohookabove'] = 0x1ECE;
  13996. t['Ohorn'] = 0x01A0;
  13997. t['Ohornacute'] = 0x1EDA;
  13998. t['Ohorndotbelow'] = 0x1EE2;
  13999. t['Ohorngrave'] = 0x1EDC;
  14000. t['Ohornhookabove'] = 0x1EDE;
  14001. t['Ohorntilde'] = 0x1EE0;
  14002. t['Ohungarumlaut'] = 0x0150;
  14003. t['Oi'] = 0x01A2;
  14004. t['Oinvertedbreve'] = 0x020E;
  14005. t['Omacron'] = 0x014C;
  14006. t['Omacronacute'] = 0x1E52;
  14007. t['Omacrongrave'] = 0x1E50;
  14008. t['Omega'] = 0x2126;
  14009. t['Omegacyrillic'] = 0x0460;
  14010. t['Omegagreek'] = 0x03A9;
  14011. t['Omegaroundcyrillic'] = 0x047A;
  14012. t['Omegatitlocyrillic'] = 0x047C;
  14013. t['Omegatonos'] = 0x038F;
  14014. t['Omicron'] = 0x039F;
  14015. t['Omicrontonos'] = 0x038C;
  14016. t['Omonospace'] = 0xFF2F;
  14017. t['Oneroman'] = 0x2160;
  14018. t['Oogonek'] = 0x01EA;
  14019. t['Oogonekmacron'] = 0x01EC;
  14020. t['Oopen'] = 0x0186;
  14021. t['Oslash'] = 0x00D8;
  14022. t['Oslashacute'] = 0x01FE;
  14023. t['Oslashsmall'] = 0xF7F8;
  14024. t['Osmall'] = 0xF76F;
  14025. t['Ostrokeacute'] = 0x01FE;
  14026. t['Otcyrillic'] = 0x047E;
  14027. t['Otilde'] = 0x00D5;
  14028. t['Otildeacute'] = 0x1E4C;
  14029. t['Otildedieresis'] = 0x1E4E;
  14030. t['Otildesmall'] = 0xF7F5;
  14031. t['P'] = 0x0050;
  14032. t['Pacute'] = 0x1E54;
  14033. t['Pcircle'] = 0x24C5;
  14034. t['Pdotaccent'] = 0x1E56;
  14035. t['Pecyrillic'] = 0x041F;
  14036. t['Peharmenian'] = 0x054A;
  14037. t['Pemiddlehookcyrillic'] = 0x04A6;
  14038. t['Phi'] = 0x03A6;
  14039. t['Phook'] = 0x01A4;
  14040. t['Pi'] = 0x03A0;
  14041. t['Piwrarmenian'] = 0x0553;
  14042. t['Pmonospace'] = 0xFF30;
  14043. t['Psi'] = 0x03A8;
  14044. t['Psicyrillic'] = 0x0470;
  14045. t['Psmall'] = 0xF770;
  14046. t['Q'] = 0x0051;
  14047. t['Qcircle'] = 0x24C6;
  14048. t['Qmonospace'] = 0xFF31;
  14049. t['Qsmall'] = 0xF771;
  14050. t['R'] = 0x0052;
  14051. t['Raarmenian'] = 0x054C;
  14052. t['Racute'] = 0x0154;
  14053. t['Rcaron'] = 0x0158;
  14054. t['Rcedilla'] = 0x0156;
  14055. t['Rcircle'] = 0x24C7;
  14056. t['Rcommaaccent'] = 0x0156;
  14057. t['Rdblgrave'] = 0x0210;
  14058. t['Rdotaccent'] = 0x1E58;
  14059. t['Rdotbelow'] = 0x1E5A;
  14060. t['Rdotbelowmacron'] = 0x1E5C;
  14061. t['Reharmenian'] = 0x0550;
  14062. t['Rfraktur'] = 0x211C;
  14063. t['Rho'] = 0x03A1;
  14064. t['Ringsmall'] = 0xF6FC;
  14065. t['Rinvertedbreve'] = 0x0212;
  14066. t['Rlinebelow'] = 0x1E5E;
  14067. t['Rmonospace'] = 0xFF32;
  14068. t['Rsmall'] = 0xF772;
  14069. t['Rsmallinverted'] = 0x0281;
  14070. t['Rsmallinvertedsuperior'] = 0x02B6;
  14071. t['S'] = 0x0053;
  14072. t['SF010000'] = 0x250C;
  14073. t['SF020000'] = 0x2514;
  14074. t['SF030000'] = 0x2510;
  14075. t['SF040000'] = 0x2518;
  14076. t['SF050000'] = 0x253C;
  14077. t['SF060000'] = 0x252C;
  14078. t['SF070000'] = 0x2534;
  14079. t['SF080000'] = 0x251C;
  14080. t['SF090000'] = 0x2524;
  14081. t['SF100000'] = 0x2500;
  14082. t['SF110000'] = 0x2502;
  14083. t['SF190000'] = 0x2561;
  14084. t['SF200000'] = 0x2562;
  14085. t['SF210000'] = 0x2556;
  14086. t['SF220000'] = 0x2555;
  14087. t['SF230000'] = 0x2563;
  14088. t['SF240000'] = 0x2551;
  14089. t['SF250000'] = 0x2557;
  14090. t['SF260000'] = 0x255D;
  14091. t['SF270000'] = 0x255C;
  14092. t['SF280000'] = 0x255B;
  14093. t['SF360000'] = 0x255E;
  14094. t['SF370000'] = 0x255F;
  14095. t['SF380000'] = 0x255A;
  14096. t['SF390000'] = 0x2554;
  14097. t['SF400000'] = 0x2569;
  14098. t['SF410000'] = 0x2566;
  14099. t['SF420000'] = 0x2560;
  14100. t['SF430000'] = 0x2550;
  14101. t['SF440000'] = 0x256C;
  14102. t['SF450000'] = 0x2567;
  14103. t['SF460000'] = 0x2568;
  14104. t['SF470000'] = 0x2564;
  14105. t['SF480000'] = 0x2565;
  14106. t['SF490000'] = 0x2559;
  14107. t['SF500000'] = 0x2558;
  14108. t['SF510000'] = 0x2552;
  14109. t['SF520000'] = 0x2553;
  14110. t['SF530000'] = 0x256B;
  14111. t['SF540000'] = 0x256A;
  14112. t['Sacute'] = 0x015A;
  14113. t['Sacutedotaccent'] = 0x1E64;
  14114. t['Sampigreek'] = 0x03E0;
  14115. t['Scaron'] = 0x0160;
  14116. t['Scarondotaccent'] = 0x1E66;
  14117. t['Scaronsmall'] = 0xF6FD;
  14118. t['Scedilla'] = 0x015E;
  14119. t['Schwa'] = 0x018F;
  14120. t['Schwacyrillic'] = 0x04D8;
  14121. t['Schwadieresiscyrillic'] = 0x04DA;
  14122. t['Scircle'] = 0x24C8;
  14123. t['Scircumflex'] = 0x015C;
  14124. t['Scommaaccent'] = 0x0218;
  14125. t['Sdotaccent'] = 0x1E60;
  14126. t['Sdotbelow'] = 0x1E62;
  14127. t['Sdotbelowdotaccent'] = 0x1E68;
  14128. t['Seharmenian'] = 0x054D;
  14129. t['Sevenroman'] = 0x2166;
  14130. t['Shaarmenian'] = 0x0547;
  14131. t['Shacyrillic'] = 0x0428;
  14132. t['Shchacyrillic'] = 0x0429;
  14133. t['Sheicoptic'] = 0x03E2;
  14134. t['Shhacyrillic'] = 0x04BA;
  14135. t['Shimacoptic'] = 0x03EC;
  14136. t['Sigma'] = 0x03A3;
  14137. t['Sixroman'] = 0x2165;
  14138. t['Smonospace'] = 0xFF33;
  14139. t['Softsigncyrillic'] = 0x042C;
  14140. t['Ssmall'] = 0xF773;
  14141. t['Stigmagreek'] = 0x03DA;
  14142. t['T'] = 0x0054;
  14143. t['Tau'] = 0x03A4;
  14144. t['Tbar'] = 0x0166;
  14145. t['Tcaron'] = 0x0164;
  14146. t['Tcedilla'] = 0x0162;
  14147. t['Tcircle'] = 0x24C9;
  14148. t['Tcircumflexbelow'] = 0x1E70;
  14149. t['Tcommaaccent'] = 0x0162;
  14150. t['Tdotaccent'] = 0x1E6A;
  14151. t['Tdotbelow'] = 0x1E6C;
  14152. t['Tecyrillic'] = 0x0422;
  14153. t['Tedescendercyrillic'] = 0x04AC;
  14154. t['Tenroman'] = 0x2169;
  14155. t['Tetsecyrillic'] = 0x04B4;
  14156. t['Theta'] = 0x0398;
  14157. t['Thook'] = 0x01AC;
  14158. t['Thorn'] = 0x00DE;
  14159. t['Thornsmall'] = 0xF7FE;
  14160. t['Threeroman'] = 0x2162;
  14161. t['Tildesmall'] = 0xF6FE;
  14162. t['Tiwnarmenian'] = 0x054F;
  14163. t['Tlinebelow'] = 0x1E6E;
  14164. t['Tmonospace'] = 0xFF34;
  14165. t['Toarmenian'] = 0x0539;
  14166. t['Tonefive'] = 0x01BC;
  14167. t['Tonesix'] = 0x0184;
  14168. t['Tonetwo'] = 0x01A7;
  14169. t['Tretroflexhook'] = 0x01AE;
  14170. t['Tsecyrillic'] = 0x0426;
  14171. t['Tshecyrillic'] = 0x040B;
  14172. t['Tsmall'] = 0xF774;
  14173. t['Twelveroman'] = 0x216B;
  14174. t['Tworoman'] = 0x2161;
  14175. t['U'] = 0x0055;
  14176. t['Uacute'] = 0x00DA;
  14177. t['Uacutesmall'] = 0xF7FA;
  14178. t['Ubreve'] = 0x016C;
  14179. t['Ucaron'] = 0x01D3;
  14180. t['Ucircle'] = 0x24CA;
  14181. t['Ucircumflex'] = 0x00DB;
  14182. t['Ucircumflexbelow'] = 0x1E76;
  14183. t['Ucircumflexsmall'] = 0xF7FB;
  14184. t['Ucyrillic'] = 0x0423;
  14185. t['Udblacute'] = 0x0170;
  14186. t['Udblgrave'] = 0x0214;
  14187. t['Udieresis'] = 0x00DC;
  14188. t['Udieresisacute'] = 0x01D7;
  14189. t['Udieresisbelow'] = 0x1E72;
  14190. t['Udieresiscaron'] = 0x01D9;
  14191. t['Udieresiscyrillic'] = 0x04F0;
  14192. t['Udieresisgrave'] = 0x01DB;
  14193. t['Udieresismacron'] = 0x01D5;
  14194. t['Udieresissmall'] = 0xF7FC;
  14195. t['Udotbelow'] = 0x1EE4;
  14196. t['Ugrave'] = 0x00D9;
  14197. t['Ugravesmall'] = 0xF7F9;
  14198. t['Uhookabove'] = 0x1EE6;
  14199. t['Uhorn'] = 0x01AF;
  14200. t['Uhornacute'] = 0x1EE8;
  14201. t['Uhorndotbelow'] = 0x1EF0;
  14202. t['Uhorngrave'] = 0x1EEA;
  14203. t['Uhornhookabove'] = 0x1EEC;
  14204. t['Uhorntilde'] = 0x1EEE;
  14205. t['Uhungarumlaut'] = 0x0170;
  14206. t['Uhungarumlautcyrillic'] = 0x04F2;
  14207. t['Uinvertedbreve'] = 0x0216;
  14208. t['Ukcyrillic'] = 0x0478;
  14209. t['Umacron'] = 0x016A;
  14210. t['Umacroncyrillic'] = 0x04EE;
  14211. t['Umacrondieresis'] = 0x1E7A;
  14212. t['Umonospace'] = 0xFF35;
  14213. t['Uogonek'] = 0x0172;
  14214. t['Upsilon'] = 0x03A5;
  14215. t['Upsilon1'] = 0x03D2;
  14216. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14217. t['Upsilonafrican'] = 0x01B1;
  14218. t['Upsilondieresis'] = 0x03AB;
  14219. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14220. t['Upsilonhooksymbol'] = 0x03D2;
  14221. t['Upsilontonos'] = 0x038E;
  14222. t['Uring'] = 0x016E;
  14223. t['Ushortcyrillic'] = 0x040E;
  14224. t['Usmall'] = 0xF775;
  14225. t['Ustraightcyrillic'] = 0x04AE;
  14226. t['Ustraightstrokecyrillic'] = 0x04B0;
  14227. t['Utilde'] = 0x0168;
  14228. t['Utildeacute'] = 0x1E78;
  14229. t['Utildebelow'] = 0x1E74;
  14230. t['V'] = 0x0056;
  14231. t['Vcircle'] = 0x24CB;
  14232. t['Vdotbelow'] = 0x1E7E;
  14233. t['Vecyrillic'] = 0x0412;
  14234. t['Vewarmenian'] = 0x054E;
  14235. t['Vhook'] = 0x01B2;
  14236. t['Vmonospace'] = 0xFF36;
  14237. t['Voarmenian'] = 0x0548;
  14238. t['Vsmall'] = 0xF776;
  14239. t['Vtilde'] = 0x1E7C;
  14240. t['W'] = 0x0057;
  14241. t['Wacute'] = 0x1E82;
  14242. t['Wcircle'] = 0x24CC;
  14243. t['Wcircumflex'] = 0x0174;
  14244. t['Wdieresis'] = 0x1E84;
  14245. t['Wdotaccent'] = 0x1E86;
  14246. t['Wdotbelow'] = 0x1E88;
  14247. t['Wgrave'] = 0x1E80;
  14248. t['Wmonospace'] = 0xFF37;
  14249. t['Wsmall'] = 0xF777;
  14250. t['X'] = 0x0058;
  14251. t['Xcircle'] = 0x24CD;
  14252. t['Xdieresis'] = 0x1E8C;
  14253. t['Xdotaccent'] = 0x1E8A;
  14254. t['Xeharmenian'] = 0x053D;
  14255. t['Xi'] = 0x039E;
  14256. t['Xmonospace'] = 0xFF38;
  14257. t['Xsmall'] = 0xF778;
  14258. t['Y'] = 0x0059;
  14259. t['Yacute'] = 0x00DD;
  14260. t['Yacutesmall'] = 0xF7FD;
  14261. t['Yatcyrillic'] = 0x0462;
  14262. t['Ycircle'] = 0x24CE;
  14263. t['Ycircumflex'] = 0x0176;
  14264. t['Ydieresis'] = 0x0178;
  14265. t['Ydieresissmall'] = 0xF7FF;
  14266. t['Ydotaccent'] = 0x1E8E;
  14267. t['Ydotbelow'] = 0x1EF4;
  14268. t['Yericyrillic'] = 0x042B;
  14269. t['Yerudieresiscyrillic'] = 0x04F8;
  14270. t['Ygrave'] = 0x1EF2;
  14271. t['Yhook'] = 0x01B3;
  14272. t['Yhookabove'] = 0x1EF6;
  14273. t['Yiarmenian'] = 0x0545;
  14274. t['Yicyrillic'] = 0x0407;
  14275. t['Yiwnarmenian'] = 0x0552;
  14276. t['Ymonospace'] = 0xFF39;
  14277. t['Ysmall'] = 0xF779;
  14278. t['Ytilde'] = 0x1EF8;
  14279. t['Yusbigcyrillic'] = 0x046A;
  14280. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14281. t['Yuslittlecyrillic'] = 0x0466;
  14282. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14283. t['Z'] = 0x005A;
  14284. t['Zaarmenian'] = 0x0536;
  14285. t['Zacute'] = 0x0179;
  14286. t['Zcaron'] = 0x017D;
  14287. t['Zcaronsmall'] = 0xF6FF;
  14288. t['Zcircle'] = 0x24CF;
  14289. t['Zcircumflex'] = 0x1E90;
  14290. t['Zdot'] = 0x017B;
  14291. t['Zdotaccent'] = 0x017B;
  14292. t['Zdotbelow'] = 0x1E92;
  14293. t['Zecyrillic'] = 0x0417;
  14294. t['Zedescendercyrillic'] = 0x0498;
  14295. t['Zedieresiscyrillic'] = 0x04DE;
  14296. t['Zeta'] = 0x0396;
  14297. t['Zhearmenian'] = 0x053A;
  14298. t['Zhebrevecyrillic'] = 0x04C1;
  14299. t['Zhecyrillic'] = 0x0416;
  14300. t['Zhedescendercyrillic'] = 0x0496;
  14301. t['Zhedieresiscyrillic'] = 0x04DC;
  14302. t['Zlinebelow'] = 0x1E94;
  14303. t['Zmonospace'] = 0xFF3A;
  14304. t['Zsmall'] = 0xF77A;
  14305. t['Zstroke'] = 0x01B5;
  14306. t['a'] = 0x0061;
  14307. t['aabengali'] = 0x0986;
  14308. t['aacute'] = 0x00E1;
  14309. t['aadeva'] = 0x0906;
  14310. t['aagujarati'] = 0x0A86;
  14311. t['aagurmukhi'] = 0x0A06;
  14312. t['aamatragurmukhi'] = 0x0A3E;
  14313. t['aarusquare'] = 0x3303;
  14314. t['aavowelsignbengali'] = 0x09BE;
  14315. t['aavowelsigndeva'] = 0x093E;
  14316. t['aavowelsigngujarati'] = 0x0ABE;
  14317. t['abbreviationmarkarmenian'] = 0x055F;
  14318. t['abbreviationsigndeva'] = 0x0970;
  14319. t['abengali'] = 0x0985;
  14320. t['abopomofo'] = 0x311A;
  14321. t['abreve'] = 0x0103;
  14322. t['abreveacute'] = 0x1EAF;
  14323. t['abrevecyrillic'] = 0x04D1;
  14324. t['abrevedotbelow'] = 0x1EB7;
  14325. t['abrevegrave'] = 0x1EB1;
  14326. t['abrevehookabove'] = 0x1EB3;
  14327. t['abrevetilde'] = 0x1EB5;
  14328. t['acaron'] = 0x01CE;
  14329. t['acircle'] = 0x24D0;
  14330. t['acircumflex'] = 0x00E2;
  14331. t['acircumflexacute'] = 0x1EA5;
  14332. t['acircumflexdotbelow'] = 0x1EAD;
  14333. t['acircumflexgrave'] = 0x1EA7;
  14334. t['acircumflexhookabove'] = 0x1EA9;
  14335. t['acircumflextilde'] = 0x1EAB;
  14336. t['acute'] = 0x00B4;
  14337. t['acutebelowcmb'] = 0x0317;
  14338. t['acutecmb'] = 0x0301;
  14339. t['acutecomb'] = 0x0301;
  14340. t['acutedeva'] = 0x0954;
  14341. t['acutelowmod'] = 0x02CF;
  14342. t['acutetonecmb'] = 0x0341;
  14343. t['acyrillic'] = 0x0430;
  14344. t['adblgrave'] = 0x0201;
  14345. t['addakgurmukhi'] = 0x0A71;
  14346. t['adeva'] = 0x0905;
  14347. t['adieresis'] = 0x00E4;
  14348. t['adieresiscyrillic'] = 0x04D3;
  14349. t['adieresismacron'] = 0x01DF;
  14350. t['adotbelow'] = 0x1EA1;
  14351. t['adotmacron'] = 0x01E1;
  14352. t['ae'] = 0x00E6;
  14353. t['aeacute'] = 0x01FD;
  14354. t['aekorean'] = 0x3150;
  14355. t['aemacron'] = 0x01E3;
  14356. t['afii00208'] = 0x2015;
  14357. t['afii08941'] = 0x20A4;
  14358. t['afii10017'] = 0x0410;
  14359. t['afii10018'] = 0x0411;
  14360. t['afii10019'] = 0x0412;
  14361. t['afii10020'] = 0x0413;
  14362. t['afii10021'] = 0x0414;
  14363. t['afii10022'] = 0x0415;
  14364. t['afii10023'] = 0x0401;
  14365. t['afii10024'] = 0x0416;
  14366. t['afii10025'] = 0x0417;
  14367. t['afii10026'] = 0x0418;
  14368. t['afii10027'] = 0x0419;
  14369. t['afii10028'] = 0x041A;
  14370. t['afii10029'] = 0x041B;
  14371. t['afii10030'] = 0x041C;
  14372. t['afii10031'] = 0x041D;
  14373. t['afii10032'] = 0x041E;
  14374. t['afii10033'] = 0x041F;
  14375. t['afii10034'] = 0x0420;
  14376. t['afii10035'] = 0x0421;
  14377. t['afii10036'] = 0x0422;
  14378. t['afii10037'] = 0x0423;
  14379. t['afii10038'] = 0x0424;
  14380. t['afii10039'] = 0x0425;
  14381. t['afii10040'] = 0x0426;
  14382. t['afii10041'] = 0x0427;
  14383. t['afii10042'] = 0x0428;
  14384. t['afii10043'] = 0x0429;
  14385. t['afii10044'] = 0x042A;
  14386. t['afii10045'] = 0x042B;
  14387. t['afii10046'] = 0x042C;
  14388. t['afii10047'] = 0x042D;
  14389. t['afii10048'] = 0x042E;
  14390. t['afii10049'] = 0x042F;
  14391. t['afii10050'] = 0x0490;
  14392. t['afii10051'] = 0x0402;
  14393. t['afii10052'] = 0x0403;
  14394. t['afii10053'] = 0x0404;
  14395. t['afii10054'] = 0x0405;
  14396. t['afii10055'] = 0x0406;
  14397. t['afii10056'] = 0x0407;
  14398. t['afii10057'] = 0x0408;
  14399. t['afii10058'] = 0x0409;
  14400. t['afii10059'] = 0x040A;
  14401. t['afii10060'] = 0x040B;
  14402. t['afii10061'] = 0x040C;
  14403. t['afii10062'] = 0x040E;
  14404. t['afii10063'] = 0xF6C4;
  14405. t['afii10064'] = 0xF6C5;
  14406. t['afii10065'] = 0x0430;
  14407. t['afii10066'] = 0x0431;
  14408. t['afii10067'] = 0x0432;
  14409. t['afii10068'] = 0x0433;
  14410. t['afii10069'] = 0x0434;
  14411. t['afii10070'] = 0x0435;
  14412. t['afii10071'] = 0x0451;
  14413. t['afii10072'] = 0x0436;
  14414. t['afii10073'] = 0x0437;
  14415. t['afii10074'] = 0x0438;
  14416. t['afii10075'] = 0x0439;
  14417. t['afii10076'] = 0x043A;
  14418. t['afii10077'] = 0x043B;
  14419. t['afii10078'] = 0x043C;
  14420. t['afii10079'] = 0x043D;
  14421. t['afii10080'] = 0x043E;
  14422. t['afii10081'] = 0x043F;
  14423. t['afii10082'] = 0x0440;
  14424. t['afii10083'] = 0x0441;
  14425. t['afii10084'] = 0x0442;
  14426. t['afii10085'] = 0x0443;
  14427. t['afii10086'] = 0x0444;
  14428. t['afii10087'] = 0x0445;
  14429. t['afii10088'] = 0x0446;
  14430. t['afii10089'] = 0x0447;
  14431. t['afii10090'] = 0x0448;
  14432. t['afii10091'] = 0x0449;
  14433. t['afii10092'] = 0x044A;
  14434. t['afii10093'] = 0x044B;
  14435. t['afii10094'] = 0x044C;
  14436. t['afii10095'] = 0x044D;
  14437. t['afii10096'] = 0x044E;
  14438. t['afii10097'] = 0x044F;
  14439. t['afii10098'] = 0x0491;
  14440. t['afii10099'] = 0x0452;
  14441. t['afii10100'] = 0x0453;
  14442. t['afii10101'] = 0x0454;
  14443. t['afii10102'] = 0x0455;
  14444. t['afii10103'] = 0x0456;
  14445. t['afii10104'] = 0x0457;
  14446. t['afii10105'] = 0x0458;
  14447. t['afii10106'] = 0x0459;
  14448. t['afii10107'] = 0x045A;
  14449. t['afii10108'] = 0x045B;
  14450. t['afii10109'] = 0x045C;
  14451. t['afii10110'] = 0x045E;
  14452. t['afii10145'] = 0x040F;
  14453. t['afii10146'] = 0x0462;
  14454. t['afii10147'] = 0x0472;
  14455. t['afii10148'] = 0x0474;
  14456. t['afii10192'] = 0xF6C6;
  14457. t['afii10193'] = 0x045F;
  14458. t['afii10194'] = 0x0463;
  14459. t['afii10195'] = 0x0473;
  14460. t['afii10196'] = 0x0475;
  14461. t['afii10831'] = 0xF6C7;
  14462. t['afii10832'] = 0xF6C8;
  14463. t['afii10846'] = 0x04D9;
  14464. t['afii299'] = 0x200E;
  14465. t['afii300'] = 0x200F;
  14466. t['afii301'] = 0x200D;
  14467. t['afii57381'] = 0x066A;
  14468. t['afii57388'] = 0x060C;
  14469. t['afii57392'] = 0x0660;
  14470. t['afii57393'] = 0x0661;
  14471. t['afii57394'] = 0x0662;
  14472. t['afii57395'] = 0x0663;
  14473. t['afii57396'] = 0x0664;
  14474. t['afii57397'] = 0x0665;
  14475. t['afii57398'] = 0x0666;
  14476. t['afii57399'] = 0x0667;
  14477. t['afii57400'] = 0x0668;
  14478. t['afii57401'] = 0x0669;
  14479. t['afii57403'] = 0x061B;
  14480. t['afii57407'] = 0x061F;
  14481. t['afii57409'] = 0x0621;
  14482. t['afii57410'] = 0x0622;
  14483. t['afii57411'] = 0x0623;
  14484. t['afii57412'] = 0x0624;
  14485. t['afii57413'] = 0x0625;
  14486. t['afii57414'] = 0x0626;
  14487. t['afii57415'] = 0x0627;
  14488. t['afii57416'] = 0x0628;
  14489. t['afii57417'] = 0x0629;
  14490. t['afii57418'] = 0x062A;
  14491. t['afii57419'] = 0x062B;
  14492. t['afii57420'] = 0x062C;
  14493. t['afii57421'] = 0x062D;
  14494. t['afii57422'] = 0x062E;
  14495. t['afii57423'] = 0x062F;
  14496. t['afii57424'] = 0x0630;
  14497. t['afii57425'] = 0x0631;
  14498. t['afii57426'] = 0x0632;
  14499. t['afii57427'] = 0x0633;
  14500. t['afii57428'] = 0x0634;
  14501. t['afii57429'] = 0x0635;
  14502. t['afii57430'] = 0x0636;
  14503. t['afii57431'] = 0x0637;
  14504. t['afii57432'] = 0x0638;
  14505. t['afii57433'] = 0x0639;
  14506. t['afii57434'] = 0x063A;
  14507. t['afii57440'] = 0x0640;
  14508. t['afii57441'] = 0x0641;
  14509. t['afii57442'] = 0x0642;
  14510. t['afii57443'] = 0x0643;
  14511. t['afii57444'] = 0x0644;
  14512. t['afii57445'] = 0x0645;
  14513. t['afii57446'] = 0x0646;
  14514. t['afii57448'] = 0x0648;
  14515. t['afii57449'] = 0x0649;
  14516. t['afii57450'] = 0x064A;
  14517. t['afii57451'] = 0x064B;
  14518. t['afii57452'] = 0x064C;
  14519. t['afii57453'] = 0x064D;
  14520. t['afii57454'] = 0x064E;
  14521. t['afii57455'] = 0x064F;
  14522. t['afii57456'] = 0x0650;
  14523. t['afii57457'] = 0x0651;
  14524. t['afii57458'] = 0x0652;
  14525. t['afii57470'] = 0x0647;
  14526. t['afii57505'] = 0x06A4;
  14527. t['afii57506'] = 0x067E;
  14528. t['afii57507'] = 0x0686;
  14529. t['afii57508'] = 0x0698;
  14530. t['afii57509'] = 0x06AF;
  14531. t['afii57511'] = 0x0679;
  14532. t['afii57512'] = 0x0688;
  14533. t['afii57513'] = 0x0691;
  14534. t['afii57514'] = 0x06BA;
  14535. t['afii57519'] = 0x06D2;
  14536. t['afii57534'] = 0x06D5;
  14537. t['afii57636'] = 0x20AA;
  14538. t['afii57645'] = 0x05BE;
  14539. t['afii57658'] = 0x05C3;
  14540. t['afii57664'] = 0x05D0;
  14541. t['afii57665'] = 0x05D1;
  14542. t['afii57666'] = 0x05D2;
  14543. t['afii57667'] = 0x05D3;
  14544. t['afii57668'] = 0x05D4;
  14545. t['afii57669'] = 0x05D5;
  14546. t['afii57670'] = 0x05D6;
  14547. t['afii57671'] = 0x05D7;
  14548. t['afii57672'] = 0x05D8;
  14549. t['afii57673'] = 0x05D9;
  14550. t['afii57674'] = 0x05DA;
  14551. t['afii57675'] = 0x05DB;
  14552. t['afii57676'] = 0x05DC;
  14553. t['afii57677'] = 0x05DD;
  14554. t['afii57678'] = 0x05DE;
  14555. t['afii57679'] = 0x05DF;
  14556. t['afii57680'] = 0x05E0;
  14557. t['afii57681'] = 0x05E1;
  14558. t['afii57682'] = 0x05E2;
  14559. t['afii57683'] = 0x05E3;
  14560. t['afii57684'] = 0x05E4;
  14561. t['afii57685'] = 0x05E5;
  14562. t['afii57686'] = 0x05E6;
  14563. t['afii57687'] = 0x05E7;
  14564. t['afii57688'] = 0x05E8;
  14565. t['afii57689'] = 0x05E9;
  14566. t['afii57690'] = 0x05EA;
  14567. t['afii57694'] = 0xFB2A;
  14568. t['afii57695'] = 0xFB2B;
  14569. t['afii57700'] = 0xFB4B;
  14570. t['afii57705'] = 0xFB1F;
  14571. t['afii57716'] = 0x05F0;
  14572. t['afii57717'] = 0x05F1;
  14573. t['afii57718'] = 0x05F2;
  14574. t['afii57723'] = 0xFB35;
  14575. t['afii57793'] = 0x05B4;
  14576. t['afii57794'] = 0x05B5;
  14577. t['afii57795'] = 0x05B6;
  14578. t['afii57796'] = 0x05BB;
  14579. t['afii57797'] = 0x05B8;
  14580. t['afii57798'] = 0x05B7;
  14581. t['afii57799'] = 0x05B0;
  14582. t['afii57800'] = 0x05B2;
  14583. t['afii57801'] = 0x05B1;
  14584. t['afii57802'] = 0x05B3;
  14585. t['afii57803'] = 0x05C2;
  14586. t['afii57804'] = 0x05C1;
  14587. t['afii57806'] = 0x05B9;
  14588. t['afii57807'] = 0x05BC;
  14589. t['afii57839'] = 0x05BD;
  14590. t['afii57841'] = 0x05BF;
  14591. t['afii57842'] = 0x05C0;
  14592. t['afii57929'] = 0x02BC;
  14593. t['afii61248'] = 0x2105;
  14594. t['afii61289'] = 0x2113;
  14595. t['afii61352'] = 0x2116;
  14596. t['afii61573'] = 0x202C;
  14597. t['afii61574'] = 0x202D;
  14598. t['afii61575'] = 0x202E;
  14599. t['afii61664'] = 0x200C;
  14600. t['afii63167'] = 0x066D;
  14601. t['afii64937'] = 0x02BD;
  14602. t['agrave'] = 0x00E0;
  14603. t['agujarati'] = 0x0A85;
  14604. t['agurmukhi'] = 0x0A05;
  14605. t['ahiragana'] = 0x3042;
  14606. t['ahookabove'] = 0x1EA3;
  14607. t['aibengali'] = 0x0990;
  14608. t['aibopomofo'] = 0x311E;
  14609. t['aideva'] = 0x0910;
  14610. t['aiecyrillic'] = 0x04D5;
  14611. t['aigujarati'] = 0x0A90;
  14612. t['aigurmukhi'] = 0x0A10;
  14613. t['aimatragurmukhi'] = 0x0A48;
  14614. t['ainarabic'] = 0x0639;
  14615. t['ainfinalarabic'] = 0xFECA;
  14616. t['aininitialarabic'] = 0xFECB;
  14617. t['ainmedialarabic'] = 0xFECC;
  14618. t['ainvertedbreve'] = 0x0203;
  14619. t['aivowelsignbengali'] = 0x09C8;
  14620. t['aivowelsigndeva'] = 0x0948;
  14621. t['aivowelsigngujarati'] = 0x0AC8;
  14622. t['akatakana'] = 0x30A2;
  14623. t['akatakanahalfwidth'] = 0xFF71;
  14624. t['akorean'] = 0x314F;
  14625. t['alef'] = 0x05D0;
  14626. t['alefarabic'] = 0x0627;
  14627. t['alefdageshhebrew'] = 0xFB30;
  14628. t['aleffinalarabic'] = 0xFE8E;
  14629. t['alefhamzaabovearabic'] = 0x0623;
  14630. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14631. t['alefhamzabelowarabic'] = 0x0625;
  14632. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14633. t['alefhebrew'] = 0x05D0;
  14634. t['aleflamedhebrew'] = 0xFB4F;
  14635. t['alefmaddaabovearabic'] = 0x0622;
  14636. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14637. t['alefmaksuraarabic'] = 0x0649;
  14638. t['alefmaksurafinalarabic'] = 0xFEF0;
  14639. t['alefmaksurainitialarabic'] = 0xFEF3;
  14640. t['alefmaksuramedialarabic'] = 0xFEF4;
  14641. t['alefpatahhebrew'] = 0xFB2E;
  14642. t['alefqamatshebrew'] = 0xFB2F;
  14643. t['aleph'] = 0x2135;
  14644. t['allequal'] = 0x224C;
  14645. t['alpha'] = 0x03B1;
  14646. t['alphatonos'] = 0x03AC;
  14647. t['amacron'] = 0x0101;
  14648. t['amonospace'] = 0xFF41;
  14649. t['ampersand'] = 0x0026;
  14650. t['ampersandmonospace'] = 0xFF06;
  14651. t['ampersandsmall'] = 0xF726;
  14652. t['amsquare'] = 0x33C2;
  14653. t['anbopomofo'] = 0x3122;
  14654. t['angbopomofo'] = 0x3124;
  14655. t['angbracketleft'] = 0x3008;
  14656. t['angbracketright'] = 0x3009;
  14657. t['angkhankhuthai'] = 0x0E5A;
  14658. t['angle'] = 0x2220;
  14659. t['anglebracketleft'] = 0x3008;
  14660. t['anglebracketleftvertical'] = 0xFE3F;
  14661. t['anglebracketright'] = 0x3009;
  14662. t['anglebracketrightvertical'] = 0xFE40;
  14663. t['angleleft'] = 0x2329;
  14664. t['angleright'] = 0x232A;
  14665. t['angstrom'] = 0x212B;
  14666. t['anoteleia'] = 0x0387;
  14667. t['anudattadeva'] = 0x0952;
  14668. t['anusvarabengali'] = 0x0982;
  14669. t['anusvaradeva'] = 0x0902;
  14670. t['anusvaragujarati'] = 0x0A82;
  14671. t['aogonek'] = 0x0105;
  14672. t['apaatosquare'] = 0x3300;
  14673. t['aparen'] = 0x249C;
  14674. t['apostrophearmenian'] = 0x055A;
  14675. t['apostrophemod'] = 0x02BC;
  14676. t['apple'] = 0xF8FF;
  14677. t['approaches'] = 0x2250;
  14678. t['approxequal'] = 0x2248;
  14679. t['approxequalorimage'] = 0x2252;
  14680. t['approximatelyequal'] = 0x2245;
  14681. t['araeaekorean'] = 0x318E;
  14682. t['araeakorean'] = 0x318D;
  14683. t['arc'] = 0x2312;
  14684. t['arighthalfring'] = 0x1E9A;
  14685. t['aring'] = 0x00E5;
  14686. t['aringacute'] = 0x01FB;
  14687. t['aringbelow'] = 0x1E01;
  14688. t['arrowboth'] = 0x2194;
  14689. t['arrowdashdown'] = 0x21E3;
  14690. t['arrowdashleft'] = 0x21E0;
  14691. t['arrowdashright'] = 0x21E2;
  14692. t['arrowdashup'] = 0x21E1;
  14693. t['arrowdblboth'] = 0x21D4;
  14694. t['arrowdbldown'] = 0x21D3;
  14695. t['arrowdblleft'] = 0x21D0;
  14696. t['arrowdblright'] = 0x21D2;
  14697. t['arrowdblup'] = 0x21D1;
  14698. t['arrowdown'] = 0x2193;
  14699. t['arrowdownleft'] = 0x2199;
  14700. t['arrowdownright'] = 0x2198;
  14701. t['arrowdownwhite'] = 0x21E9;
  14702. t['arrowheaddownmod'] = 0x02C5;
  14703. t['arrowheadleftmod'] = 0x02C2;
  14704. t['arrowheadrightmod'] = 0x02C3;
  14705. t['arrowheadupmod'] = 0x02C4;
  14706. t['arrowhorizex'] = 0xF8E7;
  14707. t['arrowleft'] = 0x2190;
  14708. t['arrowleftdbl'] = 0x21D0;
  14709. t['arrowleftdblstroke'] = 0x21CD;
  14710. t['arrowleftoverright'] = 0x21C6;
  14711. t['arrowleftwhite'] = 0x21E6;
  14712. t['arrowright'] = 0x2192;
  14713. t['arrowrightdblstroke'] = 0x21CF;
  14714. t['arrowrightheavy'] = 0x279E;
  14715. t['arrowrightoverleft'] = 0x21C4;
  14716. t['arrowrightwhite'] = 0x21E8;
  14717. t['arrowtableft'] = 0x21E4;
  14718. t['arrowtabright'] = 0x21E5;
  14719. t['arrowup'] = 0x2191;
  14720. t['arrowupdn'] = 0x2195;
  14721. t['arrowupdnbse'] = 0x21A8;
  14722. t['arrowupdownbase'] = 0x21A8;
  14723. t['arrowupleft'] = 0x2196;
  14724. t['arrowupleftofdown'] = 0x21C5;
  14725. t['arrowupright'] = 0x2197;
  14726. t['arrowupwhite'] = 0x21E7;
  14727. t['arrowvertex'] = 0xF8E6;
  14728. t['asciicircum'] = 0x005E;
  14729. t['asciicircummonospace'] = 0xFF3E;
  14730. t['asciitilde'] = 0x007E;
  14731. t['asciitildemonospace'] = 0xFF5E;
  14732. t['ascript'] = 0x0251;
  14733. t['ascriptturned'] = 0x0252;
  14734. t['asmallhiragana'] = 0x3041;
  14735. t['asmallkatakana'] = 0x30A1;
  14736. t['asmallkatakanahalfwidth'] = 0xFF67;
  14737. t['asterisk'] = 0x002A;
  14738. t['asteriskaltonearabic'] = 0x066D;
  14739. t['asteriskarabic'] = 0x066D;
  14740. t['asteriskmath'] = 0x2217;
  14741. t['asteriskmonospace'] = 0xFF0A;
  14742. t['asterisksmall'] = 0xFE61;
  14743. t['asterism'] = 0x2042;
  14744. t['asuperior'] = 0xF6E9;
  14745. t['asymptoticallyequal'] = 0x2243;
  14746. t['at'] = 0x0040;
  14747. t['atilde'] = 0x00E3;
  14748. t['atmonospace'] = 0xFF20;
  14749. t['atsmall'] = 0xFE6B;
  14750. t['aturned'] = 0x0250;
  14751. t['aubengali'] = 0x0994;
  14752. t['aubopomofo'] = 0x3120;
  14753. t['audeva'] = 0x0914;
  14754. t['augujarati'] = 0x0A94;
  14755. t['augurmukhi'] = 0x0A14;
  14756. t['aulengthmarkbengali'] = 0x09D7;
  14757. t['aumatragurmukhi'] = 0x0A4C;
  14758. t['auvowelsignbengali'] = 0x09CC;
  14759. t['auvowelsigndeva'] = 0x094C;
  14760. t['auvowelsigngujarati'] = 0x0ACC;
  14761. t['avagrahadeva'] = 0x093D;
  14762. t['aybarmenian'] = 0x0561;
  14763. t['ayin'] = 0x05E2;
  14764. t['ayinaltonehebrew'] = 0xFB20;
  14765. t['ayinhebrew'] = 0x05E2;
  14766. t['b'] = 0x0062;
  14767. t['babengali'] = 0x09AC;
  14768. t['backslash'] = 0x005C;
  14769. t['backslashmonospace'] = 0xFF3C;
  14770. t['badeva'] = 0x092C;
  14771. t['bagujarati'] = 0x0AAC;
  14772. t['bagurmukhi'] = 0x0A2C;
  14773. t['bahiragana'] = 0x3070;
  14774. t['bahtthai'] = 0x0E3F;
  14775. t['bakatakana'] = 0x30D0;
  14776. t['bar'] = 0x007C;
  14777. t['barmonospace'] = 0xFF5C;
  14778. t['bbopomofo'] = 0x3105;
  14779. t['bcircle'] = 0x24D1;
  14780. t['bdotaccent'] = 0x1E03;
  14781. t['bdotbelow'] = 0x1E05;
  14782. t['beamedsixteenthnotes'] = 0x266C;
  14783. t['because'] = 0x2235;
  14784. t['becyrillic'] = 0x0431;
  14785. t['beharabic'] = 0x0628;
  14786. t['behfinalarabic'] = 0xFE90;
  14787. t['behinitialarabic'] = 0xFE91;
  14788. t['behiragana'] = 0x3079;
  14789. t['behmedialarabic'] = 0xFE92;
  14790. t['behmeeminitialarabic'] = 0xFC9F;
  14791. t['behmeemisolatedarabic'] = 0xFC08;
  14792. t['behnoonfinalarabic'] = 0xFC6D;
  14793. t['bekatakana'] = 0x30D9;
  14794. t['benarmenian'] = 0x0562;
  14795. t['bet'] = 0x05D1;
  14796. t['beta'] = 0x03B2;
  14797. t['betasymbolgreek'] = 0x03D0;
  14798. t['betdagesh'] = 0xFB31;
  14799. t['betdageshhebrew'] = 0xFB31;
  14800. t['bethebrew'] = 0x05D1;
  14801. t['betrafehebrew'] = 0xFB4C;
  14802. t['bhabengali'] = 0x09AD;
  14803. t['bhadeva'] = 0x092D;
  14804. t['bhagujarati'] = 0x0AAD;
  14805. t['bhagurmukhi'] = 0x0A2D;
  14806. t['bhook'] = 0x0253;
  14807. t['bihiragana'] = 0x3073;
  14808. t['bikatakana'] = 0x30D3;
  14809. t['bilabialclick'] = 0x0298;
  14810. t['bindigurmukhi'] = 0x0A02;
  14811. t['birusquare'] = 0x3331;
  14812. t['blackcircle'] = 0x25CF;
  14813. t['blackdiamond'] = 0x25C6;
  14814. t['blackdownpointingtriangle'] = 0x25BC;
  14815. t['blackleftpointingpointer'] = 0x25C4;
  14816. t['blackleftpointingtriangle'] = 0x25C0;
  14817. t['blacklenticularbracketleft'] = 0x3010;
  14818. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14819. t['blacklenticularbracketright'] = 0x3011;
  14820. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14821. t['blacklowerlefttriangle'] = 0x25E3;
  14822. t['blacklowerrighttriangle'] = 0x25E2;
  14823. t['blackrectangle'] = 0x25AC;
  14824. t['blackrightpointingpointer'] = 0x25BA;
  14825. t['blackrightpointingtriangle'] = 0x25B6;
  14826. t['blacksmallsquare'] = 0x25AA;
  14827. t['blacksmilingface'] = 0x263B;
  14828. t['blacksquare'] = 0x25A0;
  14829. t['blackstar'] = 0x2605;
  14830. t['blackupperlefttriangle'] = 0x25E4;
  14831. t['blackupperrighttriangle'] = 0x25E5;
  14832. t['blackuppointingsmalltriangle'] = 0x25B4;
  14833. t['blackuppointingtriangle'] = 0x25B2;
  14834. t['blank'] = 0x2423;
  14835. t['blinebelow'] = 0x1E07;
  14836. t['block'] = 0x2588;
  14837. t['bmonospace'] = 0xFF42;
  14838. t['bobaimaithai'] = 0x0E1A;
  14839. t['bohiragana'] = 0x307C;
  14840. t['bokatakana'] = 0x30DC;
  14841. t['bparen'] = 0x249D;
  14842. t['bqsquare'] = 0x33C3;
  14843. t['braceex'] = 0xF8F4;
  14844. t['braceleft'] = 0x007B;
  14845. t['braceleftbt'] = 0xF8F3;
  14846. t['braceleftmid'] = 0xF8F2;
  14847. t['braceleftmonospace'] = 0xFF5B;
  14848. t['braceleftsmall'] = 0xFE5B;
  14849. t['bracelefttp'] = 0xF8F1;
  14850. t['braceleftvertical'] = 0xFE37;
  14851. t['braceright'] = 0x007D;
  14852. t['bracerightbt'] = 0xF8FE;
  14853. t['bracerightmid'] = 0xF8FD;
  14854. t['bracerightmonospace'] = 0xFF5D;
  14855. t['bracerightsmall'] = 0xFE5C;
  14856. t['bracerighttp'] = 0xF8FC;
  14857. t['bracerightvertical'] = 0xFE38;
  14858. t['bracketleft'] = 0x005B;
  14859. t['bracketleftbt'] = 0xF8F0;
  14860. t['bracketleftex'] = 0xF8EF;
  14861. t['bracketleftmonospace'] = 0xFF3B;
  14862. t['bracketlefttp'] = 0xF8EE;
  14863. t['bracketright'] = 0x005D;
  14864. t['bracketrightbt'] = 0xF8FB;
  14865. t['bracketrightex'] = 0xF8FA;
  14866. t['bracketrightmonospace'] = 0xFF3D;
  14867. t['bracketrighttp'] = 0xF8F9;
  14868. t['breve'] = 0x02D8;
  14869. t['brevebelowcmb'] = 0x032E;
  14870. t['brevecmb'] = 0x0306;
  14871. t['breveinvertedbelowcmb'] = 0x032F;
  14872. t['breveinvertedcmb'] = 0x0311;
  14873. t['breveinverteddoublecmb'] = 0x0361;
  14874. t['bridgebelowcmb'] = 0x032A;
  14875. t['bridgeinvertedbelowcmb'] = 0x033A;
  14876. t['brokenbar'] = 0x00A6;
  14877. t['bstroke'] = 0x0180;
  14878. t['bsuperior'] = 0xF6EA;
  14879. t['btopbar'] = 0x0183;
  14880. t['buhiragana'] = 0x3076;
  14881. t['bukatakana'] = 0x30D6;
  14882. t['bullet'] = 0x2022;
  14883. t['bulletinverse'] = 0x25D8;
  14884. t['bulletoperator'] = 0x2219;
  14885. t['bullseye'] = 0x25CE;
  14886. t['c'] = 0x0063;
  14887. t['caarmenian'] = 0x056E;
  14888. t['cabengali'] = 0x099A;
  14889. t['cacute'] = 0x0107;
  14890. t['cadeva'] = 0x091A;
  14891. t['cagujarati'] = 0x0A9A;
  14892. t['cagurmukhi'] = 0x0A1A;
  14893. t['calsquare'] = 0x3388;
  14894. t['candrabindubengali'] = 0x0981;
  14895. t['candrabinducmb'] = 0x0310;
  14896. t['candrabindudeva'] = 0x0901;
  14897. t['candrabindugujarati'] = 0x0A81;
  14898. t['capslock'] = 0x21EA;
  14899. t['careof'] = 0x2105;
  14900. t['caron'] = 0x02C7;
  14901. t['caronbelowcmb'] = 0x032C;
  14902. t['caroncmb'] = 0x030C;
  14903. t['carriagereturn'] = 0x21B5;
  14904. t['cbopomofo'] = 0x3118;
  14905. t['ccaron'] = 0x010D;
  14906. t['ccedilla'] = 0x00E7;
  14907. t['ccedillaacute'] = 0x1E09;
  14908. t['ccircle'] = 0x24D2;
  14909. t['ccircumflex'] = 0x0109;
  14910. t['ccurl'] = 0x0255;
  14911. t['cdot'] = 0x010B;
  14912. t['cdotaccent'] = 0x010B;
  14913. t['cdsquare'] = 0x33C5;
  14914. t['cedilla'] = 0x00B8;
  14915. t['cedillacmb'] = 0x0327;
  14916. t['cent'] = 0x00A2;
  14917. t['centigrade'] = 0x2103;
  14918. t['centinferior'] = 0xF6DF;
  14919. t['centmonospace'] = 0xFFE0;
  14920. t['centoldstyle'] = 0xF7A2;
  14921. t['centsuperior'] = 0xF6E0;
  14922. t['chaarmenian'] = 0x0579;
  14923. t['chabengali'] = 0x099B;
  14924. t['chadeva'] = 0x091B;
  14925. t['chagujarati'] = 0x0A9B;
  14926. t['chagurmukhi'] = 0x0A1B;
  14927. t['chbopomofo'] = 0x3114;
  14928. t['cheabkhasiancyrillic'] = 0x04BD;
  14929. t['checkmark'] = 0x2713;
  14930. t['checyrillic'] = 0x0447;
  14931. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14932. t['chedescendercyrillic'] = 0x04B7;
  14933. t['chedieresiscyrillic'] = 0x04F5;
  14934. t['cheharmenian'] = 0x0573;
  14935. t['chekhakassiancyrillic'] = 0x04CC;
  14936. t['cheverticalstrokecyrillic'] = 0x04B9;
  14937. t['chi'] = 0x03C7;
  14938. t['chieuchacirclekorean'] = 0x3277;
  14939. t['chieuchaparenkorean'] = 0x3217;
  14940. t['chieuchcirclekorean'] = 0x3269;
  14941. t['chieuchkorean'] = 0x314A;
  14942. t['chieuchparenkorean'] = 0x3209;
  14943. t['chochangthai'] = 0x0E0A;
  14944. t['chochanthai'] = 0x0E08;
  14945. t['chochingthai'] = 0x0E09;
  14946. t['chochoethai'] = 0x0E0C;
  14947. t['chook'] = 0x0188;
  14948. t['cieucacirclekorean'] = 0x3276;
  14949. t['cieucaparenkorean'] = 0x3216;
  14950. t['cieuccirclekorean'] = 0x3268;
  14951. t['cieuckorean'] = 0x3148;
  14952. t['cieucparenkorean'] = 0x3208;
  14953. t['cieucuparenkorean'] = 0x321C;
  14954. t['circle'] = 0x25CB;
  14955. t['circlecopyrt'] = 0x00A9;
  14956. t['circlemultiply'] = 0x2297;
  14957. t['circleot'] = 0x2299;
  14958. t['circleplus'] = 0x2295;
  14959. t['circlepostalmark'] = 0x3036;
  14960. t['circlewithlefthalfblack'] = 0x25D0;
  14961. t['circlewithrighthalfblack'] = 0x25D1;
  14962. t['circumflex'] = 0x02C6;
  14963. t['circumflexbelowcmb'] = 0x032D;
  14964. t['circumflexcmb'] = 0x0302;
  14965. t['clear'] = 0x2327;
  14966. t['clickalveolar'] = 0x01C2;
  14967. t['clickdental'] = 0x01C0;
  14968. t['clicklateral'] = 0x01C1;
  14969. t['clickretroflex'] = 0x01C3;
  14970. t['club'] = 0x2663;
  14971. t['clubsuitblack'] = 0x2663;
  14972. t['clubsuitwhite'] = 0x2667;
  14973. t['cmcubedsquare'] = 0x33A4;
  14974. t['cmonospace'] = 0xFF43;
  14975. t['cmsquaredsquare'] = 0x33A0;
  14976. t['coarmenian'] = 0x0581;
  14977. t['colon'] = 0x003A;
  14978. t['colonmonetary'] = 0x20A1;
  14979. t['colonmonospace'] = 0xFF1A;
  14980. t['colonsign'] = 0x20A1;
  14981. t['colonsmall'] = 0xFE55;
  14982. t['colontriangularhalfmod'] = 0x02D1;
  14983. t['colontriangularmod'] = 0x02D0;
  14984. t['comma'] = 0x002C;
  14985. t['commaabovecmb'] = 0x0313;
  14986. t['commaaboverightcmb'] = 0x0315;
  14987. t['commaaccent'] = 0xF6C3;
  14988. t['commaarabic'] = 0x060C;
  14989. t['commaarmenian'] = 0x055D;
  14990. t['commainferior'] = 0xF6E1;
  14991. t['commamonospace'] = 0xFF0C;
  14992. t['commareversedabovecmb'] = 0x0314;
  14993. t['commareversedmod'] = 0x02BD;
  14994. t['commasmall'] = 0xFE50;
  14995. t['commasuperior'] = 0xF6E2;
  14996. t['commaturnedabovecmb'] = 0x0312;
  14997. t['commaturnedmod'] = 0x02BB;
  14998. t['compass'] = 0x263C;
  14999. t['congruent'] = 0x2245;
  15000. t['contourintegral'] = 0x222E;
  15001. t['control'] = 0x2303;
  15002. t['controlACK'] = 0x0006;
  15003. t['controlBEL'] = 0x0007;
  15004. t['controlBS'] = 0x0008;
  15005. t['controlCAN'] = 0x0018;
  15006. t['controlCR'] = 0x000D;
  15007. t['controlDC1'] = 0x0011;
  15008. t['controlDC2'] = 0x0012;
  15009. t['controlDC3'] = 0x0013;
  15010. t['controlDC4'] = 0x0014;
  15011. t['controlDEL'] = 0x007F;
  15012. t['controlDLE'] = 0x0010;
  15013. t['controlEM'] = 0x0019;
  15014. t['controlENQ'] = 0x0005;
  15015. t['controlEOT'] = 0x0004;
  15016. t['controlESC'] = 0x001B;
  15017. t['controlETB'] = 0x0017;
  15018. t['controlETX'] = 0x0003;
  15019. t['controlFF'] = 0x000C;
  15020. t['controlFS'] = 0x001C;
  15021. t['controlGS'] = 0x001D;
  15022. t['controlHT'] = 0x0009;
  15023. t['controlLF'] = 0x000A;
  15024. t['controlNAK'] = 0x0015;
  15025. t['controlNULL'] = 0x0000;
  15026. t['controlRS'] = 0x001E;
  15027. t['controlSI'] = 0x000F;
  15028. t['controlSO'] = 0x000E;
  15029. t['controlSOT'] = 0x0002;
  15030. t['controlSTX'] = 0x0001;
  15031. t['controlSUB'] = 0x001A;
  15032. t['controlSYN'] = 0x0016;
  15033. t['controlUS'] = 0x001F;
  15034. t['controlVT'] = 0x000B;
  15035. t['copyright'] = 0x00A9;
  15036. t['copyrightsans'] = 0xF8E9;
  15037. t['copyrightserif'] = 0xF6D9;
  15038. t['cornerbracketleft'] = 0x300C;
  15039. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15040. t['cornerbracketleftvertical'] = 0xFE41;
  15041. t['cornerbracketright'] = 0x300D;
  15042. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15043. t['cornerbracketrightvertical'] = 0xFE42;
  15044. t['corporationsquare'] = 0x337F;
  15045. t['cosquare'] = 0x33C7;
  15046. t['coverkgsquare'] = 0x33C6;
  15047. t['cparen'] = 0x249E;
  15048. t['cruzeiro'] = 0x20A2;
  15049. t['cstretched'] = 0x0297;
  15050. t['curlyand'] = 0x22CF;
  15051. t['curlyor'] = 0x22CE;
  15052. t['currency'] = 0x00A4;
  15053. t['cyrBreve'] = 0xF6D1;
  15054. t['cyrFlex'] = 0xF6D2;
  15055. t['cyrbreve'] = 0xF6D4;
  15056. t['cyrflex'] = 0xF6D5;
  15057. t['d'] = 0x0064;
  15058. t['daarmenian'] = 0x0564;
  15059. t['dabengali'] = 0x09A6;
  15060. t['dadarabic'] = 0x0636;
  15061. t['dadeva'] = 0x0926;
  15062. t['dadfinalarabic'] = 0xFEBE;
  15063. t['dadinitialarabic'] = 0xFEBF;
  15064. t['dadmedialarabic'] = 0xFEC0;
  15065. t['dagesh'] = 0x05BC;
  15066. t['dageshhebrew'] = 0x05BC;
  15067. t['dagger'] = 0x2020;
  15068. t['daggerdbl'] = 0x2021;
  15069. t['dagujarati'] = 0x0AA6;
  15070. t['dagurmukhi'] = 0x0A26;
  15071. t['dahiragana'] = 0x3060;
  15072. t['dakatakana'] = 0x30C0;
  15073. t['dalarabic'] = 0x062F;
  15074. t['dalet'] = 0x05D3;
  15075. t['daletdagesh'] = 0xFB33;
  15076. t['daletdageshhebrew'] = 0xFB33;
  15077. t['dalethebrew'] = 0x05D3;
  15078. t['dalfinalarabic'] = 0xFEAA;
  15079. t['dammaarabic'] = 0x064F;
  15080. t['dammalowarabic'] = 0x064F;
  15081. t['dammatanaltonearabic'] = 0x064C;
  15082. t['dammatanarabic'] = 0x064C;
  15083. t['danda'] = 0x0964;
  15084. t['dargahebrew'] = 0x05A7;
  15085. t['dargalefthebrew'] = 0x05A7;
  15086. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15087. t['dblGrave'] = 0xF6D3;
  15088. t['dblanglebracketleft'] = 0x300A;
  15089. t['dblanglebracketleftvertical'] = 0xFE3D;
  15090. t['dblanglebracketright'] = 0x300B;
  15091. t['dblanglebracketrightvertical'] = 0xFE3E;
  15092. t['dblarchinvertedbelowcmb'] = 0x032B;
  15093. t['dblarrowleft'] = 0x21D4;
  15094. t['dblarrowright'] = 0x21D2;
  15095. t['dbldanda'] = 0x0965;
  15096. t['dblgrave'] = 0xF6D6;
  15097. t['dblgravecmb'] = 0x030F;
  15098. t['dblintegral'] = 0x222C;
  15099. t['dbllowline'] = 0x2017;
  15100. t['dbllowlinecmb'] = 0x0333;
  15101. t['dbloverlinecmb'] = 0x033F;
  15102. t['dblprimemod'] = 0x02BA;
  15103. t['dblverticalbar'] = 0x2016;
  15104. t['dblverticallineabovecmb'] = 0x030E;
  15105. t['dbopomofo'] = 0x3109;
  15106. t['dbsquare'] = 0x33C8;
  15107. t['dcaron'] = 0x010F;
  15108. t['dcedilla'] = 0x1E11;
  15109. t['dcircle'] = 0x24D3;
  15110. t['dcircumflexbelow'] = 0x1E13;
  15111. t['dcroat'] = 0x0111;
  15112. t['ddabengali'] = 0x09A1;
  15113. t['ddadeva'] = 0x0921;
  15114. t['ddagujarati'] = 0x0AA1;
  15115. t['ddagurmukhi'] = 0x0A21;
  15116. t['ddalarabic'] = 0x0688;
  15117. t['ddalfinalarabic'] = 0xFB89;
  15118. t['dddhadeva'] = 0x095C;
  15119. t['ddhabengali'] = 0x09A2;
  15120. t['ddhadeva'] = 0x0922;
  15121. t['ddhagujarati'] = 0x0AA2;
  15122. t['ddhagurmukhi'] = 0x0A22;
  15123. t['ddotaccent'] = 0x1E0B;
  15124. t['ddotbelow'] = 0x1E0D;
  15125. t['decimalseparatorarabic'] = 0x066B;
  15126. t['decimalseparatorpersian'] = 0x066B;
  15127. t['decyrillic'] = 0x0434;
  15128. t['degree'] = 0x00B0;
  15129. t['dehihebrew'] = 0x05AD;
  15130. t['dehiragana'] = 0x3067;
  15131. t['deicoptic'] = 0x03EF;
  15132. t['dekatakana'] = 0x30C7;
  15133. t['deleteleft'] = 0x232B;
  15134. t['deleteright'] = 0x2326;
  15135. t['delta'] = 0x03B4;
  15136. t['deltaturned'] = 0x018D;
  15137. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15138. t['dezh'] = 0x02A4;
  15139. t['dhabengali'] = 0x09A7;
  15140. t['dhadeva'] = 0x0927;
  15141. t['dhagujarati'] = 0x0AA7;
  15142. t['dhagurmukhi'] = 0x0A27;
  15143. t['dhook'] = 0x0257;
  15144. t['dialytikatonos'] = 0x0385;
  15145. t['dialytikatonoscmb'] = 0x0344;
  15146. t['diamond'] = 0x2666;
  15147. t['diamondsuitwhite'] = 0x2662;
  15148. t['dieresis'] = 0x00A8;
  15149. t['dieresisacute'] = 0xF6D7;
  15150. t['dieresisbelowcmb'] = 0x0324;
  15151. t['dieresiscmb'] = 0x0308;
  15152. t['dieresisgrave'] = 0xF6D8;
  15153. t['dieresistonos'] = 0x0385;
  15154. t['dihiragana'] = 0x3062;
  15155. t['dikatakana'] = 0x30C2;
  15156. t['dittomark'] = 0x3003;
  15157. t['divide'] = 0x00F7;
  15158. t['divides'] = 0x2223;
  15159. t['divisionslash'] = 0x2215;
  15160. t['djecyrillic'] = 0x0452;
  15161. t['dkshade'] = 0x2593;
  15162. t['dlinebelow'] = 0x1E0F;
  15163. t['dlsquare'] = 0x3397;
  15164. t['dmacron'] = 0x0111;
  15165. t['dmonospace'] = 0xFF44;
  15166. t['dnblock'] = 0x2584;
  15167. t['dochadathai'] = 0x0E0E;
  15168. t['dodekthai'] = 0x0E14;
  15169. t['dohiragana'] = 0x3069;
  15170. t['dokatakana'] = 0x30C9;
  15171. t['dollar'] = 0x0024;
  15172. t['dollarinferior'] = 0xF6E3;
  15173. t['dollarmonospace'] = 0xFF04;
  15174. t['dollaroldstyle'] = 0xF724;
  15175. t['dollarsmall'] = 0xFE69;
  15176. t['dollarsuperior'] = 0xF6E4;
  15177. t['dong'] = 0x20AB;
  15178. t['dorusquare'] = 0x3326;
  15179. t['dotaccent'] = 0x02D9;
  15180. t['dotaccentcmb'] = 0x0307;
  15181. t['dotbelowcmb'] = 0x0323;
  15182. t['dotbelowcomb'] = 0x0323;
  15183. t['dotkatakana'] = 0x30FB;
  15184. t['dotlessi'] = 0x0131;
  15185. t['dotlessj'] = 0xF6BE;
  15186. t['dotlessjstrokehook'] = 0x0284;
  15187. t['dotmath'] = 0x22C5;
  15188. t['dottedcircle'] = 0x25CC;
  15189. t['doubleyodpatah'] = 0xFB1F;
  15190. t['doubleyodpatahhebrew'] = 0xFB1F;
  15191. t['downtackbelowcmb'] = 0x031E;
  15192. t['downtackmod'] = 0x02D5;
  15193. t['dparen'] = 0x249F;
  15194. t['dsuperior'] = 0xF6EB;
  15195. t['dtail'] = 0x0256;
  15196. t['dtopbar'] = 0x018C;
  15197. t['duhiragana'] = 0x3065;
  15198. t['dukatakana'] = 0x30C5;
  15199. t['dz'] = 0x01F3;
  15200. t['dzaltone'] = 0x02A3;
  15201. t['dzcaron'] = 0x01C6;
  15202. t['dzcurl'] = 0x02A5;
  15203. t['dzeabkhasiancyrillic'] = 0x04E1;
  15204. t['dzecyrillic'] = 0x0455;
  15205. t['dzhecyrillic'] = 0x045F;
  15206. t['e'] = 0x0065;
  15207. t['eacute'] = 0x00E9;
  15208. t['earth'] = 0x2641;
  15209. t['ebengali'] = 0x098F;
  15210. t['ebopomofo'] = 0x311C;
  15211. t['ebreve'] = 0x0115;
  15212. t['ecandradeva'] = 0x090D;
  15213. t['ecandragujarati'] = 0x0A8D;
  15214. t['ecandravowelsigndeva'] = 0x0945;
  15215. t['ecandravowelsigngujarati'] = 0x0AC5;
  15216. t['ecaron'] = 0x011B;
  15217. t['ecedillabreve'] = 0x1E1D;
  15218. t['echarmenian'] = 0x0565;
  15219. t['echyiwnarmenian'] = 0x0587;
  15220. t['ecircle'] = 0x24D4;
  15221. t['ecircumflex'] = 0x00EA;
  15222. t['ecircumflexacute'] = 0x1EBF;
  15223. t['ecircumflexbelow'] = 0x1E19;
  15224. t['ecircumflexdotbelow'] = 0x1EC7;
  15225. t['ecircumflexgrave'] = 0x1EC1;
  15226. t['ecircumflexhookabove'] = 0x1EC3;
  15227. t['ecircumflextilde'] = 0x1EC5;
  15228. t['ecyrillic'] = 0x0454;
  15229. t['edblgrave'] = 0x0205;
  15230. t['edeva'] = 0x090F;
  15231. t['edieresis'] = 0x00EB;
  15232. t['edot'] = 0x0117;
  15233. t['edotaccent'] = 0x0117;
  15234. t['edotbelow'] = 0x1EB9;
  15235. t['eegurmukhi'] = 0x0A0F;
  15236. t['eematragurmukhi'] = 0x0A47;
  15237. t['efcyrillic'] = 0x0444;
  15238. t['egrave'] = 0x00E8;
  15239. t['egujarati'] = 0x0A8F;
  15240. t['eharmenian'] = 0x0567;
  15241. t['ehbopomofo'] = 0x311D;
  15242. t['ehiragana'] = 0x3048;
  15243. t['ehookabove'] = 0x1EBB;
  15244. t['eibopomofo'] = 0x311F;
  15245. t['eight'] = 0x0038;
  15246. t['eightarabic'] = 0x0668;
  15247. t['eightbengali'] = 0x09EE;
  15248. t['eightcircle'] = 0x2467;
  15249. t['eightcircleinversesansserif'] = 0x2791;
  15250. t['eightdeva'] = 0x096E;
  15251. t['eighteencircle'] = 0x2471;
  15252. t['eighteenparen'] = 0x2485;
  15253. t['eighteenperiod'] = 0x2499;
  15254. t['eightgujarati'] = 0x0AEE;
  15255. t['eightgurmukhi'] = 0x0A6E;
  15256. t['eighthackarabic'] = 0x0668;
  15257. t['eighthangzhou'] = 0x3028;
  15258. t['eighthnotebeamed'] = 0x266B;
  15259. t['eightideographicparen'] = 0x3227;
  15260. t['eightinferior'] = 0x2088;
  15261. t['eightmonospace'] = 0xFF18;
  15262. t['eightoldstyle'] = 0xF738;
  15263. t['eightparen'] = 0x247B;
  15264. t['eightperiod'] = 0x248F;
  15265. t['eightpersian'] = 0x06F8;
  15266. t['eightroman'] = 0x2177;
  15267. t['eightsuperior'] = 0x2078;
  15268. t['eightthai'] = 0x0E58;
  15269. t['einvertedbreve'] = 0x0207;
  15270. t['eiotifiedcyrillic'] = 0x0465;
  15271. t['ekatakana'] = 0x30A8;
  15272. t['ekatakanahalfwidth'] = 0xFF74;
  15273. t['ekonkargurmukhi'] = 0x0A74;
  15274. t['ekorean'] = 0x3154;
  15275. t['elcyrillic'] = 0x043B;
  15276. t['element'] = 0x2208;
  15277. t['elevencircle'] = 0x246A;
  15278. t['elevenparen'] = 0x247E;
  15279. t['elevenperiod'] = 0x2492;
  15280. t['elevenroman'] = 0x217A;
  15281. t['ellipsis'] = 0x2026;
  15282. t['ellipsisvertical'] = 0x22EE;
  15283. t['emacron'] = 0x0113;
  15284. t['emacronacute'] = 0x1E17;
  15285. t['emacrongrave'] = 0x1E15;
  15286. t['emcyrillic'] = 0x043C;
  15287. t['emdash'] = 0x2014;
  15288. t['emdashvertical'] = 0xFE31;
  15289. t['emonospace'] = 0xFF45;
  15290. t['emphasismarkarmenian'] = 0x055B;
  15291. t['emptyset'] = 0x2205;
  15292. t['enbopomofo'] = 0x3123;
  15293. t['encyrillic'] = 0x043D;
  15294. t['endash'] = 0x2013;
  15295. t['endashvertical'] = 0xFE32;
  15296. t['endescendercyrillic'] = 0x04A3;
  15297. t['eng'] = 0x014B;
  15298. t['engbopomofo'] = 0x3125;
  15299. t['enghecyrillic'] = 0x04A5;
  15300. t['enhookcyrillic'] = 0x04C8;
  15301. t['enspace'] = 0x2002;
  15302. t['eogonek'] = 0x0119;
  15303. t['eokorean'] = 0x3153;
  15304. t['eopen'] = 0x025B;
  15305. t['eopenclosed'] = 0x029A;
  15306. t['eopenreversed'] = 0x025C;
  15307. t['eopenreversedclosed'] = 0x025E;
  15308. t['eopenreversedhook'] = 0x025D;
  15309. t['eparen'] = 0x24A0;
  15310. t['epsilon'] = 0x03B5;
  15311. t['epsilontonos'] = 0x03AD;
  15312. t['equal'] = 0x003D;
  15313. t['equalmonospace'] = 0xFF1D;
  15314. t['equalsmall'] = 0xFE66;
  15315. t['equalsuperior'] = 0x207C;
  15316. t['equivalence'] = 0x2261;
  15317. t['erbopomofo'] = 0x3126;
  15318. t['ercyrillic'] = 0x0440;
  15319. t['ereversed'] = 0x0258;
  15320. t['ereversedcyrillic'] = 0x044D;
  15321. t['escyrillic'] = 0x0441;
  15322. t['esdescendercyrillic'] = 0x04AB;
  15323. t['esh'] = 0x0283;
  15324. t['eshcurl'] = 0x0286;
  15325. t['eshortdeva'] = 0x090E;
  15326. t['eshortvowelsigndeva'] = 0x0946;
  15327. t['eshreversedloop'] = 0x01AA;
  15328. t['eshsquatreversed'] = 0x0285;
  15329. t['esmallhiragana'] = 0x3047;
  15330. t['esmallkatakana'] = 0x30A7;
  15331. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15332. t['estimated'] = 0x212E;
  15333. t['esuperior'] = 0xF6EC;
  15334. t['eta'] = 0x03B7;
  15335. t['etarmenian'] = 0x0568;
  15336. t['etatonos'] = 0x03AE;
  15337. t['eth'] = 0x00F0;
  15338. t['etilde'] = 0x1EBD;
  15339. t['etildebelow'] = 0x1E1B;
  15340. t['etnahtafoukhhebrew'] = 0x0591;
  15341. t['etnahtafoukhlefthebrew'] = 0x0591;
  15342. t['etnahtahebrew'] = 0x0591;
  15343. t['etnahtalefthebrew'] = 0x0591;
  15344. t['eturned'] = 0x01DD;
  15345. t['eukorean'] = 0x3161;
  15346. t['euro'] = 0x20AC;
  15347. t['evowelsignbengali'] = 0x09C7;
  15348. t['evowelsigndeva'] = 0x0947;
  15349. t['evowelsigngujarati'] = 0x0AC7;
  15350. t['exclam'] = 0x0021;
  15351. t['exclamarmenian'] = 0x055C;
  15352. t['exclamdbl'] = 0x203C;
  15353. t['exclamdown'] = 0x00A1;
  15354. t['exclamdownsmall'] = 0xF7A1;
  15355. t['exclammonospace'] = 0xFF01;
  15356. t['exclamsmall'] = 0xF721;
  15357. t['existential'] = 0x2203;
  15358. t['ezh'] = 0x0292;
  15359. t['ezhcaron'] = 0x01EF;
  15360. t['ezhcurl'] = 0x0293;
  15361. t['ezhreversed'] = 0x01B9;
  15362. t['ezhtail'] = 0x01BA;
  15363. t['f'] = 0x0066;
  15364. t['fadeva'] = 0x095E;
  15365. t['fagurmukhi'] = 0x0A5E;
  15366. t['fahrenheit'] = 0x2109;
  15367. t['fathaarabic'] = 0x064E;
  15368. t['fathalowarabic'] = 0x064E;
  15369. t['fathatanarabic'] = 0x064B;
  15370. t['fbopomofo'] = 0x3108;
  15371. t['fcircle'] = 0x24D5;
  15372. t['fdotaccent'] = 0x1E1F;
  15373. t['feharabic'] = 0x0641;
  15374. t['feharmenian'] = 0x0586;
  15375. t['fehfinalarabic'] = 0xFED2;
  15376. t['fehinitialarabic'] = 0xFED3;
  15377. t['fehmedialarabic'] = 0xFED4;
  15378. t['feicoptic'] = 0x03E5;
  15379. t['female'] = 0x2640;
  15380. t['ff'] = 0xFB00;
  15381. t['ffi'] = 0xFB03;
  15382. t['ffl'] = 0xFB04;
  15383. t['fi'] = 0xFB01;
  15384. t['fifteencircle'] = 0x246E;
  15385. t['fifteenparen'] = 0x2482;
  15386. t['fifteenperiod'] = 0x2496;
  15387. t['figuredash'] = 0x2012;
  15388. t['filledbox'] = 0x25A0;
  15389. t['filledrect'] = 0x25AC;
  15390. t['finalkaf'] = 0x05DA;
  15391. t['finalkafdagesh'] = 0xFB3A;
  15392. t['finalkafdageshhebrew'] = 0xFB3A;
  15393. t['finalkafhebrew'] = 0x05DA;
  15394. t['finalmem'] = 0x05DD;
  15395. t['finalmemhebrew'] = 0x05DD;
  15396. t['finalnun'] = 0x05DF;
  15397. t['finalnunhebrew'] = 0x05DF;
  15398. t['finalpe'] = 0x05E3;
  15399. t['finalpehebrew'] = 0x05E3;
  15400. t['finaltsadi'] = 0x05E5;
  15401. t['finaltsadihebrew'] = 0x05E5;
  15402. t['firsttonechinese'] = 0x02C9;
  15403. t['fisheye'] = 0x25C9;
  15404. t['fitacyrillic'] = 0x0473;
  15405. t['five'] = 0x0035;
  15406. t['fivearabic'] = 0x0665;
  15407. t['fivebengali'] = 0x09EB;
  15408. t['fivecircle'] = 0x2464;
  15409. t['fivecircleinversesansserif'] = 0x278E;
  15410. t['fivedeva'] = 0x096B;
  15411. t['fiveeighths'] = 0x215D;
  15412. t['fivegujarati'] = 0x0AEB;
  15413. t['fivegurmukhi'] = 0x0A6B;
  15414. t['fivehackarabic'] = 0x0665;
  15415. t['fivehangzhou'] = 0x3025;
  15416. t['fiveideographicparen'] = 0x3224;
  15417. t['fiveinferior'] = 0x2085;
  15418. t['fivemonospace'] = 0xFF15;
  15419. t['fiveoldstyle'] = 0xF735;
  15420. t['fiveparen'] = 0x2478;
  15421. t['fiveperiod'] = 0x248C;
  15422. t['fivepersian'] = 0x06F5;
  15423. t['fiveroman'] = 0x2174;
  15424. t['fivesuperior'] = 0x2075;
  15425. t['fivethai'] = 0x0E55;
  15426. t['fl'] = 0xFB02;
  15427. t['florin'] = 0x0192;
  15428. t['fmonospace'] = 0xFF46;
  15429. t['fmsquare'] = 0x3399;
  15430. t['fofanthai'] = 0x0E1F;
  15431. t['fofathai'] = 0x0E1D;
  15432. t['fongmanthai'] = 0x0E4F;
  15433. t['forall'] = 0x2200;
  15434. t['four'] = 0x0034;
  15435. t['fourarabic'] = 0x0664;
  15436. t['fourbengali'] = 0x09EA;
  15437. t['fourcircle'] = 0x2463;
  15438. t['fourcircleinversesansserif'] = 0x278D;
  15439. t['fourdeva'] = 0x096A;
  15440. t['fourgujarati'] = 0x0AEA;
  15441. t['fourgurmukhi'] = 0x0A6A;
  15442. t['fourhackarabic'] = 0x0664;
  15443. t['fourhangzhou'] = 0x3024;
  15444. t['fourideographicparen'] = 0x3223;
  15445. t['fourinferior'] = 0x2084;
  15446. t['fourmonospace'] = 0xFF14;
  15447. t['fournumeratorbengali'] = 0x09F7;
  15448. t['fouroldstyle'] = 0xF734;
  15449. t['fourparen'] = 0x2477;
  15450. t['fourperiod'] = 0x248B;
  15451. t['fourpersian'] = 0x06F4;
  15452. t['fourroman'] = 0x2173;
  15453. t['foursuperior'] = 0x2074;
  15454. t['fourteencircle'] = 0x246D;
  15455. t['fourteenparen'] = 0x2481;
  15456. t['fourteenperiod'] = 0x2495;
  15457. t['fourthai'] = 0x0E54;
  15458. t['fourthtonechinese'] = 0x02CB;
  15459. t['fparen'] = 0x24A1;
  15460. t['fraction'] = 0x2044;
  15461. t['franc'] = 0x20A3;
  15462. t['g'] = 0x0067;
  15463. t['gabengali'] = 0x0997;
  15464. t['gacute'] = 0x01F5;
  15465. t['gadeva'] = 0x0917;
  15466. t['gafarabic'] = 0x06AF;
  15467. t['gaffinalarabic'] = 0xFB93;
  15468. t['gafinitialarabic'] = 0xFB94;
  15469. t['gafmedialarabic'] = 0xFB95;
  15470. t['gagujarati'] = 0x0A97;
  15471. t['gagurmukhi'] = 0x0A17;
  15472. t['gahiragana'] = 0x304C;
  15473. t['gakatakana'] = 0x30AC;
  15474. t['gamma'] = 0x03B3;
  15475. t['gammalatinsmall'] = 0x0263;
  15476. t['gammasuperior'] = 0x02E0;
  15477. t['gangiacoptic'] = 0x03EB;
  15478. t['gbopomofo'] = 0x310D;
  15479. t['gbreve'] = 0x011F;
  15480. t['gcaron'] = 0x01E7;
  15481. t['gcedilla'] = 0x0123;
  15482. t['gcircle'] = 0x24D6;
  15483. t['gcircumflex'] = 0x011D;
  15484. t['gcommaaccent'] = 0x0123;
  15485. t['gdot'] = 0x0121;
  15486. t['gdotaccent'] = 0x0121;
  15487. t['gecyrillic'] = 0x0433;
  15488. t['gehiragana'] = 0x3052;
  15489. t['gekatakana'] = 0x30B2;
  15490. t['geometricallyequal'] = 0x2251;
  15491. t['gereshaccenthebrew'] = 0x059C;
  15492. t['gereshhebrew'] = 0x05F3;
  15493. t['gereshmuqdamhebrew'] = 0x059D;
  15494. t['germandbls'] = 0x00DF;
  15495. t['gershayimaccenthebrew'] = 0x059E;
  15496. t['gershayimhebrew'] = 0x05F4;
  15497. t['getamark'] = 0x3013;
  15498. t['ghabengali'] = 0x0998;
  15499. t['ghadarmenian'] = 0x0572;
  15500. t['ghadeva'] = 0x0918;
  15501. t['ghagujarati'] = 0x0A98;
  15502. t['ghagurmukhi'] = 0x0A18;
  15503. t['ghainarabic'] = 0x063A;
  15504. t['ghainfinalarabic'] = 0xFECE;
  15505. t['ghaininitialarabic'] = 0xFECF;
  15506. t['ghainmedialarabic'] = 0xFED0;
  15507. t['ghemiddlehookcyrillic'] = 0x0495;
  15508. t['ghestrokecyrillic'] = 0x0493;
  15509. t['gheupturncyrillic'] = 0x0491;
  15510. t['ghhadeva'] = 0x095A;
  15511. t['ghhagurmukhi'] = 0x0A5A;
  15512. t['ghook'] = 0x0260;
  15513. t['ghzsquare'] = 0x3393;
  15514. t['gihiragana'] = 0x304E;
  15515. t['gikatakana'] = 0x30AE;
  15516. t['gimarmenian'] = 0x0563;
  15517. t['gimel'] = 0x05D2;
  15518. t['gimeldagesh'] = 0xFB32;
  15519. t['gimeldageshhebrew'] = 0xFB32;
  15520. t['gimelhebrew'] = 0x05D2;
  15521. t['gjecyrillic'] = 0x0453;
  15522. t['glottalinvertedstroke'] = 0x01BE;
  15523. t['glottalstop'] = 0x0294;
  15524. t['glottalstopinverted'] = 0x0296;
  15525. t['glottalstopmod'] = 0x02C0;
  15526. t['glottalstopreversed'] = 0x0295;
  15527. t['glottalstopreversedmod'] = 0x02C1;
  15528. t['glottalstopreversedsuperior'] = 0x02E4;
  15529. t['glottalstopstroke'] = 0x02A1;
  15530. t['glottalstopstrokereversed'] = 0x02A2;
  15531. t['gmacron'] = 0x1E21;
  15532. t['gmonospace'] = 0xFF47;
  15533. t['gohiragana'] = 0x3054;
  15534. t['gokatakana'] = 0x30B4;
  15535. t['gparen'] = 0x24A2;
  15536. t['gpasquare'] = 0x33AC;
  15537. t['gradient'] = 0x2207;
  15538. t['grave'] = 0x0060;
  15539. t['gravebelowcmb'] = 0x0316;
  15540. t['gravecmb'] = 0x0300;
  15541. t['gravecomb'] = 0x0300;
  15542. t['gravedeva'] = 0x0953;
  15543. t['gravelowmod'] = 0x02CE;
  15544. t['gravemonospace'] = 0xFF40;
  15545. t['gravetonecmb'] = 0x0340;
  15546. t['greater'] = 0x003E;
  15547. t['greaterequal'] = 0x2265;
  15548. t['greaterequalorless'] = 0x22DB;
  15549. t['greatermonospace'] = 0xFF1E;
  15550. t['greaterorequivalent'] = 0x2273;
  15551. t['greaterorless'] = 0x2277;
  15552. t['greateroverequal'] = 0x2267;
  15553. t['greatersmall'] = 0xFE65;
  15554. t['gscript'] = 0x0261;
  15555. t['gstroke'] = 0x01E5;
  15556. t['guhiragana'] = 0x3050;
  15557. t['guillemotleft'] = 0x00AB;
  15558. t['guillemotright'] = 0x00BB;
  15559. t['guilsinglleft'] = 0x2039;
  15560. t['guilsinglright'] = 0x203A;
  15561. t['gukatakana'] = 0x30B0;
  15562. t['guramusquare'] = 0x3318;
  15563. t['gysquare'] = 0x33C9;
  15564. t['h'] = 0x0068;
  15565. t['haabkhasiancyrillic'] = 0x04A9;
  15566. t['haaltonearabic'] = 0x06C1;
  15567. t['habengali'] = 0x09B9;
  15568. t['hadescendercyrillic'] = 0x04B3;
  15569. t['hadeva'] = 0x0939;
  15570. t['hagujarati'] = 0x0AB9;
  15571. t['hagurmukhi'] = 0x0A39;
  15572. t['haharabic'] = 0x062D;
  15573. t['hahfinalarabic'] = 0xFEA2;
  15574. t['hahinitialarabic'] = 0xFEA3;
  15575. t['hahiragana'] = 0x306F;
  15576. t['hahmedialarabic'] = 0xFEA4;
  15577. t['haitusquare'] = 0x332A;
  15578. t['hakatakana'] = 0x30CF;
  15579. t['hakatakanahalfwidth'] = 0xFF8A;
  15580. t['halantgurmukhi'] = 0x0A4D;
  15581. t['hamzaarabic'] = 0x0621;
  15582. t['hamzalowarabic'] = 0x0621;
  15583. t['hangulfiller'] = 0x3164;
  15584. t['hardsigncyrillic'] = 0x044A;
  15585. t['harpoonleftbarbup'] = 0x21BC;
  15586. t['harpoonrightbarbup'] = 0x21C0;
  15587. t['hasquare'] = 0x33CA;
  15588. t['hatafpatah'] = 0x05B2;
  15589. t['hatafpatah16'] = 0x05B2;
  15590. t['hatafpatah23'] = 0x05B2;
  15591. t['hatafpatah2f'] = 0x05B2;
  15592. t['hatafpatahhebrew'] = 0x05B2;
  15593. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15594. t['hatafpatahquarterhebrew'] = 0x05B2;
  15595. t['hatafpatahwidehebrew'] = 0x05B2;
  15596. t['hatafqamats'] = 0x05B3;
  15597. t['hatafqamats1b'] = 0x05B3;
  15598. t['hatafqamats28'] = 0x05B3;
  15599. t['hatafqamats34'] = 0x05B3;
  15600. t['hatafqamatshebrew'] = 0x05B3;
  15601. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15602. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15603. t['hatafqamatswidehebrew'] = 0x05B3;
  15604. t['hatafsegol'] = 0x05B1;
  15605. t['hatafsegol17'] = 0x05B1;
  15606. t['hatafsegol24'] = 0x05B1;
  15607. t['hatafsegol30'] = 0x05B1;
  15608. t['hatafsegolhebrew'] = 0x05B1;
  15609. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15610. t['hatafsegolquarterhebrew'] = 0x05B1;
  15611. t['hatafsegolwidehebrew'] = 0x05B1;
  15612. t['hbar'] = 0x0127;
  15613. t['hbopomofo'] = 0x310F;
  15614. t['hbrevebelow'] = 0x1E2B;
  15615. t['hcedilla'] = 0x1E29;
  15616. t['hcircle'] = 0x24D7;
  15617. t['hcircumflex'] = 0x0125;
  15618. t['hdieresis'] = 0x1E27;
  15619. t['hdotaccent'] = 0x1E23;
  15620. t['hdotbelow'] = 0x1E25;
  15621. t['he'] = 0x05D4;
  15622. t['heart'] = 0x2665;
  15623. t['heartsuitblack'] = 0x2665;
  15624. t['heartsuitwhite'] = 0x2661;
  15625. t['hedagesh'] = 0xFB34;
  15626. t['hedageshhebrew'] = 0xFB34;
  15627. t['hehaltonearabic'] = 0x06C1;
  15628. t['heharabic'] = 0x0647;
  15629. t['hehebrew'] = 0x05D4;
  15630. t['hehfinalaltonearabic'] = 0xFBA7;
  15631. t['hehfinalalttwoarabic'] = 0xFEEA;
  15632. t['hehfinalarabic'] = 0xFEEA;
  15633. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15634. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15635. t['hehinitialaltonearabic'] = 0xFBA8;
  15636. t['hehinitialarabic'] = 0xFEEB;
  15637. t['hehiragana'] = 0x3078;
  15638. t['hehmedialaltonearabic'] = 0xFBA9;
  15639. t['hehmedialarabic'] = 0xFEEC;
  15640. t['heiseierasquare'] = 0x337B;
  15641. t['hekatakana'] = 0x30D8;
  15642. t['hekatakanahalfwidth'] = 0xFF8D;
  15643. t['hekutaarusquare'] = 0x3336;
  15644. t['henghook'] = 0x0267;
  15645. t['herutusquare'] = 0x3339;
  15646. t['het'] = 0x05D7;
  15647. t['hethebrew'] = 0x05D7;
  15648. t['hhook'] = 0x0266;
  15649. t['hhooksuperior'] = 0x02B1;
  15650. t['hieuhacirclekorean'] = 0x327B;
  15651. t['hieuhaparenkorean'] = 0x321B;
  15652. t['hieuhcirclekorean'] = 0x326D;
  15653. t['hieuhkorean'] = 0x314E;
  15654. t['hieuhparenkorean'] = 0x320D;
  15655. t['hihiragana'] = 0x3072;
  15656. t['hikatakana'] = 0x30D2;
  15657. t['hikatakanahalfwidth'] = 0xFF8B;
  15658. t['hiriq'] = 0x05B4;
  15659. t['hiriq14'] = 0x05B4;
  15660. t['hiriq21'] = 0x05B4;
  15661. t['hiriq2d'] = 0x05B4;
  15662. t['hiriqhebrew'] = 0x05B4;
  15663. t['hiriqnarrowhebrew'] = 0x05B4;
  15664. t['hiriqquarterhebrew'] = 0x05B4;
  15665. t['hiriqwidehebrew'] = 0x05B4;
  15666. t['hlinebelow'] = 0x1E96;
  15667. t['hmonospace'] = 0xFF48;
  15668. t['hoarmenian'] = 0x0570;
  15669. t['hohipthai'] = 0x0E2B;
  15670. t['hohiragana'] = 0x307B;
  15671. t['hokatakana'] = 0x30DB;
  15672. t['hokatakanahalfwidth'] = 0xFF8E;
  15673. t['holam'] = 0x05B9;
  15674. t['holam19'] = 0x05B9;
  15675. t['holam26'] = 0x05B9;
  15676. t['holam32'] = 0x05B9;
  15677. t['holamhebrew'] = 0x05B9;
  15678. t['holamnarrowhebrew'] = 0x05B9;
  15679. t['holamquarterhebrew'] = 0x05B9;
  15680. t['holamwidehebrew'] = 0x05B9;
  15681. t['honokhukthai'] = 0x0E2E;
  15682. t['hookabovecomb'] = 0x0309;
  15683. t['hookcmb'] = 0x0309;
  15684. t['hookpalatalizedbelowcmb'] = 0x0321;
  15685. t['hookretroflexbelowcmb'] = 0x0322;
  15686. t['hoonsquare'] = 0x3342;
  15687. t['horicoptic'] = 0x03E9;
  15688. t['horizontalbar'] = 0x2015;
  15689. t['horncmb'] = 0x031B;
  15690. t['hotsprings'] = 0x2668;
  15691. t['house'] = 0x2302;
  15692. t['hparen'] = 0x24A3;
  15693. t['hsuperior'] = 0x02B0;
  15694. t['hturned'] = 0x0265;
  15695. t['huhiragana'] = 0x3075;
  15696. t['huiitosquare'] = 0x3333;
  15697. t['hukatakana'] = 0x30D5;
  15698. t['hukatakanahalfwidth'] = 0xFF8C;
  15699. t['hungarumlaut'] = 0x02DD;
  15700. t['hungarumlautcmb'] = 0x030B;
  15701. t['hv'] = 0x0195;
  15702. t['hyphen'] = 0x002D;
  15703. t['hypheninferior'] = 0xF6E5;
  15704. t['hyphenmonospace'] = 0xFF0D;
  15705. t['hyphensmall'] = 0xFE63;
  15706. t['hyphensuperior'] = 0xF6E6;
  15707. t['hyphentwo'] = 0x2010;
  15708. t['i'] = 0x0069;
  15709. t['iacute'] = 0x00ED;
  15710. t['iacyrillic'] = 0x044F;
  15711. t['ibengali'] = 0x0987;
  15712. t['ibopomofo'] = 0x3127;
  15713. t['ibreve'] = 0x012D;
  15714. t['icaron'] = 0x01D0;
  15715. t['icircle'] = 0x24D8;
  15716. t['icircumflex'] = 0x00EE;
  15717. t['icyrillic'] = 0x0456;
  15718. t['idblgrave'] = 0x0209;
  15719. t['ideographearthcircle'] = 0x328F;
  15720. t['ideographfirecircle'] = 0x328B;
  15721. t['ideographicallianceparen'] = 0x323F;
  15722. t['ideographiccallparen'] = 0x323A;
  15723. t['ideographiccentrecircle'] = 0x32A5;
  15724. t['ideographicclose'] = 0x3006;
  15725. t['ideographiccomma'] = 0x3001;
  15726. t['ideographiccommaleft'] = 0xFF64;
  15727. t['ideographiccongratulationparen'] = 0x3237;
  15728. t['ideographiccorrectcircle'] = 0x32A3;
  15729. t['ideographicearthparen'] = 0x322F;
  15730. t['ideographicenterpriseparen'] = 0x323D;
  15731. t['ideographicexcellentcircle'] = 0x329D;
  15732. t['ideographicfestivalparen'] = 0x3240;
  15733. t['ideographicfinancialcircle'] = 0x3296;
  15734. t['ideographicfinancialparen'] = 0x3236;
  15735. t['ideographicfireparen'] = 0x322B;
  15736. t['ideographichaveparen'] = 0x3232;
  15737. t['ideographichighcircle'] = 0x32A4;
  15738. t['ideographiciterationmark'] = 0x3005;
  15739. t['ideographiclaborcircle'] = 0x3298;
  15740. t['ideographiclaborparen'] = 0x3238;
  15741. t['ideographicleftcircle'] = 0x32A7;
  15742. t['ideographiclowcircle'] = 0x32A6;
  15743. t['ideographicmedicinecircle'] = 0x32A9;
  15744. t['ideographicmetalparen'] = 0x322E;
  15745. t['ideographicmoonparen'] = 0x322A;
  15746. t['ideographicnameparen'] = 0x3234;
  15747. t['ideographicperiod'] = 0x3002;
  15748. t['ideographicprintcircle'] = 0x329E;
  15749. t['ideographicreachparen'] = 0x3243;
  15750. t['ideographicrepresentparen'] = 0x3239;
  15751. t['ideographicresourceparen'] = 0x323E;
  15752. t['ideographicrightcircle'] = 0x32A8;
  15753. t['ideographicsecretcircle'] = 0x3299;
  15754. t['ideographicselfparen'] = 0x3242;
  15755. t['ideographicsocietyparen'] = 0x3233;
  15756. t['ideographicspace'] = 0x3000;
  15757. t['ideographicspecialparen'] = 0x3235;
  15758. t['ideographicstockparen'] = 0x3231;
  15759. t['ideographicstudyparen'] = 0x323B;
  15760. t['ideographicsunparen'] = 0x3230;
  15761. t['ideographicsuperviseparen'] = 0x323C;
  15762. t['ideographicwaterparen'] = 0x322C;
  15763. t['ideographicwoodparen'] = 0x322D;
  15764. t['ideographiczero'] = 0x3007;
  15765. t['ideographmetalcircle'] = 0x328E;
  15766. t['ideographmooncircle'] = 0x328A;
  15767. t['ideographnamecircle'] = 0x3294;
  15768. t['ideographsuncircle'] = 0x3290;
  15769. t['ideographwatercircle'] = 0x328C;
  15770. t['ideographwoodcircle'] = 0x328D;
  15771. t['ideva'] = 0x0907;
  15772. t['idieresis'] = 0x00EF;
  15773. t['idieresisacute'] = 0x1E2F;
  15774. t['idieresiscyrillic'] = 0x04E5;
  15775. t['idotbelow'] = 0x1ECB;
  15776. t['iebrevecyrillic'] = 0x04D7;
  15777. t['iecyrillic'] = 0x0435;
  15778. t['ieungacirclekorean'] = 0x3275;
  15779. t['ieungaparenkorean'] = 0x3215;
  15780. t['ieungcirclekorean'] = 0x3267;
  15781. t['ieungkorean'] = 0x3147;
  15782. t['ieungparenkorean'] = 0x3207;
  15783. t['igrave'] = 0x00EC;
  15784. t['igujarati'] = 0x0A87;
  15785. t['igurmukhi'] = 0x0A07;
  15786. t['ihiragana'] = 0x3044;
  15787. t['ihookabove'] = 0x1EC9;
  15788. t['iibengali'] = 0x0988;
  15789. t['iicyrillic'] = 0x0438;
  15790. t['iideva'] = 0x0908;
  15791. t['iigujarati'] = 0x0A88;
  15792. t['iigurmukhi'] = 0x0A08;
  15793. t['iimatragurmukhi'] = 0x0A40;
  15794. t['iinvertedbreve'] = 0x020B;
  15795. t['iishortcyrillic'] = 0x0439;
  15796. t['iivowelsignbengali'] = 0x09C0;
  15797. t['iivowelsigndeva'] = 0x0940;
  15798. t['iivowelsigngujarati'] = 0x0AC0;
  15799. t['ij'] = 0x0133;
  15800. t['ikatakana'] = 0x30A4;
  15801. t['ikatakanahalfwidth'] = 0xFF72;
  15802. t['ikorean'] = 0x3163;
  15803. t['ilde'] = 0x02DC;
  15804. t['iluyhebrew'] = 0x05AC;
  15805. t['imacron'] = 0x012B;
  15806. t['imacroncyrillic'] = 0x04E3;
  15807. t['imageorapproximatelyequal'] = 0x2253;
  15808. t['imatragurmukhi'] = 0x0A3F;
  15809. t['imonospace'] = 0xFF49;
  15810. t['increment'] = 0x2206;
  15811. t['infinity'] = 0x221E;
  15812. t['iniarmenian'] = 0x056B;
  15813. t['integral'] = 0x222B;
  15814. t['integralbottom'] = 0x2321;
  15815. t['integralbt'] = 0x2321;
  15816. t['integralex'] = 0xF8F5;
  15817. t['integraltop'] = 0x2320;
  15818. t['integraltp'] = 0x2320;
  15819. t['intersection'] = 0x2229;
  15820. t['intisquare'] = 0x3305;
  15821. t['invbullet'] = 0x25D8;
  15822. t['invcircle'] = 0x25D9;
  15823. t['invsmileface'] = 0x263B;
  15824. t['iocyrillic'] = 0x0451;
  15825. t['iogonek'] = 0x012F;
  15826. t['iota'] = 0x03B9;
  15827. t['iotadieresis'] = 0x03CA;
  15828. t['iotadieresistonos'] = 0x0390;
  15829. t['iotalatin'] = 0x0269;
  15830. t['iotatonos'] = 0x03AF;
  15831. t['iparen'] = 0x24A4;
  15832. t['irigurmukhi'] = 0x0A72;
  15833. t['ismallhiragana'] = 0x3043;
  15834. t['ismallkatakana'] = 0x30A3;
  15835. t['ismallkatakanahalfwidth'] = 0xFF68;
  15836. t['issharbengali'] = 0x09FA;
  15837. t['istroke'] = 0x0268;
  15838. t['isuperior'] = 0xF6ED;
  15839. t['iterationhiragana'] = 0x309D;
  15840. t['iterationkatakana'] = 0x30FD;
  15841. t['itilde'] = 0x0129;
  15842. t['itildebelow'] = 0x1E2D;
  15843. t['iubopomofo'] = 0x3129;
  15844. t['iucyrillic'] = 0x044E;
  15845. t['ivowelsignbengali'] = 0x09BF;
  15846. t['ivowelsigndeva'] = 0x093F;
  15847. t['ivowelsigngujarati'] = 0x0ABF;
  15848. t['izhitsacyrillic'] = 0x0475;
  15849. t['izhitsadblgravecyrillic'] = 0x0477;
  15850. t['j'] = 0x006A;
  15851. t['jaarmenian'] = 0x0571;
  15852. t['jabengali'] = 0x099C;
  15853. t['jadeva'] = 0x091C;
  15854. t['jagujarati'] = 0x0A9C;
  15855. t['jagurmukhi'] = 0x0A1C;
  15856. t['jbopomofo'] = 0x3110;
  15857. t['jcaron'] = 0x01F0;
  15858. t['jcircle'] = 0x24D9;
  15859. t['jcircumflex'] = 0x0135;
  15860. t['jcrossedtail'] = 0x029D;
  15861. t['jdotlessstroke'] = 0x025F;
  15862. t['jecyrillic'] = 0x0458;
  15863. t['jeemarabic'] = 0x062C;
  15864. t['jeemfinalarabic'] = 0xFE9E;
  15865. t['jeeminitialarabic'] = 0xFE9F;
  15866. t['jeemmedialarabic'] = 0xFEA0;
  15867. t['jeharabic'] = 0x0698;
  15868. t['jehfinalarabic'] = 0xFB8B;
  15869. t['jhabengali'] = 0x099D;
  15870. t['jhadeva'] = 0x091D;
  15871. t['jhagujarati'] = 0x0A9D;
  15872. t['jhagurmukhi'] = 0x0A1D;
  15873. t['jheharmenian'] = 0x057B;
  15874. t['jis'] = 0x3004;
  15875. t['jmonospace'] = 0xFF4A;
  15876. t['jparen'] = 0x24A5;
  15877. t['jsuperior'] = 0x02B2;
  15878. t['k'] = 0x006B;
  15879. t['kabashkircyrillic'] = 0x04A1;
  15880. t['kabengali'] = 0x0995;
  15881. t['kacute'] = 0x1E31;
  15882. t['kacyrillic'] = 0x043A;
  15883. t['kadescendercyrillic'] = 0x049B;
  15884. t['kadeva'] = 0x0915;
  15885. t['kaf'] = 0x05DB;
  15886. t['kafarabic'] = 0x0643;
  15887. t['kafdagesh'] = 0xFB3B;
  15888. t['kafdageshhebrew'] = 0xFB3B;
  15889. t['kaffinalarabic'] = 0xFEDA;
  15890. t['kafhebrew'] = 0x05DB;
  15891. t['kafinitialarabic'] = 0xFEDB;
  15892. t['kafmedialarabic'] = 0xFEDC;
  15893. t['kafrafehebrew'] = 0xFB4D;
  15894. t['kagujarati'] = 0x0A95;
  15895. t['kagurmukhi'] = 0x0A15;
  15896. t['kahiragana'] = 0x304B;
  15897. t['kahookcyrillic'] = 0x04C4;
  15898. t['kakatakana'] = 0x30AB;
  15899. t['kakatakanahalfwidth'] = 0xFF76;
  15900. t['kappa'] = 0x03BA;
  15901. t['kappasymbolgreek'] = 0x03F0;
  15902. t['kapyeounmieumkorean'] = 0x3171;
  15903. t['kapyeounphieuphkorean'] = 0x3184;
  15904. t['kapyeounpieupkorean'] = 0x3178;
  15905. t['kapyeounssangpieupkorean'] = 0x3179;
  15906. t['karoriisquare'] = 0x330D;
  15907. t['kashidaautoarabic'] = 0x0640;
  15908. t['kashidaautonosidebearingarabic'] = 0x0640;
  15909. t['kasmallkatakana'] = 0x30F5;
  15910. t['kasquare'] = 0x3384;
  15911. t['kasraarabic'] = 0x0650;
  15912. t['kasratanarabic'] = 0x064D;
  15913. t['kastrokecyrillic'] = 0x049F;
  15914. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15915. t['kaverticalstrokecyrillic'] = 0x049D;
  15916. t['kbopomofo'] = 0x310E;
  15917. t['kcalsquare'] = 0x3389;
  15918. t['kcaron'] = 0x01E9;
  15919. t['kcedilla'] = 0x0137;
  15920. t['kcircle'] = 0x24DA;
  15921. t['kcommaaccent'] = 0x0137;
  15922. t['kdotbelow'] = 0x1E33;
  15923. t['keharmenian'] = 0x0584;
  15924. t['kehiragana'] = 0x3051;
  15925. t['kekatakana'] = 0x30B1;
  15926. t['kekatakanahalfwidth'] = 0xFF79;
  15927. t['kenarmenian'] = 0x056F;
  15928. t['kesmallkatakana'] = 0x30F6;
  15929. t['kgreenlandic'] = 0x0138;
  15930. t['khabengali'] = 0x0996;
  15931. t['khacyrillic'] = 0x0445;
  15932. t['khadeva'] = 0x0916;
  15933. t['khagujarati'] = 0x0A96;
  15934. t['khagurmukhi'] = 0x0A16;
  15935. t['khaharabic'] = 0x062E;
  15936. t['khahfinalarabic'] = 0xFEA6;
  15937. t['khahinitialarabic'] = 0xFEA7;
  15938. t['khahmedialarabic'] = 0xFEA8;
  15939. t['kheicoptic'] = 0x03E7;
  15940. t['khhadeva'] = 0x0959;
  15941. t['khhagurmukhi'] = 0x0A59;
  15942. t['khieukhacirclekorean'] = 0x3278;
  15943. t['khieukhaparenkorean'] = 0x3218;
  15944. t['khieukhcirclekorean'] = 0x326A;
  15945. t['khieukhkorean'] = 0x314B;
  15946. t['khieukhparenkorean'] = 0x320A;
  15947. t['khokhaithai'] = 0x0E02;
  15948. t['khokhonthai'] = 0x0E05;
  15949. t['khokhuatthai'] = 0x0E03;
  15950. t['khokhwaithai'] = 0x0E04;
  15951. t['khomutthai'] = 0x0E5B;
  15952. t['khook'] = 0x0199;
  15953. t['khorakhangthai'] = 0x0E06;
  15954. t['khzsquare'] = 0x3391;
  15955. t['kihiragana'] = 0x304D;
  15956. t['kikatakana'] = 0x30AD;
  15957. t['kikatakanahalfwidth'] = 0xFF77;
  15958. t['kiroguramusquare'] = 0x3315;
  15959. t['kiromeetorusquare'] = 0x3316;
  15960. t['kirosquare'] = 0x3314;
  15961. t['kiyeokacirclekorean'] = 0x326E;
  15962. t['kiyeokaparenkorean'] = 0x320E;
  15963. t['kiyeokcirclekorean'] = 0x3260;
  15964. t['kiyeokkorean'] = 0x3131;
  15965. t['kiyeokparenkorean'] = 0x3200;
  15966. t['kiyeoksioskorean'] = 0x3133;
  15967. t['kjecyrillic'] = 0x045C;
  15968. t['klinebelow'] = 0x1E35;
  15969. t['klsquare'] = 0x3398;
  15970. t['kmcubedsquare'] = 0x33A6;
  15971. t['kmonospace'] = 0xFF4B;
  15972. t['kmsquaredsquare'] = 0x33A2;
  15973. t['kohiragana'] = 0x3053;
  15974. t['kohmsquare'] = 0x33C0;
  15975. t['kokaithai'] = 0x0E01;
  15976. t['kokatakana'] = 0x30B3;
  15977. t['kokatakanahalfwidth'] = 0xFF7A;
  15978. t['kooposquare'] = 0x331E;
  15979. t['koppacyrillic'] = 0x0481;
  15980. t['koreanstandardsymbol'] = 0x327F;
  15981. t['koroniscmb'] = 0x0343;
  15982. t['kparen'] = 0x24A6;
  15983. t['kpasquare'] = 0x33AA;
  15984. t['ksicyrillic'] = 0x046F;
  15985. t['ktsquare'] = 0x33CF;
  15986. t['kturned'] = 0x029E;
  15987. t['kuhiragana'] = 0x304F;
  15988. t['kukatakana'] = 0x30AF;
  15989. t['kukatakanahalfwidth'] = 0xFF78;
  15990. t['kvsquare'] = 0x33B8;
  15991. t['kwsquare'] = 0x33BE;
  15992. t['l'] = 0x006C;
  15993. t['labengali'] = 0x09B2;
  15994. t['lacute'] = 0x013A;
  15995. t['ladeva'] = 0x0932;
  15996. t['lagujarati'] = 0x0AB2;
  15997. t['lagurmukhi'] = 0x0A32;
  15998. t['lakkhangyaothai'] = 0x0E45;
  15999. t['lamaleffinalarabic'] = 0xFEFC;
  16000. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16001. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16002. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16003. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16004. t['lamalefisolatedarabic'] = 0xFEFB;
  16005. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16006. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16007. t['lamarabic'] = 0x0644;
  16008. t['lambda'] = 0x03BB;
  16009. t['lambdastroke'] = 0x019B;
  16010. t['lamed'] = 0x05DC;
  16011. t['lameddagesh'] = 0xFB3C;
  16012. t['lameddageshhebrew'] = 0xFB3C;
  16013. t['lamedhebrew'] = 0x05DC;
  16014. t['lamfinalarabic'] = 0xFEDE;
  16015. t['lamhahinitialarabic'] = 0xFCCA;
  16016. t['laminitialarabic'] = 0xFEDF;
  16017. t['lamjeeminitialarabic'] = 0xFCC9;
  16018. t['lamkhahinitialarabic'] = 0xFCCB;
  16019. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16020. t['lammedialarabic'] = 0xFEE0;
  16021. t['lammeemhahinitialarabic'] = 0xFD88;
  16022. t['lammeeminitialarabic'] = 0xFCCC;
  16023. t['largecircle'] = 0x25EF;
  16024. t['lbar'] = 0x019A;
  16025. t['lbelt'] = 0x026C;
  16026. t['lbopomofo'] = 0x310C;
  16027. t['lcaron'] = 0x013E;
  16028. t['lcedilla'] = 0x013C;
  16029. t['lcircle'] = 0x24DB;
  16030. t['lcircumflexbelow'] = 0x1E3D;
  16031. t['lcommaaccent'] = 0x013C;
  16032. t['ldot'] = 0x0140;
  16033. t['ldotaccent'] = 0x0140;
  16034. t['ldotbelow'] = 0x1E37;
  16035. t['ldotbelowmacron'] = 0x1E39;
  16036. t['leftangleabovecmb'] = 0x031A;
  16037. t['lefttackbelowcmb'] = 0x0318;
  16038. t['less'] = 0x003C;
  16039. t['lessequal'] = 0x2264;
  16040. t['lessequalorgreater'] = 0x22DA;
  16041. t['lessmonospace'] = 0xFF1C;
  16042. t['lessorequivalent'] = 0x2272;
  16043. t['lessorgreater'] = 0x2276;
  16044. t['lessoverequal'] = 0x2266;
  16045. t['lesssmall'] = 0xFE64;
  16046. t['lezh'] = 0x026E;
  16047. t['lfblock'] = 0x258C;
  16048. t['lhookretroflex'] = 0x026D;
  16049. t['lira'] = 0x20A4;
  16050. t['liwnarmenian'] = 0x056C;
  16051. t['lj'] = 0x01C9;
  16052. t['ljecyrillic'] = 0x0459;
  16053. t['ll'] = 0xF6C0;
  16054. t['lladeva'] = 0x0933;
  16055. t['llagujarati'] = 0x0AB3;
  16056. t['llinebelow'] = 0x1E3B;
  16057. t['llladeva'] = 0x0934;
  16058. t['llvocalicbengali'] = 0x09E1;
  16059. t['llvocalicdeva'] = 0x0961;
  16060. t['llvocalicvowelsignbengali'] = 0x09E3;
  16061. t['llvocalicvowelsigndeva'] = 0x0963;
  16062. t['lmiddletilde'] = 0x026B;
  16063. t['lmonospace'] = 0xFF4C;
  16064. t['lmsquare'] = 0x33D0;
  16065. t['lochulathai'] = 0x0E2C;
  16066. t['logicaland'] = 0x2227;
  16067. t['logicalnot'] = 0x00AC;
  16068. t['logicalnotreversed'] = 0x2310;
  16069. t['logicalor'] = 0x2228;
  16070. t['lolingthai'] = 0x0E25;
  16071. t['longs'] = 0x017F;
  16072. t['lowlinecenterline'] = 0xFE4E;
  16073. t['lowlinecmb'] = 0x0332;
  16074. t['lowlinedashed'] = 0xFE4D;
  16075. t['lozenge'] = 0x25CA;
  16076. t['lparen'] = 0x24A7;
  16077. t['lslash'] = 0x0142;
  16078. t['lsquare'] = 0x2113;
  16079. t['lsuperior'] = 0xF6EE;
  16080. t['ltshade'] = 0x2591;
  16081. t['luthai'] = 0x0E26;
  16082. t['lvocalicbengali'] = 0x098C;
  16083. t['lvocalicdeva'] = 0x090C;
  16084. t['lvocalicvowelsignbengali'] = 0x09E2;
  16085. t['lvocalicvowelsigndeva'] = 0x0962;
  16086. t['lxsquare'] = 0x33D3;
  16087. t['m'] = 0x006D;
  16088. t['mabengali'] = 0x09AE;
  16089. t['macron'] = 0x00AF;
  16090. t['macronbelowcmb'] = 0x0331;
  16091. t['macroncmb'] = 0x0304;
  16092. t['macronlowmod'] = 0x02CD;
  16093. t['macronmonospace'] = 0xFFE3;
  16094. t['macute'] = 0x1E3F;
  16095. t['madeva'] = 0x092E;
  16096. t['magujarati'] = 0x0AAE;
  16097. t['magurmukhi'] = 0x0A2E;
  16098. t['mahapakhhebrew'] = 0x05A4;
  16099. t['mahapakhlefthebrew'] = 0x05A4;
  16100. t['mahiragana'] = 0x307E;
  16101. t['maichattawalowleftthai'] = 0xF895;
  16102. t['maichattawalowrightthai'] = 0xF894;
  16103. t['maichattawathai'] = 0x0E4B;
  16104. t['maichattawaupperleftthai'] = 0xF893;
  16105. t['maieklowleftthai'] = 0xF88C;
  16106. t['maieklowrightthai'] = 0xF88B;
  16107. t['maiekthai'] = 0x0E48;
  16108. t['maiekupperleftthai'] = 0xF88A;
  16109. t['maihanakatleftthai'] = 0xF884;
  16110. t['maihanakatthai'] = 0x0E31;
  16111. t['maitaikhuleftthai'] = 0xF889;
  16112. t['maitaikhuthai'] = 0x0E47;
  16113. t['maitholowleftthai'] = 0xF88F;
  16114. t['maitholowrightthai'] = 0xF88E;
  16115. t['maithothai'] = 0x0E49;
  16116. t['maithoupperleftthai'] = 0xF88D;
  16117. t['maitrilowleftthai'] = 0xF892;
  16118. t['maitrilowrightthai'] = 0xF891;
  16119. t['maitrithai'] = 0x0E4A;
  16120. t['maitriupperleftthai'] = 0xF890;
  16121. t['maiyamokthai'] = 0x0E46;
  16122. t['makatakana'] = 0x30DE;
  16123. t['makatakanahalfwidth'] = 0xFF8F;
  16124. t['male'] = 0x2642;
  16125. t['mansyonsquare'] = 0x3347;
  16126. t['maqafhebrew'] = 0x05BE;
  16127. t['mars'] = 0x2642;
  16128. t['masoracirclehebrew'] = 0x05AF;
  16129. t['masquare'] = 0x3383;
  16130. t['mbopomofo'] = 0x3107;
  16131. t['mbsquare'] = 0x33D4;
  16132. t['mcircle'] = 0x24DC;
  16133. t['mcubedsquare'] = 0x33A5;
  16134. t['mdotaccent'] = 0x1E41;
  16135. t['mdotbelow'] = 0x1E43;
  16136. t['meemarabic'] = 0x0645;
  16137. t['meemfinalarabic'] = 0xFEE2;
  16138. t['meeminitialarabic'] = 0xFEE3;
  16139. t['meemmedialarabic'] = 0xFEE4;
  16140. t['meemmeeminitialarabic'] = 0xFCD1;
  16141. t['meemmeemisolatedarabic'] = 0xFC48;
  16142. t['meetorusquare'] = 0x334D;
  16143. t['mehiragana'] = 0x3081;
  16144. t['meizierasquare'] = 0x337E;
  16145. t['mekatakana'] = 0x30E1;
  16146. t['mekatakanahalfwidth'] = 0xFF92;
  16147. t['mem'] = 0x05DE;
  16148. t['memdagesh'] = 0xFB3E;
  16149. t['memdageshhebrew'] = 0xFB3E;
  16150. t['memhebrew'] = 0x05DE;
  16151. t['menarmenian'] = 0x0574;
  16152. t['merkhahebrew'] = 0x05A5;
  16153. t['merkhakefulahebrew'] = 0x05A6;
  16154. t['merkhakefulalefthebrew'] = 0x05A6;
  16155. t['merkhalefthebrew'] = 0x05A5;
  16156. t['mhook'] = 0x0271;
  16157. t['mhzsquare'] = 0x3392;
  16158. t['middledotkatakanahalfwidth'] = 0xFF65;
  16159. t['middot'] = 0x00B7;
  16160. t['mieumacirclekorean'] = 0x3272;
  16161. t['mieumaparenkorean'] = 0x3212;
  16162. t['mieumcirclekorean'] = 0x3264;
  16163. t['mieumkorean'] = 0x3141;
  16164. t['mieumpansioskorean'] = 0x3170;
  16165. t['mieumparenkorean'] = 0x3204;
  16166. t['mieumpieupkorean'] = 0x316E;
  16167. t['mieumsioskorean'] = 0x316F;
  16168. t['mihiragana'] = 0x307F;
  16169. t['mikatakana'] = 0x30DF;
  16170. t['mikatakanahalfwidth'] = 0xFF90;
  16171. t['minus'] = 0x2212;
  16172. t['minusbelowcmb'] = 0x0320;
  16173. t['minuscircle'] = 0x2296;
  16174. t['minusmod'] = 0x02D7;
  16175. t['minusplus'] = 0x2213;
  16176. t['minute'] = 0x2032;
  16177. t['miribaarusquare'] = 0x334A;
  16178. t['mirisquare'] = 0x3349;
  16179. t['mlonglegturned'] = 0x0270;
  16180. t['mlsquare'] = 0x3396;
  16181. t['mmcubedsquare'] = 0x33A3;
  16182. t['mmonospace'] = 0xFF4D;
  16183. t['mmsquaredsquare'] = 0x339F;
  16184. t['mohiragana'] = 0x3082;
  16185. t['mohmsquare'] = 0x33C1;
  16186. t['mokatakana'] = 0x30E2;
  16187. t['mokatakanahalfwidth'] = 0xFF93;
  16188. t['molsquare'] = 0x33D6;
  16189. t['momathai'] = 0x0E21;
  16190. t['moverssquare'] = 0x33A7;
  16191. t['moverssquaredsquare'] = 0x33A8;
  16192. t['mparen'] = 0x24A8;
  16193. t['mpasquare'] = 0x33AB;
  16194. t['mssquare'] = 0x33B3;
  16195. t['msuperior'] = 0xF6EF;
  16196. t['mturned'] = 0x026F;
  16197. t['mu'] = 0x00B5;
  16198. t['mu1'] = 0x00B5;
  16199. t['muasquare'] = 0x3382;
  16200. t['muchgreater'] = 0x226B;
  16201. t['muchless'] = 0x226A;
  16202. t['mufsquare'] = 0x338C;
  16203. t['mugreek'] = 0x03BC;
  16204. t['mugsquare'] = 0x338D;
  16205. t['muhiragana'] = 0x3080;
  16206. t['mukatakana'] = 0x30E0;
  16207. t['mukatakanahalfwidth'] = 0xFF91;
  16208. t['mulsquare'] = 0x3395;
  16209. t['multiply'] = 0x00D7;
  16210. t['mumsquare'] = 0x339B;
  16211. t['munahhebrew'] = 0x05A3;
  16212. t['munahlefthebrew'] = 0x05A3;
  16213. t['musicalnote'] = 0x266A;
  16214. t['musicalnotedbl'] = 0x266B;
  16215. t['musicflatsign'] = 0x266D;
  16216. t['musicsharpsign'] = 0x266F;
  16217. t['mussquare'] = 0x33B2;
  16218. t['muvsquare'] = 0x33B6;
  16219. t['muwsquare'] = 0x33BC;
  16220. t['mvmegasquare'] = 0x33B9;
  16221. t['mvsquare'] = 0x33B7;
  16222. t['mwmegasquare'] = 0x33BF;
  16223. t['mwsquare'] = 0x33BD;
  16224. t['n'] = 0x006E;
  16225. t['nabengali'] = 0x09A8;
  16226. t['nabla'] = 0x2207;
  16227. t['nacute'] = 0x0144;
  16228. t['nadeva'] = 0x0928;
  16229. t['nagujarati'] = 0x0AA8;
  16230. t['nagurmukhi'] = 0x0A28;
  16231. t['nahiragana'] = 0x306A;
  16232. t['nakatakana'] = 0x30CA;
  16233. t['nakatakanahalfwidth'] = 0xFF85;
  16234. t['napostrophe'] = 0x0149;
  16235. t['nasquare'] = 0x3381;
  16236. t['nbopomofo'] = 0x310B;
  16237. t['nbspace'] = 0x00A0;
  16238. t['ncaron'] = 0x0148;
  16239. t['ncedilla'] = 0x0146;
  16240. t['ncircle'] = 0x24DD;
  16241. t['ncircumflexbelow'] = 0x1E4B;
  16242. t['ncommaaccent'] = 0x0146;
  16243. t['ndotaccent'] = 0x1E45;
  16244. t['ndotbelow'] = 0x1E47;
  16245. t['nehiragana'] = 0x306D;
  16246. t['nekatakana'] = 0x30CD;
  16247. t['nekatakanahalfwidth'] = 0xFF88;
  16248. t['newsheqelsign'] = 0x20AA;
  16249. t['nfsquare'] = 0x338B;
  16250. t['ngabengali'] = 0x0999;
  16251. t['ngadeva'] = 0x0919;
  16252. t['ngagujarati'] = 0x0A99;
  16253. t['ngagurmukhi'] = 0x0A19;
  16254. t['ngonguthai'] = 0x0E07;
  16255. t['nhiragana'] = 0x3093;
  16256. t['nhookleft'] = 0x0272;
  16257. t['nhookretroflex'] = 0x0273;
  16258. t['nieunacirclekorean'] = 0x326F;
  16259. t['nieunaparenkorean'] = 0x320F;
  16260. t['nieuncieuckorean'] = 0x3135;
  16261. t['nieuncirclekorean'] = 0x3261;
  16262. t['nieunhieuhkorean'] = 0x3136;
  16263. t['nieunkorean'] = 0x3134;
  16264. t['nieunpansioskorean'] = 0x3168;
  16265. t['nieunparenkorean'] = 0x3201;
  16266. t['nieunsioskorean'] = 0x3167;
  16267. t['nieuntikeutkorean'] = 0x3166;
  16268. t['nihiragana'] = 0x306B;
  16269. t['nikatakana'] = 0x30CB;
  16270. t['nikatakanahalfwidth'] = 0xFF86;
  16271. t['nikhahitleftthai'] = 0xF899;
  16272. t['nikhahitthai'] = 0x0E4D;
  16273. t['nine'] = 0x0039;
  16274. t['ninearabic'] = 0x0669;
  16275. t['ninebengali'] = 0x09EF;
  16276. t['ninecircle'] = 0x2468;
  16277. t['ninecircleinversesansserif'] = 0x2792;
  16278. t['ninedeva'] = 0x096F;
  16279. t['ninegujarati'] = 0x0AEF;
  16280. t['ninegurmukhi'] = 0x0A6F;
  16281. t['ninehackarabic'] = 0x0669;
  16282. t['ninehangzhou'] = 0x3029;
  16283. t['nineideographicparen'] = 0x3228;
  16284. t['nineinferior'] = 0x2089;
  16285. t['ninemonospace'] = 0xFF19;
  16286. t['nineoldstyle'] = 0xF739;
  16287. t['nineparen'] = 0x247C;
  16288. t['nineperiod'] = 0x2490;
  16289. t['ninepersian'] = 0x06F9;
  16290. t['nineroman'] = 0x2178;
  16291. t['ninesuperior'] = 0x2079;
  16292. t['nineteencircle'] = 0x2472;
  16293. t['nineteenparen'] = 0x2486;
  16294. t['nineteenperiod'] = 0x249A;
  16295. t['ninethai'] = 0x0E59;
  16296. t['nj'] = 0x01CC;
  16297. t['njecyrillic'] = 0x045A;
  16298. t['nkatakana'] = 0x30F3;
  16299. t['nkatakanahalfwidth'] = 0xFF9D;
  16300. t['nlegrightlong'] = 0x019E;
  16301. t['nlinebelow'] = 0x1E49;
  16302. t['nmonospace'] = 0xFF4E;
  16303. t['nmsquare'] = 0x339A;
  16304. t['nnabengali'] = 0x09A3;
  16305. t['nnadeva'] = 0x0923;
  16306. t['nnagujarati'] = 0x0AA3;
  16307. t['nnagurmukhi'] = 0x0A23;
  16308. t['nnnadeva'] = 0x0929;
  16309. t['nohiragana'] = 0x306E;
  16310. t['nokatakana'] = 0x30CE;
  16311. t['nokatakanahalfwidth'] = 0xFF89;
  16312. t['nonbreakingspace'] = 0x00A0;
  16313. t['nonenthai'] = 0x0E13;
  16314. t['nonuthai'] = 0x0E19;
  16315. t['noonarabic'] = 0x0646;
  16316. t['noonfinalarabic'] = 0xFEE6;
  16317. t['noonghunnaarabic'] = 0x06BA;
  16318. t['noonghunnafinalarabic'] = 0xFB9F;
  16319. t['nooninitialarabic'] = 0xFEE7;
  16320. t['noonjeeminitialarabic'] = 0xFCD2;
  16321. t['noonjeemisolatedarabic'] = 0xFC4B;
  16322. t['noonmedialarabic'] = 0xFEE8;
  16323. t['noonmeeminitialarabic'] = 0xFCD5;
  16324. t['noonmeemisolatedarabic'] = 0xFC4E;
  16325. t['noonnoonfinalarabic'] = 0xFC8D;
  16326. t['notcontains'] = 0x220C;
  16327. t['notelement'] = 0x2209;
  16328. t['notelementof'] = 0x2209;
  16329. t['notequal'] = 0x2260;
  16330. t['notgreater'] = 0x226F;
  16331. t['notgreaternorequal'] = 0x2271;
  16332. t['notgreaternorless'] = 0x2279;
  16333. t['notidentical'] = 0x2262;
  16334. t['notless'] = 0x226E;
  16335. t['notlessnorequal'] = 0x2270;
  16336. t['notparallel'] = 0x2226;
  16337. t['notprecedes'] = 0x2280;
  16338. t['notsubset'] = 0x2284;
  16339. t['notsucceeds'] = 0x2281;
  16340. t['notsuperset'] = 0x2285;
  16341. t['nowarmenian'] = 0x0576;
  16342. t['nparen'] = 0x24A9;
  16343. t['nssquare'] = 0x33B1;
  16344. t['nsuperior'] = 0x207F;
  16345. t['ntilde'] = 0x00F1;
  16346. t['nu'] = 0x03BD;
  16347. t['nuhiragana'] = 0x306C;
  16348. t['nukatakana'] = 0x30CC;
  16349. t['nukatakanahalfwidth'] = 0xFF87;
  16350. t['nuktabengali'] = 0x09BC;
  16351. t['nuktadeva'] = 0x093C;
  16352. t['nuktagujarati'] = 0x0ABC;
  16353. t['nuktagurmukhi'] = 0x0A3C;
  16354. t['numbersign'] = 0x0023;
  16355. t['numbersignmonospace'] = 0xFF03;
  16356. t['numbersignsmall'] = 0xFE5F;
  16357. t['numeralsigngreek'] = 0x0374;
  16358. t['numeralsignlowergreek'] = 0x0375;
  16359. t['numero'] = 0x2116;
  16360. t['nun'] = 0x05E0;
  16361. t['nundagesh'] = 0xFB40;
  16362. t['nundageshhebrew'] = 0xFB40;
  16363. t['nunhebrew'] = 0x05E0;
  16364. t['nvsquare'] = 0x33B5;
  16365. t['nwsquare'] = 0x33BB;
  16366. t['nyabengali'] = 0x099E;
  16367. t['nyadeva'] = 0x091E;
  16368. t['nyagujarati'] = 0x0A9E;
  16369. t['nyagurmukhi'] = 0x0A1E;
  16370. t['o'] = 0x006F;
  16371. t['oacute'] = 0x00F3;
  16372. t['oangthai'] = 0x0E2D;
  16373. t['obarred'] = 0x0275;
  16374. t['obarredcyrillic'] = 0x04E9;
  16375. t['obarreddieresiscyrillic'] = 0x04EB;
  16376. t['obengali'] = 0x0993;
  16377. t['obopomofo'] = 0x311B;
  16378. t['obreve'] = 0x014F;
  16379. t['ocandradeva'] = 0x0911;
  16380. t['ocandragujarati'] = 0x0A91;
  16381. t['ocandravowelsigndeva'] = 0x0949;
  16382. t['ocandravowelsigngujarati'] = 0x0AC9;
  16383. t['ocaron'] = 0x01D2;
  16384. t['ocircle'] = 0x24DE;
  16385. t['ocircumflex'] = 0x00F4;
  16386. t['ocircumflexacute'] = 0x1ED1;
  16387. t['ocircumflexdotbelow'] = 0x1ED9;
  16388. t['ocircumflexgrave'] = 0x1ED3;
  16389. t['ocircumflexhookabove'] = 0x1ED5;
  16390. t['ocircumflextilde'] = 0x1ED7;
  16391. t['ocyrillic'] = 0x043E;
  16392. t['odblacute'] = 0x0151;
  16393. t['odblgrave'] = 0x020D;
  16394. t['odeva'] = 0x0913;
  16395. t['odieresis'] = 0x00F6;
  16396. t['odieresiscyrillic'] = 0x04E7;
  16397. t['odotbelow'] = 0x1ECD;
  16398. t['oe'] = 0x0153;
  16399. t['oekorean'] = 0x315A;
  16400. t['ogonek'] = 0x02DB;
  16401. t['ogonekcmb'] = 0x0328;
  16402. t['ograve'] = 0x00F2;
  16403. t['ogujarati'] = 0x0A93;
  16404. t['oharmenian'] = 0x0585;
  16405. t['ohiragana'] = 0x304A;
  16406. t['ohookabove'] = 0x1ECF;
  16407. t['ohorn'] = 0x01A1;
  16408. t['ohornacute'] = 0x1EDB;
  16409. t['ohorndotbelow'] = 0x1EE3;
  16410. t['ohorngrave'] = 0x1EDD;
  16411. t['ohornhookabove'] = 0x1EDF;
  16412. t['ohorntilde'] = 0x1EE1;
  16413. t['ohungarumlaut'] = 0x0151;
  16414. t['oi'] = 0x01A3;
  16415. t['oinvertedbreve'] = 0x020F;
  16416. t['okatakana'] = 0x30AA;
  16417. t['okatakanahalfwidth'] = 0xFF75;
  16418. t['okorean'] = 0x3157;
  16419. t['olehebrew'] = 0x05AB;
  16420. t['omacron'] = 0x014D;
  16421. t['omacronacute'] = 0x1E53;
  16422. t['omacrongrave'] = 0x1E51;
  16423. t['omdeva'] = 0x0950;
  16424. t['omega'] = 0x03C9;
  16425. t['omega1'] = 0x03D6;
  16426. t['omegacyrillic'] = 0x0461;
  16427. t['omegalatinclosed'] = 0x0277;
  16428. t['omegaroundcyrillic'] = 0x047B;
  16429. t['omegatitlocyrillic'] = 0x047D;
  16430. t['omegatonos'] = 0x03CE;
  16431. t['omgujarati'] = 0x0AD0;
  16432. t['omicron'] = 0x03BF;
  16433. t['omicrontonos'] = 0x03CC;
  16434. t['omonospace'] = 0xFF4F;
  16435. t['one'] = 0x0031;
  16436. t['onearabic'] = 0x0661;
  16437. t['onebengali'] = 0x09E7;
  16438. t['onecircle'] = 0x2460;
  16439. t['onecircleinversesansserif'] = 0x278A;
  16440. t['onedeva'] = 0x0967;
  16441. t['onedotenleader'] = 0x2024;
  16442. t['oneeighth'] = 0x215B;
  16443. t['onefitted'] = 0xF6DC;
  16444. t['onegujarati'] = 0x0AE7;
  16445. t['onegurmukhi'] = 0x0A67;
  16446. t['onehackarabic'] = 0x0661;
  16447. t['onehalf'] = 0x00BD;
  16448. t['onehangzhou'] = 0x3021;
  16449. t['oneideographicparen'] = 0x3220;
  16450. t['oneinferior'] = 0x2081;
  16451. t['onemonospace'] = 0xFF11;
  16452. t['onenumeratorbengali'] = 0x09F4;
  16453. t['oneoldstyle'] = 0xF731;
  16454. t['oneparen'] = 0x2474;
  16455. t['oneperiod'] = 0x2488;
  16456. t['onepersian'] = 0x06F1;
  16457. t['onequarter'] = 0x00BC;
  16458. t['oneroman'] = 0x2170;
  16459. t['onesuperior'] = 0x00B9;
  16460. t['onethai'] = 0x0E51;
  16461. t['onethird'] = 0x2153;
  16462. t['oogonek'] = 0x01EB;
  16463. t['oogonekmacron'] = 0x01ED;
  16464. t['oogurmukhi'] = 0x0A13;
  16465. t['oomatragurmukhi'] = 0x0A4B;
  16466. t['oopen'] = 0x0254;
  16467. t['oparen'] = 0x24AA;
  16468. t['openbullet'] = 0x25E6;
  16469. t['option'] = 0x2325;
  16470. t['ordfeminine'] = 0x00AA;
  16471. t['ordmasculine'] = 0x00BA;
  16472. t['orthogonal'] = 0x221F;
  16473. t['oshortdeva'] = 0x0912;
  16474. t['oshortvowelsigndeva'] = 0x094A;
  16475. t['oslash'] = 0x00F8;
  16476. t['oslashacute'] = 0x01FF;
  16477. t['osmallhiragana'] = 0x3049;
  16478. t['osmallkatakana'] = 0x30A9;
  16479. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16480. t['ostrokeacute'] = 0x01FF;
  16481. t['osuperior'] = 0xF6F0;
  16482. t['otcyrillic'] = 0x047F;
  16483. t['otilde'] = 0x00F5;
  16484. t['otildeacute'] = 0x1E4D;
  16485. t['otildedieresis'] = 0x1E4F;
  16486. t['oubopomofo'] = 0x3121;
  16487. t['overline'] = 0x203E;
  16488. t['overlinecenterline'] = 0xFE4A;
  16489. t['overlinecmb'] = 0x0305;
  16490. t['overlinedashed'] = 0xFE49;
  16491. t['overlinedblwavy'] = 0xFE4C;
  16492. t['overlinewavy'] = 0xFE4B;
  16493. t['overscore'] = 0x00AF;
  16494. t['ovowelsignbengali'] = 0x09CB;
  16495. t['ovowelsigndeva'] = 0x094B;
  16496. t['ovowelsigngujarati'] = 0x0ACB;
  16497. t['p'] = 0x0070;
  16498. t['paampssquare'] = 0x3380;
  16499. t['paasentosquare'] = 0x332B;
  16500. t['pabengali'] = 0x09AA;
  16501. t['pacute'] = 0x1E55;
  16502. t['padeva'] = 0x092A;
  16503. t['pagedown'] = 0x21DF;
  16504. t['pageup'] = 0x21DE;
  16505. t['pagujarati'] = 0x0AAA;
  16506. t['pagurmukhi'] = 0x0A2A;
  16507. t['pahiragana'] = 0x3071;
  16508. t['paiyannoithai'] = 0x0E2F;
  16509. t['pakatakana'] = 0x30D1;
  16510. t['palatalizationcyrilliccmb'] = 0x0484;
  16511. t['palochkacyrillic'] = 0x04C0;
  16512. t['pansioskorean'] = 0x317F;
  16513. t['paragraph'] = 0x00B6;
  16514. t['parallel'] = 0x2225;
  16515. t['parenleft'] = 0x0028;
  16516. t['parenleftaltonearabic'] = 0xFD3E;
  16517. t['parenleftbt'] = 0xF8ED;
  16518. t['parenleftex'] = 0xF8EC;
  16519. t['parenleftinferior'] = 0x208D;
  16520. t['parenleftmonospace'] = 0xFF08;
  16521. t['parenleftsmall'] = 0xFE59;
  16522. t['parenleftsuperior'] = 0x207D;
  16523. t['parenlefttp'] = 0xF8EB;
  16524. t['parenleftvertical'] = 0xFE35;
  16525. t['parenright'] = 0x0029;
  16526. t['parenrightaltonearabic'] = 0xFD3F;
  16527. t['parenrightbt'] = 0xF8F8;
  16528. t['parenrightex'] = 0xF8F7;
  16529. t['parenrightinferior'] = 0x208E;
  16530. t['parenrightmonospace'] = 0xFF09;
  16531. t['parenrightsmall'] = 0xFE5A;
  16532. t['parenrightsuperior'] = 0x207E;
  16533. t['parenrighttp'] = 0xF8F6;
  16534. t['parenrightvertical'] = 0xFE36;
  16535. t['partialdiff'] = 0x2202;
  16536. t['paseqhebrew'] = 0x05C0;
  16537. t['pashtahebrew'] = 0x0599;
  16538. t['pasquare'] = 0x33A9;
  16539. t['patah'] = 0x05B7;
  16540. t['patah11'] = 0x05B7;
  16541. t['patah1d'] = 0x05B7;
  16542. t['patah2a'] = 0x05B7;
  16543. t['patahhebrew'] = 0x05B7;
  16544. t['patahnarrowhebrew'] = 0x05B7;
  16545. t['patahquarterhebrew'] = 0x05B7;
  16546. t['patahwidehebrew'] = 0x05B7;
  16547. t['pazerhebrew'] = 0x05A1;
  16548. t['pbopomofo'] = 0x3106;
  16549. t['pcircle'] = 0x24DF;
  16550. t['pdotaccent'] = 0x1E57;
  16551. t['pe'] = 0x05E4;
  16552. t['pecyrillic'] = 0x043F;
  16553. t['pedagesh'] = 0xFB44;
  16554. t['pedageshhebrew'] = 0xFB44;
  16555. t['peezisquare'] = 0x333B;
  16556. t['pefinaldageshhebrew'] = 0xFB43;
  16557. t['peharabic'] = 0x067E;
  16558. t['peharmenian'] = 0x057A;
  16559. t['pehebrew'] = 0x05E4;
  16560. t['pehfinalarabic'] = 0xFB57;
  16561. t['pehinitialarabic'] = 0xFB58;
  16562. t['pehiragana'] = 0x307A;
  16563. t['pehmedialarabic'] = 0xFB59;
  16564. t['pekatakana'] = 0x30DA;
  16565. t['pemiddlehookcyrillic'] = 0x04A7;
  16566. t['perafehebrew'] = 0xFB4E;
  16567. t['percent'] = 0x0025;
  16568. t['percentarabic'] = 0x066A;
  16569. t['percentmonospace'] = 0xFF05;
  16570. t['percentsmall'] = 0xFE6A;
  16571. t['period'] = 0x002E;
  16572. t['periodarmenian'] = 0x0589;
  16573. t['periodcentered'] = 0x00B7;
  16574. t['periodhalfwidth'] = 0xFF61;
  16575. t['periodinferior'] = 0xF6E7;
  16576. t['periodmonospace'] = 0xFF0E;
  16577. t['periodsmall'] = 0xFE52;
  16578. t['periodsuperior'] = 0xF6E8;
  16579. t['perispomenigreekcmb'] = 0x0342;
  16580. t['perpendicular'] = 0x22A5;
  16581. t['perthousand'] = 0x2030;
  16582. t['peseta'] = 0x20A7;
  16583. t['pfsquare'] = 0x338A;
  16584. t['phabengali'] = 0x09AB;
  16585. t['phadeva'] = 0x092B;
  16586. t['phagujarati'] = 0x0AAB;
  16587. t['phagurmukhi'] = 0x0A2B;
  16588. t['phi'] = 0x03C6;
  16589. t['phi1'] = 0x03D5;
  16590. t['phieuphacirclekorean'] = 0x327A;
  16591. t['phieuphaparenkorean'] = 0x321A;
  16592. t['phieuphcirclekorean'] = 0x326C;
  16593. t['phieuphkorean'] = 0x314D;
  16594. t['phieuphparenkorean'] = 0x320C;
  16595. t['philatin'] = 0x0278;
  16596. t['phinthuthai'] = 0x0E3A;
  16597. t['phisymbolgreek'] = 0x03D5;
  16598. t['phook'] = 0x01A5;
  16599. t['phophanthai'] = 0x0E1E;
  16600. t['phophungthai'] = 0x0E1C;
  16601. t['phosamphaothai'] = 0x0E20;
  16602. t['pi'] = 0x03C0;
  16603. t['pieupacirclekorean'] = 0x3273;
  16604. t['pieupaparenkorean'] = 0x3213;
  16605. t['pieupcieuckorean'] = 0x3176;
  16606. t['pieupcirclekorean'] = 0x3265;
  16607. t['pieupkiyeokkorean'] = 0x3172;
  16608. t['pieupkorean'] = 0x3142;
  16609. t['pieupparenkorean'] = 0x3205;
  16610. t['pieupsioskiyeokkorean'] = 0x3174;
  16611. t['pieupsioskorean'] = 0x3144;
  16612. t['pieupsiostikeutkorean'] = 0x3175;
  16613. t['pieupthieuthkorean'] = 0x3177;
  16614. t['pieuptikeutkorean'] = 0x3173;
  16615. t['pihiragana'] = 0x3074;
  16616. t['pikatakana'] = 0x30D4;
  16617. t['pisymbolgreek'] = 0x03D6;
  16618. t['piwrarmenian'] = 0x0583;
  16619. t['plus'] = 0x002B;
  16620. t['plusbelowcmb'] = 0x031F;
  16621. t['pluscircle'] = 0x2295;
  16622. t['plusminus'] = 0x00B1;
  16623. t['plusmod'] = 0x02D6;
  16624. t['plusmonospace'] = 0xFF0B;
  16625. t['plussmall'] = 0xFE62;
  16626. t['plussuperior'] = 0x207A;
  16627. t['pmonospace'] = 0xFF50;
  16628. t['pmsquare'] = 0x33D8;
  16629. t['pohiragana'] = 0x307D;
  16630. t['pointingindexdownwhite'] = 0x261F;
  16631. t['pointingindexleftwhite'] = 0x261C;
  16632. t['pointingindexrightwhite'] = 0x261E;
  16633. t['pointingindexupwhite'] = 0x261D;
  16634. t['pokatakana'] = 0x30DD;
  16635. t['poplathai'] = 0x0E1B;
  16636. t['postalmark'] = 0x3012;
  16637. t['postalmarkface'] = 0x3020;
  16638. t['pparen'] = 0x24AB;
  16639. t['precedes'] = 0x227A;
  16640. t['prescription'] = 0x211E;
  16641. t['primemod'] = 0x02B9;
  16642. t['primereversed'] = 0x2035;
  16643. t['product'] = 0x220F;
  16644. t['projective'] = 0x2305;
  16645. t['prolongedkana'] = 0x30FC;
  16646. t['propellor'] = 0x2318;
  16647. t['propersubset'] = 0x2282;
  16648. t['propersuperset'] = 0x2283;
  16649. t['proportion'] = 0x2237;
  16650. t['proportional'] = 0x221D;
  16651. t['psi'] = 0x03C8;
  16652. t['psicyrillic'] = 0x0471;
  16653. t['psilipneumatacyrilliccmb'] = 0x0486;
  16654. t['pssquare'] = 0x33B0;
  16655. t['puhiragana'] = 0x3077;
  16656. t['pukatakana'] = 0x30D7;
  16657. t['pvsquare'] = 0x33B4;
  16658. t['pwsquare'] = 0x33BA;
  16659. t['q'] = 0x0071;
  16660. t['qadeva'] = 0x0958;
  16661. t['qadmahebrew'] = 0x05A8;
  16662. t['qafarabic'] = 0x0642;
  16663. t['qaffinalarabic'] = 0xFED6;
  16664. t['qafinitialarabic'] = 0xFED7;
  16665. t['qafmedialarabic'] = 0xFED8;
  16666. t['qamats'] = 0x05B8;
  16667. t['qamats10'] = 0x05B8;
  16668. t['qamats1a'] = 0x05B8;
  16669. t['qamats1c'] = 0x05B8;
  16670. t['qamats27'] = 0x05B8;
  16671. t['qamats29'] = 0x05B8;
  16672. t['qamats33'] = 0x05B8;
  16673. t['qamatsde'] = 0x05B8;
  16674. t['qamatshebrew'] = 0x05B8;
  16675. t['qamatsnarrowhebrew'] = 0x05B8;
  16676. t['qamatsqatanhebrew'] = 0x05B8;
  16677. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16678. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16679. t['qamatsqatanwidehebrew'] = 0x05B8;
  16680. t['qamatsquarterhebrew'] = 0x05B8;
  16681. t['qamatswidehebrew'] = 0x05B8;
  16682. t['qarneyparahebrew'] = 0x059F;
  16683. t['qbopomofo'] = 0x3111;
  16684. t['qcircle'] = 0x24E0;
  16685. t['qhook'] = 0x02A0;
  16686. t['qmonospace'] = 0xFF51;
  16687. t['qof'] = 0x05E7;
  16688. t['qofdagesh'] = 0xFB47;
  16689. t['qofdageshhebrew'] = 0xFB47;
  16690. t['qofhebrew'] = 0x05E7;
  16691. t['qparen'] = 0x24AC;
  16692. t['quarternote'] = 0x2669;
  16693. t['qubuts'] = 0x05BB;
  16694. t['qubuts18'] = 0x05BB;
  16695. t['qubuts25'] = 0x05BB;
  16696. t['qubuts31'] = 0x05BB;
  16697. t['qubutshebrew'] = 0x05BB;
  16698. t['qubutsnarrowhebrew'] = 0x05BB;
  16699. t['qubutsquarterhebrew'] = 0x05BB;
  16700. t['qubutswidehebrew'] = 0x05BB;
  16701. t['question'] = 0x003F;
  16702. t['questionarabic'] = 0x061F;
  16703. t['questionarmenian'] = 0x055E;
  16704. t['questiondown'] = 0x00BF;
  16705. t['questiondownsmall'] = 0xF7BF;
  16706. t['questiongreek'] = 0x037E;
  16707. t['questionmonospace'] = 0xFF1F;
  16708. t['questionsmall'] = 0xF73F;
  16709. t['quotedbl'] = 0x0022;
  16710. t['quotedblbase'] = 0x201E;
  16711. t['quotedblleft'] = 0x201C;
  16712. t['quotedblmonospace'] = 0xFF02;
  16713. t['quotedblprime'] = 0x301E;
  16714. t['quotedblprimereversed'] = 0x301D;
  16715. t['quotedblright'] = 0x201D;
  16716. t['quoteleft'] = 0x2018;
  16717. t['quoteleftreversed'] = 0x201B;
  16718. t['quotereversed'] = 0x201B;
  16719. t['quoteright'] = 0x2019;
  16720. t['quoterightn'] = 0x0149;
  16721. t['quotesinglbase'] = 0x201A;
  16722. t['quotesingle'] = 0x0027;
  16723. t['quotesinglemonospace'] = 0xFF07;
  16724. t['r'] = 0x0072;
  16725. t['raarmenian'] = 0x057C;
  16726. t['rabengali'] = 0x09B0;
  16727. t['racute'] = 0x0155;
  16728. t['radeva'] = 0x0930;
  16729. t['radical'] = 0x221A;
  16730. t['radicalex'] = 0xF8E5;
  16731. t['radoverssquare'] = 0x33AE;
  16732. t['radoverssquaredsquare'] = 0x33AF;
  16733. t['radsquare'] = 0x33AD;
  16734. t['rafe'] = 0x05BF;
  16735. t['rafehebrew'] = 0x05BF;
  16736. t['ragujarati'] = 0x0AB0;
  16737. t['ragurmukhi'] = 0x0A30;
  16738. t['rahiragana'] = 0x3089;
  16739. t['rakatakana'] = 0x30E9;
  16740. t['rakatakanahalfwidth'] = 0xFF97;
  16741. t['ralowerdiagonalbengali'] = 0x09F1;
  16742. t['ramiddlediagonalbengali'] = 0x09F0;
  16743. t['ramshorn'] = 0x0264;
  16744. t['ratio'] = 0x2236;
  16745. t['rbopomofo'] = 0x3116;
  16746. t['rcaron'] = 0x0159;
  16747. t['rcedilla'] = 0x0157;
  16748. t['rcircle'] = 0x24E1;
  16749. t['rcommaaccent'] = 0x0157;
  16750. t['rdblgrave'] = 0x0211;
  16751. t['rdotaccent'] = 0x1E59;
  16752. t['rdotbelow'] = 0x1E5B;
  16753. t['rdotbelowmacron'] = 0x1E5D;
  16754. t['referencemark'] = 0x203B;
  16755. t['reflexsubset'] = 0x2286;
  16756. t['reflexsuperset'] = 0x2287;
  16757. t['registered'] = 0x00AE;
  16758. t['registersans'] = 0xF8E8;
  16759. t['registerserif'] = 0xF6DA;
  16760. t['reharabic'] = 0x0631;
  16761. t['reharmenian'] = 0x0580;
  16762. t['rehfinalarabic'] = 0xFEAE;
  16763. t['rehiragana'] = 0x308C;
  16764. t['rekatakana'] = 0x30EC;
  16765. t['rekatakanahalfwidth'] = 0xFF9A;
  16766. t['resh'] = 0x05E8;
  16767. t['reshdageshhebrew'] = 0xFB48;
  16768. t['reshhebrew'] = 0x05E8;
  16769. t['reversedtilde'] = 0x223D;
  16770. t['reviahebrew'] = 0x0597;
  16771. t['reviamugrashhebrew'] = 0x0597;
  16772. t['revlogicalnot'] = 0x2310;
  16773. t['rfishhook'] = 0x027E;
  16774. t['rfishhookreversed'] = 0x027F;
  16775. t['rhabengali'] = 0x09DD;
  16776. t['rhadeva'] = 0x095D;
  16777. t['rho'] = 0x03C1;
  16778. t['rhook'] = 0x027D;
  16779. t['rhookturned'] = 0x027B;
  16780. t['rhookturnedsuperior'] = 0x02B5;
  16781. t['rhosymbolgreek'] = 0x03F1;
  16782. t['rhotichookmod'] = 0x02DE;
  16783. t['rieulacirclekorean'] = 0x3271;
  16784. t['rieulaparenkorean'] = 0x3211;
  16785. t['rieulcirclekorean'] = 0x3263;
  16786. t['rieulhieuhkorean'] = 0x3140;
  16787. t['rieulkiyeokkorean'] = 0x313A;
  16788. t['rieulkiyeoksioskorean'] = 0x3169;
  16789. t['rieulkorean'] = 0x3139;
  16790. t['rieulmieumkorean'] = 0x313B;
  16791. t['rieulpansioskorean'] = 0x316C;
  16792. t['rieulparenkorean'] = 0x3203;
  16793. t['rieulphieuphkorean'] = 0x313F;
  16794. t['rieulpieupkorean'] = 0x313C;
  16795. t['rieulpieupsioskorean'] = 0x316B;
  16796. t['rieulsioskorean'] = 0x313D;
  16797. t['rieulthieuthkorean'] = 0x313E;
  16798. t['rieultikeutkorean'] = 0x316A;
  16799. t['rieulyeorinhieuhkorean'] = 0x316D;
  16800. t['rightangle'] = 0x221F;
  16801. t['righttackbelowcmb'] = 0x0319;
  16802. t['righttriangle'] = 0x22BF;
  16803. t['rihiragana'] = 0x308A;
  16804. t['rikatakana'] = 0x30EA;
  16805. t['rikatakanahalfwidth'] = 0xFF98;
  16806. t['ring'] = 0x02DA;
  16807. t['ringbelowcmb'] = 0x0325;
  16808. t['ringcmb'] = 0x030A;
  16809. t['ringhalfleft'] = 0x02BF;
  16810. t['ringhalfleftarmenian'] = 0x0559;
  16811. t['ringhalfleftbelowcmb'] = 0x031C;
  16812. t['ringhalfleftcentered'] = 0x02D3;
  16813. t['ringhalfright'] = 0x02BE;
  16814. t['ringhalfrightbelowcmb'] = 0x0339;
  16815. t['ringhalfrightcentered'] = 0x02D2;
  16816. t['rinvertedbreve'] = 0x0213;
  16817. t['rittorusquare'] = 0x3351;
  16818. t['rlinebelow'] = 0x1E5F;
  16819. t['rlongleg'] = 0x027C;
  16820. t['rlonglegturned'] = 0x027A;
  16821. t['rmonospace'] = 0xFF52;
  16822. t['rohiragana'] = 0x308D;
  16823. t['rokatakana'] = 0x30ED;
  16824. t['rokatakanahalfwidth'] = 0xFF9B;
  16825. t['roruathai'] = 0x0E23;
  16826. t['rparen'] = 0x24AD;
  16827. t['rrabengali'] = 0x09DC;
  16828. t['rradeva'] = 0x0931;
  16829. t['rragurmukhi'] = 0x0A5C;
  16830. t['rreharabic'] = 0x0691;
  16831. t['rrehfinalarabic'] = 0xFB8D;
  16832. t['rrvocalicbengali'] = 0x09E0;
  16833. t['rrvocalicdeva'] = 0x0960;
  16834. t['rrvocalicgujarati'] = 0x0AE0;
  16835. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16836. t['rrvocalicvowelsigndeva'] = 0x0944;
  16837. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16838. t['rsuperior'] = 0xF6F1;
  16839. t['rtblock'] = 0x2590;
  16840. t['rturned'] = 0x0279;
  16841. t['rturnedsuperior'] = 0x02B4;
  16842. t['ruhiragana'] = 0x308B;
  16843. t['rukatakana'] = 0x30EB;
  16844. t['rukatakanahalfwidth'] = 0xFF99;
  16845. t['rupeemarkbengali'] = 0x09F2;
  16846. t['rupeesignbengali'] = 0x09F3;
  16847. t['rupiah'] = 0xF6DD;
  16848. t['ruthai'] = 0x0E24;
  16849. t['rvocalicbengali'] = 0x098B;
  16850. t['rvocalicdeva'] = 0x090B;
  16851. t['rvocalicgujarati'] = 0x0A8B;
  16852. t['rvocalicvowelsignbengali'] = 0x09C3;
  16853. t['rvocalicvowelsigndeva'] = 0x0943;
  16854. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16855. t['s'] = 0x0073;
  16856. t['sabengali'] = 0x09B8;
  16857. t['sacute'] = 0x015B;
  16858. t['sacutedotaccent'] = 0x1E65;
  16859. t['sadarabic'] = 0x0635;
  16860. t['sadeva'] = 0x0938;
  16861. t['sadfinalarabic'] = 0xFEBA;
  16862. t['sadinitialarabic'] = 0xFEBB;
  16863. t['sadmedialarabic'] = 0xFEBC;
  16864. t['sagujarati'] = 0x0AB8;
  16865. t['sagurmukhi'] = 0x0A38;
  16866. t['sahiragana'] = 0x3055;
  16867. t['sakatakana'] = 0x30B5;
  16868. t['sakatakanahalfwidth'] = 0xFF7B;
  16869. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16870. t['samekh'] = 0x05E1;
  16871. t['samekhdagesh'] = 0xFB41;
  16872. t['samekhdageshhebrew'] = 0xFB41;
  16873. t['samekhhebrew'] = 0x05E1;
  16874. t['saraaathai'] = 0x0E32;
  16875. t['saraaethai'] = 0x0E41;
  16876. t['saraaimaimalaithai'] = 0x0E44;
  16877. t['saraaimaimuanthai'] = 0x0E43;
  16878. t['saraamthai'] = 0x0E33;
  16879. t['saraathai'] = 0x0E30;
  16880. t['saraethai'] = 0x0E40;
  16881. t['saraiileftthai'] = 0xF886;
  16882. t['saraiithai'] = 0x0E35;
  16883. t['saraileftthai'] = 0xF885;
  16884. t['saraithai'] = 0x0E34;
  16885. t['saraothai'] = 0x0E42;
  16886. t['saraueeleftthai'] = 0xF888;
  16887. t['saraueethai'] = 0x0E37;
  16888. t['saraueleftthai'] = 0xF887;
  16889. t['sarauethai'] = 0x0E36;
  16890. t['sarauthai'] = 0x0E38;
  16891. t['sarauuthai'] = 0x0E39;
  16892. t['sbopomofo'] = 0x3119;
  16893. t['scaron'] = 0x0161;
  16894. t['scarondotaccent'] = 0x1E67;
  16895. t['scedilla'] = 0x015F;
  16896. t['schwa'] = 0x0259;
  16897. t['schwacyrillic'] = 0x04D9;
  16898. t['schwadieresiscyrillic'] = 0x04DB;
  16899. t['schwahook'] = 0x025A;
  16900. t['scircle'] = 0x24E2;
  16901. t['scircumflex'] = 0x015D;
  16902. t['scommaaccent'] = 0x0219;
  16903. t['sdotaccent'] = 0x1E61;
  16904. t['sdotbelow'] = 0x1E63;
  16905. t['sdotbelowdotaccent'] = 0x1E69;
  16906. t['seagullbelowcmb'] = 0x033C;
  16907. t['second'] = 0x2033;
  16908. t['secondtonechinese'] = 0x02CA;
  16909. t['section'] = 0x00A7;
  16910. t['seenarabic'] = 0x0633;
  16911. t['seenfinalarabic'] = 0xFEB2;
  16912. t['seeninitialarabic'] = 0xFEB3;
  16913. t['seenmedialarabic'] = 0xFEB4;
  16914. t['segol'] = 0x05B6;
  16915. t['segol13'] = 0x05B6;
  16916. t['segol1f'] = 0x05B6;
  16917. t['segol2c'] = 0x05B6;
  16918. t['segolhebrew'] = 0x05B6;
  16919. t['segolnarrowhebrew'] = 0x05B6;
  16920. t['segolquarterhebrew'] = 0x05B6;
  16921. t['segoltahebrew'] = 0x0592;
  16922. t['segolwidehebrew'] = 0x05B6;
  16923. t['seharmenian'] = 0x057D;
  16924. t['sehiragana'] = 0x305B;
  16925. t['sekatakana'] = 0x30BB;
  16926. t['sekatakanahalfwidth'] = 0xFF7E;
  16927. t['semicolon'] = 0x003B;
  16928. t['semicolonarabic'] = 0x061B;
  16929. t['semicolonmonospace'] = 0xFF1B;
  16930. t['semicolonsmall'] = 0xFE54;
  16931. t['semivoicedmarkkana'] = 0x309C;
  16932. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16933. t['sentisquare'] = 0x3322;
  16934. t['sentosquare'] = 0x3323;
  16935. t['seven'] = 0x0037;
  16936. t['sevenarabic'] = 0x0667;
  16937. t['sevenbengali'] = 0x09ED;
  16938. t['sevencircle'] = 0x2466;
  16939. t['sevencircleinversesansserif'] = 0x2790;
  16940. t['sevendeva'] = 0x096D;
  16941. t['seveneighths'] = 0x215E;
  16942. t['sevengujarati'] = 0x0AED;
  16943. t['sevengurmukhi'] = 0x0A6D;
  16944. t['sevenhackarabic'] = 0x0667;
  16945. t['sevenhangzhou'] = 0x3027;
  16946. t['sevenideographicparen'] = 0x3226;
  16947. t['seveninferior'] = 0x2087;
  16948. t['sevenmonospace'] = 0xFF17;
  16949. t['sevenoldstyle'] = 0xF737;
  16950. t['sevenparen'] = 0x247A;
  16951. t['sevenperiod'] = 0x248E;
  16952. t['sevenpersian'] = 0x06F7;
  16953. t['sevenroman'] = 0x2176;
  16954. t['sevensuperior'] = 0x2077;
  16955. t['seventeencircle'] = 0x2470;
  16956. t['seventeenparen'] = 0x2484;
  16957. t['seventeenperiod'] = 0x2498;
  16958. t['seventhai'] = 0x0E57;
  16959. t['sfthyphen'] = 0x00AD;
  16960. t['shaarmenian'] = 0x0577;
  16961. t['shabengali'] = 0x09B6;
  16962. t['shacyrillic'] = 0x0448;
  16963. t['shaddaarabic'] = 0x0651;
  16964. t['shaddadammaarabic'] = 0xFC61;
  16965. t['shaddadammatanarabic'] = 0xFC5E;
  16966. t['shaddafathaarabic'] = 0xFC60;
  16967. t['shaddakasraarabic'] = 0xFC62;
  16968. t['shaddakasratanarabic'] = 0xFC5F;
  16969. t['shade'] = 0x2592;
  16970. t['shadedark'] = 0x2593;
  16971. t['shadelight'] = 0x2591;
  16972. t['shademedium'] = 0x2592;
  16973. t['shadeva'] = 0x0936;
  16974. t['shagujarati'] = 0x0AB6;
  16975. t['shagurmukhi'] = 0x0A36;
  16976. t['shalshelethebrew'] = 0x0593;
  16977. t['shbopomofo'] = 0x3115;
  16978. t['shchacyrillic'] = 0x0449;
  16979. t['sheenarabic'] = 0x0634;
  16980. t['sheenfinalarabic'] = 0xFEB6;
  16981. t['sheeninitialarabic'] = 0xFEB7;
  16982. t['sheenmedialarabic'] = 0xFEB8;
  16983. t['sheicoptic'] = 0x03E3;
  16984. t['sheqel'] = 0x20AA;
  16985. t['sheqelhebrew'] = 0x20AA;
  16986. t['sheva'] = 0x05B0;
  16987. t['sheva115'] = 0x05B0;
  16988. t['sheva15'] = 0x05B0;
  16989. t['sheva22'] = 0x05B0;
  16990. t['sheva2e'] = 0x05B0;
  16991. t['shevahebrew'] = 0x05B0;
  16992. t['shevanarrowhebrew'] = 0x05B0;
  16993. t['shevaquarterhebrew'] = 0x05B0;
  16994. t['shevawidehebrew'] = 0x05B0;
  16995. t['shhacyrillic'] = 0x04BB;
  16996. t['shimacoptic'] = 0x03ED;
  16997. t['shin'] = 0x05E9;
  16998. t['shindagesh'] = 0xFB49;
  16999. t['shindageshhebrew'] = 0xFB49;
  17000. t['shindageshshindot'] = 0xFB2C;
  17001. t['shindageshshindothebrew'] = 0xFB2C;
  17002. t['shindageshsindot'] = 0xFB2D;
  17003. t['shindageshsindothebrew'] = 0xFB2D;
  17004. t['shindothebrew'] = 0x05C1;
  17005. t['shinhebrew'] = 0x05E9;
  17006. t['shinshindot'] = 0xFB2A;
  17007. t['shinshindothebrew'] = 0xFB2A;
  17008. t['shinsindot'] = 0xFB2B;
  17009. t['shinsindothebrew'] = 0xFB2B;
  17010. t['shook'] = 0x0282;
  17011. t['sigma'] = 0x03C3;
  17012. t['sigma1'] = 0x03C2;
  17013. t['sigmafinal'] = 0x03C2;
  17014. t['sigmalunatesymbolgreek'] = 0x03F2;
  17015. t['sihiragana'] = 0x3057;
  17016. t['sikatakana'] = 0x30B7;
  17017. t['sikatakanahalfwidth'] = 0xFF7C;
  17018. t['siluqhebrew'] = 0x05BD;
  17019. t['siluqlefthebrew'] = 0x05BD;
  17020. t['similar'] = 0x223C;
  17021. t['sindothebrew'] = 0x05C2;
  17022. t['siosacirclekorean'] = 0x3274;
  17023. t['siosaparenkorean'] = 0x3214;
  17024. t['sioscieuckorean'] = 0x317E;
  17025. t['sioscirclekorean'] = 0x3266;
  17026. t['sioskiyeokkorean'] = 0x317A;
  17027. t['sioskorean'] = 0x3145;
  17028. t['siosnieunkorean'] = 0x317B;
  17029. t['siosparenkorean'] = 0x3206;
  17030. t['siospieupkorean'] = 0x317D;
  17031. t['siostikeutkorean'] = 0x317C;
  17032. t['six'] = 0x0036;
  17033. t['sixarabic'] = 0x0666;
  17034. t['sixbengali'] = 0x09EC;
  17035. t['sixcircle'] = 0x2465;
  17036. t['sixcircleinversesansserif'] = 0x278F;
  17037. t['sixdeva'] = 0x096C;
  17038. t['sixgujarati'] = 0x0AEC;
  17039. t['sixgurmukhi'] = 0x0A6C;
  17040. t['sixhackarabic'] = 0x0666;
  17041. t['sixhangzhou'] = 0x3026;
  17042. t['sixideographicparen'] = 0x3225;
  17043. t['sixinferior'] = 0x2086;
  17044. t['sixmonospace'] = 0xFF16;
  17045. t['sixoldstyle'] = 0xF736;
  17046. t['sixparen'] = 0x2479;
  17047. t['sixperiod'] = 0x248D;
  17048. t['sixpersian'] = 0x06F6;
  17049. t['sixroman'] = 0x2175;
  17050. t['sixsuperior'] = 0x2076;
  17051. t['sixteencircle'] = 0x246F;
  17052. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17053. t['sixteenparen'] = 0x2483;
  17054. t['sixteenperiod'] = 0x2497;
  17055. t['sixthai'] = 0x0E56;
  17056. t['slash'] = 0x002F;
  17057. t['slashmonospace'] = 0xFF0F;
  17058. t['slong'] = 0x017F;
  17059. t['slongdotaccent'] = 0x1E9B;
  17060. t['smileface'] = 0x263A;
  17061. t['smonospace'] = 0xFF53;
  17062. t['sofpasuqhebrew'] = 0x05C3;
  17063. t['softhyphen'] = 0x00AD;
  17064. t['softsigncyrillic'] = 0x044C;
  17065. t['sohiragana'] = 0x305D;
  17066. t['sokatakana'] = 0x30BD;
  17067. t['sokatakanahalfwidth'] = 0xFF7F;
  17068. t['soliduslongoverlaycmb'] = 0x0338;
  17069. t['solidusshortoverlaycmb'] = 0x0337;
  17070. t['sorusithai'] = 0x0E29;
  17071. t['sosalathai'] = 0x0E28;
  17072. t['sosothai'] = 0x0E0B;
  17073. t['sosuathai'] = 0x0E2A;
  17074. t['space'] = 0x0020;
  17075. t['spacehackarabic'] = 0x0020;
  17076. t['spade'] = 0x2660;
  17077. t['spadesuitblack'] = 0x2660;
  17078. t['spadesuitwhite'] = 0x2664;
  17079. t['sparen'] = 0x24AE;
  17080. t['squarebelowcmb'] = 0x033B;
  17081. t['squarecc'] = 0x33C4;
  17082. t['squarecm'] = 0x339D;
  17083. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17084. t['squarehorizontalfill'] = 0x25A4;
  17085. t['squarekg'] = 0x338F;
  17086. t['squarekm'] = 0x339E;
  17087. t['squarekmcapital'] = 0x33CE;
  17088. t['squareln'] = 0x33D1;
  17089. t['squarelog'] = 0x33D2;
  17090. t['squaremg'] = 0x338E;
  17091. t['squaremil'] = 0x33D5;
  17092. t['squaremm'] = 0x339C;
  17093. t['squaremsquared'] = 0x33A1;
  17094. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17095. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17096. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17097. t['squareverticalfill'] = 0x25A5;
  17098. t['squarewhitewithsmallblack'] = 0x25A3;
  17099. t['srsquare'] = 0x33DB;
  17100. t['ssabengali'] = 0x09B7;
  17101. t['ssadeva'] = 0x0937;
  17102. t['ssagujarati'] = 0x0AB7;
  17103. t['ssangcieuckorean'] = 0x3149;
  17104. t['ssanghieuhkorean'] = 0x3185;
  17105. t['ssangieungkorean'] = 0x3180;
  17106. t['ssangkiyeokkorean'] = 0x3132;
  17107. t['ssangnieunkorean'] = 0x3165;
  17108. t['ssangpieupkorean'] = 0x3143;
  17109. t['ssangsioskorean'] = 0x3146;
  17110. t['ssangtikeutkorean'] = 0x3138;
  17111. t['ssuperior'] = 0xF6F2;
  17112. t['sterling'] = 0x00A3;
  17113. t['sterlingmonospace'] = 0xFFE1;
  17114. t['strokelongoverlaycmb'] = 0x0336;
  17115. t['strokeshortoverlaycmb'] = 0x0335;
  17116. t['subset'] = 0x2282;
  17117. t['subsetnotequal'] = 0x228A;
  17118. t['subsetorequal'] = 0x2286;
  17119. t['succeeds'] = 0x227B;
  17120. t['suchthat'] = 0x220B;
  17121. t['suhiragana'] = 0x3059;
  17122. t['sukatakana'] = 0x30B9;
  17123. t['sukatakanahalfwidth'] = 0xFF7D;
  17124. t['sukunarabic'] = 0x0652;
  17125. t['summation'] = 0x2211;
  17126. t['sun'] = 0x263C;
  17127. t['superset'] = 0x2283;
  17128. t['supersetnotequal'] = 0x228B;
  17129. t['supersetorequal'] = 0x2287;
  17130. t['svsquare'] = 0x33DC;
  17131. t['syouwaerasquare'] = 0x337C;
  17132. t['t'] = 0x0074;
  17133. t['tabengali'] = 0x09A4;
  17134. t['tackdown'] = 0x22A4;
  17135. t['tackleft'] = 0x22A3;
  17136. t['tadeva'] = 0x0924;
  17137. t['tagujarati'] = 0x0AA4;
  17138. t['tagurmukhi'] = 0x0A24;
  17139. t['taharabic'] = 0x0637;
  17140. t['tahfinalarabic'] = 0xFEC2;
  17141. t['tahinitialarabic'] = 0xFEC3;
  17142. t['tahiragana'] = 0x305F;
  17143. t['tahmedialarabic'] = 0xFEC4;
  17144. t['taisyouerasquare'] = 0x337D;
  17145. t['takatakana'] = 0x30BF;
  17146. t['takatakanahalfwidth'] = 0xFF80;
  17147. t['tatweelarabic'] = 0x0640;
  17148. t['tau'] = 0x03C4;
  17149. t['tav'] = 0x05EA;
  17150. t['tavdages'] = 0xFB4A;
  17151. t['tavdagesh'] = 0xFB4A;
  17152. t['tavdageshhebrew'] = 0xFB4A;
  17153. t['tavhebrew'] = 0x05EA;
  17154. t['tbar'] = 0x0167;
  17155. t['tbopomofo'] = 0x310A;
  17156. t['tcaron'] = 0x0165;
  17157. t['tccurl'] = 0x02A8;
  17158. t['tcedilla'] = 0x0163;
  17159. t['tcheharabic'] = 0x0686;
  17160. t['tchehfinalarabic'] = 0xFB7B;
  17161. t['tchehinitialarabic'] = 0xFB7C;
  17162. t['tchehmedialarabic'] = 0xFB7D;
  17163. t['tcircle'] = 0x24E3;
  17164. t['tcircumflexbelow'] = 0x1E71;
  17165. t['tcommaaccent'] = 0x0163;
  17166. t['tdieresis'] = 0x1E97;
  17167. t['tdotaccent'] = 0x1E6B;
  17168. t['tdotbelow'] = 0x1E6D;
  17169. t['tecyrillic'] = 0x0442;
  17170. t['tedescendercyrillic'] = 0x04AD;
  17171. t['teharabic'] = 0x062A;
  17172. t['tehfinalarabic'] = 0xFE96;
  17173. t['tehhahinitialarabic'] = 0xFCA2;
  17174. t['tehhahisolatedarabic'] = 0xFC0C;
  17175. t['tehinitialarabic'] = 0xFE97;
  17176. t['tehiragana'] = 0x3066;
  17177. t['tehjeeminitialarabic'] = 0xFCA1;
  17178. t['tehjeemisolatedarabic'] = 0xFC0B;
  17179. t['tehmarbutaarabic'] = 0x0629;
  17180. t['tehmarbutafinalarabic'] = 0xFE94;
  17181. t['tehmedialarabic'] = 0xFE98;
  17182. t['tehmeeminitialarabic'] = 0xFCA4;
  17183. t['tehmeemisolatedarabic'] = 0xFC0E;
  17184. t['tehnoonfinalarabic'] = 0xFC73;
  17185. t['tekatakana'] = 0x30C6;
  17186. t['tekatakanahalfwidth'] = 0xFF83;
  17187. t['telephone'] = 0x2121;
  17188. t['telephoneblack'] = 0x260E;
  17189. t['telishagedolahebrew'] = 0x05A0;
  17190. t['telishaqetanahebrew'] = 0x05A9;
  17191. t['tencircle'] = 0x2469;
  17192. t['tenideographicparen'] = 0x3229;
  17193. t['tenparen'] = 0x247D;
  17194. t['tenperiod'] = 0x2491;
  17195. t['tenroman'] = 0x2179;
  17196. t['tesh'] = 0x02A7;
  17197. t['tet'] = 0x05D8;
  17198. t['tetdagesh'] = 0xFB38;
  17199. t['tetdageshhebrew'] = 0xFB38;
  17200. t['tethebrew'] = 0x05D8;
  17201. t['tetsecyrillic'] = 0x04B5;
  17202. t['tevirhebrew'] = 0x059B;
  17203. t['tevirlefthebrew'] = 0x059B;
  17204. t['thabengali'] = 0x09A5;
  17205. t['thadeva'] = 0x0925;
  17206. t['thagujarati'] = 0x0AA5;
  17207. t['thagurmukhi'] = 0x0A25;
  17208. t['thalarabic'] = 0x0630;
  17209. t['thalfinalarabic'] = 0xFEAC;
  17210. t['thanthakhatlowleftthai'] = 0xF898;
  17211. t['thanthakhatlowrightthai'] = 0xF897;
  17212. t['thanthakhatthai'] = 0x0E4C;
  17213. t['thanthakhatupperleftthai'] = 0xF896;
  17214. t['theharabic'] = 0x062B;
  17215. t['thehfinalarabic'] = 0xFE9A;
  17216. t['thehinitialarabic'] = 0xFE9B;
  17217. t['thehmedialarabic'] = 0xFE9C;
  17218. t['thereexists'] = 0x2203;
  17219. t['therefore'] = 0x2234;
  17220. t['theta'] = 0x03B8;
  17221. t['theta1'] = 0x03D1;
  17222. t['thetasymbolgreek'] = 0x03D1;
  17223. t['thieuthacirclekorean'] = 0x3279;
  17224. t['thieuthaparenkorean'] = 0x3219;
  17225. t['thieuthcirclekorean'] = 0x326B;
  17226. t['thieuthkorean'] = 0x314C;
  17227. t['thieuthparenkorean'] = 0x320B;
  17228. t['thirteencircle'] = 0x246C;
  17229. t['thirteenparen'] = 0x2480;
  17230. t['thirteenperiod'] = 0x2494;
  17231. t['thonangmonthothai'] = 0x0E11;
  17232. t['thook'] = 0x01AD;
  17233. t['thophuthaothai'] = 0x0E12;
  17234. t['thorn'] = 0x00FE;
  17235. t['thothahanthai'] = 0x0E17;
  17236. t['thothanthai'] = 0x0E10;
  17237. t['thothongthai'] = 0x0E18;
  17238. t['thothungthai'] = 0x0E16;
  17239. t['thousandcyrillic'] = 0x0482;
  17240. t['thousandsseparatorarabic'] = 0x066C;
  17241. t['thousandsseparatorpersian'] = 0x066C;
  17242. t['three'] = 0x0033;
  17243. t['threearabic'] = 0x0663;
  17244. t['threebengali'] = 0x09E9;
  17245. t['threecircle'] = 0x2462;
  17246. t['threecircleinversesansserif'] = 0x278C;
  17247. t['threedeva'] = 0x0969;
  17248. t['threeeighths'] = 0x215C;
  17249. t['threegujarati'] = 0x0AE9;
  17250. t['threegurmukhi'] = 0x0A69;
  17251. t['threehackarabic'] = 0x0663;
  17252. t['threehangzhou'] = 0x3023;
  17253. t['threeideographicparen'] = 0x3222;
  17254. t['threeinferior'] = 0x2083;
  17255. t['threemonospace'] = 0xFF13;
  17256. t['threenumeratorbengali'] = 0x09F6;
  17257. t['threeoldstyle'] = 0xF733;
  17258. t['threeparen'] = 0x2476;
  17259. t['threeperiod'] = 0x248A;
  17260. t['threepersian'] = 0x06F3;
  17261. t['threequarters'] = 0x00BE;
  17262. t['threequartersemdash'] = 0xF6DE;
  17263. t['threeroman'] = 0x2172;
  17264. t['threesuperior'] = 0x00B3;
  17265. t['threethai'] = 0x0E53;
  17266. t['thzsquare'] = 0x3394;
  17267. t['tihiragana'] = 0x3061;
  17268. t['tikatakana'] = 0x30C1;
  17269. t['tikatakanahalfwidth'] = 0xFF81;
  17270. t['tikeutacirclekorean'] = 0x3270;
  17271. t['tikeutaparenkorean'] = 0x3210;
  17272. t['tikeutcirclekorean'] = 0x3262;
  17273. t['tikeutkorean'] = 0x3137;
  17274. t['tikeutparenkorean'] = 0x3202;
  17275. t['tilde'] = 0x02DC;
  17276. t['tildebelowcmb'] = 0x0330;
  17277. t['tildecmb'] = 0x0303;
  17278. t['tildecomb'] = 0x0303;
  17279. t['tildedoublecmb'] = 0x0360;
  17280. t['tildeoperator'] = 0x223C;
  17281. t['tildeoverlaycmb'] = 0x0334;
  17282. t['tildeverticalcmb'] = 0x033E;
  17283. t['timescircle'] = 0x2297;
  17284. t['tipehahebrew'] = 0x0596;
  17285. t['tipehalefthebrew'] = 0x0596;
  17286. t['tippigurmukhi'] = 0x0A70;
  17287. t['titlocyrilliccmb'] = 0x0483;
  17288. t['tiwnarmenian'] = 0x057F;
  17289. t['tlinebelow'] = 0x1E6F;
  17290. t['tmonospace'] = 0xFF54;
  17291. t['toarmenian'] = 0x0569;
  17292. t['tohiragana'] = 0x3068;
  17293. t['tokatakana'] = 0x30C8;
  17294. t['tokatakanahalfwidth'] = 0xFF84;
  17295. t['tonebarextrahighmod'] = 0x02E5;
  17296. t['tonebarextralowmod'] = 0x02E9;
  17297. t['tonebarhighmod'] = 0x02E6;
  17298. t['tonebarlowmod'] = 0x02E8;
  17299. t['tonebarmidmod'] = 0x02E7;
  17300. t['tonefive'] = 0x01BD;
  17301. t['tonesix'] = 0x0185;
  17302. t['tonetwo'] = 0x01A8;
  17303. t['tonos'] = 0x0384;
  17304. t['tonsquare'] = 0x3327;
  17305. t['topatakthai'] = 0x0E0F;
  17306. t['tortoiseshellbracketleft'] = 0x3014;
  17307. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17308. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17309. t['tortoiseshellbracketright'] = 0x3015;
  17310. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17311. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17312. t['totaothai'] = 0x0E15;
  17313. t['tpalatalhook'] = 0x01AB;
  17314. t['tparen'] = 0x24AF;
  17315. t['trademark'] = 0x2122;
  17316. t['trademarksans'] = 0xF8EA;
  17317. t['trademarkserif'] = 0xF6DB;
  17318. t['tretroflexhook'] = 0x0288;
  17319. t['triagdn'] = 0x25BC;
  17320. t['triaglf'] = 0x25C4;
  17321. t['triagrt'] = 0x25BA;
  17322. t['triagup'] = 0x25B2;
  17323. t['ts'] = 0x02A6;
  17324. t['tsadi'] = 0x05E6;
  17325. t['tsadidagesh'] = 0xFB46;
  17326. t['tsadidageshhebrew'] = 0xFB46;
  17327. t['tsadihebrew'] = 0x05E6;
  17328. t['tsecyrillic'] = 0x0446;
  17329. t['tsere'] = 0x05B5;
  17330. t['tsere12'] = 0x05B5;
  17331. t['tsere1e'] = 0x05B5;
  17332. t['tsere2b'] = 0x05B5;
  17333. t['tserehebrew'] = 0x05B5;
  17334. t['tserenarrowhebrew'] = 0x05B5;
  17335. t['tserequarterhebrew'] = 0x05B5;
  17336. t['tserewidehebrew'] = 0x05B5;
  17337. t['tshecyrillic'] = 0x045B;
  17338. t['tsuperior'] = 0xF6F3;
  17339. t['ttabengali'] = 0x099F;
  17340. t['ttadeva'] = 0x091F;
  17341. t['ttagujarati'] = 0x0A9F;
  17342. t['ttagurmukhi'] = 0x0A1F;
  17343. t['tteharabic'] = 0x0679;
  17344. t['ttehfinalarabic'] = 0xFB67;
  17345. t['ttehinitialarabic'] = 0xFB68;
  17346. t['ttehmedialarabic'] = 0xFB69;
  17347. t['tthabengali'] = 0x09A0;
  17348. t['tthadeva'] = 0x0920;
  17349. t['tthagujarati'] = 0x0AA0;
  17350. t['tthagurmukhi'] = 0x0A20;
  17351. t['tturned'] = 0x0287;
  17352. t['tuhiragana'] = 0x3064;
  17353. t['tukatakana'] = 0x30C4;
  17354. t['tukatakanahalfwidth'] = 0xFF82;
  17355. t['tusmallhiragana'] = 0x3063;
  17356. t['tusmallkatakana'] = 0x30C3;
  17357. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17358. t['twelvecircle'] = 0x246B;
  17359. t['twelveparen'] = 0x247F;
  17360. t['twelveperiod'] = 0x2493;
  17361. t['twelveroman'] = 0x217B;
  17362. t['twentycircle'] = 0x2473;
  17363. t['twentyhangzhou'] = 0x5344;
  17364. t['twentyparen'] = 0x2487;
  17365. t['twentyperiod'] = 0x249B;
  17366. t['two'] = 0x0032;
  17367. t['twoarabic'] = 0x0662;
  17368. t['twobengali'] = 0x09E8;
  17369. t['twocircle'] = 0x2461;
  17370. t['twocircleinversesansserif'] = 0x278B;
  17371. t['twodeva'] = 0x0968;
  17372. t['twodotenleader'] = 0x2025;
  17373. t['twodotleader'] = 0x2025;
  17374. t['twodotleadervertical'] = 0xFE30;
  17375. t['twogujarati'] = 0x0AE8;
  17376. t['twogurmukhi'] = 0x0A68;
  17377. t['twohackarabic'] = 0x0662;
  17378. t['twohangzhou'] = 0x3022;
  17379. t['twoideographicparen'] = 0x3221;
  17380. t['twoinferior'] = 0x2082;
  17381. t['twomonospace'] = 0xFF12;
  17382. t['twonumeratorbengali'] = 0x09F5;
  17383. t['twooldstyle'] = 0xF732;
  17384. t['twoparen'] = 0x2475;
  17385. t['twoperiod'] = 0x2489;
  17386. t['twopersian'] = 0x06F2;
  17387. t['tworoman'] = 0x2171;
  17388. t['twostroke'] = 0x01BB;
  17389. t['twosuperior'] = 0x00B2;
  17390. t['twothai'] = 0x0E52;
  17391. t['twothirds'] = 0x2154;
  17392. t['u'] = 0x0075;
  17393. t['uacute'] = 0x00FA;
  17394. t['ubar'] = 0x0289;
  17395. t['ubengali'] = 0x0989;
  17396. t['ubopomofo'] = 0x3128;
  17397. t['ubreve'] = 0x016D;
  17398. t['ucaron'] = 0x01D4;
  17399. t['ucircle'] = 0x24E4;
  17400. t['ucircumflex'] = 0x00FB;
  17401. t['ucircumflexbelow'] = 0x1E77;
  17402. t['ucyrillic'] = 0x0443;
  17403. t['udattadeva'] = 0x0951;
  17404. t['udblacute'] = 0x0171;
  17405. t['udblgrave'] = 0x0215;
  17406. t['udeva'] = 0x0909;
  17407. t['udieresis'] = 0x00FC;
  17408. t['udieresisacute'] = 0x01D8;
  17409. t['udieresisbelow'] = 0x1E73;
  17410. t['udieresiscaron'] = 0x01DA;
  17411. t['udieresiscyrillic'] = 0x04F1;
  17412. t['udieresisgrave'] = 0x01DC;
  17413. t['udieresismacron'] = 0x01D6;
  17414. t['udotbelow'] = 0x1EE5;
  17415. t['ugrave'] = 0x00F9;
  17416. t['ugujarati'] = 0x0A89;
  17417. t['ugurmukhi'] = 0x0A09;
  17418. t['uhiragana'] = 0x3046;
  17419. t['uhookabove'] = 0x1EE7;
  17420. t['uhorn'] = 0x01B0;
  17421. t['uhornacute'] = 0x1EE9;
  17422. t['uhorndotbelow'] = 0x1EF1;
  17423. t['uhorngrave'] = 0x1EEB;
  17424. t['uhornhookabove'] = 0x1EED;
  17425. t['uhorntilde'] = 0x1EEF;
  17426. t['uhungarumlaut'] = 0x0171;
  17427. t['uhungarumlautcyrillic'] = 0x04F3;
  17428. t['uinvertedbreve'] = 0x0217;
  17429. t['ukatakana'] = 0x30A6;
  17430. t['ukatakanahalfwidth'] = 0xFF73;
  17431. t['ukcyrillic'] = 0x0479;
  17432. t['ukorean'] = 0x315C;
  17433. t['umacron'] = 0x016B;
  17434. t['umacroncyrillic'] = 0x04EF;
  17435. t['umacrondieresis'] = 0x1E7B;
  17436. t['umatragurmukhi'] = 0x0A41;
  17437. t['umonospace'] = 0xFF55;
  17438. t['underscore'] = 0x005F;
  17439. t['underscoredbl'] = 0x2017;
  17440. t['underscoremonospace'] = 0xFF3F;
  17441. t['underscorevertical'] = 0xFE33;
  17442. t['underscorewavy'] = 0xFE4F;
  17443. t['union'] = 0x222A;
  17444. t['universal'] = 0x2200;
  17445. t['uogonek'] = 0x0173;
  17446. t['uparen'] = 0x24B0;
  17447. t['upblock'] = 0x2580;
  17448. t['upperdothebrew'] = 0x05C4;
  17449. t['upsilon'] = 0x03C5;
  17450. t['upsilondieresis'] = 0x03CB;
  17451. t['upsilondieresistonos'] = 0x03B0;
  17452. t['upsilonlatin'] = 0x028A;
  17453. t['upsilontonos'] = 0x03CD;
  17454. t['uptackbelowcmb'] = 0x031D;
  17455. t['uptackmod'] = 0x02D4;
  17456. t['uragurmukhi'] = 0x0A73;
  17457. t['uring'] = 0x016F;
  17458. t['ushortcyrillic'] = 0x045E;
  17459. t['usmallhiragana'] = 0x3045;
  17460. t['usmallkatakana'] = 0x30A5;
  17461. t['usmallkatakanahalfwidth'] = 0xFF69;
  17462. t['ustraightcyrillic'] = 0x04AF;
  17463. t['ustraightstrokecyrillic'] = 0x04B1;
  17464. t['utilde'] = 0x0169;
  17465. t['utildeacute'] = 0x1E79;
  17466. t['utildebelow'] = 0x1E75;
  17467. t['uubengali'] = 0x098A;
  17468. t['uudeva'] = 0x090A;
  17469. t['uugujarati'] = 0x0A8A;
  17470. t['uugurmukhi'] = 0x0A0A;
  17471. t['uumatragurmukhi'] = 0x0A42;
  17472. t['uuvowelsignbengali'] = 0x09C2;
  17473. t['uuvowelsigndeva'] = 0x0942;
  17474. t['uuvowelsigngujarati'] = 0x0AC2;
  17475. t['uvowelsignbengali'] = 0x09C1;
  17476. t['uvowelsigndeva'] = 0x0941;
  17477. t['uvowelsigngujarati'] = 0x0AC1;
  17478. t['v'] = 0x0076;
  17479. t['vadeva'] = 0x0935;
  17480. t['vagujarati'] = 0x0AB5;
  17481. t['vagurmukhi'] = 0x0A35;
  17482. t['vakatakana'] = 0x30F7;
  17483. t['vav'] = 0x05D5;
  17484. t['vavdagesh'] = 0xFB35;
  17485. t['vavdagesh65'] = 0xFB35;
  17486. t['vavdageshhebrew'] = 0xFB35;
  17487. t['vavhebrew'] = 0x05D5;
  17488. t['vavholam'] = 0xFB4B;
  17489. t['vavholamhebrew'] = 0xFB4B;
  17490. t['vavvavhebrew'] = 0x05F0;
  17491. t['vavyodhebrew'] = 0x05F1;
  17492. t['vcircle'] = 0x24E5;
  17493. t['vdotbelow'] = 0x1E7F;
  17494. t['vecyrillic'] = 0x0432;
  17495. t['veharabic'] = 0x06A4;
  17496. t['vehfinalarabic'] = 0xFB6B;
  17497. t['vehinitialarabic'] = 0xFB6C;
  17498. t['vehmedialarabic'] = 0xFB6D;
  17499. t['vekatakana'] = 0x30F9;
  17500. t['venus'] = 0x2640;
  17501. t['verticalbar'] = 0x007C;
  17502. t['verticallineabovecmb'] = 0x030D;
  17503. t['verticallinebelowcmb'] = 0x0329;
  17504. t['verticallinelowmod'] = 0x02CC;
  17505. t['verticallinemod'] = 0x02C8;
  17506. t['vewarmenian'] = 0x057E;
  17507. t['vhook'] = 0x028B;
  17508. t['vikatakana'] = 0x30F8;
  17509. t['viramabengali'] = 0x09CD;
  17510. t['viramadeva'] = 0x094D;
  17511. t['viramagujarati'] = 0x0ACD;
  17512. t['visargabengali'] = 0x0983;
  17513. t['visargadeva'] = 0x0903;
  17514. t['visargagujarati'] = 0x0A83;
  17515. t['vmonospace'] = 0xFF56;
  17516. t['voarmenian'] = 0x0578;
  17517. t['voicediterationhiragana'] = 0x309E;
  17518. t['voicediterationkatakana'] = 0x30FE;
  17519. t['voicedmarkkana'] = 0x309B;
  17520. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17521. t['vokatakana'] = 0x30FA;
  17522. t['vparen'] = 0x24B1;
  17523. t['vtilde'] = 0x1E7D;
  17524. t['vturned'] = 0x028C;
  17525. t['vuhiragana'] = 0x3094;
  17526. t['vukatakana'] = 0x30F4;
  17527. t['w'] = 0x0077;
  17528. t['wacute'] = 0x1E83;
  17529. t['waekorean'] = 0x3159;
  17530. t['wahiragana'] = 0x308F;
  17531. t['wakatakana'] = 0x30EF;
  17532. t['wakatakanahalfwidth'] = 0xFF9C;
  17533. t['wakorean'] = 0x3158;
  17534. t['wasmallhiragana'] = 0x308E;
  17535. t['wasmallkatakana'] = 0x30EE;
  17536. t['wattosquare'] = 0x3357;
  17537. t['wavedash'] = 0x301C;
  17538. t['wavyunderscorevertical'] = 0xFE34;
  17539. t['wawarabic'] = 0x0648;
  17540. t['wawfinalarabic'] = 0xFEEE;
  17541. t['wawhamzaabovearabic'] = 0x0624;
  17542. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17543. t['wbsquare'] = 0x33DD;
  17544. t['wcircle'] = 0x24E6;
  17545. t['wcircumflex'] = 0x0175;
  17546. t['wdieresis'] = 0x1E85;
  17547. t['wdotaccent'] = 0x1E87;
  17548. t['wdotbelow'] = 0x1E89;
  17549. t['wehiragana'] = 0x3091;
  17550. t['weierstrass'] = 0x2118;
  17551. t['wekatakana'] = 0x30F1;
  17552. t['wekorean'] = 0x315E;
  17553. t['weokorean'] = 0x315D;
  17554. t['wgrave'] = 0x1E81;
  17555. t['whitebullet'] = 0x25E6;
  17556. t['whitecircle'] = 0x25CB;
  17557. t['whitecircleinverse'] = 0x25D9;
  17558. t['whitecornerbracketleft'] = 0x300E;
  17559. t['whitecornerbracketleftvertical'] = 0xFE43;
  17560. t['whitecornerbracketright'] = 0x300F;
  17561. t['whitecornerbracketrightvertical'] = 0xFE44;
  17562. t['whitediamond'] = 0x25C7;
  17563. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17564. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17565. t['whitedownpointingtriangle'] = 0x25BD;
  17566. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17567. t['whiteleftpointingtriangle'] = 0x25C1;
  17568. t['whitelenticularbracketleft'] = 0x3016;
  17569. t['whitelenticularbracketright'] = 0x3017;
  17570. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17571. t['whiterightpointingtriangle'] = 0x25B7;
  17572. t['whitesmallsquare'] = 0x25AB;
  17573. t['whitesmilingface'] = 0x263A;
  17574. t['whitesquare'] = 0x25A1;
  17575. t['whitestar'] = 0x2606;
  17576. t['whitetelephone'] = 0x260F;
  17577. t['whitetortoiseshellbracketleft'] = 0x3018;
  17578. t['whitetortoiseshellbracketright'] = 0x3019;
  17579. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17580. t['whiteuppointingtriangle'] = 0x25B3;
  17581. t['wihiragana'] = 0x3090;
  17582. t['wikatakana'] = 0x30F0;
  17583. t['wikorean'] = 0x315F;
  17584. t['wmonospace'] = 0xFF57;
  17585. t['wohiragana'] = 0x3092;
  17586. t['wokatakana'] = 0x30F2;
  17587. t['wokatakanahalfwidth'] = 0xFF66;
  17588. t['won'] = 0x20A9;
  17589. t['wonmonospace'] = 0xFFE6;
  17590. t['wowaenthai'] = 0x0E27;
  17591. t['wparen'] = 0x24B2;
  17592. t['wring'] = 0x1E98;
  17593. t['wsuperior'] = 0x02B7;
  17594. t['wturned'] = 0x028D;
  17595. t['wynn'] = 0x01BF;
  17596. t['x'] = 0x0078;
  17597. t['xabovecmb'] = 0x033D;
  17598. t['xbopomofo'] = 0x3112;
  17599. t['xcircle'] = 0x24E7;
  17600. t['xdieresis'] = 0x1E8D;
  17601. t['xdotaccent'] = 0x1E8B;
  17602. t['xeharmenian'] = 0x056D;
  17603. t['xi'] = 0x03BE;
  17604. t['xmonospace'] = 0xFF58;
  17605. t['xparen'] = 0x24B3;
  17606. t['xsuperior'] = 0x02E3;
  17607. t['y'] = 0x0079;
  17608. t['yaadosquare'] = 0x334E;
  17609. t['yabengali'] = 0x09AF;
  17610. t['yacute'] = 0x00FD;
  17611. t['yadeva'] = 0x092F;
  17612. t['yaekorean'] = 0x3152;
  17613. t['yagujarati'] = 0x0AAF;
  17614. t['yagurmukhi'] = 0x0A2F;
  17615. t['yahiragana'] = 0x3084;
  17616. t['yakatakana'] = 0x30E4;
  17617. t['yakatakanahalfwidth'] = 0xFF94;
  17618. t['yakorean'] = 0x3151;
  17619. t['yamakkanthai'] = 0x0E4E;
  17620. t['yasmallhiragana'] = 0x3083;
  17621. t['yasmallkatakana'] = 0x30E3;
  17622. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17623. t['yatcyrillic'] = 0x0463;
  17624. t['ycircle'] = 0x24E8;
  17625. t['ycircumflex'] = 0x0177;
  17626. t['ydieresis'] = 0x00FF;
  17627. t['ydotaccent'] = 0x1E8F;
  17628. t['ydotbelow'] = 0x1EF5;
  17629. t['yeharabic'] = 0x064A;
  17630. t['yehbarreearabic'] = 0x06D2;
  17631. t['yehbarreefinalarabic'] = 0xFBAF;
  17632. t['yehfinalarabic'] = 0xFEF2;
  17633. t['yehhamzaabovearabic'] = 0x0626;
  17634. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17635. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17636. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17637. t['yehinitialarabic'] = 0xFEF3;
  17638. t['yehmedialarabic'] = 0xFEF4;
  17639. t['yehmeeminitialarabic'] = 0xFCDD;
  17640. t['yehmeemisolatedarabic'] = 0xFC58;
  17641. t['yehnoonfinalarabic'] = 0xFC94;
  17642. t['yehthreedotsbelowarabic'] = 0x06D1;
  17643. t['yekorean'] = 0x3156;
  17644. t['yen'] = 0x00A5;
  17645. t['yenmonospace'] = 0xFFE5;
  17646. t['yeokorean'] = 0x3155;
  17647. t['yeorinhieuhkorean'] = 0x3186;
  17648. t['yerahbenyomohebrew'] = 0x05AA;
  17649. t['yerahbenyomolefthebrew'] = 0x05AA;
  17650. t['yericyrillic'] = 0x044B;
  17651. t['yerudieresiscyrillic'] = 0x04F9;
  17652. t['yesieungkorean'] = 0x3181;
  17653. t['yesieungpansioskorean'] = 0x3183;
  17654. t['yesieungsioskorean'] = 0x3182;
  17655. t['yetivhebrew'] = 0x059A;
  17656. t['ygrave'] = 0x1EF3;
  17657. t['yhook'] = 0x01B4;
  17658. t['yhookabove'] = 0x1EF7;
  17659. t['yiarmenian'] = 0x0575;
  17660. t['yicyrillic'] = 0x0457;
  17661. t['yikorean'] = 0x3162;
  17662. t['yinyang'] = 0x262F;
  17663. t['yiwnarmenian'] = 0x0582;
  17664. t['ymonospace'] = 0xFF59;
  17665. t['yod'] = 0x05D9;
  17666. t['yoddagesh'] = 0xFB39;
  17667. t['yoddageshhebrew'] = 0xFB39;
  17668. t['yodhebrew'] = 0x05D9;
  17669. t['yodyodhebrew'] = 0x05F2;
  17670. t['yodyodpatahhebrew'] = 0xFB1F;
  17671. t['yohiragana'] = 0x3088;
  17672. t['yoikorean'] = 0x3189;
  17673. t['yokatakana'] = 0x30E8;
  17674. t['yokatakanahalfwidth'] = 0xFF96;
  17675. t['yokorean'] = 0x315B;
  17676. t['yosmallhiragana'] = 0x3087;
  17677. t['yosmallkatakana'] = 0x30E7;
  17678. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17679. t['yotgreek'] = 0x03F3;
  17680. t['yoyaekorean'] = 0x3188;
  17681. t['yoyakorean'] = 0x3187;
  17682. t['yoyakthai'] = 0x0E22;
  17683. t['yoyingthai'] = 0x0E0D;
  17684. t['yparen'] = 0x24B4;
  17685. t['ypogegrammeni'] = 0x037A;
  17686. t['ypogegrammenigreekcmb'] = 0x0345;
  17687. t['yr'] = 0x01A6;
  17688. t['yring'] = 0x1E99;
  17689. t['ysuperior'] = 0x02B8;
  17690. t['ytilde'] = 0x1EF9;
  17691. t['yturned'] = 0x028E;
  17692. t['yuhiragana'] = 0x3086;
  17693. t['yuikorean'] = 0x318C;
  17694. t['yukatakana'] = 0x30E6;
  17695. t['yukatakanahalfwidth'] = 0xFF95;
  17696. t['yukorean'] = 0x3160;
  17697. t['yusbigcyrillic'] = 0x046B;
  17698. t['yusbigiotifiedcyrillic'] = 0x046D;
  17699. t['yuslittlecyrillic'] = 0x0467;
  17700. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17701. t['yusmallhiragana'] = 0x3085;
  17702. t['yusmallkatakana'] = 0x30E5;
  17703. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17704. t['yuyekorean'] = 0x318B;
  17705. t['yuyeokorean'] = 0x318A;
  17706. t['yyabengali'] = 0x09DF;
  17707. t['yyadeva'] = 0x095F;
  17708. t['z'] = 0x007A;
  17709. t['zaarmenian'] = 0x0566;
  17710. t['zacute'] = 0x017A;
  17711. t['zadeva'] = 0x095B;
  17712. t['zagurmukhi'] = 0x0A5B;
  17713. t['zaharabic'] = 0x0638;
  17714. t['zahfinalarabic'] = 0xFEC6;
  17715. t['zahinitialarabic'] = 0xFEC7;
  17716. t['zahiragana'] = 0x3056;
  17717. t['zahmedialarabic'] = 0xFEC8;
  17718. t['zainarabic'] = 0x0632;
  17719. t['zainfinalarabic'] = 0xFEB0;
  17720. t['zakatakana'] = 0x30B6;
  17721. t['zaqefgadolhebrew'] = 0x0595;
  17722. t['zaqefqatanhebrew'] = 0x0594;
  17723. t['zarqahebrew'] = 0x0598;
  17724. t['zayin'] = 0x05D6;
  17725. t['zayindagesh'] = 0xFB36;
  17726. t['zayindageshhebrew'] = 0xFB36;
  17727. t['zayinhebrew'] = 0x05D6;
  17728. t['zbopomofo'] = 0x3117;
  17729. t['zcaron'] = 0x017E;
  17730. t['zcircle'] = 0x24E9;
  17731. t['zcircumflex'] = 0x1E91;
  17732. t['zcurl'] = 0x0291;
  17733. t['zdot'] = 0x017C;
  17734. t['zdotaccent'] = 0x017C;
  17735. t['zdotbelow'] = 0x1E93;
  17736. t['zecyrillic'] = 0x0437;
  17737. t['zedescendercyrillic'] = 0x0499;
  17738. t['zedieresiscyrillic'] = 0x04DF;
  17739. t['zehiragana'] = 0x305C;
  17740. t['zekatakana'] = 0x30BC;
  17741. t['zero'] = 0x0030;
  17742. t['zeroarabic'] = 0x0660;
  17743. t['zerobengali'] = 0x09E6;
  17744. t['zerodeva'] = 0x0966;
  17745. t['zerogujarati'] = 0x0AE6;
  17746. t['zerogurmukhi'] = 0x0A66;
  17747. t['zerohackarabic'] = 0x0660;
  17748. t['zeroinferior'] = 0x2080;
  17749. t['zeromonospace'] = 0xFF10;
  17750. t['zerooldstyle'] = 0xF730;
  17751. t['zeropersian'] = 0x06F0;
  17752. t['zerosuperior'] = 0x2070;
  17753. t['zerothai'] = 0x0E50;
  17754. t['zerowidthjoiner'] = 0xFEFF;
  17755. t['zerowidthnonjoiner'] = 0x200C;
  17756. t['zerowidthspace'] = 0x200B;
  17757. t['zeta'] = 0x03B6;
  17758. t['zhbopomofo'] = 0x3113;
  17759. t['zhearmenian'] = 0x056A;
  17760. t['zhebrevecyrillic'] = 0x04C2;
  17761. t['zhecyrillic'] = 0x0436;
  17762. t['zhedescendercyrillic'] = 0x0497;
  17763. t['zhedieresiscyrillic'] = 0x04DD;
  17764. t['zihiragana'] = 0x3058;
  17765. t['zikatakana'] = 0x30B8;
  17766. t['zinorhebrew'] = 0x05AE;
  17767. t['zlinebelow'] = 0x1E95;
  17768. t['zmonospace'] = 0xFF5A;
  17769. t['zohiragana'] = 0x305E;
  17770. t['zokatakana'] = 0x30BE;
  17771. t['zparen'] = 0x24B5;
  17772. t['zretroflexhook'] = 0x0290;
  17773. t['zstroke'] = 0x01B6;
  17774. t['zuhiragana'] = 0x305A;
  17775. t['zukatakana'] = 0x30BA;
  17776. t['.notdef'] = 0x0000;
  17777. t['angbracketleftbig'] = 0x2329;
  17778. t['angbracketleftBig'] = 0x2329;
  17779. t['angbracketleftbigg'] = 0x2329;
  17780. t['angbracketleftBigg'] = 0x2329;
  17781. t['angbracketrightBig'] = 0x232A;
  17782. t['angbracketrightbig'] = 0x232A;
  17783. t['angbracketrightBigg'] = 0x232A;
  17784. t['angbracketrightbigg'] = 0x232A;
  17785. t['arrowhookleft'] = 0x21AA;
  17786. t['arrowhookright'] = 0x21A9;
  17787. t['arrowlefttophalf'] = 0x21BC;
  17788. t['arrowleftbothalf'] = 0x21BD;
  17789. t['arrownortheast'] = 0x2197;
  17790. t['arrownorthwest'] = 0x2196;
  17791. t['arrowrighttophalf'] = 0x21C0;
  17792. t['arrowrightbothalf'] = 0x21C1;
  17793. t['arrowsoutheast'] = 0x2198;
  17794. t['arrowsouthwest'] = 0x2199;
  17795. t['backslashbig'] = 0x2216;
  17796. t['backslashBig'] = 0x2216;
  17797. t['backslashBigg'] = 0x2216;
  17798. t['backslashbigg'] = 0x2216;
  17799. t['bardbl'] = 0x2016;
  17800. t['bracehtipdownleft'] = 0xFE37;
  17801. t['bracehtipdownright'] = 0xFE37;
  17802. t['bracehtipupleft'] = 0xFE38;
  17803. t['bracehtipupright'] = 0xFE38;
  17804. t['braceleftBig'] = 0x007B;
  17805. t['braceleftbig'] = 0x007B;
  17806. t['braceleftbigg'] = 0x007B;
  17807. t['braceleftBigg'] = 0x007B;
  17808. t['bracerightBig'] = 0x007D;
  17809. t['bracerightbig'] = 0x007D;
  17810. t['bracerightbigg'] = 0x007D;
  17811. t['bracerightBigg'] = 0x007D;
  17812. t['bracketleftbig'] = 0x005B;
  17813. t['bracketleftBig'] = 0x005B;
  17814. t['bracketleftbigg'] = 0x005B;
  17815. t['bracketleftBigg'] = 0x005B;
  17816. t['bracketrightBig'] = 0x005D;
  17817. t['bracketrightbig'] = 0x005D;
  17818. t['bracketrightbigg'] = 0x005D;
  17819. t['bracketrightBigg'] = 0x005D;
  17820. t['ceilingleftbig'] = 0x2308;
  17821. t['ceilingleftBig'] = 0x2308;
  17822. t['ceilingleftBigg'] = 0x2308;
  17823. t['ceilingleftbigg'] = 0x2308;
  17824. t['ceilingrightbig'] = 0x2309;
  17825. t['ceilingrightBig'] = 0x2309;
  17826. t['ceilingrightbigg'] = 0x2309;
  17827. t['ceilingrightBigg'] = 0x2309;
  17828. t['circledotdisplay'] = 0x2299;
  17829. t['circledottext'] = 0x2299;
  17830. t['circlemultiplydisplay'] = 0x2297;
  17831. t['circlemultiplytext'] = 0x2297;
  17832. t['circleplusdisplay'] = 0x2295;
  17833. t['circleplustext'] = 0x2295;
  17834. t['contintegraldisplay'] = 0x222E;
  17835. t['contintegraltext'] = 0x222E;
  17836. t['coproductdisplay'] = 0x2210;
  17837. t['coproducttext'] = 0x2210;
  17838. t['floorleftBig'] = 0x230A;
  17839. t['floorleftbig'] = 0x230A;
  17840. t['floorleftbigg'] = 0x230A;
  17841. t['floorleftBigg'] = 0x230A;
  17842. t['floorrightbig'] = 0x230B;
  17843. t['floorrightBig'] = 0x230B;
  17844. t['floorrightBigg'] = 0x230B;
  17845. t['floorrightbigg'] = 0x230B;
  17846. t['hatwide'] = 0x0302;
  17847. t['hatwider'] = 0x0302;
  17848. t['hatwidest'] = 0x0302;
  17849. t['intercal'] = 0x1D40;
  17850. t['integraldisplay'] = 0x222B;
  17851. t['integraltext'] = 0x222B;
  17852. t['intersectiondisplay'] = 0x22C2;
  17853. t['intersectiontext'] = 0x22C2;
  17854. t['logicalanddisplay'] = 0x2227;
  17855. t['logicalandtext'] = 0x2227;
  17856. t['logicalordisplay'] = 0x2228;
  17857. t['logicalortext'] = 0x2228;
  17858. t['parenleftBig'] = 0x0028;
  17859. t['parenleftbig'] = 0x0028;
  17860. t['parenleftBigg'] = 0x0028;
  17861. t['parenleftbigg'] = 0x0028;
  17862. t['parenrightBig'] = 0x0029;
  17863. t['parenrightbig'] = 0x0029;
  17864. t['parenrightBigg'] = 0x0029;
  17865. t['parenrightbigg'] = 0x0029;
  17866. t['prime'] = 0x2032;
  17867. t['productdisplay'] = 0x220F;
  17868. t['producttext'] = 0x220F;
  17869. t['radicalbig'] = 0x221A;
  17870. t['radicalBig'] = 0x221A;
  17871. t['radicalBigg'] = 0x221A;
  17872. t['radicalbigg'] = 0x221A;
  17873. t['radicalbt'] = 0x221A;
  17874. t['radicaltp'] = 0x221A;
  17875. t['radicalvertex'] = 0x221A;
  17876. t['slashbig'] = 0x002F;
  17877. t['slashBig'] = 0x002F;
  17878. t['slashBigg'] = 0x002F;
  17879. t['slashbigg'] = 0x002F;
  17880. t['summationdisplay'] = 0x2211;
  17881. t['summationtext'] = 0x2211;
  17882. t['tildewide'] = 0x02DC;
  17883. t['tildewider'] = 0x02DC;
  17884. t['tildewidest'] = 0x02DC;
  17885. t['uniondisplay'] = 0x22C3;
  17886. t['unionmultidisplay'] = 0x228E;
  17887. t['unionmultitext'] = 0x228E;
  17888. t['unionsqdisplay'] = 0x2294;
  17889. t['unionsqtext'] = 0x2294;
  17890. t['uniontext'] = 0x22C3;
  17891. t['vextenddouble'] = 0x2225;
  17892. t['vextendsingle'] = 0x2223;
  17893. });
  17894. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17895. t['space'] = 0x0020;
  17896. t['a1'] = 0x2701;
  17897. t['a2'] = 0x2702;
  17898. t['a202'] = 0x2703;
  17899. t['a3'] = 0x2704;
  17900. t['a4'] = 0x260E;
  17901. t['a5'] = 0x2706;
  17902. t['a119'] = 0x2707;
  17903. t['a118'] = 0x2708;
  17904. t['a117'] = 0x2709;
  17905. t['a11'] = 0x261B;
  17906. t['a12'] = 0x261E;
  17907. t['a13'] = 0x270C;
  17908. t['a14'] = 0x270D;
  17909. t['a15'] = 0x270E;
  17910. t['a16'] = 0x270F;
  17911. t['a105'] = 0x2710;
  17912. t['a17'] = 0x2711;
  17913. t['a18'] = 0x2712;
  17914. t['a19'] = 0x2713;
  17915. t['a20'] = 0x2714;
  17916. t['a21'] = 0x2715;
  17917. t['a22'] = 0x2716;
  17918. t['a23'] = 0x2717;
  17919. t['a24'] = 0x2718;
  17920. t['a25'] = 0x2719;
  17921. t['a26'] = 0x271A;
  17922. t['a27'] = 0x271B;
  17923. t['a28'] = 0x271C;
  17924. t['a6'] = 0x271D;
  17925. t['a7'] = 0x271E;
  17926. t['a8'] = 0x271F;
  17927. t['a9'] = 0x2720;
  17928. t['a10'] = 0x2721;
  17929. t['a29'] = 0x2722;
  17930. t['a30'] = 0x2723;
  17931. t['a31'] = 0x2724;
  17932. t['a32'] = 0x2725;
  17933. t['a33'] = 0x2726;
  17934. t['a34'] = 0x2727;
  17935. t['a35'] = 0x2605;
  17936. t['a36'] = 0x2729;
  17937. t['a37'] = 0x272A;
  17938. t['a38'] = 0x272B;
  17939. t['a39'] = 0x272C;
  17940. t['a40'] = 0x272D;
  17941. t['a41'] = 0x272E;
  17942. t['a42'] = 0x272F;
  17943. t['a43'] = 0x2730;
  17944. t['a44'] = 0x2731;
  17945. t['a45'] = 0x2732;
  17946. t['a46'] = 0x2733;
  17947. t['a47'] = 0x2734;
  17948. t['a48'] = 0x2735;
  17949. t['a49'] = 0x2736;
  17950. t['a50'] = 0x2737;
  17951. t['a51'] = 0x2738;
  17952. t['a52'] = 0x2739;
  17953. t['a53'] = 0x273A;
  17954. t['a54'] = 0x273B;
  17955. t['a55'] = 0x273C;
  17956. t['a56'] = 0x273D;
  17957. t['a57'] = 0x273E;
  17958. t['a58'] = 0x273F;
  17959. t['a59'] = 0x2740;
  17960. t['a60'] = 0x2741;
  17961. t['a61'] = 0x2742;
  17962. t['a62'] = 0x2743;
  17963. t['a63'] = 0x2744;
  17964. t['a64'] = 0x2745;
  17965. t['a65'] = 0x2746;
  17966. t['a66'] = 0x2747;
  17967. t['a67'] = 0x2748;
  17968. t['a68'] = 0x2749;
  17969. t['a69'] = 0x274A;
  17970. t['a70'] = 0x274B;
  17971. t['a71'] = 0x25CF;
  17972. t['a72'] = 0x274D;
  17973. t['a73'] = 0x25A0;
  17974. t['a74'] = 0x274F;
  17975. t['a203'] = 0x2750;
  17976. t['a75'] = 0x2751;
  17977. t['a204'] = 0x2752;
  17978. t['a76'] = 0x25B2;
  17979. t['a77'] = 0x25BC;
  17980. t['a78'] = 0x25C6;
  17981. t['a79'] = 0x2756;
  17982. t['a81'] = 0x25D7;
  17983. t['a82'] = 0x2758;
  17984. t['a83'] = 0x2759;
  17985. t['a84'] = 0x275A;
  17986. t['a97'] = 0x275B;
  17987. t['a98'] = 0x275C;
  17988. t['a99'] = 0x275D;
  17989. t['a100'] = 0x275E;
  17990. t['a101'] = 0x2761;
  17991. t['a102'] = 0x2762;
  17992. t['a103'] = 0x2763;
  17993. t['a104'] = 0x2764;
  17994. t['a106'] = 0x2765;
  17995. t['a107'] = 0x2766;
  17996. t['a108'] = 0x2767;
  17997. t['a112'] = 0x2663;
  17998. t['a111'] = 0x2666;
  17999. t['a110'] = 0x2665;
  18000. t['a109'] = 0x2660;
  18001. t['a120'] = 0x2460;
  18002. t['a121'] = 0x2461;
  18003. t['a122'] = 0x2462;
  18004. t['a123'] = 0x2463;
  18005. t['a124'] = 0x2464;
  18006. t['a125'] = 0x2465;
  18007. t['a126'] = 0x2466;
  18008. t['a127'] = 0x2467;
  18009. t['a128'] = 0x2468;
  18010. t['a129'] = 0x2469;
  18011. t['a130'] = 0x2776;
  18012. t['a131'] = 0x2777;
  18013. t['a132'] = 0x2778;
  18014. t['a133'] = 0x2779;
  18015. t['a134'] = 0x277A;
  18016. t['a135'] = 0x277B;
  18017. t['a136'] = 0x277C;
  18018. t['a137'] = 0x277D;
  18019. t['a138'] = 0x277E;
  18020. t['a139'] = 0x277F;
  18021. t['a140'] = 0x2780;
  18022. t['a141'] = 0x2781;
  18023. t['a142'] = 0x2782;
  18024. t['a143'] = 0x2783;
  18025. t['a144'] = 0x2784;
  18026. t['a145'] = 0x2785;
  18027. t['a146'] = 0x2786;
  18028. t['a147'] = 0x2787;
  18029. t['a148'] = 0x2788;
  18030. t['a149'] = 0x2789;
  18031. t['a150'] = 0x278A;
  18032. t['a151'] = 0x278B;
  18033. t['a152'] = 0x278C;
  18034. t['a153'] = 0x278D;
  18035. t['a154'] = 0x278E;
  18036. t['a155'] = 0x278F;
  18037. t['a156'] = 0x2790;
  18038. t['a157'] = 0x2791;
  18039. t['a158'] = 0x2792;
  18040. t['a159'] = 0x2793;
  18041. t['a160'] = 0x2794;
  18042. t['a161'] = 0x2192;
  18043. t['a163'] = 0x2194;
  18044. t['a164'] = 0x2195;
  18045. t['a196'] = 0x2798;
  18046. t['a165'] = 0x2799;
  18047. t['a192'] = 0x279A;
  18048. t['a166'] = 0x279B;
  18049. t['a167'] = 0x279C;
  18050. t['a168'] = 0x279D;
  18051. t['a169'] = 0x279E;
  18052. t['a170'] = 0x279F;
  18053. t['a171'] = 0x27A0;
  18054. t['a172'] = 0x27A1;
  18055. t['a173'] = 0x27A2;
  18056. t['a162'] = 0x27A3;
  18057. t['a174'] = 0x27A4;
  18058. t['a175'] = 0x27A5;
  18059. t['a176'] = 0x27A6;
  18060. t['a177'] = 0x27A7;
  18061. t['a178'] = 0x27A8;
  18062. t['a179'] = 0x27A9;
  18063. t['a193'] = 0x27AA;
  18064. t['a180'] = 0x27AB;
  18065. t['a199'] = 0x27AC;
  18066. t['a181'] = 0x27AD;
  18067. t['a200'] = 0x27AE;
  18068. t['a182'] = 0x27AF;
  18069. t['a201'] = 0x27B1;
  18070. t['a183'] = 0x27B2;
  18071. t['a184'] = 0x27B3;
  18072. t['a197'] = 0x27B4;
  18073. t['a185'] = 0x27B5;
  18074. t['a194'] = 0x27B6;
  18075. t['a198'] = 0x27B7;
  18076. t['a186'] = 0x27B8;
  18077. t['a195'] = 0x27B9;
  18078. t['a187'] = 0x27BA;
  18079. t['a188'] = 0x27BB;
  18080. t['a189'] = 0x27BC;
  18081. t['a190'] = 0x27BD;
  18082. t['a191'] = 0x27BE;
  18083. t['a89'] = 0x2768;
  18084. t['a90'] = 0x2769;
  18085. t['a93'] = 0x276A;
  18086. t['a94'] = 0x276B;
  18087. t['a91'] = 0x276C;
  18088. t['a92'] = 0x276D;
  18089. t['a205'] = 0x276E;
  18090. t['a85'] = 0x276F;
  18091. t['a206'] = 0x2770;
  18092. t['a86'] = 0x2771;
  18093. t['a87'] = 0x2772;
  18094. t['a88'] = 0x2773;
  18095. t['a95'] = 0x2774;
  18096. t['a96'] = 0x2775;
  18097. t['.notdef'] = 0x0000;
  18098. });
  18099. exports.getGlyphsUnicode = getGlyphsUnicode;
  18100. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18101. /***/ }),
  18102. /* 9 */
  18103. /***/ (function(module, exports, __w_pdfjs_require__) {
  18104. "use strict";
  18105. var sharedUtil = __w_pdfjs_require__(0);
  18106. var displayDOMUtils = __w_pdfjs_require__(3);
  18107. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18108. var AnnotationType = sharedUtil.AnnotationType;
  18109. var stringToPDFString = sharedUtil.stringToPDFString;
  18110. var Util = sharedUtil.Util;
  18111. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18112. var LinkTarget = displayDOMUtils.LinkTarget;
  18113. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18114. var warn = sharedUtil.warn;
  18115. var CustomStyle = displayDOMUtils.CustomStyle;
  18116. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18117. function AnnotationElementFactory() {
  18118. }
  18119. AnnotationElementFactory.prototype = {
  18120. create: function AnnotationElementFactory_create(parameters) {
  18121. var subtype = parameters.data.annotationType;
  18122. switch (subtype) {
  18123. case AnnotationType.LINK:
  18124. return new LinkAnnotationElement(parameters);
  18125. case AnnotationType.TEXT:
  18126. return new TextAnnotationElement(parameters);
  18127. case AnnotationType.WIDGET:
  18128. var fieldType = parameters.data.fieldType;
  18129. switch (fieldType) {
  18130. case 'Tx':
  18131. return new TextWidgetAnnotationElement(parameters);
  18132. case 'Btn':
  18133. if (parameters.data.radioButton) {
  18134. return new RadioButtonWidgetAnnotationElement(parameters);
  18135. } else if (parameters.data.checkBox) {
  18136. return new CheckboxWidgetAnnotationElement(parameters);
  18137. }
  18138. warn('Unimplemented button widget annotation: pushbutton');
  18139. break;
  18140. case 'Ch':
  18141. return new ChoiceWidgetAnnotationElement(parameters);
  18142. }
  18143. return new WidgetAnnotationElement(parameters);
  18144. case AnnotationType.POPUP:
  18145. return new PopupAnnotationElement(parameters);
  18146. case AnnotationType.HIGHLIGHT:
  18147. return new HighlightAnnotationElement(parameters);
  18148. case AnnotationType.UNDERLINE:
  18149. return new UnderlineAnnotationElement(parameters);
  18150. case AnnotationType.SQUIGGLY:
  18151. return new SquigglyAnnotationElement(parameters);
  18152. case AnnotationType.STRIKEOUT:
  18153. return new StrikeOutAnnotationElement(parameters);
  18154. case AnnotationType.FILEATTACHMENT:
  18155. return new FileAttachmentAnnotationElement(parameters);
  18156. default:
  18157. return new AnnotationElement(parameters);
  18158. }
  18159. }
  18160. };
  18161. var AnnotationElement = function AnnotationElementClosure() {
  18162. function AnnotationElement(parameters, isRenderable) {
  18163. this.isRenderable = isRenderable || false;
  18164. this.data = parameters.data;
  18165. this.layer = parameters.layer;
  18166. this.page = parameters.page;
  18167. this.viewport = parameters.viewport;
  18168. this.linkService = parameters.linkService;
  18169. this.downloadManager = parameters.downloadManager;
  18170. this.imageResourcesPath = parameters.imageResourcesPath;
  18171. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18172. if (isRenderable) {
  18173. this.container = this._createContainer();
  18174. }
  18175. }
  18176. AnnotationElement.prototype = {
  18177. _createContainer: function AnnotationElement_createContainer() {
  18178. var data = this.data, page = this.page, viewport = this.viewport;
  18179. var container = document.createElement('section');
  18180. var width = data.rect[2] - data.rect[0];
  18181. var height = data.rect[3] - data.rect[1];
  18182. container.setAttribute('data-annotation-id', data.id);
  18183. var rect = Util.normalizeRect([
  18184. data.rect[0],
  18185. page.view[3] - data.rect[1] + page.view[1],
  18186. data.rect[2],
  18187. page.view[3] - data.rect[3] + page.view[1]
  18188. ]);
  18189. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18190. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18191. if (data.borderStyle.width > 0) {
  18192. container.style.borderWidth = data.borderStyle.width + 'px';
  18193. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18194. width = width - 2 * data.borderStyle.width;
  18195. height = height - 2 * data.borderStyle.width;
  18196. }
  18197. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18198. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18199. if (horizontalRadius > 0 || verticalRadius > 0) {
  18200. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18201. CustomStyle.setProp('borderRadius', container, radius);
  18202. }
  18203. switch (data.borderStyle.style) {
  18204. case AnnotationBorderStyleType.SOLID:
  18205. container.style.borderStyle = 'solid';
  18206. break;
  18207. case AnnotationBorderStyleType.DASHED:
  18208. container.style.borderStyle = 'dashed';
  18209. break;
  18210. case AnnotationBorderStyleType.BEVELED:
  18211. warn('Unimplemented border style: beveled');
  18212. break;
  18213. case AnnotationBorderStyleType.INSET:
  18214. warn('Unimplemented border style: inset');
  18215. break;
  18216. case AnnotationBorderStyleType.UNDERLINE:
  18217. container.style.borderBottomStyle = 'solid';
  18218. break;
  18219. default:
  18220. break;
  18221. }
  18222. if (data.color) {
  18223. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18224. } else {
  18225. container.style.borderWidth = 0;
  18226. }
  18227. }
  18228. container.style.left = rect[0] + 'px';
  18229. container.style.top = rect[1] + 'px';
  18230. container.style.width = width + 'px';
  18231. container.style.height = height + 'px';
  18232. return container;
  18233. },
  18234. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  18235. if (!trigger) {
  18236. trigger = document.createElement('div');
  18237. trigger.style.height = container.style.height;
  18238. trigger.style.width = container.style.width;
  18239. container.appendChild(trigger);
  18240. }
  18241. var popupElement = new PopupElement({
  18242. container: container,
  18243. trigger: trigger,
  18244. color: data.color,
  18245. title: data.title,
  18246. contents: data.contents,
  18247. hideWrapper: true
  18248. });
  18249. var popup = popupElement.render();
  18250. popup.style.left = container.style.width;
  18251. container.appendChild(popup);
  18252. },
  18253. render: function AnnotationElement_render() {
  18254. throw new Error('Abstract method AnnotationElement.render called');
  18255. }
  18256. };
  18257. return AnnotationElement;
  18258. }();
  18259. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  18260. function LinkAnnotationElement(parameters) {
  18261. AnnotationElement.call(this, parameters, true);
  18262. }
  18263. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  18264. render: function LinkAnnotationElement_render() {
  18265. this.container.className = 'linkAnnotation';
  18266. var link = document.createElement('a');
  18267. addLinkAttributes(link, {
  18268. url: this.data.url,
  18269. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  18270. });
  18271. if (!this.data.url) {
  18272. if (this.data.action) {
  18273. this._bindNamedAction(link, this.data.action);
  18274. } else {
  18275. this._bindLink(link, this.data.dest);
  18276. }
  18277. }
  18278. this.container.appendChild(link);
  18279. return this.container;
  18280. },
  18281. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  18282. var self = this;
  18283. link.href = this.linkService.getDestinationHash(destination);
  18284. link.onclick = function () {
  18285. if (destination) {
  18286. self.linkService.navigateTo(destination);
  18287. }
  18288. return false;
  18289. };
  18290. if (destination) {
  18291. link.className = 'internalLink';
  18292. }
  18293. },
  18294. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  18295. var self = this;
  18296. link.href = this.linkService.getAnchorUrl('');
  18297. link.onclick = function () {
  18298. self.linkService.executeNamedAction(action);
  18299. return false;
  18300. };
  18301. link.className = 'internalLink';
  18302. }
  18303. });
  18304. return LinkAnnotationElement;
  18305. }();
  18306. var TextAnnotationElement = function TextAnnotationElementClosure() {
  18307. function TextAnnotationElement(parameters) {
  18308. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18309. AnnotationElement.call(this, parameters, isRenderable);
  18310. }
  18311. Util.inherit(TextAnnotationElement, AnnotationElement, {
  18312. render: function TextAnnotationElement_render() {
  18313. this.container.className = 'textAnnotation';
  18314. var image = document.createElement('img');
  18315. image.style.height = this.container.style.height;
  18316. image.style.width = this.container.style.width;
  18317. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  18318. image.alt = '[{{type}} Annotation]';
  18319. image.dataset.l10nId = 'text_annotation_type';
  18320. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  18321. if (!this.data.hasPopup) {
  18322. this._createPopup(this.container, image, this.data);
  18323. }
  18324. this.container.appendChild(image);
  18325. return this.container;
  18326. }
  18327. });
  18328. return TextAnnotationElement;
  18329. }();
  18330. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  18331. function WidgetAnnotationElement(parameters, isRenderable) {
  18332. AnnotationElement.call(this, parameters, isRenderable);
  18333. }
  18334. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  18335. render: function WidgetAnnotationElement_render() {
  18336. return this.container;
  18337. }
  18338. });
  18339. return WidgetAnnotationElement;
  18340. }();
  18341. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  18342. var TEXT_ALIGNMENT = [
  18343. 'left',
  18344. 'center',
  18345. 'right'
  18346. ];
  18347. function TextWidgetAnnotationElement(parameters) {
  18348. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18349. WidgetAnnotationElement.call(this, parameters, isRenderable);
  18350. }
  18351. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  18352. render: function TextWidgetAnnotationElement_render() {
  18353. this.container.className = 'textWidgetAnnotation';
  18354. var element = null;
  18355. if (this.renderInteractiveForms) {
  18356. if (this.data.multiLine) {
  18357. element = document.createElement('textarea');
  18358. element.textContent = this.data.fieldValue;
  18359. } else {
  18360. element = document.createElement('input');
  18361. element.type = 'text';
  18362. element.setAttribute('value', this.data.fieldValue);
  18363. }
  18364. element.disabled = this.data.readOnly;
  18365. if (this.data.maxLen !== null) {
  18366. element.maxLength = this.data.maxLen;
  18367. }
  18368. if (this.data.comb) {
  18369. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18370. var combWidth = fieldWidth / this.data.maxLen;
  18371. element.classList.add('comb');
  18372. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  18373. }
  18374. } else {
  18375. element = document.createElement('div');
  18376. element.textContent = this.data.fieldValue;
  18377. element.style.verticalAlign = 'middle';
  18378. element.style.display = 'table-cell';
  18379. var font = null;
  18380. if (this.data.fontRefName) {
  18381. font = this.page.commonObjs.getData(this.data.fontRefName);
  18382. }
  18383. this._setTextStyle(element, font);
  18384. }
  18385. if (this.data.textAlignment !== null) {
  18386. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18387. }
  18388. this.container.appendChild(element);
  18389. return this.container;
  18390. },
  18391. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  18392. var style = element.style;
  18393. style.fontSize = this.data.fontSize + 'px';
  18394. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  18395. if (!font) {
  18396. return;
  18397. }
  18398. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  18399. style.fontStyle = font.italic ? 'italic' : 'normal';
  18400. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  18401. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  18402. style.fontFamily = fontFamily + fallbackName;
  18403. }
  18404. });
  18405. return TextWidgetAnnotationElement;
  18406. }();
  18407. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  18408. function CheckboxWidgetAnnotationElement(parameters) {
  18409. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18410. }
  18411. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  18412. render: function CheckboxWidgetAnnotationElement_render() {
  18413. this.container.className = 'buttonWidgetAnnotation checkBox';
  18414. var element = document.createElement('input');
  18415. element.disabled = this.data.readOnly;
  18416. element.type = 'checkbox';
  18417. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  18418. element.setAttribute('checked', true);
  18419. }
  18420. this.container.appendChild(element);
  18421. return this.container;
  18422. }
  18423. });
  18424. return CheckboxWidgetAnnotationElement;
  18425. }();
  18426. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  18427. function RadioButtonWidgetAnnotationElement(parameters) {
  18428. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18429. }
  18430. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  18431. render: function RadioButtonWidgetAnnotationElement_render() {
  18432. this.container.className = 'buttonWidgetAnnotation radioButton';
  18433. var element = document.createElement('input');
  18434. element.disabled = this.data.readOnly;
  18435. element.type = 'radio';
  18436. element.name = this.data.fieldName;
  18437. if (this.data.fieldValue === this.data.buttonValue) {
  18438. element.setAttribute('checked', true);
  18439. }
  18440. this.container.appendChild(element);
  18441. return this.container;
  18442. }
  18443. });
  18444. return RadioButtonWidgetAnnotationElement;
  18445. }();
  18446. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  18447. function ChoiceWidgetAnnotationElement(parameters) {
  18448. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18449. }
  18450. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  18451. render: function ChoiceWidgetAnnotationElement_render() {
  18452. this.container.className = 'choiceWidgetAnnotation';
  18453. var selectElement = document.createElement('select');
  18454. selectElement.disabled = this.data.readOnly;
  18455. if (!this.data.combo) {
  18456. selectElement.size = this.data.options.length;
  18457. if (this.data.multiSelect) {
  18458. selectElement.multiple = true;
  18459. }
  18460. }
  18461. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  18462. var option = this.data.options[i];
  18463. var optionElement = document.createElement('option');
  18464. optionElement.textContent = option.displayValue;
  18465. optionElement.value = option.exportValue;
  18466. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  18467. optionElement.setAttribute('selected', true);
  18468. }
  18469. selectElement.appendChild(optionElement);
  18470. }
  18471. this.container.appendChild(selectElement);
  18472. return this.container;
  18473. }
  18474. });
  18475. return ChoiceWidgetAnnotationElement;
  18476. }();
  18477. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  18478. function PopupAnnotationElement(parameters) {
  18479. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18480. AnnotationElement.call(this, parameters, isRenderable);
  18481. }
  18482. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  18483. render: function PopupAnnotationElement_render() {
  18484. this.container.className = 'popupAnnotation';
  18485. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  18486. var parentElement = this.layer.querySelector(selector);
  18487. if (!parentElement) {
  18488. return this.container;
  18489. }
  18490. var popup = new PopupElement({
  18491. container: this.container,
  18492. trigger: parentElement,
  18493. color: this.data.color,
  18494. title: this.data.title,
  18495. contents: this.data.contents
  18496. });
  18497. var parentLeft = parseFloat(parentElement.style.left);
  18498. var parentWidth = parseFloat(parentElement.style.width);
  18499. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  18500. this.container.style.left = parentLeft + parentWidth + 'px';
  18501. this.container.appendChild(popup.render());
  18502. return this.container;
  18503. }
  18504. });
  18505. return PopupAnnotationElement;
  18506. }();
  18507. var PopupElement = function PopupElementClosure() {
  18508. var BACKGROUND_ENLIGHT = 0.7;
  18509. function PopupElement(parameters) {
  18510. this.container = parameters.container;
  18511. this.trigger = parameters.trigger;
  18512. this.color = parameters.color;
  18513. this.title = parameters.title;
  18514. this.contents = parameters.contents;
  18515. this.hideWrapper = parameters.hideWrapper || false;
  18516. this.pinned = false;
  18517. }
  18518. PopupElement.prototype = {
  18519. render: function PopupElement_render() {
  18520. var wrapper = document.createElement('div');
  18521. wrapper.className = 'popupWrapper';
  18522. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18523. this.hideElement.setAttribute('hidden', true);
  18524. var popup = document.createElement('div');
  18525. popup.className = 'popup';
  18526. var color = this.color;
  18527. if (color) {
  18528. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18529. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18530. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18531. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  18532. }
  18533. var contents = this._formatContents(this.contents);
  18534. var title = document.createElement('h1');
  18535. title.textContent = this.title;
  18536. this.trigger.addEventListener('click', this._toggle.bind(this));
  18537. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  18538. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  18539. popup.addEventListener('click', this._hide.bind(this, true));
  18540. popup.appendChild(title);
  18541. popup.appendChild(contents);
  18542. wrapper.appendChild(popup);
  18543. return wrapper;
  18544. },
  18545. _formatContents: function PopupElement_formatContents(contents) {
  18546. var p = document.createElement('p');
  18547. var lines = contents.split(/(?:\r\n?|\n)/);
  18548. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18549. var line = lines[i];
  18550. p.appendChild(document.createTextNode(line));
  18551. if (i < ii - 1) {
  18552. p.appendChild(document.createElement('br'));
  18553. }
  18554. }
  18555. return p;
  18556. },
  18557. _toggle: function PopupElement_toggle() {
  18558. if (this.pinned) {
  18559. this._hide(true);
  18560. } else {
  18561. this._show(true);
  18562. }
  18563. },
  18564. _show: function PopupElement_show(pin) {
  18565. if (pin) {
  18566. this.pinned = true;
  18567. }
  18568. if (this.hideElement.hasAttribute('hidden')) {
  18569. this.hideElement.removeAttribute('hidden');
  18570. this.container.style.zIndex += 1;
  18571. }
  18572. },
  18573. _hide: function PopupElement_hide(unpin) {
  18574. if (unpin) {
  18575. this.pinned = false;
  18576. }
  18577. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18578. this.hideElement.setAttribute('hidden', true);
  18579. this.container.style.zIndex -= 1;
  18580. }
  18581. }
  18582. };
  18583. return PopupElement;
  18584. }();
  18585. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  18586. function HighlightAnnotationElement(parameters) {
  18587. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18588. AnnotationElement.call(this, parameters, isRenderable);
  18589. }
  18590. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  18591. render: function HighlightAnnotationElement_render() {
  18592. this.container.className = 'highlightAnnotation';
  18593. if (!this.data.hasPopup) {
  18594. this._createPopup(this.container, null, this.data);
  18595. }
  18596. return this.container;
  18597. }
  18598. });
  18599. return HighlightAnnotationElement;
  18600. }();
  18601. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  18602. function UnderlineAnnotationElement(parameters) {
  18603. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18604. AnnotationElement.call(this, parameters, isRenderable);
  18605. }
  18606. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  18607. render: function UnderlineAnnotationElement_render() {
  18608. this.container.className = 'underlineAnnotation';
  18609. if (!this.data.hasPopup) {
  18610. this._createPopup(this.container, null, this.data);
  18611. }
  18612. return this.container;
  18613. }
  18614. });
  18615. return UnderlineAnnotationElement;
  18616. }();
  18617. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  18618. function SquigglyAnnotationElement(parameters) {
  18619. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18620. AnnotationElement.call(this, parameters, isRenderable);
  18621. }
  18622. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  18623. render: function SquigglyAnnotationElement_render() {
  18624. this.container.className = 'squigglyAnnotation';
  18625. if (!this.data.hasPopup) {
  18626. this._createPopup(this.container, null, this.data);
  18627. }
  18628. return this.container;
  18629. }
  18630. });
  18631. return SquigglyAnnotationElement;
  18632. }();
  18633. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  18634. function StrikeOutAnnotationElement(parameters) {
  18635. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18636. AnnotationElement.call(this, parameters, isRenderable);
  18637. }
  18638. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  18639. render: function StrikeOutAnnotationElement_render() {
  18640. this.container.className = 'strikeoutAnnotation';
  18641. if (!this.data.hasPopup) {
  18642. this._createPopup(this.container, null, this.data);
  18643. }
  18644. return this.container;
  18645. }
  18646. });
  18647. return StrikeOutAnnotationElement;
  18648. }();
  18649. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  18650. function FileAttachmentAnnotationElement(parameters) {
  18651. AnnotationElement.call(this, parameters, true);
  18652. var file = this.data.file;
  18653. this.filename = getFilenameFromUrl(file.filename);
  18654. this.content = file.content;
  18655. this.linkService.onFileAttachmentAnnotation({
  18656. id: stringToPDFString(file.filename),
  18657. filename: file.filename,
  18658. content: file.content
  18659. });
  18660. }
  18661. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  18662. render: function FileAttachmentAnnotationElement_render() {
  18663. this.container.className = 'fileAttachmentAnnotation';
  18664. var trigger = document.createElement('div');
  18665. trigger.style.height = this.container.style.height;
  18666. trigger.style.width = this.container.style.width;
  18667. trigger.addEventListener('dblclick', this._download.bind(this));
  18668. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18669. this._createPopup(this.container, trigger, this.data);
  18670. }
  18671. this.container.appendChild(trigger);
  18672. return this.container;
  18673. },
  18674. _download: function FileAttachmentAnnotationElement_download() {
  18675. if (!this.downloadManager) {
  18676. warn('Download cannot be started due to unavailable download manager');
  18677. return;
  18678. }
  18679. this.downloadManager.downloadData(this.content, this.filename, '');
  18680. }
  18681. });
  18682. return FileAttachmentAnnotationElement;
  18683. }();
  18684. var AnnotationLayer = function AnnotationLayerClosure() {
  18685. return {
  18686. render: function AnnotationLayer_render(parameters) {
  18687. var annotationElementFactory = new AnnotationElementFactory();
  18688. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18689. var data = parameters.annotations[i];
  18690. if (!data) {
  18691. continue;
  18692. }
  18693. var element = annotationElementFactory.create({
  18694. data: data,
  18695. layer: parameters.div,
  18696. page: parameters.page,
  18697. viewport: parameters.viewport,
  18698. linkService: parameters.linkService,
  18699. downloadManager: parameters.downloadManager,
  18700. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  18701. renderInteractiveForms: parameters.renderInteractiveForms || false
  18702. });
  18703. if (element.isRenderable) {
  18704. parameters.div.appendChild(element.render());
  18705. }
  18706. }
  18707. },
  18708. update: function AnnotationLayer_update(parameters) {
  18709. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18710. var data = parameters.annotations[i];
  18711. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  18712. if (element) {
  18713. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  18714. }
  18715. }
  18716. parameters.div.removeAttribute('hidden');
  18717. }
  18718. };
  18719. }();
  18720. exports.AnnotationLayer = AnnotationLayer;
  18721. /***/ }),
  18722. /* 10 */
  18723. /***/ (function(module, exports, __w_pdfjs_require__) {
  18724. "use strict";
  18725. var sharedUtil = __w_pdfjs_require__(0);
  18726. var displayFontLoader = __w_pdfjs_require__(45);
  18727. var displayCanvas = __w_pdfjs_require__(44);
  18728. var displayMetadata = __w_pdfjs_require__(24);
  18729. var displayDOMUtils = __w_pdfjs_require__(3);
  18730. var amdRequire;
  18731. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18732. var MessageHandler = sharedUtil.MessageHandler;
  18733. var MissingPDFException = sharedUtil.MissingPDFException;
  18734. var PageViewport = sharedUtil.PageViewport;
  18735. var PasswordException = sharedUtil.PasswordException;
  18736. var StatTimer = sharedUtil.StatTimer;
  18737. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18738. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18739. var Util = sharedUtil.Util;
  18740. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18741. var error = sharedUtil.error;
  18742. var deprecated = sharedUtil.deprecated;
  18743. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  18744. var info = sharedUtil.info;
  18745. var isInt = sharedUtil.isInt;
  18746. var isArray = sharedUtil.isArray;
  18747. var isArrayBuffer = sharedUtil.isArrayBuffer;
  18748. var isSameOrigin = sharedUtil.isSameOrigin;
  18749. var loadJpegStream = sharedUtil.loadJpegStream;
  18750. var stringToBytes = sharedUtil.stringToBytes;
  18751. var globalScope = sharedUtil.globalScope;
  18752. var warn = sharedUtil.warn;
  18753. var FontFaceObject = displayFontLoader.FontFaceObject;
  18754. var FontLoader = displayFontLoader.FontLoader;
  18755. var CanvasGraphics = displayCanvas.CanvasGraphics;
  18756. var Metadata = displayMetadata.Metadata;
  18757. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18758. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  18759. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  18760. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  18761. var isWorkerDisabled = false;
  18762. var workerSrc;
  18763. var isPostMessageTransfersDisabled = false;
  18764. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  18765. var fakeWorkerFilesLoader = null;
  18766. var useRequireEnsure = false;
  18767. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  18768. var task = new PDFDocumentLoadingTask();
  18769. if (arguments.length > 1) {
  18770. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  18771. }
  18772. if (pdfDataRangeTransport) {
  18773. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  18774. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  18775. pdfDataRangeTransport.length = src.length;
  18776. pdfDataRangeTransport.initialData = src.initialData;
  18777. if (!pdfDataRangeTransport.abort) {
  18778. pdfDataRangeTransport.abort = function () {
  18779. };
  18780. }
  18781. }
  18782. src = Object.create(src);
  18783. src.range = pdfDataRangeTransport;
  18784. }
  18785. task.onPassword = passwordCallback || null;
  18786. task.onProgress = progressCallback || null;
  18787. var source;
  18788. if (typeof src === 'string') {
  18789. source = { url: src };
  18790. } else if (isArrayBuffer(src)) {
  18791. source = { data: src };
  18792. } else if (src instanceof PDFDataRangeTransport) {
  18793. source = { range: src };
  18794. } else {
  18795. if (typeof src !== 'object') {
  18796. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  18797. }
  18798. if (!src.url && !src.data && !src.range) {
  18799. error('Invalid parameter object: need either .data, .range or .url');
  18800. }
  18801. source = src;
  18802. }
  18803. var params = {};
  18804. var rangeTransport = null;
  18805. var worker = null;
  18806. for (var key in source) {
  18807. if (key === 'url' && typeof window !== 'undefined') {
  18808. params[key] = new URL(source[key], window.location).href;
  18809. continue;
  18810. } else if (key === 'range') {
  18811. rangeTransport = source[key];
  18812. continue;
  18813. } else if (key === 'worker') {
  18814. worker = source[key];
  18815. continue;
  18816. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  18817. var pdfBytes = source[key];
  18818. if (typeof pdfBytes === 'string') {
  18819. params[key] = stringToBytes(pdfBytes);
  18820. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  18821. params[key] = new Uint8Array(pdfBytes);
  18822. } else if (isArrayBuffer(pdfBytes)) {
  18823. params[key] = new Uint8Array(pdfBytes);
  18824. } else {
  18825. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  18826. }
  18827. continue;
  18828. }
  18829. params[key] = source[key];
  18830. }
  18831. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  18832. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  18833. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  18834. if (!worker) {
  18835. var workerPort = getDefaultSetting('workerPort');
  18836. worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
  18837. task._worker = worker;
  18838. }
  18839. var docId = task.docId;
  18840. worker.promise.then(function () {
  18841. if (task.destroyed) {
  18842. throw new Error('Loading aborted');
  18843. }
  18844. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  18845. if (task.destroyed) {
  18846. throw new Error('Loading aborted');
  18847. }
  18848. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  18849. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  18850. task._transport = transport;
  18851. messageHandler.send('Ready', null);
  18852. });
  18853. }).catch(task._capability.reject);
  18854. return task;
  18855. }
  18856. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  18857. if (worker.destroyed) {
  18858. return Promise.reject(new Error('Worker was destroyed'));
  18859. }
  18860. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  18861. source.disableStream = getDefaultSetting('disableStream');
  18862. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  18863. if (pdfDataRangeTransport) {
  18864. source.length = pdfDataRangeTransport.length;
  18865. source.initialData = pdfDataRangeTransport.initialData;
  18866. }
  18867. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  18868. docId: docId,
  18869. source: source,
  18870. disableRange: getDefaultSetting('disableRange'),
  18871. maxImageSize: getDefaultSetting('maxImageSize'),
  18872. disableFontFace: getDefaultSetting('disableFontFace'),
  18873. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  18874. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  18875. docBaseUrl: source.docBaseUrl,
  18876. disableNativeImageDecoder: source.disableNativeImageDecoder
  18877. }).then(function (workerId) {
  18878. if (worker.destroyed) {
  18879. throw new Error('Worker was destroyed');
  18880. }
  18881. return workerId;
  18882. });
  18883. }
  18884. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  18885. var nextDocumentId = 0;
  18886. function PDFDocumentLoadingTask() {
  18887. this._capability = createPromiseCapability();
  18888. this._transport = null;
  18889. this._worker = null;
  18890. this.docId = 'd' + nextDocumentId++;
  18891. this.destroyed = false;
  18892. this.onPassword = null;
  18893. this.onProgress = null;
  18894. this.onUnsupportedFeature = null;
  18895. }
  18896. PDFDocumentLoadingTask.prototype = {
  18897. get promise() {
  18898. return this._capability.promise;
  18899. },
  18900. destroy: function () {
  18901. this.destroyed = true;
  18902. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  18903. return transportDestroyed.then(function () {
  18904. this._transport = null;
  18905. if (this._worker) {
  18906. this._worker.destroy();
  18907. this._worker = null;
  18908. }
  18909. }.bind(this));
  18910. },
  18911. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  18912. return this.promise.then.apply(this.promise, arguments);
  18913. }
  18914. };
  18915. return PDFDocumentLoadingTask;
  18916. }();
  18917. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  18918. function PDFDataRangeTransport(length, initialData) {
  18919. this.length = length;
  18920. this.initialData = initialData;
  18921. this._rangeListeners = [];
  18922. this._progressListeners = [];
  18923. this._progressiveReadListeners = [];
  18924. this._readyCapability = createPromiseCapability();
  18925. }
  18926. PDFDataRangeTransport.prototype = {
  18927. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  18928. this._rangeListeners.push(listener);
  18929. },
  18930. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  18931. this._progressListeners.push(listener);
  18932. },
  18933. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  18934. this._progressiveReadListeners.push(listener);
  18935. },
  18936. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  18937. var listeners = this._rangeListeners;
  18938. for (var i = 0, n = listeners.length; i < n; ++i) {
  18939. listeners[i](begin, chunk);
  18940. }
  18941. },
  18942. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  18943. this._readyCapability.promise.then(function () {
  18944. var listeners = this._progressListeners;
  18945. for (var i = 0, n = listeners.length; i < n; ++i) {
  18946. listeners[i](loaded);
  18947. }
  18948. }.bind(this));
  18949. },
  18950. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  18951. this._readyCapability.promise.then(function () {
  18952. var listeners = this._progressiveReadListeners;
  18953. for (var i = 0, n = listeners.length; i < n; ++i) {
  18954. listeners[i](chunk);
  18955. }
  18956. }.bind(this));
  18957. },
  18958. transportReady: function PDFDataRangeTransport_transportReady() {
  18959. this._readyCapability.resolve();
  18960. },
  18961. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  18962. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  18963. },
  18964. abort: function PDFDataRangeTransport_abort() {
  18965. }
  18966. };
  18967. return PDFDataRangeTransport;
  18968. }();
  18969. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  18970. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  18971. this.pdfInfo = pdfInfo;
  18972. this.transport = transport;
  18973. this.loadingTask = loadingTask;
  18974. }
  18975. PDFDocumentProxy.prototype = {
  18976. get numPages() {
  18977. return this.pdfInfo.numPages;
  18978. },
  18979. get fingerprint() {
  18980. return this.pdfInfo.fingerprint;
  18981. },
  18982. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  18983. return this.transport.getPage(pageNumber);
  18984. },
  18985. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  18986. return this.transport.getPageIndex(ref);
  18987. },
  18988. getDestinations: function PDFDocumentProxy_getDestinations() {
  18989. return this.transport.getDestinations();
  18990. },
  18991. getDestination: function PDFDocumentProxy_getDestination(id) {
  18992. return this.transport.getDestination(id);
  18993. },
  18994. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  18995. return this.transport.getPageLabels();
  18996. },
  18997. getAttachments: function PDFDocumentProxy_getAttachments() {
  18998. return this.transport.getAttachments();
  18999. },
  19000. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19001. return this.transport.getJavaScript();
  19002. },
  19003. getOutline: function PDFDocumentProxy_getOutline() {
  19004. return this.transport.getOutline();
  19005. },
  19006. getMetadata: function PDFDocumentProxy_getMetadata() {
  19007. return this.transport.getMetadata();
  19008. },
  19009. getData: function PDFDocumentProxy_getData() {
  19010. return this.transport.getData();
  19011. },
  19012. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19013. return this.transport.downloadInfoCapability.promise;
  19014. },
  19015. getStats: function PDFDocumentProxy_getStats() {
  19016. return this.transport.getStats();
  19017. },
  19018. cleanup: function PDFDocumentProxy_cleanup() {
  19019. this.transport.startCleanup();
  19020. },
  19021. destroy: function PDFDocumentProxy_destroy() {
  19022. return this.loadingTask.destroy();
  19023. }
  19024. };
  19025. return PDFDocumentProxy;
  19026. }();
  19027. var PDFPageProxy = function PDFPageProxyClosure() {
  19028. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19029. this.pageIndex = pageIndex;
  19030. this.pageInfo = pageInfo;
  19031. this.transport = transport;
  19032. this.stats = new StatTimer();
  19033. this.stats.enabled = getDefaultSetting('enableStats');
  19034. this.commonObjs = transport.commonObjs;
  19035. this.objs = new PDFObjects();
  19036. this.cleanupAfterRender = false;
  19037. this.pendingCleanup = false;
  19038. this.intentStates = Object.create(null);
  19039. this.destroyed = false;
  19040. }
  19041. PDFPageProxy.prototype = {
  19042. get pageNumber() {
  19043. return this.pageIndex + 1;
  19044. },
  19045. get rotate() {
  19046. return this.pageInfo.rotate;
  19047. },
  19048. get ref() {
  19049. return this.pageInfo.ref;
  19050. },
  19051. get userUnit() {
  19052. return this.pageInfo.userUnit;
  19053. },
  19054. get view() {
  19055. return this.pageInfo.view;
  19056. },
  19057. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19058. if (arguments.length < 2) {
  19059. rotate = this.rotate;
  19060. }
  19061. return new PageViewport(this.view, scale, rotate, 0, 0);
  19062. },
  19063. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19064. var intent = params && params.intent || null;
  19065. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19066. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19067. this.annotationsIntent = intent;
  19068. }
  19069. return this.annotationsPromise;
  19070. },
  19071. render: function PDFPageProxy_render(params) {
  19072. var stats = this.stats;
  19073. stats.time('Overall');
  19074. this.pendingCleanup = false;
  19075. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19076. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19077. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19078. if (!this.intentStates[renderingIntent]) {
  19079. this.intentStates[renderingIntent] = Object.create(null);
  19080. }
  19081. var intentState = this.intentStates[renderingIntent];
  19082. if (!intentState.displayReadyCapability) {
  19083. intentState.receivingOperatorList = true;
  19084. intentState.displayReadyCapability = createPromiseCapability();
  19085. intentState.operatorList = {
  19086. fnArray: [],
  19087. argsArray: [],
  19088. lastChunk: false
  19089. };
  19090. this.stats.time('Page Request');
  19091. this.transport.messageHandler.send('RenderPageRequest', {
  19092. pageIndex: this.pageNumber - 1,
  19093. intent: renderingIntent,
  19094. renderInteractiveForms: renderInteractiveForms
  19095. });
  19096. }
  19097. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19098. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19099. if (!intentState.renderTasks) {
  19100. intentState.renderTasks = [];
  19101. }
  19102. intentState.renderTasks.push(internalRenderTask);
  19103. var renderTask = internalRenderTask.task;
  19104. if (params.continueCallback) {
  19105. deprecated('render is used with continueCallback parameter');
  19106. renderTask.onContinue = params.continueCallback;
  19107. }
  19108. var self = this;
  19109. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19110. if (self.pendingCleanup) {
  19111. complete();
  19112. return;
  19113. }
  19114. stats.time('Rendering');
  19115. internalRenderTask.initializeGraphics(transparency);
  19116. internalRenderTask.operatorListChanged();
  19117. }, function pageDisplayReadPromiseError(reason) {
  19118. complete(reason);
  19119. });
  19120. function complete(error) {
  19121. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19122. if (i >= 0) {
  19123. intentState.renderTasks.splice(i, 1);
  19124. }
  19125. if (self.cleanupAfterRender) {
  19126. self.pendingCleanup = true;
  19127. }
  19128. self._tryCleanup();
  19129. if (error) {
  19130. internalRenderTask.capability.reject(error);
  19131. } else {
  19132. internalRenderTask.capability.resolve();
  19133. }
  19134. stats.timeEnd('Rendering');
  19135. stats.timeEnd('Overall');
  19136. }
  19137. return renderTask;
  19138. },
  19139. getOperatorList: function PDFPageProxy_getOperatorList() {
  19140. function operatorListChanged() {
  19141. if (intentState.operatorList.lastChunk) {
  19142. intentState.opListReadCapability.resolve(intentState.operatorList);
  19143. var i = intentState.renderTasks.indexOf(opListTask);
  19144. if (i >= 0) {
  19145. intentState.renderTasks.splice(i, 1);
  19146. }
  19147. }
  19148. }
  19149. var renderingIntent = 'oplist';
  19150. if (!this.intentStates[renderingIntent]) {
  19151. this.intentStates[renderingIntent] = Object.create(null);
  19152. }
  19153. var intentState = this.intentStates[renderingIntent];
  19154. var opListTask;
  19155. if (!intentState.opListReadCapability) {
  19156. opListTask = {};
  19157. opListTask.operatorListChanged = operatorListChanged;
  19158. intentState.receivingOperatorList = true;
  19159. intentState.opListReadCapability = createPromiseCapability();
  19160. intentState.renderTasks = [];
  19161. intentState.renderTasks.push(opListTask);
  19162. intentState.operatorList = {
  19163. fnArray: [],
  19164. argsArray: [],
  19165. lastChunk: false
  19166. };
  19167. this.transport.messageHandler.send('RenderPageRequest', {
  19168. pageIndex: this.pageIndex,
  19169. intent: renderingIntent
  19170. });
  19171. }
  19172. return intentState.opListReadCapability.promise;
  19173. },
  19174. getTextContent: function PDFPageProxy_getTextContent(params) {
  19175. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19176. pageIndex: this.pageNumber - 1,
  19177. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19178. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19179. });
  19180. },
  19181. _destroy: function PDFPageProxy_destroy() {
  19182. this.destroyed = true;
  19183. this.transport.pageCache[this.pageIndex] = null;
  19184. var waitOn = [];
  19185. Object.keys(this.intentStates).forEach(function (intent) {
  19186. if (intent === 'oplist') {
  19187. return;
  19188. }
  19189. var intentState = this.intentStates[intent];
  19190. intentState.renderTasks.forEach(function (renderTask) {
  19191. var renderCompleted = renderTask.capability.promise.catch(function () {
  19192. });
  19193. waitOn.push(renderCompleted);
  19194. renderTask.cancel();
  19195. });
  19196. }, this);
  19197. this.objs.clear();
  19198. this.annotationsPromise = null;
  19199. this.pendingCleanup = false;
  19200. return Promise.all(waitOn);
  19201. },
  19202. destroy: function () {
  19203. deprecated('page destroy method, use cleanup() instead');
  19204. this.cleanup();
  19205. },
  19206. cleanup: function PDFPageProxy_cleanup() {
  19207. this.pendingCleanup = true;
  19208. this._tryCleanup();
  19209. },
  19210. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19211. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19212. var intentState = this.intentStates[intent];
  19213. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19214. }, this)) {
  19215. return;
  19216. }
  19217. Object.keys(this.intentStates).forEach(function (intent) {
  19218. delete this.intentStates[intent];
  19219. }, this);
  19220. this.objs.clear();
  19221. this.annotationsPromise = null;
  19222. this.pendingCleanup = false;
  19223. },
  19224. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19225. var intentState = this.intentStates[intent];
  19226. if (intentState.displayReadyCapability) {
  19227. intentState.displayReadyCapability.resolve(transparency);
  19228. }
  19229. },
  19230. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  19231. var intentState = this.intentStates[intent];
  19232. var i, ii;
  19233. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  19234. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  19235. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  19236. }
  19237. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  19238. for (i = 0; i < intentState.renderTasks.length; i++) {
  19239. intentState.renderTasks[i].operatorListChanged();
  19240. }
  19241. if (operatorListChunk.lastChunk) {
  19242. intentState.receivingOperatorList = false;
  19243. this._tryCleanup();
  19244. }
  19245. }
  19246. };
  19247. return PDFPageProxy;
  19248. }();
  19249. var PDFWorker = function PDFWorkerClosure() {
  19250. var nextFakeWorkerId = 0;
  19251. function getWorkerSrc() {
  19252. if (typeof workerSrc !== 'undefined') {
  19253. return workerSrc;
  19254. }
  19255. if (getDefaultSetting('workerSrc')) {
  19256. return getDefaultSetting('workerSrc');
  19257. }
  19258. if (pdfjsFilePath) {
  19259. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  19260. }
  19261. error('No PDFJS.workerSrc specified');
  19262. }
  19263. var fakeWorkerFilesLoadedCapability;
  19264. function setupFakeWorkerGlobal() {
  19265. var WorkerMessageHandler;
  19266. if (fakeWorkerFilesLoadedCapability) {
  19267. return fakeWorkerFilesLoadedCapability.promise;
  19268. }
  19269. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  19270. var pdfjsCoreWorker = __w_pdfjs_require__(23);
  19271. __w_pdfjs_require__(39);
  19272. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  19273. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  19274. return fakeWorkerFilesLoadedCapability.promise;
  19275. }
  19276. function FakeWorkerPort(defer) {
  19277. this._listeners = [];
  19278. this._defer = defer;
  19279. this._deferred = Promise.resolve(undefined);
  19280. }
  19281. FakeWorkerPort.prototype = {
  19282. postMessage: function (obj, transfers) {
  19283. function cloneValue(value) {
  19284. if (typeof value !== 'object' || value === null) {
  19285. return value;
  19286. }
  19287. if (cloned.has(value)) {
  19288. return cloned.get(value);
  19289. }
  19290. var result;
  19291. var buffer;
  19292. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  19293. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  19294. if (value === buffer) {
  19295. result = value;
  19296. } else if (transferable) {
  19297. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  19298. } else {
  19299. result = new value.constructor(value);
  19300. }
  19301. cloned.set(value, result);
  19302. return result;
  19303. }
  19304. result = isArray(value) ? [] : {};
  19305. cloned.set(value, result);
  19306. for (var i in value) {
  19307. var desc, p = value;
  19308. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  19309. p = Object.getPrototypeOf(p);
  19310. }
  19311. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  19312. continue;
  19313. }
  19314. result[i] = cloneValue(desc.value);
  19315. }
  19316. return result;
  19317. }
  19318. if (!this._defer) {
  19319. this._listeners.forEach(function (listener) {
  19320. listener.call(this, { data: obj });
  19321. }, this);
  19322. return;
  19323. }
  19324. var cloned = new WeakMap();
  19325. var e = { data: cloneValue(obj) };
  19326. this._deferred.then(function () {
  19327. this._listeners.forEach(function (listener) {
  19328. listener.call(this, e);
  19329. }, this);
  19330. }.bind(this));
  19331. },
  19332. addEventListener: function (name, listener) {
  19333. this._listeners.push(listener);
  19334. },
  19335. removeEventListener: function (name, listener) {
  19336. var i = this._listeners.indexOf(listener);
  19337. this._listeners.splice(i, 1);
  19338. },
  19339. terminate: function () {
  19340. this._listeners = [];
  19341. }
  19342. };
  19343. function createCDNWrapper(url) {
  19344. var wrapper = 'importScripts(\'' + url + '\');';
  19345. return URL.createObjectURL(new Blob([wrapper]));
  19346. }
  19347. function PDFWorker(name, port) {
  19348. this.name = name;
  19349. this.destroyed = false;
  19350. this._readyCapability = createPromiseCapability();
  19351. this._port = null;
  19352. this._webWorker = null;
  19353. this._messageHandler = null;
  19354. if (port) {
  19355. this._initializeFromPort(port);
  19356. return;
  19357. }
  19358. this._initialize();
  19359. }
  19360. PDFWorker.prototype = {
  19361. get promise() {
  19362. return this._readyCapability.promise;
  19363. },
  19364. get port() {
  19365. return this._port;
  19366. },
  19367. get messageHandler() {
  19368. return this._messageHandler;
  19369. },
  19370. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  19371. this._port = port;
  19372. this._messageHandler = new MessageHandler('main', 'worker', port);
  19373. this._messageHandler.on('ready', function () {
  19374. });
  19375. this._readyCapability.resolve();
  19376. },
  19377. _initialize: function PDFWorker_initialize() {
  19378. this._setupFakeWorker();
  19379. },
  19380. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  19381. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  19382. warn('Setting up fake worker.');
  19383. isWorkerDisabled = true;
  19384. }
  19385. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  19386. if (this.destroyed) {
  19387. this._readyCapability.reject(new Error('Worker was destroyed'));
  19388. return;
  19389. }
  19390. var isTypedArraysPresent = Uint8Array !== Float32Array;
  19391. var port = new FakeWorkerPort(isTypedArraysPresent);
  19392. this._port = port;
  19393. var id = 'fake' + nextFakeWorkerId++;
  19394. var workerHandler = new MessageHandler(id + '_worker', id, port);
  19395. WorkerMessageHandler.setup(workerHandler, port);
  19396. var messageHandler = new MessageHandler(id, id + '_worker', port);
  19397. this._messageHandler = messageHandler;
  19398. this._readyCapability.resolve();
  19399. }.bind(this));
  19400. },
  19401. destroy: function PDFWorker_destroy() {
  19402. this.destroyed = true;
  19403. if (this._webWorker) {
  19404. this._webWorker.terminate();
  19405. this._webWorker = null;
  19406. }
  19407. this._port = null;
  19408. if (this._messageHandler) {
  19409. this._messageHandler.destroy();
  19410. this._messageHandler = null;
  19411. }
  19412. }
  19413. };
  19414. return PDFWorker;
  19415. }();
  19416. var WorkerTransport = function WorkerTransportClosure() {
  19417. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  19418. this.messageHandler = messageHandler;
  19419. this.loadingTask = loadingTask;
  19420. this.pdfDataRangeTransport = pdfDataRangeTransport;
  19421. this.commonObjs = new PDFObjects();
  19422. this.fontLoader = new FontLoader(loadingTask.docId);
  19423. this.CMapReaderFactory = new CMapReaderFactory({
  19424. baseUrl: getDefaultSetting('cMapUrl'),
  19425. isCompressed: getDefaultSetting('cMapPacked')
  19426. });
  19427. this.destroyed = false;
  19428. this.destroyCapability = null;
  19429. this._passwordCapability = null;
  19430. this.pageCache = [];
  19431. this.pagePromises = [];
  19432. this.downloadInfoCapability = createPromiseCapability();
  19433. this.setupMessageHandler();
  19434. }
  19435. WorkerTransport.prototype = {
  19436. destroy: function WorkerTransport_destroy() {
  19437. if (this.destroyCapability) {
  19438. return this.destroyCapability.promise;
  19439. }
  19440. this.destroyed = true;
  19441. this.destroyCapability = createPromiseCapability();
  19442. if (this._passwordCapability) {
  19443. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  19444. }
  19445. var waitOn = [];
  19446. this.pageCache.forEach(function (page) {
  19447. if (page) {
  19448. waitOn.push(page._destroy());
  19449. }
  19450. });
  19451. this.pageCache = [];
  19452. this.pagePromises = [];
  19453. var self = this;
  19454. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  19455. waitOn.push(terminated);
  19456. Promise.all(waitOn).then(function () {
  19457. self.fontLoader.clear();
  19458. if (self.pdfDataRangeTransport) {
  19459. self.pdfDataRangeTransport.abort();
  19460. self.pdfDataRangeTransport = null;
  19461. }
  19462. if (self.messageHandler) {
  19463. self.messageHandler.destroy();
  19464. self.messageHandler = null;
  19465. }
  19466. self.destroyCapability.resolve();
  19467. }, this.destroyCapability.reject);
  19468. return this.destroyCapability.promise;
  19469. },
  19470. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  19471. var messageHandler = this.messageHandler;
  19472. var loadingTask = this.loadingTask;
  19473. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  19474. if (pdfDataRangeTransport) {
  19475. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  19476. messageHandler.send('OnDataRange', {
  19477. begin: begin,
  19478. chunk: chunk
  19479. });
  19480. });
  19481. pdfDataRangeTransport.addProgressListener(function (loaded) {
  19482. messageHandler.send('OnDataProgress', { loaded: loaded });
  19483. });
  19484. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  19485. messageHandler.send('OnDataRange', { chunk: chunk });
  19486. });
  19487. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  19488. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  19489. }, this);
  19490. }
  19491. messageHandler.on('GetDoc', function transportDoc(data) {
  19492. var pdfInfo = data.pdfInfo;
  19493. this.numPages = data.pdfInfo.numPages;
  19494. var loadingTask = this.loadingTask;
  19495. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  19496. this.pdfDocument = pdfDocument;
  19497. loadingTask._capability.resolve(pdfDocument);
  19498. }, this);
  19499. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  19500. this._passwordCapability = createPromiseCapability();
  19501. if (loadingTask.onPassword) {
  19502. var updatePassword = function (password) {
  19503. this._passwordCapability.resolve({ password: password });
  19504. }.bind(this);
  19505. loadingTask.onPassword(updatePassword, exception.code);
  19506. } else {
  19507. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  19508. }
  19509. return this._passwordCapability.promise;
  19510. }, this);
  19511. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  19512. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  19513. }, this);
  19514. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  19515. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  19516. }, this);
  19517. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  19518. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  19519. }, this);
  19520. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  19521. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  19522. }, this);
  19523. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  19524. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  19525. }, this);
  19526. messageHandler.on('DataLoaded', function transportPage(data) {
  19527. this.downloadInfoCapability.resolve(data);
  19528. }, this);
  19529. messageHandler.on('PDFManagerReady', function transportPage(data) {
  19530. if (this.pdfDataRangeTransport) {
  19531. this.pdfDataRangeTransport.transportReady();
  19532. }
  19533. }, this);
  19534. messageHandler.on('StartRenderPage', function transportRender(data) {
  19535. if (this.destroyed) {
  19536. return;
  19537. }
  19538. var page = this.pageCache[data.pageIndex];
  19539. page.stats.timeEnd('Page Request');
  19540. page._startRenderPage(data.transparency, data.intent);
  19541. }, this);
  19542. messageHandler.on('RenderPageChunk', function transportRender(data) {
  19543. if (this.destroyed) {
  19544. return;
  19545. }
  19546. var page = this.pageCache[data.pageIndex];
  19547. page._renderPageChunk(data.operatorList, data.intent);
  19548. }, this);
  19549. messageHandler.on('commonobj', function transportObj(data) {
  19550. if (this.destroyed) {
  19551. return;
  19552. }
  19553. var id = data[0];
  19554. var type = data[1];
  19555. if (this.commonObjs.hasData(id)) {
  19556. return;
  19557. }
  19558. switch (type) {
  19559. case 'Font':
  19560. var exportedData = data[2];
  19561. if ('error' in exportedData) {
  19562. var exportedError = exportedData.error;
  19563. warn('Error during font loading: ' + exportedError);
  19564. this.commonObjs.resolve(id, exportedError);
  19565. break;
  19566. }
  19567. var fontRegistry = null;
  19568. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  19569. fontRegistry = {
  19570. registerFont: function (font, url) {
  19571. globalScope['FontInspector'].fontAdded(font, url);
  19572. }
  19573. };
  19574. }
  19575. var font = new FontFaceObject(exportedData, {
  19576. isEvalSuported: getDefaultSetting('isEvalSupported'),
  19577. disableFontFace: getDefaultSetting('disableFontFace'),
  19578. fontRegistry: fontRegistry
  19579. });
  19580. this.fontLoader.bind([font], function fontReady(fontObjs) {
  19581. this.commonObjs.resolve(id, font);
  19582. }.bind(this));
  19583. break;
  19584. case 'FontPath':
  19585. this.commonObjs.resolve(id, data[2]);
  19586. break;
  19587. default:
  19588. error('Got unknown common object type ' + type);
  19589. }
  19590. }, this);
  19591. messageHandler.on('obj', function transportObj(data) {
  19592. if (this.destroyed) {
  19593. return;
  19594. }
  19595. var id = data[0];
  19596. var pageIndex = data[1];
  19597. var type = data[2];
  19598. var pageProxy = this.pageCache[pageIndex];
  19599. var imageData;
  19600. if (pageProxy.objs.hasData(id)) {
  19601. return;
  19602. }
  19603. switch (type) {
  19604. case 'JpegStream':
  19605. imageData = data[3];
  19606. loadJpegStream(id, imageData, pageProxy.objs);
  19607. break;
  19608. case 'Image':
  19609. imageData = data[3];
  19610. pageProxy.objs.resolve(id, imageData);
  19611. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  19612. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  19613. pageProxy.cleanupAfterRender = true;
  19614. }
  19615. break;
  19616. default:
  19617. error('Got unknown object type ' + type);
  19618. }
  19619. }, this);
  19620. messageHandler.on('DocProgress', function transportDocProgress(data) {
  19621. if (this.destroyed) {
  19622. return;
  19623. }
  19624. var loadingTask = this.loadingTask;
  19625. if (loadingTask.onProgress) {
  19626. loadingTask.onProgress({
  19627. loaded: data.loaded,
  19628. total: data.total
  19629. });
  19630. }
  19631. }, this);
  19632. messageHandler.on('PageError', function transportError(data) {
  19633. if (this.destroyed) {
  19634. return;
  19635. }
  19636. var page = this.pageCache[data.pageNum - 1];
  19637. var intentState = page.intentStates[data.intent];
  19638. if (intentState.displayReadyCapability) {
  19639. intentState.displayReadyCapability.reject(data.error);
  19640. } else {
  19641. error(data.error);
  19642. }
  19643. if (intentState.operatorList) {
  19644. intentState.operatorList.lastChunk = true;
  19645. for (var i = 0; i < intentState.renderTasks.length; i++) {
  19646. intentState.renderTasks[i].operatorListChanged();
  19647. }
  19648. }
  19649. }, this);
  19650. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  19651. if (this.destroyed) {
  19652. return;
  19653. }
  19654. var featureId = data.featureId;
  19655. var loadingTask = this.loadingTask;
  19656. if (loadingTask.onUnsupportedFeature) {
  19657. loadingTask.onUnsupportedFeature(featureId);
  19658. }
  19659. _UnsupportedManager.notify(featureId);
  19660. }, this);
  19661. messageHandler.on('JpegDecode', function (data) {
  19662. if (this.destroyed) {
  19663. return Promise.reject(new Error('Worker was destroyed'));
  19664. }
  19665. if (typeof document === 'undefined') {
  19666. return Promise.reject(new Error('"document" is not defined.'));
  19667. }
  19668. var imageUrl = data[0];
  19669. var components = data[1];
  19670. if (components !== 3 && components !== 1) {
  19671. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  19672. }
  19673. return new Promise(function (resolve, reject) {
  19674. var img = new Image();
  19675. img.onload = function () {
  19676. var width = img.width;
  19677. var height = img.height;
  19678. var size = width * height;
  19679. var rgbaLength = size * 4;
  19680. var buf = new Uint8Array(size * components);
  19681. var tmpCanvas = document.createElement('canvas');
  19682. tmpCanvas.width = width;
  19683. tmpCanvas.height = height;
  19684. var tmpCtx = tmpCanvas.getContext('2d');
  19685. tmpCtx.drawImage(img, 0, 0);
  19686. var data = tmpCtx.getImageData(0, 0, width, height).data;
  19687. var i, j;
  19688. if (components === 3) {
  19689. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  19690. buf[j] = data[i];
  19691. buf[j + 1] = data[i + 1];
  19692. buf[j + 2] = data[i + 2];
  19693. }
  19694. } else if (components === 1) {
  19695. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  19696. buf[j] = data[i];
  19697. }
  19698. }
  19699. resolve({
  19700. data: buf,
  19701. width: width,
  19702. height: height
  19703. });
  19704. };
  19705. img.onerror = function () {
  19706. reject(new Error('JpegDecode failed to load image'));
  19707. };
  19708. img.src = imageUrl;
  19709. });
  19710. }, this);
  19711. messageHandler.on('FetchBuiltInCMap', function (data) {
  19712. if (this.destroyed) {
  19713. return Promise.reject(new Error('Worker was destroyed'));
  19714. }
  19715. return this.CMapReaderFactory.fetch({ name: data.name });
  19716. }, this);
  19717. },
  19718. getData: function WorkerTransport_getData() {
  19719. return this.messageHandler.sendWithPromise('GetData', null);
  19720. },
  19721. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  19722. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  19723. return Promise.reject(new Error('Invalid page request'));
  19724. }
  19725. var pageIndex = pageNumber - 1;
  19726. if (pageIndex in this.pagePromises) {
  19727. return this.pagePromises[pageIndex];
  19728. }
  19729. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  19730. if (this.destroyed) {
  19731. throw new Error('Transport destroyed');
  19732. }
  19733. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  19734. this.pageCache[pageIndex] = page;
  19735. return page;
  19736. }.bind(this));
  19737. this.pagePromises[pageIndex] = promise;
  19738. return promise;
  19739. },
  19740. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  19741. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  19742. return Promise.reject(new Error(reason));
  19743. });
  19744. },
  19745. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  19746. return this.messageHandler.sendWithPromise('GetAnnotations', {
  19747. pageIndex: pageIndex,
  19748. intent: intent
  19749. });
  19750. },
  19751. getDestinations: function WorkerTransport_getDestinations() {
  19752. return this.messageHandler.sendWithPromise('GetDestinations', null);
  19753. },
  19754. getDestination: function WorkerTransport_getDestination(id) {
  19755. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  19756. },
  19757. getPageLabels: function WorkerTransport_getPageLabels() {
  19758. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  19759. },
  19760. getAttachments: function WorkerTransport_getAttachments() {
  19761. return this.messageHandler.sendWithPromise('GetAttachments', null);
  19762. },
  19763. getJavaScript: function WorkerTransport_getJavaScript() {
  19764. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  19765. },
  19766. getOutline: function WorkerTransport_getOutline() {
  19767. return this.messageHandler.sendWithPromise('GetOutline', null);
  19768. },
  19769. getMetadata: function WorkerTransport_getMetadata() {
  19770. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  19771. return {
  19772. info: results[0],
  19773. metadata: results[1] ? new Metadata(results[1]) : null
  19774. };
  19775. });
  19776. },
  19777. getStats: function WorkerTransport_getStats() {
  19778. return this.messageHandler.sendWithPromise('GetStats', null);
  19779. },
  19780. startCleanup: function WorkerTransport_startCleanup() {
  19781. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  19782. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  19783. var page = this.pageCache[i];
  19784. if (page) {
  19785. page.cleanup();
  19786. }
  19787. }
  19788. this.commonObjs.clear();
  19789. this.fontLoader.clear();
  19790. }.bind(this));
  19791. }
  19792. };
  19793. return WorkerTransport;
  19794. }();
  19795. var PDFObjects = function PDFObjectsClosure() {
  19796. function PDFObjects() {
  19797. this.objs = Object.create(null);
  19798. }
  19799. PDFObjects.prototype = {
  19800. ensureObj: function PDFObjects_ensureObj(objId) {
  19801. if (this.objs[objId]) {
  19802. return this.objs[objId];
  19803. }
  19804. var obj = {
  19805. capability: createPromiseCapability(),
  19806. data: null,
  19807. resolved: false
  19808. };
  19809. this.objs[objId] = obj;
  19810. return obj;
  19811. },
  19812. get: function PDFObjects_get(objId, callback) {
  19813. if (callback) {
  19814. this.ensureObj(objId).capability.promise.then(callback);
  19815. return null;
  19816. }
  19817. var obj = this.objs[objId];
  19818. if (!obj || !obj.resolved) {
  19819. error('Requesting object that isn\'t resolved yet ' + objId);
  19820. }
  19821. return obj.data;
  19822. },
  19823. resolve: function PDFObjects_resolve(objId, data) {
  19824. var obj = this.ensureObj(objId);
  19825. obj.resolved = true;
  19826. obj.data = data;
  19827. obj.capability.resolve(data);
  19828. },
  19829. isResolved: function PDFObjects_isResolved(objId) {
  19830. var objs = this.objs;
  19831. if (!objs[objId]) {
  19832. return false;
  19833. }
  19834. return objs[objId].resolved;
  19835. },
  19836. hasData: function PDFObjects_hasData(objId) {
  19837. return this.isResolved(objId);
  19838. },
  19839. getData: function PDFObjects_getData(objId) {
  19840. var objs = this.objs;
  19841. if (!objs[objId] || !objs[objId].resolved) {
  19842. return null;
  19843. }
  19844. return objs[objId].data;
  19845. },
  19846. clear: function PDFObjects_clear() {
  19847. this.objs = Object.create(null);
  19848. }
  19849. };
  19850. return PDFObjects;
  19851. }();
  19852. var RenderTask = function RenderTaskClosure() {
  19853. function RenderTask(internalRenderTask) {
  19854. this._internalRenderTask = internalRenderTask;
  19855. this.onContinue = null;
  19856. }
  19857. RenderTask.prototype = {
  19858. get promise() {
  19859. return this._internalRenderTask.capability.promise;
  19860. },
  19861. cancel: function RenderTask_cancel() {
  19862. this._internalRenderTask.cancel();
  19863. },
  19864. then: function RenderTask_then(onFulfilled, onRejected) {
  19865. return this.promise.then.apply(this.promise, arguments);
  19866. }
  19867. };
  19868. return RenderTask;
  19869. }();
  19870. var InternalRenderTask = function InternalRenderTaskClosure() {
  19871. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  19872. this.callback = callback;
  19873. this.params = params;
  19874. this.objs = objs;
  19875. this.commonObjs = commonObjs;
  19876. this.operatorListIdx = null;
  19877. this.operatorList = operatorList;
  19878. this.pageNumber = pageNumber;
  19879. this.canvasFactory = canvasFactory;
  19880. this.running = false;
  19881. this.graphicsReadyCallback = null;
  19882. this.graphicsReady = false;
  19883. this.useRequestAnimationFrame = false;
  19884. this.cancelled = false;
  19885. this.capability = createPromiseCapability();
  19886. this.task = new RenderTask(this);
  19887. this._continueBound = this._continue.bind(this);
  19888. this._scheduleNextBound = this._scheduleNext.bind(this);
  19889. this._nextBound = this._next.bind(this);
  19890. }
  19891. InternalRenderTask.prototype = {
  19892. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  19893. if (this.cancelled) {
  19894. return;
  19895. }
  19896. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  19897. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  19898. this.stepper.init(this.operatorList);
  19899. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  19900. }
  19901. var params = this.params;
  19902. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  19903. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  19904. this.operatorListIdx = 0;
  19905. this.graphicsReady = true;
  19906. if (this.graphicsReadyCallback) {
  19907. this.graphicsReadyCallback();
  19908. }
  19909. },
  19910. cancel: function InternalRenderTask_cancel() {
  19911. this.running = false;
  19912. this.cancelled = true;
  19913. this.callback('cancelled');
  19914. },
  19915. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  19916. if (!this.graphicsReady) {
  19917. if (!this.graphicsReadyCallback) {
  19918. this.graphicsReadyCallback = this._continueBound;
  19919. }
  19920. return;
  19921. }
  19922. if (this.stepper) {
  19923. this.stepper.updateOperatorList(this.operatorList);
  19924. }
  19925. if (this.running) {
  19926. return;
  19927. }
  19928. this._continue();
  19929. },
  19930. _continue: function InternalRenderTask__continue() {
  19931. this.running = true;
  19932. if (this.cancelled) {
  19933. return;
  19934. }
  19935. if (this.task.onContinue) {
  19936. this.task.onContinue(this._scheduleNextBound);
  19937. } else {
  19938. this._scheduleNext();
  19939. }
  19940. },
  19941. _scheduleNext: function InternalRenderTask__scheduleNext() {
  19942. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  19943. window.requestAnimationFrame(this._nextBound);
  19944. } else {
  19945. Promise.resolve(undefined).then(this._nextBound);
  19946. }
  19947. },
  19948. _next: function InternalRenderTask__next() {
  19949. if (this.cancelled) {
  19950. return;
  19951. }
  19952. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  19953. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  19954. this.running = false;
  19955. if (this.operatorList.lastChunk) {
  19956. this.gfx.endDrawing();
  19957. this.callback();
  19958. }
  19959. }
  19960. }
  19961. };
  19962. return InternalRenderTask;
  19963. }();
  19964. var _UnsupportedManager = function UnsupportedManagerClosure() {
  19965. var listeners = [];
  19966. return {
  19967. listen: function (cb) {
  19968. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  19969. listeners.push(cb);
  19970. },
  19971. notify: function (featureId) {
  19972. for (var i = 0, ii = listeners.length; i < ii; i++) {
  19973. listeners[i](featureId);
  19974. }
  19975. }
  19976. };
  19977. }();
  19978. exports.version = '1.7.344';
  19979. exports.build = 'c2905614';
  19980. exports.getDocument = getDocument;
  19981. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  19982. exports.PDFWorker = PDFWorker;
  19983. exports.PDFDocumentProxy = PDFDocumentProxy;
  19984. exports.PDFPageProxy = PDFPageProxy;
  19985. exports._UnsupportedManager = _UnsupportedManager;
  19986. /***/ }),
  19987. /* 11 */
  19988. /***/ (function(module, exports, __w_pdfjs_require__) {
  19989. "use strict";
  19990. var sharedUtil = __w_pdfjs_require__(0);
  19991. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  19992. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  19993. var ImageKind = sharedUtil.ImageKind;
  19994. var OPS = sharedUtil.OPS;
  19995. var Util = sharedUtil.Util;
  19996. var isNum = sharedUtil.isNum;
  19997. var isArray = sharedUtil.isArray;
  19998. var warn = sharedUtil.warn;
  19999. var createObjectURL = sharedUtil.createObjectURL;
  20000. var SVG_DEFAULTS = {
  20001. fontStyle: 'normal',
  20002. fontWeight: 'normal',
  20003. fillColor: '#000000'
  20004. };
  20005. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20006. var PNG_HEADER = new Uint8Array([
  20007. 0x89,
  20008. 0x50,
  20009. 0x4e,
  20010. 0x47,
  20011. 0x0d,
  20012. 0x0a,
  20013. 0x1a,
  20014. 0x0a
  20015. ]);
  20016. var CHUNK_WRAPPER_SIZE = 12;
  20017. var crcTable = new Int32Array(256);
  20018. for (var i = 0; i < 256; i++) {
  20019. var c = i;
  20020. for (var h = 0; h < 8; h++) {
  20021. if (c & 1) {
  20022. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20023. } else {
  20024. c = c >> 1 & 0x7fffffff;
  20025. }
  20026. }
  20027. crcTable[i] = c;
  20028. }
  20029. function crc32(data, start, end) {
  20030. var crc = -1;
  20031. for (var i = start; i < end; i++) {
  20032. var a = (crc ^ data[i]) & 0xff;
  20033. var b = crcTable[a];
  20034. crc = crc >>> 8 ^ b;
  20035. }
  20036. return crc ^ -1;
  20037. }
  20038. function writePngChunk(type, body, data, offset) {
  20039. var p = offset;
  20040. var len = body.length;
  20041. data[p] = len >> 24 & 0xff;
  20042. data[p + 1] = len >> 16 & 0xff;
  20043. data[p + 2] = len >> 8 & 0xff;
  20044. data[p + 3] = len & 0xff;
  20045. p += 4;
  20046. data[p] = type.charCodeAt(0) & 0xff;
  20047. data[p + 1] = type.charCodeAt(1) & 0xff;
  20048. data[p + 2] = type.charCodeAt(2) & 0xff;
  20049. data[p + 3] = type.charCodeAt(3) & 0xff;
  20050. p += 4;
  20051. data.set(body, p);
  20052. p += body.length;
  20053. var crc = crc32(data, offset + 4, p);
  20054. data[p] = crc >> 24 & 0xff;
  20055. data[p + 1] = crc >> 16 & 0xff;
  20056. data[p + 2] = crc >> 8 & 0xff;
  20057. data[p + 3] = crc & 0xff;
  20058. }
  20059. function adler32(data, start, end) {
  20060. var a = 1;
  20061. var b = 0;
  20062. for (var i = start; i < end; ++i) {
  20063. a = (a + (data[i] & 0xff)) % 65521;
  20064. b = (b + a) % 65521;
  20065. }
  20066. return b << 16 | a;
  20067. }
  20068. function encode(imgData, kind, forceDataSchema) {
  20069. var width = imgData.width;
  20070. var height = imgData.height;
  20071. var bitDepth, colorType, lineSize;
  20072. var bytes = imgData.data;
  20073. switch (kind) {
  20074. case ImageKind.GRAYSCALE_1BPP:
  20075. colorType = 0;
  20076. bitDepth = 1;
  20077. lineSize = width + 7 >> 3;
  20078. break;
  20079. case ImageKind.RGB_24BPP:
  20080. colorType = 2;
  20081. bitDepth = 8;
  20082. lineSize = width * 3;
  20083. break;
  20084. case ImageKind.RGBA_32BPP:
  20085. colorType = 6;
  20086. bitDepth = 8;
  20087. lineSize = width * 4;
  20088. break;
  20089. default:
  20090. throw new Error('invalid format');
  20091. }
  20092. var literals = new Uint8Array((1 + lineSize) * height);
  20093. var offsetLiterals = 0, offsetBytes = 0;
  20094. var y, i;
  20095. for (y = 0; y < height; ++y) {
  20096. literals[offsetLiterals++] = 0;
  20097. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20098. offsetBytes += lineSize;
  20099. offsetLiterals += lineSize;
  20100. }
  20101. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20102. offsetLiterals = 0;
  20103. for (y = 0; y < height; y++) {
  20104. offsetLiterals++;
  20105. for (i = 0; i < lineSize; i++) {
  20106. literals[offsetLiterals++] ^= 0xFF;
  20107. }
  20108. }
  20109. }
  20110. var ihdr = new Uint8Array([
  20111. width >> 24 & 0xff,
  20112. width >> 16 & 0xff,
  20113. width >> 8 & 0xff,
  20114. width & 0xff,
  20115. height >> 24 & 0xff,
  20116. height >> 16 & 0xff,
  20117. height >> 8 & 0xff,
  20118. height & 0xff,
  20119. bitDepth,
  20120. colorType,
  20121. 0x00,
  20122. 0x00,
  20123. 0x00
  20124. ]);
  20125. var len = literals.length;
  20126. var maxBlockLength = 0xFFFF;
  20127. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20128. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20129. var pi = 0;
  20130. idat[pi++] = 0x78;
  20131. idat[pi++] = 0x9c;
  20132. var pos = 0;
  20133. while (len > maxBlockLength) {
  20134. idat[pi++] = 0x00;
  20135. idat[pi++] = 0xff;
  20136. idat[pi++] = 0xff;
  20137. idat[pi++] = 0x00;
  20138. idat[pi++] = 0x00;
  20139. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20140. pi += maxBlockLength;
  20141. pos += maxBlockLength;
  20142. len -= maxBlockLength;
  20143. }
  20144. idat[pi++] = 0x01;
  20145. idat[pi++] = len & 0xff;
  20146. idat[pi++] = len >> 8 & 0xff;
  20147. idat[pi++] = ~len & 0xffff & 0xff;
  20148. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20149. idat.set(literals.subarray(pos), pi);
  20150. pi += literals.length - pos;
  20151. var adler = adler32(literals, 0, literals.length);
  20152. idat[pi++] = adler >> 24 & 0xff;
  20153. idat[pi++] = adler >> 16 & 0xff;
  20154. idat[pi++] = adler >> 8 & 0xff;
  20155. idat[pi++] = adler & 0xff;
  20156. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20157. var data = new Uint8Array(pngLength);
  20158. var offset = 0;
  20159. data.set(PNG_HEADER, offset);
  20160. offset += PNG_HEADER.length;
  20161. writePngChunk('IHDR', ihdr, data, offset);
  20162. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20163. writePngChunk('IDATA', idat, data, offset);
  20164. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20165. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20166. return createObjectURL(data, 'image/png', forceDataSchema);
  20167. }
  20168. return function convertImgDataToPng(imgData, forceDataSchema) {
  20169. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20170. return encode(imgData, kind, forceDataSchema);
  20171. };
  20172. }();
  20173. var SVGExtraState = function SVGExtraStateClosure() {
  20174. function SVGExtraState() {
  20175. this.fontSizeScale = 1;
  20176. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20177. this.fontSize = 0;
  20178. this.textMatrix = IDENTITY_MATRIX;
  20179. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20180. this.leading = 0;
  20181. this.x = 0;
  20182. this.y = 0;
  20183. this.lineX = 0;
  20184. this.lineY = 0;
  20185. this.charSpacing = 0;
  20186. this.wordSpacing = 0;
  20187. this.textHScale = 1;
  20188. this.textRise = 0;
  20189. this.fillColor = SVG_DEFAULTS.fillColor;
  20190. this.strokeColor = '#000000';
  20191. this.fillAlpha = 1;
  20192. this.strokeAlpha = 1;
  20193. this.lineWidth = 1;
  20194. this.lineJoin = '';
  20195. this.lineCap = '';
  20196. this.miterLimit = 0;
  20197. this.dashArray = [];
  20198. this.dashPhase = 0;
  20199. this.dependencies = [];
  20200. this.activeClipUrl = null;
  20201. this.clipGroup = null;
  20202. this.maskId = '';
  20203. }
  20204. SVGExtraState.prototype = {
  20205. clone: function SVGExtraState_clone() {
  20206. return Object.create(this);
  20207. },
  20208. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20209. this.x = x;
  20210. this.y = y;
  20211. }
  20212. };
  20213. return SVGExtraState;
  20214. }();
  20215. var SVGGraphics = function SVGGraphicsClosure() {
  20216. function opListToTree(opList) {
  20217. var opTree = [];
  20218. var tmp = [];
  20219. var opListLen = opList.length;
  20220. for (var x = 0; x < opListLen; x++) {
  20221. if (opList[x].fn === 'save') {
  20222. opTree.push({
  20223. 'fnId': 92,
  20224. 'fn': 'group',
  20225. 'items': []
  20226. });
  20227. tmp.push(opTree);
  20228. opTree = opTree[opTree.length - 1].items;
  20229. continue;
  20230. }
  20231. if (opList[x].fn === 'restore') {
  20232. opTree = tmp.pop();
  20233. } else {
  20234. opTree.push(opList[x]);
  20235. }
  20236. }
  20237. return opTree;
  20238. }
  20239. function pf(value) {
  20240. if (value === (value | 0)) {
  20241. return value.toString();
  20242. }
  20243. var s = value.toFixed(10);
  20244. var i = s.length - 1;
  20245. if (s[i] !== '0') {
  20246. return s;
  20247. }
  20248. do {
  20249. i--;
  20250. } while (s[i] === '0');
  20251. return s.substr(0, s[i] === '.' ? i : i + 1);
  20252. }
  20253. function pm(m) {
  20254. if (m[4] === 0 && m[5] === 0) {
  20255. if (m[1] === 0 && m[2] === 0) {
  20256. if (m[0] === 1 && m[3] === 1) {
  20257. return '';
  20258. }
  20259. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  20260. }
  20261. if (m[0] === m[3] && m[1] === -m[2]) {
  20262. var a = Math.acos(m[0]) * 180 / Math.PI;
  20263. return 'rotate(' + pf(a) + ')';
  20264. }
  20265. } else {
  20266. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20267. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20268. }
  20269. }
  20270. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20271. }
  20272. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  20273. this.current = new SVGExtraState();
  20274. this.transformMatrix = IDENTITY_MATRIX;
  20275. this.transformStack = [];
  20276. this.extraStack = [];
  20277. this.commonObjs = commonObjs;
  20278. this.objs = objs;
  20279. this.pendingEOFill = false;
  20280. this.embedFonts = false;
  20281. this.embeddedFonts = Object.create(null);
  20282. this.cssStyle = null;
  20283. this.forceDataSchema = !!forceDataSchema;
  20284. }
  20285. var NS = 'http://www.w3.org/2000/svg';
  20286. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  20287. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  20288. var LINE_CAP_STYLES = [
  20289. 'butt',
  20290. 'round',
  20291. 'square'
  20292. ];
  20293. var LINE_JOIN_STYLES = [
  20294. 'miter',
  20295. 'round',
  20296. 'bevel'
  20297. ];
  20298. var clipCount = 0;
  20299. var maskCount = 0;
  20300. SVGGraphics.prototype = {
  20301. save: function SVGGraphics_save() {
  20302. this.transformStack.push(this.transformMatrix);
  20303. var old = this.current;
  20304. this.extraStack.push(old);
  20305. this.current = old.clone();
  20306. },
  20307. restore: function SVGGraphics_restore() {
  20308. this.transformMatrix = this.transformStack.pop();
  20309. this.current = this.extraStack.pop();
  20310. this.tgrp = null;
  20311. },
  20312. group: function SVGGraphics_group(items) {
  20313. this.save();
  20314. this.executeOpTree(items);
  20315. this.restore();
  20316. },
  20317. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  20318. var fnArray = operatorList.fnArray;
  20319. var fnArrayLen = fnArray.length;
  20320. var argsArray = operatorList.argsArray;
  20321. var self = this;
  20322. for (var i = 0; i < fnArrayLen; i++) {
  20323. if (OPS.dependency === fnArray[i]) {
  20324. var deps = argsArray[i];
  20325. for (var n = 0, nn = deps.length; n < nn; n++) {
  20326. var obj = deps[n];
  20327. var common = obj.substring(0, 2) === 'g_';
  20328. var promise;
  20329. if (common) {
  20330. promise = new Promise(function (resolve) {
  20331. self.commonObjs.get(obj, resolve);
  20332. });
  20333. } else {
  20334. promise = new Promise(function (resolve) {
  20335. self.objs.get(obj, resolve);
  20336. });
  20337. }
  20338. this.current.dependencies.push(promise);
  20339. }
  20340. }
  20341. }
  20342. return Promise.all(this.current.dependencies);
  20343. },
  20344. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  20345. var transformMatrix = [
  20346. a,
  20347. b,
  20348. c,
  20349. d,
  20350. e,
  20351. f
  20352. ];
  20353. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  20354. this.tgrp = null;
  20355. },
  20356. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  20357. this.viewport = viewport;
  20358. var svgElement = this._initialize(viewport);
  20359. return this.loadDependencies(operatorList).then(function () {
  20360. this.transformMatrix = IDENTITY_MATRIX;
  20361. var opTree = this.convertOpList(operatorList);
  20362. this.executeOpTree(opTree);
  20363. return svgElement;
  20364. }.bind(this));
  20365. },
  20366. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  20367. var argsArray = operatorList.argsArray;
  20368. var fnArray = operatorList.fnArray;
  20369. var fnArrayLen = fnArray.length;
  20370. var REVOPS = [];
  20371. var opList = [];
  20372. for (var op in OPS) {
  20373. REVOPS[OPS[op]] = op;
  20374. }
  20375. for (var x = 0; x < fnArrayLen; x++) {
  20376. var fnId = fnArray[x];
  20377. opList.push({
  20378. 'fnId': fnId,
  20379. 'fn': REVOPS[fnId],
  20380. 'args': argsArray[x]
  20381. });
  20382. }
  20383. return opListToTree(opList);
  20384. },
  20385. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  20386. var opTreeLen = opTree.length;
  20387. for (var x = 0; x < opTreeLen; x++) {
  20388. var fn = opTree[x].fn;
  20389. var fnId = opTree[x].fnId;
  20390. var args = opTree[x].args;
  20391. switch (fnId | 0) {
  20392. case OPS.beginText:
  20393. this.beginText();
  20394. break;
  20395. case OPS.setLeading:
  20396. this.setLeading(args);
  20397. break;
  20398. case OPS.setLeadingMoveText:
  20399. this.setLeadingMoveText(args[0], args[1]);
  20400. break;
  20401. case OPS.setFont:
  20402. this.setFont(args);
  20403. break;
  20404. case OPS.showText:
  20405. this.showText(args[0]);
  20406. break;
  20407. case OPS.showSpacedText:
  20408. this.showText(args[0]);
  20409. break;
  20410. case OPS.endText:
  20411. this.endText();
  20412. break;
  20413. case OPS.moveText:
  20414. this.moveText(args[0], args[1]);
  20415. break;
  20416. case OPS.setCharSpacing:
  20417. this.setCharSpacing(args[0]);
  20418. break;
  20419. case OPS.setWordSpacing:
  20420. this.setWordSpacing(args[0]);
  20421. break;
  20422. case OPS.setHScale:
  20423. this.setHScale(args[0]);
  20424. break;
  20425. case OPS.setTextMatrix:
  20426. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20427. break;
  20428. case OPS.setLineWidth:
  20429. this.setLineWidth(args[0]);
  20430. break;
  20431. case OPS.setLineJoin:
  20432. this.setLineJoin(args[0]);
  20433. break;
  20434. case OPS.setLineCap:
  20435. this.setLineCap(args[0]);
  20436. break;
  20437. case OPS.setMiterLimit:
  20438. this.setMiterLimit(args[0]);
  20439. break;
  20440. case OPS.setFillRGBColor:
  20441. this.setFillRGBColor(args[0], args[1], args[2]);
  20442. break;
  20443. case OPS.setStrokeRGBColor:
  20444. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20445. break;
  20446. case OPS.setDash:
  20447. this.setDash(args[0], args[1]);
  20448. break;
  20449. case OPS.setGState:
  20450. this.setGState(args[0]);
  20451. break;
  20452. case OPS.fill:
  20453. this.fill();
  20454. break;
  20455. case OPS.eoFill:
  20456. this.eoFill();
  20457. break;
  20458. case OPS.stroke:
  20459. this.stroke();
  20460. break;
  20461. case OPS.fillStroke:
  20462. this.fillStroke();
  20463. break;
  20464. case OPS.eoFillStroke:
  20465. this.eoFillStroke();
  20466. break;
  20467. case OPS.clip:
  20468. this.clip('nonzero');
  20469. break;
  20470. case OPS.eoClip:
  20471. this.clip('evenodd');
  20472. break;
  20473. case OPS.paintSolidColorImageMask:
  20474. this.paintSolidColorImageMask();
  20475. break;
  20476. case OPS.paintJpegXObject:
  20477. this.paintJpegXObject(args[0], args[1], args[2]);
  20478. break;
  20479. case OPS.paintImageXObject:
  20480. this.paintImageXObject(args[0]);
  20481. break;
  20482. case OPS.paintInlineImageXObject:
  20483. this.paintInlineImageXObject(args[0]);
  20484. break;
  20485. case OPS.paintImageMaskXObject:
  20486. this.paintImageMaskXObject(args[0]);
  20487. break;
  20488. case OPS.paintFormXObjectBegin:
  20489. this.paintFormXObjectBegin(args[0], args[1]);
  20490. break;
  20491. case OPS.paintFormXObjectEnd:
  20492. this.paintFormXObjectEnd();
  20493. break;
  20494. case OPS.closePath:
  20495. this.closePath();
  20496. break;
  20497. case OPS.closeStroke:
  20498. this.closeStroke();
  20499. break;
  20500. case OPS.closeFillStroke:
  20501. this.closeFillStroke();
  20502. break;
  20503. case OPS.nextLine:
  20504. this.nextLine();
  20505. break;
  20506. case OPS.transform:
  20507. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20508. break;
  20509. case OPS.constructPath:
  20510. this.constructPath(args[0], args[1]);
  20511. break;
  20512. case OPS.endPath:
  20513. this.endPath();
  20514. break;
  20515. case 92:
  20516. this.group(opTree[x].items);
  20517. break;
  20518. default:
  20519. warn('Unimplemented operator ' + fn);
  20520. break;
  20521. }
  20522. }
  20523. },
  20524. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  20525. this.current.wordSpacing = wordSpacing;
  20526. },
  20527. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  20528. this.current.charSpacing = charSpacing;
  20529. },
  20530. nextLine: function SVGGraphics_nextLine() {
  20531. this.moveText(0, this.current.leading);
  20532. },
  20533. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  20534. var current = this.current;
  20535. this.current.textMatrix = this.current.lineMatrix = [
  20536. a,
  20537. b,
  20538. c,
  20539. d,
  20540. e,
  20541. f
  20542. ];
  20543. this.current.x = this.current.lineX = 0;
  20544. this.current.y = this.current.lineY = 0;
  20545. current.xcoords = [];
  20546. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20547. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20548. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20549. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20550. current.txtElement = document.createElementNS(NS, 'svg:text');
  20551. current.txtElement.appendChild(current.tspan);
  20552. },
  20553. beginText: function SVGGraphics_beginText() {
  20554. this.current.x = this.current.lineX = 0;
  20555. this.current.y = this.current.lineY = 0;
  20556. this.current.textMatrix = IDENTITY_MATRIX;
  20557. this.current.lineMatrix = IDENTITY_MATRIX;
  20558. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20559. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  20560. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  20561. this.current.xcoords = [];
  20562. },
  20563. moveText: function SVGGraphics_moveText(x, y) {
  20564. var current = this.current;
  20565. this.current.x = this.current.lineX += x;
  20566. this.current.y = this.current.lineY += y;
  20567. current.xcoords = [];
  20568. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20569. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20570. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20571. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20572. },
  20573. showText: function SVGGraphics_showText(glyphs) {
  20574. var current = this.current;
  20575. var font = current.font;
  20576. var fontSize = current.fontSize;
  20577. if (fontSize === 0) {
  20578. return;
  20579. }
  20580. var charSpacing = current.charSpacing;
  20581. var wordSpacing = current.wordSpacing;
  20582. var fontDirection = current.fontDirection;
  20583. var textHScale = current.textHScale * fontDirection;
  20584. var glyphsLength = glyphs.length;
  20585. var vertical = font.vertical;
  20586. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20587. var x = 0, i;
  20588. for (i = 0; i < glyphsLength; ++i) {
  20589. var glyph = glyphs[i];
  20590. if (glyph === null) {
  20591. x += fontDirection * wordSpacing;
  20592. continue;
  20593. } else if (isNum(glyph)) {
  20594. x += -glyph * fontSize * 0.001;
  20595. continue;
  20596. }
  20597. current.xcoords.push(current.x + x * textHScale);
  20598. var width = glyph.width;
  20599. var character = glyph.fontChar;
  20600. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  20601. x += charWidth;
  20602. current.tspan.textContent += character;
  20603. }
  20604. if (vertical) {
  20605. current.y -= x * textHScale;
  20606. } else {
  20607. current.x += x * textHScale;
  20608. }
  20609. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  20610. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20611. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20612. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20613. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20614. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  20615. }
  20616. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20617. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  20618. }
  20619. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20620. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  20621. }
  20622. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  20623. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  20624. current.txtElement.appendChild(current.tspan);
  20625. current.txtgrp.appendChild(current.txtElement);
  20626. this._ensureTransformGroup().appendChild(current.txtElement);
  20627. },
  20628. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  20629. this.setLeading(-y);
  20630. this.moveText(x, y);
  20631. },
  20632. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  20633. if (!this.cssStyle) {
  20634. this.cssStyle = document.createElementNS(NS, 'svg:style');
  20635. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  20636. this.defs.appendChild(this.cssStyle);
  20637. }
  20638. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20639. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  20640. },
  20641. setFont: function SVGGraphics_setFont(details) {
  20642. var current = this.current;
  20643. var fontObj = this.commonObjs.get(details[0]);
  20644. var size = details[1];
  20645. this.current.font = fontObj;
  20646. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  20647. this.addFontStyle(fontObj);
  20648. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20649. }
  20650. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  20651. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  20652. var italic = fontObj.italic ? 'italic' : 'normal';
  20653. if (size < 0) {
  20654. size = -size;
  20655. current.fontDirection = -1;
  20656. } else {
  20657. current.fontDirection = 1;
  20658. }
  20659. current.fontSize = size;
  20660. current.fontFamily = fontObj.loadedName;
  20661. current.fontWeight = bold;
  20662. current.fontStyle = italic;
  20663. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20664. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20665. current.xcoords = [];
  20666. },
  20667. endText: function SVGGraphics_endText() {
  20668. },
  20669. setLineWidth: function SVGGraphics_setLineWidth(width) {
  20670. this.current.lineWidth = width;
  20671. },
  20672. setLineCap: function SVGGraphics_setLineCap(style) {
  20673. this.current.lineCap = LINE_CAP_STYLES[style];
  20674. },
  20675. setLineJoin: function SVGGraphics_setLineJoin(style) {
  20676. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20677. },
  20678. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  20679. this.current.miterLimit = limit;
  20680. },
  20681. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  20682. var color = Util.makeCssRgb(r, g, b);
  20683. this.current.strokeColor = color;
  20684. },
  20685. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  20686. var color = Util.makeCssRgb(r, g, b);
  20687. this.current.fillColor = color;
  20688. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20689. this.current.xcoords = [];
  20690. },
  20691. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  20692. this.current.dashArray = dashArray;
  20693. this.current.dashPhase = dashPhase;
  20694. },
  20695. constructPath: function SVGGraphics_constructPath(ops, args) {
  20696. var current = this.current;
  20697. var x = current.x, y = current.y;
  20698. current.path = document.createElementNS(NS, 'svg:path');
  20699. var d = [];
  20700. var opLength = ops.length;
  20701. for (var i = 0, j = 0; i < opLength; i++) {
  20702. switch (ops[i] | 0) {
  20703. case OPS.rectangle:
  20704. x = args[j++];
  20705. y = args[j++];
  20706. var width = args[j++];
  20707. var height = args[j++];
  20708. var xw = x + width;
  20709. var yh = y + height;
  20710. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  20711. break;
  20712. case OPS.moveTo:
  20713. x = args[j++];
  20714. y = args[j++];
  20715. d.push('M', pf(x), pf(y));
  20716. break;
  20717. case OPS.lineTo:
  20718. x = args[j++];
  20719. y = args[j++];
  20720. d.push('L', pf(x), pf(y));
  20721. break;
  20722. case OPS.curveTo:
  20723. x = args[j + 4];
  20724. y = args[j + 5];
  20725. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  20726. j += 6;
  20727. break;
  20728. case OPS.curveTo2:
  20729. x = args[j + 2];
  20730. y = args[j + 3];
  20731. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  20732. j += 4;
  20733. break;
  20734. case OPS.curveTo3:
  20735. x = args[j + 2];
  20736. y = args[j + 3];
  20737. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  20738. j += 4;
  20739. break;
  20740. case OPS.closePath:
  20741. d.push('Z');
  20742. break;
  20743. }
  20744. }
  20745. current.path.setAttributeNS(null, 'd', d.join(' '));
  20746. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  20747. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  20748. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  20749. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  20750. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  20751. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  20752. current.path.setAttributeNS(null, 'fill', 'none');
  20753. this._ensureTransformGroup().appendChild(current.path);
  20754. current.element = current.path;
  20755. current.setCurrentPoint(x, y);
  20756. },
  20757. endPath: function SVGGraphics_endPath() {
  20758. },
  20759. clip: function SVGGraphics_clip(type) {
  20760. var current = this.current;
  20761. var clipId = 'clippath' + clipCount;
  20762. clipCount++;
  20763. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  20764. clipPath.setAttributeNS(null, 'id', clipId);
  20765. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20766. var clipElement = current.element.cloneNode();
  20767. if (type === 'evenodd') {
  20768. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  20769. } else {
  20770. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  20771. }
  20772. clipPath.appendChild(clipElement);
  20773. this.defs.appendChild(clipPath);
  20774. if (current.activeClipUrl) {
  20775. current.clipGroup = null;
  20776. this.extraStack.forEach(function (prev) {
  20777. prev.clipGroup = null;
  20778. });
  20779. }
  20780. current.activeClipUrl = 'url(#' + clipId + ')';
  20781. this.tgrp = null;
  20782. },
  20783. closePath: function SVGGraphics_closePath() {
  20784. var current = this.current;
  20785. var d = current.path.getAttributeNS(null, 'd');
  20786. d += 'Z';
  20787. current.path.setAttributeNS(null, 'd', d);
  20788. },
  20789. setLeading: function SVGGraphics_setLeading(leading) {
  20790. this.current.leading = -leading;
  20791. },
  20792. setTextRise: function SVGGraphics_setTextRise(textRise) {
  20793. this.current.textRise = textRise;
  20794. },
  20795. setHScale: function SVGGraphics_setHScale(scale) {
  20796. this.current.textHScale = scale / 100;
  20797. },
  20798. setGState: function SVGGraphics_setGState(states) {
  20799. for (var i = 0, ii = states.length; i < ii; i++) {
  20800. var state = states[i];
  20801. var key = state[0];
  20802. var value = state[1];
  20803. switch (key) {
  20804. case 'LW':
  20805. this.setLineWidth(value);
  20806. break;
  20807. case 'LC':
  20808. this.setLineCap(value);
  20809. break;
  20810. case 'LJ':
  20811. this.setLineJoin(value);
  20812. break;
  20813. case 'ML':
  20814. this.setMiterLimit(value);
  20815. break;
  20816. case 'D':
  20817. this.setDash(value[0], value[1]);
  20818. break;
  20819. case 'Font':
  20820. this.setFont(value);
  20821. break;
  20822. default:
  20823. warn('Unimplemented graphic state ' + key);
  20824. break;
  20825. }
  20826. }
  20827. },
  20828. fill: function SVGGraphics_fill() {
  20829. var current = this.current;
  20830. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20831. },
  20832. stroke: function SVGGraphics_stroke() {
  20833. var current = this.current;
  20834. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  20835. current.element.setAttributeNS(null, 'fill', 'none');
  20836. },
  20837. eoFill: function SVGGraphics_eoFill() {
  20838. var current = this.current;
  20839. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20840. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20841. },
  20842. fillStroke: function SVGGraphics_fillStroke() {
  20843. this.stroke();
  20844. this.fill();
  20845. },
  20846. eoFillStroke: function SVGGraphics_eoFillStroke() {
  20847. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20848. this.fillStroke();
  20849. },
  20850. closeStroke: function SVGGraphics_closeStroke() {
  20851. this.closePath();
  20852. this.stroke();
  20853. },
  20854. closeFillStroke: function SVGGraphics_closeFillStroke() {
  20855. this.closePath();
  20856. this.fillStroke();
  20857. },
  20858. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  20859. var current = this.current;
  20860. var rect = document.createElementNS(NS, 'svg:rect');
  20861. rect.setAttributeNS(null, 'x', '0');
  20862. rect.setAttributeNS(null, 'y', '0');
  20863. rect.setAttributeNS(null, 'width', '1px');
  20864. rect.setAttributeNS(null, 'height', '1px');
  20865. rect.setAttributeNS(null, 'fill', current.fillColor);
  20866. this._ensureTransformGroup().appendChild(rect);
  20867. },
  20868. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  20869. var imgObj = this.objs.get(objId);
  20870. var imgEl = document.createElementNS(NS, 'svg:image');
  20871. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  20872. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  20873. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  20874. imgEl.setAttributeNS(null, 'x', '0');
  20875. imgEl.setAttributeNS(null, 'y', pf(-h));
  20876. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  20877. this._ensureTransformGroup().appendChild(imgEl);
  20878. },
  20879. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  20880. var imgData = this.objs.get(objId);
  20881. if (!imgData) {
  20882. warn('Dependent image isn\'t ready yet');
  20883. return;
  20884. }
  20885. this.paintInlineImageXObject(imgData);
  20886. },
  20887. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  20888. var width = imgData.width;
  20889. var height = imgData.height;
  20890. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  20891. var cliprect = document.createElementNS(NS, 'svg:rect');
  20892. cliprect.setAttributeNS(null, 'x', '0');
  20893. cliprect.setAttributeNS(null, 'y', '0');
  20894. cliprect.setAttributeNS(null, 'width', pf(width));
  20895. cliprect.setAttributeNS(null, 'height', pf(height));
  20896. this.current.element = cliprect;
  20897. this.clip('nonzero');
  20898. var imgEl = document.createElementNS(NS, 'svg:image');
  20899. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  20900. imgEl.setAttributeNS(null, 'x', '0');
  20901. imgEl.setAttributeNS(null, 'y', pf(-height));
  20902. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  20903. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  20904. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  20905. if (mask) {
  20906. mask.appendChild(imgEl);
  20907. } else {
  20908. this._ensureTransformGroup().appendChild(imgEl);
  20909. }
  20910. },
  20911. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  20912. var current = this.current;
  20913. var width = imgData.width;
  20914. var height = imgData.height;
  20915. var fillColor = current.fillColor;
  20916. current.maskId = 'mask' + maskCount++;
  20917. var mask = document.createElementNS(NS, 'svg:mask');
  20918. mask.setAttributeNS(null, 'id', current.maskId);
  20919. var rect = document.createElementNS(NS, 'svg:rect');
  20920. rect.setAttributeNS(null, 'x', '0');
  20921. rect.setAttributeNS(null, 'y', '0');
  20922. rect.setAttributeNS(null, 'width', pf(width));
  20923. rect.setAttributeNS(null, 'height', pf(height));
  20924. rect.setAttributeNS(null, 'fill', fillColor);
  20925. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  20926. this.defs.appendChild(mask);
  20927. this._ensureTransformGroup().appendChild(rect);
  20928. this.paintInlineImageXObject(imgData, mask);
  20929. },
  20930. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  20931. if (isArray(matrix) && matrix.length === 6) {
  20932. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20933. }
  20934. if (isArray(bbox) && bbox.length === 4) {
  20935. var width = bbox[2] - bbox[0];
  20936. var height = bbox[3] - bbox[1];
  20937. var cliprect = document.createElementNS(NS, 'svg:rect');
  20938. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20939. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20940. cliprect.setAttributeNS(null, 'width', pf(width));
  20941. cliprect.setAttributeNS(null, 'height', pf(height));
  20942. this.current.element = cliprect;
  20943. this.clip('nonzero');
  20944. this.endPath();
  20945. }
  20946. },
  20947. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  20948. },
  20949. _initialize: function SVGGraphics_initialize(viewport) {
  20950. var svg = document.createElementNS(NS, 'svg:svg');
  20951. svg.setAttributeNS(null, 'version', '1.1');
  20952. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  20953. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  20954. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  20955. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  20956. var definitions = document.createElementNS(NS, 'svg:defs');
  20957. svg.appendChild(definitions);
  20958. this.defs = definitions;
  20959. var rootGroup = document.createElementNS(NS, 'svg:g');
  20960. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20961. svg.appendChild(rootGroup);
  20962. this.svg = rootGroup;
  20963. return svg;
  20964. },
  20965. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  20966. if (!this.current.clipGroup) {
  20967. var clipGroup = document.createElementNS(NS, 'svg:g');
  20968. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20969. this.svg.appendChild(clipGroup);
  20970. this.current.clipGroup = clipGroup;
  20971. }
  20972. return this.current.clipGroup;
  20973. },
  20974. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  20975. if (!this.tgrp) {
  20976. this.tgrp = document.createElementNS(NS, 'svg:g');
  20977. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20978. if (this.current.activeClipUrl) {
  20979. this._ensureClipGroup().appendChild(this.tgrp);
  20980. } else {
  20981. this.svg.appendChild(this.tgrp);
  20982. }
  20983. }
  20984. return this.tgrp;
  20985. }
  20986. };
  20987. return SVGGraphics;
  20988. }();
  20989. exports.SVGGraphics = SVGGraphics;
  20990. /***/ }),
  20991. /* 12 */
  20992. /***/ (function(module, exports, __w_pdfjs_require__) {
  20993. "use strict";
  20994. var sharedUtil = __w_pdfjs_require__(0);
  20995. var displayDOMUtils = __w_pdfjs_require__(3);
  20996. var Util = sharedUtil.Util;
  20997. var createPromiseCapability = sharedUtil.createPromiseCapability;
  20998. var CustomStyle = displayDOMUtils.CustomStyle;
  20999. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21000. var renderTextLayer = function renderTextLayerClosure() {
  21001. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21002. var NonWhitespaceRegexp = /\S/;
  21003. function isAllWhitespace(str) {
  21004. return !NonWhitespaceRegexp.test(str);
  21005. }
  21006. var styleBuf = [
  21007. 'left: ',
  21008. 0,
  21009. 'px; top: ',
  21010. 0,
  21011. 'px; font-size: ',
  21012. 0,
  21013. 'px; font-family: ',
  21014. '',
  21015. ';'
  21016. ];
  21017. function appendText(task, geom, styles) {
  21018. var textDiv = document.createElement('div');
  21019. var textDivProperties = {
  21020. style: null,
  21021. angle: 0,
  21022. canvasWidth: 0,
  21023. isWhitespace: false,
  21024. originalTransform: null,
  21025. paddingBottom: 0,
  21026. paddingLeft: 0,
  21027. paddingRight: 0,
  21028. paddingTop: 0,
  21029. scale: 1
  21030. };
  21031. task._textDivs.push(textDiv);
  21032. if (isAllWhitespace(geom.str)) {
  21033. textDivProperties.isWhitespace = true;
  21034. task._textDivProperties.set(textDiv, textDivProperties);
  21035. return;
  21036. }
  21037. var tx = Util.transform(task._viewport.transform, geom.transform);
  21038. var angle = Math.atan2(tx[1], tx[0]);
  21039. var style = styles[geom.fontName];
  21040. if (style.vertical) {
  21041. angle += Math.PI / 2;
  21042. }
  21043. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21044. var fontAscent = fontHeight;
  21045. if (style.ascent) {
  21046. fontAscent = style.ascent * fontAscent;
  21047. } else if (style.descent) {
  21048. fontAscent = (1 + style.descent) * fontAscent;
  21049. }
  21050. var left;
  21051. var top;
  21052. if (angle === 0) {
  21053. left = tx[4];
  21054. top = tx[5] - fontAscent;
  21055. } else {
  21056. left = tx[4] + fontAscent * Math.sin(angle);
  21057. top = tx[5] - fontAscent * Math.cos(angle);
  21058. }
  21059. styleBuf[1] = left;
  21060. styleBuf[3] = top;
  21061. styleBuf[5] = fontHeight;
  21062. styleBuf[7] = style.fontFamily;
  21063. textDivProperties.style = styleBuf.join('');
  21064. textDiv.setAttribute('style', textDivProperties.style);
  21065. textDiv.textContent = geom.str;
  21066. if (getDefaultSetting('pdfBug')) {
  21067. textDiv.dataset.fontName = geom.fontName;
  21068. }
  21069. if (angle !== 0) {
  21070. textDivProperties.angle = angle * (180 / Math.PI);
  21071. }
  21072. if (geom.str.length > 1) {
  21073. if (style.vertical) {
  21074. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21075. } else {
  21076. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21077. }
  21078. }
  21079. task._textDivProperties.set(textDiv, textDivProperties);
  21080. if (task._enhanceTextSelection) {
  21081. var angleCos = 1, angleSin = 0;
  21082. if (angle !== 0) {
  21083. angleCos = Math.cos(angle);
  21084. angleSin = Math.sin(angle);
  21085. }
  21086. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21087. var divHeight = fontHeight;
  21088. var m, b;
  21089. if (angle !== 0) {
  21090. m = [
  21091. angleCos,
  21092. angleSin,
  21093. -angleSin,
  21094. angleCos,
  21095. left,
  21096. top
  21097. ];
  21098. b = Util.getAxialAlignedBoundingBox([
  21099. 0,
  21100. 0,
  21101. divWidth,
  21102. divHeight
  21103. ], m);
  21104. } else {
  21105. b = [
  21106. left,
  21107. top,
  21108. left + divWidth,
  21109. top + divHeight
  21110. ];
  21111. }
  21112. task._bounds.push({
  21113. left: b[0],
  21114. top: b[1],
  21115. right: b[2],
  21116. bottom: b[3],
  21117. div: textDiv,
  21118. size: [
  21119. divWidth,
  21120. divHeight
  21121. ],
  21122. m: m
  21123. });
  21124. }
  21125. }
  21126. function render(task) {
  21127. if (task._canceled) {
  21128. return;
  21129. }
  21130. var textLayerFrag = task._container;
  21131. var textDivs = task._textDivs;
  21132. var capability = task._capability;
  21133. var textDivsLength = textDivs.length;
  21134. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21135. task._renderingDone = true;
  21136. capability.resolve();
  21137. return;
  21138. }
  21139. var canvas = document.createElement('canvas');
  21140. var ctx = canvas.getContext('2d', { alpha: false });
  21141. var lastFontSize;
  21142. var lastFontFamily;
  21143. for (var i = 0; i < textDivsLength; i++) {
  21144. var textDiv = textDivs[i];
  21145. var textDivProperties = task._textDivProperties.get(textDiv);
  21146. if (textDivProperties.isWhitespace) {
  21147. continue;
  21148. }
  21149. var fontSize = textDiv.style.fontSize;
  21150. var fontFamily = textDiv.style.fontFamily;
  21151. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21152. ctx.font = fontSize + ' ' + fontFamily;
  21153. lastFontSize = fontSize;
  21154. lastFontFamily = fontFamily;
  21155. }
  21156. var width = ctx.measureText(textDiv.textContent).width;
  21157. textLayerFrag.appendChild(textDiv);
  21158. var transform = '';
  21159. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21160. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21161. transform = 'scaleX(' + textDivProperties.scale + ')';
  21162. }
  21163. if (textDivProperties.angle !== 0) {
  21164. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21165. }
  21166. if (transform !== '') {
  21167. textDivProperties.originalTransform = transform;
  21168. CustomStyle.setProp('transform', textDiv, transform);
  21169. }
  21170. task._textDivProperties.set(textDiv, textDivProperties);
  21171. }
  21172. task._renderingDone = true;
  21173. capability.resolve();
  21174. }
  21175. function expand(task) {
  21176. var bounds = task._bounds;
  21177. var viewport = task._viewport;
  21178. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21179. for (var i = 0; i < expanded.length; i++) {
  21180. var div = bounds[i].div;
  21181. var divProperties = task._textDivProperties.get(div);
  21182. if (divProperties.angle === 0) {
  21183. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21184. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21185. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21186. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21187. task._textDivProperties.set(div, divProperties);
  21188. continue;
  21189. }
  21190. var e = expanded[i], b = bounds[i];
  21191. var m = b.m, c = m[0], s = m[1];
  21192. var points = [
  21193. [
  21194. 0,
  21195. 0
  21196. ],
  21197. [
  21198. 0,
  21199. b.size[1]
  21200. ],
  21201. [
  21202. b.size[0],
  21203. 0
  21204. ],
  21205. b.size
  21206. ];
  21207. var ts = new Float64Array(64);
  21208. points.forEach(function (p, i) {
  21209. var t = Util.applyTransform(p, m);
  21210. ts[i + 0] = c && (e.left - t[0]) / c;
  21211. ts[i + 4] = s && (e.top - t[1]) / s;
  21212. ts[i + 8] = c && (e.right - t[0]) / c;
  21213. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21214. ts[i + 16] = s && (e.left - t[0]) / -s;
  21215. ts[i + 20] = c && (e.top - t[1]) / c;
  21216. ts[i + 24] = s && (e.right - t[0]) / -s;
  21217. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21218. ts[i + 32] = c && (e.left - t[0]) / -c;
  21219. ts[i + 36] = s && (e.top - t[1]) / -s;
  21220. ts[i + 40] = c && (e.right - t[0]) / -c;
  21221. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21222. ts[i + 48] = s && (e.left - t[0]) / s;
  21223. ts[i + 52] = c && (e.top - t[1]) / -c;
  21224. ts[i + 56] = s && (e.right - t[0]) / s;
  21225. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21226. });
  21227. var findPositiveMin = function (ts, offset, count) {
  21228. var result = 0;
  21229. for (var i = 0; i < count; i++) {
  21230. var t = ts[offset++];
  21231. if (t > 0) {
  21232. result = result ? Math.min(t, result) : t;
  21233. }
  21234. }
  21235. return result;
  21236. };
  21237. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21238. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21239. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21240. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21241. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21242. task._textDivProperties.set(div, divProperties);
  21243. }
  21244. }
  21245. function expandBounds(width, height, boxes) {
  21246. var bounds = boxes.map(function (box, i) {
  21247. return {
  21248. x1: box.left,
  21249. y1: box.top,
  21250. x2: box.right,
  21251. y2: box.bottom,
  21252. index: i,
  21253. x1New: undefined,
  21254. x2New: undefined
  21255. };
  21256. });
  21257. expandBoundsLTR(width, bounds);
  21258. var expanded = new Array(boxes.length);
  21259. bounds.forEach(function (b) {
  21260. var i = b.index;
  21261. expanded[i] = {
  21262. left: b.x1New,
  21263. top: 0,
  21264. right: b.x2New,
  21265. bottom: 0
  21266. };
  21267. });
  21268. boxes.map(function (box, i) {
  21269. var e = expanded[i], b = bounds[i];
  21270. b.x1 = box.top;
  21271. b.y1 = width - e.right;
  21272. b.x2 = box.bottom;
  21273. b.y2 = width - e.left;
  21274. b.index = i;
  21275. b.x1New = undefined;
  21276. b.x2New = undefined;
  21277. });
  21278. expandBoundsLTR(height, bounds);
  21279. bounds.forEach(function (b) {
  21280. var i = b.index;
  21281. expanded[i].top = b.x1New;
  21282. expanded[i].bottom = b.x2New;
  21283. });
  21284. return expanded;
  21285. }
  21286. function expandBoundsLTR(width, bounds) {
  21287. bounds.sort(function (a, b) {
  21288. return a.x1 - b.x1 || a.index - b.index;
  21289. });
  21290. var fakeBoundary = {
  21291. x1: -Infinity,
  21292. y1: -Infinity,
  21293. x2: 0,
  21294. y2: Infinity,
  21295. index: -1,
  21296. x1New: 0,
  21297. x2New: 0
  21298. };
  21299. var horizon = [{
  21300. start: -Infinity,
  21301. end: Infinity,
  21302. boundary: fakeBoundary
  21303. }];
  21304. bounds.forEach(function (boundary) {
  21305. var i = 0;
  21306. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  21307. i++;
  21308. }
  21309. var j = horizon.length - 1;
  21310. while (j >= 0 && horizon[j].start >= boundary.y2) {
  21311. j--;
  21312. }
  21313. var horizonPart, affectedBoundary;
  21314. var q, k, maxXNew = -Infinity;
  21315. for (q = i; q <= j; q++) {
  21316. horizonPart = horizon[q];
  21317. affectedBoundary = horizonPart.boundary;
  21318. var xNew;
  21319. if (affectedBoundary.x2 > boundary.x1) {
  21320. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  21321. } else if (affectedBoundary.x2New === undefined) {
  21322. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  21323. } else {
  21324. xNew = affectedBoundary.x2New;
  21325. }
  21326. if (xNew > maxXNew) {
  21327. maxXNew = xNew;
  21328. }
  21329. }
  21330. boundary.x1New = maxXNew;
  21331. for (q = i; q <= j; q++) {
  21332. horizonPart = horizon[q];
  21333. affectedBoundary = horizonPart.boundary;
  21334. if (affectedBoundary.x2New === undefined) {
  21335. if (affectedBoundary.x2 > boundary.x1) {
  21336. if (affectedBoundary.index > boundary.index) {
  21337. affectedBoundary.x2New = affectedBoundary.x2;
  21338. }
  21339. } else {
  21340. affectedBoundary.x2New = maxXNew;
  21341. }
  21342. } else if (affectedBoundary.x2New > maxXNew) {
  21343. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  21344. }
  21345. }
  21346. var changedHorizon = [], lastBoundary = null;
  21347. for (q = i; q <= j; q++) {
  21348. horizonPart = horizon[q];
  21349. affectedBoundary = horizonPart.boundary;
  21350. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  21351. if (lastBoundary === useBoundary) {
  21352. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  21353. } else {
  21354. changedHorizon.push({
  21355. start: horizonPart.start,
  21356. end: horizonPart.end,
  21357. boundary: useBoundary
  21358. });
  21359. lastBoundary = useBoundary;
  21360. }
  21361. }
  21362. if (horizon[i].start < boundary.y1) {
  21363. changedHorizon[0].start = boundary.y1;
  21364. changedHorizon.unshift({
  21365. start: horizon[i].start,
  21366. end: boundary.y1,
  21367. boundary: horizon[i].boundary
  21368. });
  21369. }
  21370. if (boundary.y2 < horizon[j].end) {
  21371. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  21372. changedHorizon.push({
  21373. start: boundary.y2,
  21374. end: horizon[j].end,
  21375. boundary: horizon[j].boundary
  21376. });
  21377. }
  21378. for (q = i; q <= j; q++) {
  21379. horizonPart = horizon[q];
  21380. affectedBoundary = horizonPart.boundary;
  21381. if (affectedBoundary.x2New !== undefined) {
  21382. continue;
  21383. }
  21384. var used = false;
  21385. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  21386. used = horizon[k].boundary === affectedBoundary;
  21387. }
  21388. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  21389. used = horizon[k].boundary === affectedBoundary;
  21390. }
  21391. for (k = 0; !used && k < changedHorizon.length; k++) {
  21392. used = changedHorizon[k].boundary === affectedBoundary;
  21393. }
  21394. if (!used) {
  21395. affectedBoundary.x2New = maxXNew;
  21396. }
  21397. }
  21398. Array.prototype.splice.apply(horizon, [
  21399. i,
  21400. j - i + 1
  21401. ].concat(changedHorizon));
  21402. });
  21403. horizon.forEach(function (horizonPart) {
  21404. var affectedBoundary = horizonPart.boundary;
  21405. if (affectedBoundary.x2New === undefined) {
  21406. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  21407. }
  21408. });
  21409. }
  21410. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  21411. this._textContent = textContent;
  21412. this._container = container;
  21413. this._viewport = viewport;
  21414. this._textDivs = textDivs || [];
  21415. this._textDivProperties = new WeakMap();
  21416. this._renderingDone = false;
  21417. this._canceled = false;
  21418. this._capability = createPromiseCapability();
  21419. this._renderTimer = null;
  21420. this._bounds = [];
  21421. this._enhanceTextSelection = !!enhanceTextSelection;
  21422. }
  21423. TextLayerRenderTask.prototype = {
  21424. get promise() {
  21425. return this._capability.promise;
  21426. },
  21427. cancel: function TextLayer_cancel() {
  21428. this._canceled = true;
  21429. if (this._renderTimer !== null) {
  21430. clearTimeout(this._renderTimer);
  21431. this._renderTimer = null;
  21432. }
  21433. this._capability.reject('canceled');
  21434. },
  21435. _render: function TextLayer_render(timeout) {
  21436. var textItems = this._textContent.items;
  21437. var textStyles = this._textContent.styles;
  21438. for (var i = 0, len = textItems.length; i < len; i++) {
  21439. appendText(this, textItems[i], textStyles);
  21440. }
  21441. if (!timeout) {
  21442. render(this);
  21443. } else {
  21444. var self = this;
  21445. this._renderTimer = setTimeout(function () {
  21446. render(self);
  21447. self._renderTimer = null;
  21448. }, timeout);
  21449. }
  21450. },
  21451. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  21452. if (!this._enhanceTextSelection || !this._renderingDone) {
  21453. return;
  21454. }
  21455. if (this._bounds !== null) {
  21456. expand(this);
  21457. this._bounds = null;
  21458. }
  21459. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  21460. var div = this._textDivs[i];
  21461. var divProperties = this._textDivProperties.get(div);
  21462. if (divProperties.isWhitespace) {
  21463. continue;
  21464. }
  21465. if (expandDivs) {
  21466. var transform = '', padding = '';
  21467. if (divProperties.scale !== 1) {
  21468. transform = 'scaleX(' + divProperties.scale + ')';
  21469. }
  21470. if (divProperties.angle !== 0) {
  21471. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  21472. }
  21473. if (divProperties.paddingLeft !== 0) {
  21474. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  21475. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  21476. }
  21477. if (divProperties.paddingTop !== 0) {
  21478. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  21479. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  21480. }
  21481. if (divProperties.paddingRight !== 0) {
  21482. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  21483. }
  21484. if (divProperties.paddingBottom !== 0) {
  21485. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  21486. }
  21487. if (padding !== '') {
  21488. div.setAttribute('style', divProperties.style + padding);
  21489. }
  21490. if (transform !== '') {
  21491. CustomStyle.setProp('transform', div, transform);
  21492. }
  21493. } else {
  21494. div.style.padding = 0;
  21495. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  21496. }
  21497. }
  21498. }
  21499. };
  21500. function renderTextLayer(renderParameters) {
  21501. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  21502. task._render(renderParameters.timeout);
  21503. return task;
  21504. }
  21505. return renderTextLayer;
  21506. }();
  21507. exports.renderTextLayer = renderTextLayer;
  21508. /***/ }),
  21509. /* 13 */
  21510. /***/ (function(module, exports) {
  21511. var g;
  21512. g = function () {
  21513. return this;
  21514. }();
  21515. try {
  21516. g = g || Function("return this")() || (1, eval)("this");
  21517. } catch (e) {
  21518. if (typeof window === "object")
  21519. g = window;
  21520. }
  21521. module.exports = g;
  21522. /***/ }),
  21523. /* 14 */
  21524. /***/ (function(module, exports, __w_pdfjs_require__) {
  21525. "use strict";
  21526. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  21527. var QeTable = [
  21528. {
  21529. qe: 0x5601,
  21530. nmps: 1,
  21531. nlps: 1,
  21532. switchFlag: 1
  21533. },
  21534. {
  21535. qe: 0x3401,
  21536. nmps: 2,
  21537. nlps: 6,
  21538. switchFlag: 0
  21539. },
  21540. {
  21541. qe: 0x1801,
  21542. nmps: 3,
  21543. nlps: 9,
  21544. switchFlag: 0
  21545. },
  21546. {
  21547. qe: 0x0AC1,
  21548. nmps: 4,
  21549. nlps: 12,
  21550. switchFlag: 0
  21551. },
  21552. {
  21553. qe: 0x0521,
  21554. nmps: 5,
  21555. nlps: 29,
  21556. switchFlag: 0
  21557. },
  21558. {
  21559. qe: 0x0221,
  21560. nmps: 38,
  21561. nlps: 33,
  21562. switchFlag: 0
  21563. },
  21564. {
  21565. qe: 0x5601,
  21566. nmps: 7,
  21567. nlps: 6,
  21568. switchFlag: 1
  21569. },
  21570. {
  21571. qe: 0x5401,
  21572. nmps: 8,
  21573. nlps: 14,
  21574. switchFlag: 0
  21575. },
  21576. {
  21577. qe: 0x4801,
  21578. nmps: 9,
  21579. nlps: 14,
  21580. switchFlag: 0
  21581. },
  21582. {
  21583. qe: 0x3801,
  21584. nmps: 10,
  21585. nlps: 14,
  21586. switchFlag: 0
  21587. },
  21588. {
  21589. qe: 0x3001,
  21590. nmps: 11,
  21591. nlps: 17,
  21592. switchFlag: 0
  21593. },
  21594. {
  21595. qe: 0x2401,
  21596. nmps: 12,
  21597. nlps: 18,
  21598. switchFlag: 0
  21599. },
  21600. {
  21601. qe: 0x1C01,
  21602. nmps: 13,
  21603. nlps: 20,
  21604. switchFlag: 0
  21605. },
  21606. {
  21607. qe: 0x1601,
  21608. nmps: 29,
  21609. nlps: 21,
  21610. switchFlag: 0
  21611. },
  21612. {
  21613. qe: 0x5601,
  21614. nmps: 15,
  21615. nlps: 14,
  21616. switchFlag: 1
  21617. },
  21618. {
  21619. qe: 0x5401,
  21620. nmps: 16,
  21621. nlps: 14,
  21622. switchFlag: 0
  21623. },
  21624. {
  21625. qe: 0x5101,
  21626. nmps: 17,
  21627. nlps: 15,
  21628. switchFlag: 0
  21629. },
  21630. {
  21631. qe: 0x4801,
  21632. nmps: 18,
  21633. nlps: 16,
  21634. switchFlag: 0
  21635. },
  21636. {
  21637. qe: 0x3801,
  21638. nmps: 19,
  21639. nlps: 17,
  21640. switchFlag: 0
  21641. },
  21642. {
  21643. qe: 0x3401,
  21644. nmps: 20,
  21645. nlps: 18,
  21646. switchFlag: 0
  21647. },
  21648. {
  21649. qe: 0x3001,
  21650. nmps: 21,
  21651. nlps: 19,
  21652. switchFlag: 0
  21653. },
  21654. {
  21655. qe: 0x2801,
  21656. nmps: 22,
  21657. nlps: 19,
  21658. switchFlag: 0
  21659. },
  21660. {
  21661. qe: 0x2401,
  21662. nmps: 23,
  21663. nlps: 20,
  21664. switchFlag: 0
  21665. },
  21666. {
  21667. qe: 0x2201,
  21668. nmps: 24,
  21669. nlps: 21,
  21670. switchFlag: 0
  21671. },
  21672. {
  21673. qe: 0x1C01,
  21674. nmps: 25,
  21675. nlps: 22,
  21676. switchFlag: 0
  21677. },
  21678. {
  21679. qe: 0x1801,
  21680. nmps: 26,
  21681. nlps: 23,
  21682. switchFlag: 0
  21683. },
  21684. {
  21685. qe: 0x1601,
  21686. nmps: 27,
  21687. nlps: 24,
  21688. switchFlag: 0
  21689. },
  21690. {
  21691. qe: 0x1401,
  21692. nmps: 28,
  21693. nlps: 25,
  21694. switchFlag: 0
  21695. },
  21696. {
  21697. qe: 0x1201,
  21698. nmps: 29,
  21699. nlps: 26,
  21700. switchFlag: 0
  21701. },
  21702. {
  21703. qe: 0x1101,
  21704. nmps: 30,
  21705. nlps: 27,
  21706. switchFlag: 0
  21707. },
  21708. {
  21709. qe: 0x0AC1,
  21710. nmps: 31,
  21711. nlps: 28,
  21712. switchFlag: 0
  21713. },
  21714. {
  21715. qe: 0x09C1,
  21716. nmps: 32,
  21717. nlps: 29,
  21718. switchFlag: 0
  21719. },
  21720. {
  21721. qe: 0x08A1,
  21722. nmps: 33,
  21723. nlps: 30,
  21724. switchFlag: 0
  21725. },
  21726. {
  21727. qe: 0x0521,
  21728. nmps: 34,
  21729. nlps: 31,
  21730. switchFlag: 0
  21731. },
  21732. {
  21733. qe: 0x0441,
  21734. nmps: 35,
  21735. nlps: 32,
  21736. switchFlag: 0
  21737. },
  21738. {
  21739. qe: 0x02A1,
  21740. nmps: 36,
  21741. nlps: 33,
  21742. switchFlag: 0
  21743. },
  21744. {
  21745. qe: 0x0221,
  21746. nmps: 37,
  21747. nlps: 34,
  21748. switchFlag: 0
  21749. },
  21750. {
  21751. qe: 0x0141,
  21752. nmps: 38,
  21753. nlps: 35,
  21754. switchFlag: 0
  21755. },
  21756. {
  21757. qe: 0x0111,
  21758. nmps: 39,
  21759. nlps: 36,
  21760. switchFlag: 0
  21761. },
  21762. {
  21763. qe: 0x0085,
  21764. nmps: 40,
  21765. nlps: 37,
  21766. switchFlag: 0
  21767. },
  21768. {
  21769. qe: 0x0049,
  21770. nmps: 41,
  21771. nlps: 38,
  21772. switchFlag: 0
  21773. },
  21774. {
  21775. qe: 0x0025,
  21776. nmps: 42,
  21777. nlps: 39,
  21778. switchFlag: 0
  21779. },
  21780. {
  21781. qe: 0x0015,
  21782. nmps: 43,
  21783. nlps: 40,
  21784. switchFlag: 0
  21785. },
  21786. {
  21787. qe: 0x0009,
  21788. nmps: 44,
  21789. nlps: 41,
  21790. switchFlag: 0
  21791. },
  21792. {
  21793. qe: 0x0005,
  21794. nmps: 45,
  21795. nlps: 42,
  21796. switchFlag: 0
  21797. },
  21798. {
  21799. qe: 0x0001,
  21800. nmps: 45,
  21801. nlps: 43,
  21802. switchFlag: 0
  21803. },
  21804. {
  21805. qe: 0x5601,
  21806. nmps: 46,
  21807. nlps: 46,
  21808. switchFlag: 0
  21809. }
  21810. ];
  21811. function ArithmeticDecoder(data, start, end) {
  21812. this.data = data;
  21813. this.bp = start;
  21814. this.dataEnd = end;
  21815. this.chigh = data[start];
  21816. this.clow = 0;
  21817. this.byteIn();
  21818. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  21819. this.clow = this.clow << 7 & 0xFFFF;
  21820. this.ct -= 7;
  21821. this.a = 0x8000;
  21822. }
  21823. ArithmeticDecoder.prototype = {
  21824. byteIn: function ArithmeticDecoder_byteIn() {
  21825. var data = this.data;
  21826. var bp = this.bp;
  21827. if (data[bp] === 0xFF) {
  21828. var b1 = data[bp + 1];
  21829. if (b1 > 0x8F) {
  21830. this.clow += 0xFF00;
  21831. this.ct = 8;
  21832. } else {
  21833. bp++;
  21834. this.clow += data[bp] << 9;
  21835. this.ct = 7;
  21836. this.bp = bp;
  21837. }
  21838. } else {
  21839. bp++;
  21840. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  21841. this.ct = 8;
  21842. this.bp = bp;
  21843. }
  21844. if (this.clow > 0xFFFF) {
  21845. this.chigh += this.clow >> 16;
  21846. this.clow &= 0xFFFF;
  21847. }
  21848. },
  21849. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  21850. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  21851. var qeTableIcx = QeTable[cx_index];
  21852. var qeIcx = qeTableIcx.qe;
  21853. var d;
  21854. var a = this.a - qeIcx;
  21855. if (this.chigh < qeIcx) {
  21856. if (a < qeIcx) {
  21857. a = qeIcx;
  21858. d = cx_mps;
  21859. cx_index = qeTableIcx.nmps;
  21860. } else {
  21861. a = qeIcx;
  21862. d = 1 ^ cx_mps;
  21863. if (qeTableIcx.switchFlag === 1) {
  21864. cx_mps = d;
  21865. }
  21866. cx_index = qeTableIcx.nlps;
  21867. }
  21868. } else {
  21869. this.chigh -= qeIcx;
  21870. if ((a & 0x8000) !== 0) {
  21871. this.a = a;
  21872. return cx_mps;
  21873. }
  21874. if (a < qeIcx) {
  21875. d = 1 ^ cx_mps;
  21876. if (qeTableIcx.switchFlag === 1) {
  21877. cx_mps = d;
  21878. }
  21879. cx_index = qeTableIcx.nlps;
  21880. } else {
  21881. d = cx_mps;
  21882. cx_index = qeTableIcx.nmps;
  21883. }
  21884. }
  21885. do {
  21886. if (this.ct === 0) {
  21887. this.byteIn();
  21888. }
  21889. a <<= 1;
  21890. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  21891. this.clow = this.clow << 1 & 0xFFFF;
  21892. this.ct--;
  21893. } while ((a & 0x8000) === 0);
  21894. this.a = a;
  21895. contexts[pos] = cx_index << 1 | cx_mps;
  21896. return d;
  21897. }
  21898. };
  21899. return ArithmeticDecoder;
  21900. }();
  21901. exports.ArithmeticDecoder = ArithmeticDecoder;
  21902. /***/ }),
  21903. /* 15 */
  21904. /***/ (function(module, exports, __w_pdfjs_require__) {
  21905. "use strict";
  21906. var sharedUtil = __w_pdfjs_require__(0);
  21907. var coreCharsets = __w_pdfjs_require__(29);
  21908. var coreEncodings = __w_pdfjs_require__(5);
  21909. var error = sharedUtil.error;
  21910. var info = sharedUtil.info;
  21911. var bytesToString = sharedUtil.bytesToString;
  21912. var warn = sharedUtil.warn;
  21913. var isArray = sharedUtil.isArray;
  21914. var Util = sharedUtil.Util;
  21915. var stringToBytes = sharedUtil.stringToBytes;
  21916. var assert = sharedUtil.assert;
  21917. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  21918. var ExpertCharset = coreCharsets.ExpertCharset;
  21919. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  21920. var StandardEncoding = coreEncodings.StandardEncoding;
  21921. var ExpertEncoding = coreEncodings.ExpertEncoding;
  21922. var MAX_SUBR_NESTING = 10;
  21923. var CFFStandardStrings = [
  21924. '.notdef',
  21925. 'space',
  21926. 'exclam',
  21927. 'quotedbl',
  21928. 'numbersign',
  21929. 'dollar',
  21930. 'percent',
  21931. 'ampersand',
  21932. 'quoteright',
  21933. 'parenleft',
  21934. 'parenright',
  21935. 'asterisk',
  21936. 'plus',
  21937. 'comma',
  21938. 'hyphen',
  21939. 'period',
  21940. 'slash',
  21941. 'zero',
  21942. 'one',
  21943. 'two',
  21944. 'three',
  21945. 'four',
  21946. 'five',
  21947. 'six',
  21948. 'seven',
  21949. 'eight',
  21950. 'nine',
  21951. 'colon',
  21952. 'semicolon',
  21953. 'less',
  21954. 'equal',
  21955. 'greater',
  21956. 'question',
  21957. 'at',
  21958. 'A',
  21959. 'B',
  21960. 'C',
  21961. 'D',
  21962. 'E',
  21963. 'F',
  21964. 'G',
  21965. 'H',
  21966. 'I',
  21967. 'J',
  21968. 'K',
  21969. 'L',
  21970. 'M',
  21971. 'N',
  21972. 'O',
  21973. 'P',
  21974. 'Q',
  21975. 'R',
  21976. 'S',
  21977. 'T',
  21978. 'U',
  21979. 'V',
  21980. 'W',
  21981. 'X',
  21982. 'Y',
  21983. 'Z',
  21984. 'bracketleft',
  21985. 'backslash',
  21986. 'bracketright',
  21987. 'asciicircum',
  21988. 'underscore',
  21989. 'quoteleft',
  21990. 'a',
  21991. 'b',
  21992. 'c',
  21993. 'd',
  21994. 'e',
  21995. 'f',
  21996. 'g',
  21997. 'h',
  21998. 'i',
  21999. 'j',
  22000. 'k',
  22001. 'l',
  22002. 'm',
  22003. 'n',
  22004. 'o',
  22005. 'p',
  22006. 'q',
  22007. 'r',
  22008. 's',
  22009. 't',
  22010. 'u',
  22011. 'v',
  22012. 'w',
  22013. 'x',
  22014. 'y',
  22015. 'z',
  22016. 'braceleft',
  22017. 'bar',
  22018. 'braceright',
  22019. 'asciitilde',
  22020. 'exclamdown',
  22021. 'cent',
  22022. 'sterling',
  22023. 'fraction',
  22024. 'yen',
  22025. 'florin',
  22026. 'section',
  22027. 'currency',
  22028. 'quotesingle',
  22029. 'quotedblleft',
  22030. 'guillemotleft',
  22031. 'guilsinglleft',
  22032. 'guilsinglright',
  22033. 'fi',
  22034. 'fl',
  22035. 'endash',
  22036. 'dagger',
  22037. 'daggerdbl',
  22038. 'periodcentered',
  22039. 'paragraph',
  22040. 'bullet',
  22041. 'quotesinglbase',
  22042. 'quotedblbase',
  22043. 'quotedblright',
  22044. 'guillemotright',
  22045. 'ellipsis',
  22046. 'perthousand',
  22047. 'questiondown',
  22048. 'grave',
  22049. 'acute',
  22050. 'circumflex',
  22051. 'tilde',
  22052. 'macron',
  22053. 'breve',
  22054. 'dotaccent',
  22055. 'dieresis',
  22056. 'ring',
  22057. 'cedilla',
  22058. 'hungarumlaut',
  22059. 'ogonek',
  22060. 'caron',
  22061. 'emdash',
  22062. 'AE',
  22063. 'ordfeminine',
  22064. 'Lslash',
  22065. 'Oslash',
  22066. 'OE',
  22067. 'ordmasculine',
  22068. 'ae',
  22069. 'dotlessi',
  22070. 'lslash',
  22071. 'oslash',
  22072. 'oe',
  22073. 'germandbls',
  22074. 'onesuperior',
  22075. 'logicalnot',
  22076. 'mu',
  22077. 'trademark',
  22078. 'Eth',
  22079. 'onehalf',
  22080. 'plusminus',
  22081. 'Thorn',
  22082. 'onequarter',
  22083. 'divide',
  22084. 'brokenbar',
  22085. 'degree',
  22086. 'thorn',
  22087. 'threequarters',
  22088. 'twosuperior',
  22089. 'registered',
  22090. 'minus',
  22091. 'eth',
  22092. 'multiply',
  22093. 'threesuperior',
  22094. 'copyright',
  22095. 'Aacute',
  22096. 'Acircumflex',
  22097. 'Adieresis',
  22098. 'Agrave',
  22099. 'Aring',
  22100. 'Atilde',
  22101. 'Ccedilla',
  22102. 'Eacute',
  22103. 'Ecircumflex',
  22104. 'Edieresis',
  22105. 'Egrave',
  22106. 'Iacute',
  22107. 'Icircumflex',
  22108. 'Idieresis',
  22109. 'Igrave',
  22110. 'Ntilde',
  22111. 'Oacute',
  22112. 'Ocircumflex',
  22113. 'Odieresis',
  22114. 'Ograve',
  22115. 'Otilde',
  22116. 'Scaron',
  22117. 'Uacute',
  22118. 'Ucircumflex',
  22119. 'Udieresis',
  22120. 'Ugrave',
  22121. 'Yacute',
  22122. 'Ydieresis',
  22123. 'Zcaron',
  22124. 'aacute',
  22125. 'acircumflex',
  22126. 'adieresis',
  22127. 'agrave',
  22128. 'aring',
  22129. 'atilde',
  22130. 'ccedilla',
  22131. 'eacute',
  22132. 'ecircumflex',
  22133. 'edieresis',
  22134. 'egrave',
  22135. 'iacute',
  22136. 'icircumflex',
  22137. 'idieresis',
  22138. 'igrave',
  22139. 'ntilde',
  22140. 'oacute',
  22141. 'ocircumflex',
  22142. 'odieresis',
  22143. 'ograve',
  22144. 'otilde',
  22145. 'scaron',
  22146. 'uacute',
  22147. 'ucircumflex',
  22148. 'udieresis',
  22149. 'ugrave',
  22150. 'yacute',
  22151. 'ydieresis',
  22152. 'zcaron',
  22153. 'exclamsmall',
  22154. 'Hungarumlautsmall',
  22155. 'dollaroldstyle',
  22156. 'dollarsuperior',
  22157. 'ampersandsmall',
  22158. 'Acutesmall',
  22159. 'parenleftsuperior',
  22160. 'parenrightsuperior',
  22161. 'twodotenleader',
  22162. 'onedotenleader',
  22163. 'zerooldstyle',
  22164. 'oneoldstyle',
  22165. 'twooldstyle',
  22166. 'threeoldstyle',
  22167. 'fouroldstyle',
  22168. 'fiveoldstyle',
  22169. 'sixoldstyle',
  22170. 'sevenoldstyle',
  22171. 'eightoldstyle',
  22172. 'nineoldstyle',
  22173. 'commasuperior',
  22174. 'threequartersemdash',
  22175. 'periodsuperior',
  22176. 'questionsmall',
  22177. 'asuperior',
  22178. 'bsuperior',
  22179. 'centsuperior',
  22180. 'dsuperior',
  22181. 'esuperior',
  22182. 'isuperior',
  22183. 'lsuperior',
  22184. 'msuperior',
  22185. 'nsuperior',
  22186. 'osuperior',
  22187. 'rsuperior',
  22188. 'ssuperior',
  22189. 'tsuperior',
  22190. 'ff',
  22191. 'ffi',
  22192. 'ffl',
  22193. 'parenleftinferior',
  22194. 'parenrightinferior',
  22195. 'Circumflexsmall',
  22196. 'hyphensuperior',
  22197. 'Gravesmall',
  22198. 'Asmall',
  22199. 'Bsmall',
  22200. 'Csmall',
  22201. 'Dsmall',
  22202. 'Esmall',
  22203. 'Fsmall',
  22204. 'Gsmall',
  22205. 'Hsmall',
  22206. 'Ismall',
  22207. 'Jsmall',
  22208. 'Ksmall',
  22209. 'Lsmall',
  22210. 'Msmall',
  22211. 'Nsmall',
  22212. 'Osmall',
  22213. 'Psmall',
  22214. 'Qsmall',
  22215. 'Rsmall',
  22216. 'Ssmall',
  22217. 'Tsmall',
  22218. 'Usmall',
  22219. 'Vsmall',
  22220. 'Wsmall',
  22221. 'Xsmall',
  22222. 'Ysmall',
  22223. 'Zsmall',
  22224. 'colonmonetary',
  22225. 'onefitted',
  22226. 'rupiah',
  22227. 'Tildesmall',
  22228. 'exclamdownsmall',
  22229. 'centoldstyle',
  22230. 'Lslashsmall',
  22231. 'Scaronsmall',
  22232. 'Zcaronsmall',
  22233. 'Dieresissmall',
  22234. 'Brevesmall',
  22235. 'Caronsmall',
  22236. 'Dotaccentsmall',
  22237. 'Macronsmall',
  22238. 'figuredash',
  22239. 'hypheninferior',
  22240. 'Ogoneksmall',
  22241. 'Ringsmall',
  22242. 'Cedillasmall',
  22243. 'questiondownsmall',
  22244. 'oneeighth',
  22245. 'threeeighths',
  22246. 'fiveeighths',
  22247. 'seveneighths',
  22248. 'onethird',
  22249. 'twothirds',
  22250. 'zerosuperior',
  22251. 'foursuperior',
  22252. 'fivesuperior',
  22253. 'sixsuperior',
  22254. 'sevensuperior',
  22255. 'eightsuperior',
  22256. 'ninesuperior',
  22257. 'zeroinferior',
  22258. 'oneinferior',
  22259. 'twoinferior',
  22260. 'threeinferior',
  22261. 'fourinferior',
  22262. 'fiveinferior',
  22263. 'sixinferior',
  22264. 'seveninferior',
  22265. 'eightinferior',
  22266. 'nineinferior',
  22267. 'centinferior',
  22268. 'dollarinferior',
  22269. 'periodinferior',
  22270. 'commainferior',
  22271. 'Agravesmall',
  22272. 'Aacutesmall',
  22273. 'Acircumflexsmall',
  22274. 'Atildesmall',
  22275. 'Adieresissmall',
  22276. 'Aringsmall',
  22277. 'AEsmall',
  22278. 'Ccedillasmall',
  22279. 'Egravesmall',
  22280. 'Eacutesmall',
  22281. 'Ecircumflexsmall',
  22282. 'Edieresissmall',
  22283. 'Igravesmall',
  22284. 'Iacutesmall',
  22285. 'Icircumflexsmall',
  22286. 'Idieresissmall',
  22287. 'Ethsmall',
  22288. 'Ntildesmall',
  22289. 'Ogravesmall',
  22290. 'Oacutesmall',
  22291. 'Ocircumflexsmall',
  22292. 'Otildesmall',
  22293. 'Odieresissmall',
  22294. 'OEsmall',
  22295. 'Oslashsmall',
  22296. 'Ugravesmall',
  22297. 'Uacutesmall',
  22298. 'Ucircumflexsmall',
  22299. 'Udieresissmall',
  22300. 'Yacutesmall',
  22301. 'Thornsmall',
  22302. 'Ydieresissmall',
  22303. '001.000',
  22304. '001.001',
  22305. '001.002',
  22306. '001.003',
  22307. 'Black',
  22308. 'Bold',
  22309. 'Book',
  22310. 'Light',
  22311. 'Medium',
  22312. 'Regular',
  22313. 'Roman',
  22314. 'Semibold'
  22315. ];
  22316. var CFFParser = function CFFParserClosure() {
  22317. var CharstringValidationData = [
  22318. null,
  22319. {
  22320. id: 'hstem',
  22321. min: 2,
  22322. stackClearing: true,
  22323. stem: true
  22324. },
  22325. null,
  22326. {
  22327. id: 'vstem',
  22328. min: 2,
  22329. stackClearing: true,
  22330. stem: true
  22331. },
  22332. {
  22333. id: 'vmoveto',
  22334. min: 1,
  22335. stackClearing: true
  22336. },
  22337. {
  22338. id: 'rlineto',
  22339. min: 2,
  22340. resetStack: true
  22341. },
  22342. {
  22343. id: 'hlineto',
  22344. min: 1,
  22345. resetStack: true
  22346. },
  22347. {
  22348. id: 'vlineto',
  22349. min: 1,
  22350. resetStack: true
  22351. },
  22352. {
  22353. id: 'rrcurveto',
  22354. min: 6,
  22355. resetStack: true
  22356. },
  22357. null,
  22358. {
  22359. id: 'callsubr',
  22360. min: 1,
  22361. undefStack: true
  22362. },
  22363. {
  22364. id: 'return',
  22365. min: 0,
  22366. undefStack: true
  22367. },
  22368. null,
  22369. null,
  22370. {
  22371. id: 'endchar',
  22372. min: 0,
  22373. stackClearing: true
  22374. },
  22375. null,
  22376. null,
  22377. null,
  22378. {
  22379. id: 'hstemhm',
  22380. min: 2,
  22381. stackClearing: true,
  22382. stem: true
  22383. },
  22384. {
  22385. id: 'hintmask',
  22386. min: 0,
  22387. stackClearing: true
  22388. },
  22389. {
  22390. id: 'cntrmask',
  22391. min: 0,
  22392. stackClearing: true
  22393. },
  22394. {
  22395. id: 'rmoveto',
  22396. min: 2,
  22397. stackClearing: true
  22398. },
  22399. {
  22400. id: 'hmoveto',
  22401. min: 1,
  22402. stackClearing: true
  22403. },
  22404. {
  22405. id: 'vstemhm',
  22406. min: 2,
  22407. stackClearing: true,
  22408. stem: true
  22409. },
  22410. {
  22411. id: 'rcurveline',
  22412. min: 8,
  22413. resetStack: true
  22414. },
  22415. {
  22416. id: 'rlinecurve',
  22417. min: 8,
  22418. resetStack: true
  22419. },
  22420. {
  22421. id: 'vvcurveto',
  22422. min: 4,
  22423. resetStack: true
  22424. },
  22425. {
  22426. id: 'hhcurveto',
  22427. min: 4,
  22428. resetStack: true
  22429. },
  22430. null,
  22431. {
  22432. id: 'callgsubr',
  22433. min: 1,
  22434. undefStack: true
  22435. },
  22436. {
  22437. id: 'vhcurveto',
  22438. min: 4,
  22439. resetStack: true
  22440. },
  22441. {
  22442. id: 'hvcurveto',
  22443. min: 4,
  22444. resetStack: true
  22445. }
  22446. ];
  22447. var CharstringValidationData12 = [
  22448. null,
  22449. null,
  22450. null,
  22451. {
  22452. id: 'and',
  22453. min: 2,
  22454. stackDelta: -1
  22455. },
  22456. {
  22457. id: 'or',
  22458. min: 2,
  22459. stackDelta: -1
  22460. },
  22461. {
  22462. id: 'not',
  22463. min: 1,
  22464. stackDelta: 0
  22465. },
  22466. null,
  22467. null,
  22468. null,
  22469. {
  22470. id: 'abs',
  22471. min: 1,
  22472. stackDelta: 0
  22473. },
  22474. {
  22475. id: 'add',
  22476. min: 2,
  22477. stackDelta: -1,
  22478. stackFn: function stack_div(stack, index) {
  22479. stack[index - 2] = stack[index - 2] + stack[index - 1];
  22480. }
  22481. },
  22482. {
  22483. id: 'sub',
  22484. min: 2,
  22485. stackDelta: -1,
  22486. stackFn: function stack_div(stack, index) {
  22487. stack[index - 2] = stack[index - 2] - stack[index - 1];
  22488. }
  22489. },
  22490. {
  22491. id: 'div',
  22492. min: 2,
  22493. stackDelta: -1,
  22494. stackFn: function stack_div(stack, index) {
  22495. stack[index - 2] = stack[index - 2] / stack[index - 1];
  22496. }
  22497. },
  22498. null,
  22499. {
  22500. id: 'neg',
  22501. min: 1,
  22502. stackDelta: 0,
  22503. stackFn: function stack_div(stack, index) {
  22504. stack[index - 1] = -stack[index - 1];
  22505. }
  22506. },
  22507. {
  22508. id: 'eq',
  22509. min: 2,
  22510. stackDelta: -1
  22511. },
  22512. null,
  22513. null,
  22514. {
  22515. id: 'drop',
  22516. min: 1,
  22517. stackDelta: -1
  22518. },
  22519. null,
  22520. {
  22521. id: 'put',
  22522. min: 2,
  22523. stackDelta: -2
  22524. },
  22525. {
  22526. id: 'get',
  22527. min: 1,
  22528. stackDelta: 0
  22529. },
  22530. {
  22531. id: 'ifelse',
  22532. min: 4,
  22533. stackDelta: -3
  22534. },
  22535. {
  22536. id: 'random',
  22537. min: 0,
  22538. stackDelta: 1
  22539. },
  22540. {
  22541. id: 'mul',
  22542. min: 2,
  22543. stackDelta: -1,
  22544. stackFn: function stack_div(stack, index) {
  22545. stack[index - 2] = stack[index - 2] * stack[index - 1];
  22546. }
  22547. },
  22548. null,
  22549. {
  22550. id: 'sqrt',
  22551. min: 1,
  22552. stackDelta: 0
  22553. },
  22554. {
  22555. id: 'dup',
  22556. min: 1,
  22557. stackDelta: 1
  22558. },
  22559. {
  22560. id: 'exch',
  22561. min: 2,
  22562. stackDelta: 0
  22563. },
  22564. {
  22565. id: 'index',
  22566. min: 2,
  22567. stackDelta: 0
  22568. },
  22569. {
  22570. id: 'roll',
  22571. min: 3,
  22572. stackDelta: -2
  22573. },
  22574. null,
  22575. null,
  22576. null,
  22577. {
  22578. id: 'hflex',
  22579. min: 7,
  22580. resetStack: true
  22581. },
  22582. {
  22583. id: 'flex',
  22584. min: 13,
  22585. resetStack: true
  22586. },
  22587. {
  22588. id: 'hflex1',
  22589. min: 9,
  22590. resetStack: true
  22591. },
  22592. {
  22593. id: 'flex1',
  22594. min: 11,
  22595. resetStack: true
  22596. }
  22597. ];
  22598. function CFFParser(file, properties, seacAnalysisEnabled) {
  22599. this.bytes = file.getBytes();
  22600. this.properties = properties;
  22601. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  22602. }
  22603. CFFParser.prototype = {
  22604. parse: function CFFParser_parse() {
  22605. var properties = this.properties;
  22606. var cff = new CFF();
  22607. this.cff = cff;
  22608. var header = this.parseHeader();
  22609. var nameIndex = this.parseIndex(header.endPos);
  22610. var topDictIndex = this.parseIndex(nameIndex.endPos);
  22611. var stringIndex = this.parseIndex(topDictIndex.endPos);
  22612. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  22613. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  22614. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  22615. cff.header = header.obj;
  22616. cff.names = this.parseNameIndex(nameIndex.obj);
  22617. cff.strings = this.parseStringIndex(stringIndex.obj);
  22618. cff.topDict = topDict;
  22619. cff.globalSubrIndex = globalSubrIndex.obj;
  22620. this.parsePrivateDict(cff.topDict);
  22621. cff.isCIDFont = topDict.hasName('ROS');
  22622. var charStringOffset = topDict.getByName('CharStrings');
  22623. var charStringIndex = this.parseIndex(charStringOffset).obj;
  22624. var fontMatrix = topDict.getByName('FontMatrix');
  22625. if (fontMatrix) {
  22626. properties.fontMatrix = fontMatrix;
  22627. }
  22628. var fontBBox = topDict.getByName('FontBBox');
  22629. if (fontBBox) {
  22630. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  22631. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  22632. properties.ascentScaled = true;
  22633. }
  22634. var charset, encoding;
  22635. if (cff.isCIDFont) {
  22636. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  22637. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  22638. var dictRaw = fdArrayIndex.get(i);
  22639. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  22640. this.parsePrivateDict(fontDict);
  22641. cff.fdArray.push(fontDict);
  22642. }
  22643. encoding = null;
  22644. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  22645. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  22646. } else {
  22647. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  22648. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  22649. }
  22650. cff.charset = charset;
  22651. cff.encoding = encoding;
  22652. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  22653. cff.charStrings = charStringsAndSeacs.charStrings;
  22654. cff.seacs = charStringsAndSeacs.seacs;
  22655. cff.widths = charStringsAndSeacs.widths;
  22656. return cff;
  22657. },
  22658. parseHeader: function CFFParser_parseHeader() {
  22659. var bytes = this.bytes;
  22660. var bytesLength = bytes.length;
  22661. var offset = 0;
  22662. while (offset < bytesLength && bytes[offset] !== 1) {
  22663. ++offset;
  22664. }
  22665. if (offset >= bytesLength) {
  22666. error('Invalid CFF header');
  22667. } else if (offset !== 0) {
  22668. info('cff data is shifted');
  22669. bytes = bytes.subarray(offset);
  22670. this.bytes = bytes;
  22671. }
  22672. var major = bytes[0];
  22673. var minor = bytes[1];
  22674. var hdrSize = bytes[2];
  22675. var offSize = bytes[3];
  22676. var header = new CFFHeader(major, minor, hdrSize, offSize);
  22677. return {
  22678. obj: header,
  22679. endPos: hdrSize
  22680. };
  22681. },
  22682. parseDict: function CFFParser_parseDict(dict) {
  22683. var pos = 0;
  22684. function parseOperand() {
  22685. var value = dict[pos++];
  22686. if (value === 30) {
  22687. return parseFloatOperand();
  22688. } else if (value === 28) {
  22689. value = dict[pos++];
  22690. value = (value << 24 | dict[pos++] << 16) >> 16;
  22691. return value;
  22692. } else if (value === 29) {
  22693. value = dict[pos++];
  22694. value = value << 8 | dict[pos++];
  22695. value = value << 8 | dict[pos++];
  22696. value = value << 8 | dict[pos++];
  22697. return value;
  22698. } else if (value >= 32 && value <= 246) {
  22699. return value - 139;
  22700. } else if (value >= 247 && value <= 250) {
  22701. return (value - 247) * 256 + dict[pos++] + 108;
  22702. } else if (value >= 251 && value <= 254) {
  22703. return -((value - 251) * 256) - dict[pos++] - 108;
  22704. }
  22705. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  22706. return NaN;
  22707. }
  22708. function parseFloatOperand() {
  22709. var str = '';
  22710. var eof = 15;
  22711. var lookup = [
  22712. '0',
  22713. '1',
  22714. '2',
  22715. '3',
  22716. '4',
  22717. '5',
  22718. '6',
  22719. '7',
  22720. '8',
  22721. '9',
  22722. '.',
  22723. 'E',
  22724. 'E-',
  22725. null,
  22726. '-'
  22727. ];
  22728. var length = dict.length;
  22729. while (pos < length) {
  22730. var b = dict[pos++];
  22731. var b1 = b >> 4;
  22732. var b2 = b & 15;
  22733. if (b1 === eof) {
  22734. break;
  22735. }
  22736. str += lookup[b1];
  22737. if (b2 === eof) {
  22738. break;
  22739. }
  22740. str += lookup[b2];
  22741. }
  22742. return parseFloat(str);
  22743. }
  22744. var operands = [];
  22745. var entries = [];
  22746. pos = 0;
  22747. var end = dict.length;
  22748. while (pos < end) {
  22749. var b = dict[pos];
  22750. if (b <= 21) {
  22751. if (b === 12) {
  22752. b = b << 8 | dict[++pos];
  22753. }
  22754. entries.push([
  22755. b,
  22756. operands
  22757. ]);
  22758. operands = [];
  22759. ++pos;
  22760. } else {
  22761. operands.push(parseOperand());
  22762. }
  22763. }
  22764. return entries;
  22765. },
  22766. parseIndex: function CFFParser_parseIndex(pos) {
  22767. var cffIndex = new CFFIndex();
  22768. var bytes = this.bytes;
  22769. var count = bytes[pos++] << 8 | bytes[pos++];
  22770. var offsets = [];
  22771. var end = pos;
  22772. var i, ii;
  22773. if (count !== 0) {
  22774. var offsetSize = bytes[pos++];
  22775. var startPos = pos + (count + 1) * offsetSize - 1;
  22776. for (i = 0, ii = count + 1; i < ii; ++i) {
  22777. var offset = 0;
  22778. for (var j = 0; j < offsetSize; ++j) {
  22779. offset <<= 8;
  22780. offset += bytes[pos++];
  22781. }
  22782. offsets.push(startPos + offset);
  22783. }
  22784. end = offsets[count];
  22785. }
  22786. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  22787. var offsetStart = offsets[i];
  22788. var offsetEnd = offsets[i + 1];
  22789. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  22790. }
  22791. return {
  22792. obj: cffIndex,
  22793. endPos: end
  22794. };
  22795. },
  22796. parseNameIndex: function CFFParser_parseNameIndex(index) {
  22797. var names = [];
  22798. for (var i = 0, ii = index.count; i < ii; ++i) {
  22799. var name = index.get(i);
  22800. var length = Math.min(name.length, 127);
  22801. var data = [];
  22802. for (var j = 0; j < length; ++j) {
  22803. var c = name[j];
  22804. if (j === 0 && c === 0) {
  22805. data[j] = c;
  22806. continue;
  22807. }
  22808. 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) {
  22809. data[j] = 95;
  22810. continue;
  22811. }
  22812. data[j] = c;
  22813. }
  22814. names.push(bytesToString(data));
  22815. }
  22816. return names;
  22817. },
  22818. parseStringIndex: function CFFParser_parseStringIndex(index) {
  22819. var strings = new CFFStrings();
  22820. for (var i = 0, ii = index.count; i < ii; ++i) {
  22821. var data = index.get(i);
  22822. strings.add(bytesToString(data));
  22823. }
  22824. return strings;
  22825. },
  22826. createDict: function CFFParser_createDict(Type, dict, strings) {
  22827. var cffDict = new Type(strings);
  22828. for (var i = 0, ii = dict.length; i < ii; ++i) {
  22829. var pair = dict[i];
  22830. var key = pair[0];
  22831. var value = pair[1];
  22832. cffDict.setByKey(key, value);
  22833. }
  22834. return cffDict;
  22835. },
  22836. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  22837. if (state.callDepth > MAX_SUBR_NESTING) {
  22838. return false;
  22839. }
  22840. var stackSize = state.stackSize;
  22841. var stack = state.stack;
  22842. var length = data.length;
  22843. for (var j = 0; j < length;) {
  22844. var value = data[j++];
  22845. var validationCommand = null;
  22846. if (value === 12) {
  22847. var q = data[j++];
  22848. if (q === 0) {
  22849. data[j - 2] = 139;
  22850. data[j - 1] = 22;
  22851. stackSize = 0;
  22852. } else {
  22853. validationCommand = CharstringValidationData12[q];
  22854. }
  22855. } else if (value === 28) {
  22856. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  22857. j += 2;
  22858. stackSize++;
  22859. } else if (value === 14) {
  22860. if (stackSize >= 4) {
  22861. stackSize -= 4;
  22862. if (this.seacAnalysisEnabled) {
  22863. state.seac = stack.slice(stackSize, stackSize + 4);
  22864. return false;
  22865. }
  22866. }
  22867. validationCommand = CharstringValidationData[value];
  22868. } else if (value >= 32 && value <= 246) {
  22869. stack[stackSize] = value - 139;
  22870. stackSize++;
  22871. } else if (value >= 247 && value <= 254) {
  22872. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  22873. j++;
  22874. stackSize++;
  22875. } else if (value === 255) {
  22876. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  22877. j += 4;
  22878. stackSize++;
  22879. } else if (value === 19 || value === 20) {
  22880. state.hints += stackSize >> 1;
  22881. j += state.hints + 7 >> 3;
  22882. stackSize %= 2;
  22883. validationCommand = CharstringValidationData[value];
  22884. } else if (value === 10 || value === 29) {
  22885. var subrsIndex;
  22886. if (value === 10) {
  22887. subrsIndex = localSubrIndex;
  22888. } else {
  22889. subrsIndex = globalSubrIndex;
  22890. }
  22891. if (!subrsIndex) {
  22892. validationCommand = CharstringValidationData[value];
  22893. warn('Missing subrsIndex for ' + validationCommand.id);
  22894. return false;
  22895. }
  22896. var bias = 32768;
  22897. if (subrsIndex.count < 1240) {
  22898. bias = 107;
  22899. } else if (subrsIndex.count < 33900) {
  22900. bias = 1131;
  22901. }
  22902. var subrNumber = stack[--stackSize] + bias;
  22903. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  22904. validationCommand = CharstringValidationData[value];
  22905. warn('Out of bounds subrIndex for ' + validationCommand.id);
  22906. return false;
  22907. }
  22908. state.stackSize = stackSize;
  22909. state.callDepth++;
  22910. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  22911. if (!valid) {
  22912. return false;
  22913. }
  22914. state.callDepth--;
  22915. stackSize = state.stackSize;
  22916. continue;
  22917. } else if (value === 11) {
  22918. state.stackSize = stackSize;
  22919. return true;
  22920. } else {
  22921. validationCommand = CharstringValidationData[value];
  22922. }
  22923. if (validationCommand) {
  22924. if (validationCommand.stem) {
  22925. state.hints += stackSize >> 1;
  22926. }
  22927. if ('min' in validationCommand) {
  22928. if (!state.undefStack && stackSize < validationCommand.min) {
  22929. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  22930. return false;
  22931. }
  22932. }
  22933. if (state.firstStackClearing && validationCommand.stackClearing) {
  22934. state.firstStackClearing = false;
  22935. stackSize -= validationCommand.min;
  22936. if (stackSize >= 2 && validationCommand.stem) {
  22937. stackSize %= 2;
  22938. } else if (stackSize > 1) {
  22939. warn('Found too many parameters for stack-clearing command');
  22940. }
  22941. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  22942. state.width = stack[stackSize - 1];
  22943. }
  22944. }
  22945. if ('stackDelta' in validationCommand) {
  22946. if ('stackFn' in validationCommand) {
  22947. validationCommand.stackFn(stack, stackSize);
  22948. }
  22949. stackSize += validationCommand.stackDelta;
  22950. } else if (validationCommand.stackClearing) {
  22951. stackSize = 0;
  22952. } else if (validationCommand.resetStack) {
  22953. stackSize = 0;
  22954. state.undefStack = false;
  22955. } else if (validationCommand.undefStack) {
  22956. stackSize = 0;
  22957. state.undefStack = true;
  22958. state.firstStackClearing = false;
  22959. }
  22960. }
  22961. }
  22962. state.stackSize = stackSize;
  22963. return true;
  22964. },
  22965. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  22966. var seacs = [];
  22967. var widths = [];
  22968. var count = charStrings.count;
  22969. for (var i = 0; i < count; i++) {
  22970. var charstring = charStrings.get(i);
  22971. var state = {
  22972. callDepth: 0,
  22973. stackSize: 0,
  22974. stack: [],
  22975. undefStack: true,
  22976. hints: 0,
  22977. firstStackClearing: true,
  22978. seac: null,
  22979. width: null
  22980. };
  22981. var valid = true;
  22982. var localSubrToUse = null;
  22983. if (fdSelect && fdArray.length) {
  22984. var fdIndex = fdSelect.getFDIndex(i);
  22985. if (fdIndex === -1) {
  22986. warn('Glyph index is not in fd select.');
  22987. valid = false;
  22988. }
  22989. if (fdIndex >= fdArray.length) {
  22990. warn('Invalid fd index for glyph index.');
  22991. valid = false;
  22992. }
  22993. if (valid) {
  22994. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  22995. }
  22996. } else if (localSubrIndex) {
  22997. localSubrToUse = localSubrIndex;
  22998. }
  22999. if (valid) {
  23000. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23001. }
  23002. if (state.width !== null) {
  23003. widths[i] = state.width;
  23004. }
  23005. if (state.seac !== null) {
  23006. seacs[i] = state.seac;
  23007. }
  23008. if (!valid) {
  23009. charStrings.set(i, new Uint8Array([14]));
  23010. }
  23011. }
  23012. return {
  23013. charStrings: charStrings,
  23014. seacs: seacs,
  23015. widths: widths
  23016. };
  23017. },
  23018. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23019. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23020. parentDict.setByKey(18, [
  23021. 0,
  23022. 0
  23023. ]);
  23024. parentDict.privateDict = privateDict;
  23025. },
  23026. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23027. if (!parentDict.hasName('Private')) {
  23028. this.emptyPrivateDictionary(parentDict);
  23029. return;
  23030. }
  23031. var privateOffset = parentDict.getByName('Private');
  23032. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23033. parentDict.removeByName('Private');
  23034. return;
  23035. }
  23036. var size = privateOffset[0];
  23037. var offset = privateOffset[1];
  23038. if (size === 0 || offset >= this.bytes.length) {
  23039. this.emptyPrivateDictionary(parentDict);
  23040. return;
  23041. }
  23042. var privateDictEnd = offset + size;
  23043. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23044. var dict = this.parseDict(dictData);
  23045. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23046. parentDict.privateDict = privateDict;
  23047. if (!privateDict.getByName('Subrs')) {
  23048. return;
  23049. }
  23050. var subrsOffset = privateDict.getByName('Subrs');
  23051. var relativeOffset = offset + subrsOffset;
  23052. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23053. this.emptyPrivateDictionary(parentDict);
  23054. return;
  23055. }
  23056. var subrsIndex = this.parseIndex(relativeOffset);
  23057. privateDict.subrsIndex = subrsIndex.obj;
  23058. },
  23059. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23060. if (pos === 0) {
  23061. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23062. } else if (pos === 1) {
  23063. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23064. } else if (pos === 2) {
  23065. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23066. }
  23067. var bytes = this.bytes;
  23068. var start = pos;
  23069. var format = bytes[pos++];
  23070. var charset = ['.notdef'];
  23071. var id, count, i;
  23072. length -= 1;
  23073. switch (format) {
  23074. case 0:
  23075. for (i = 0; i < length; i++) {
  23076. id = bytes[pos++] << 8 | bytes[pos++];
  23077. charset.push(cid ? id : strings.get(id));
  23078. }
  23079. break;
  23080. case 1:
  23081. while (charset.length <= length) {
  23082. id = bytes[pos++] << 8 | bytes[pos++];
  23083. count = bytes[pos++];
  23084. for (i = 0; i <= count; i++) {
  23085. charset.push(cid ? id++ : strings.get(id++));
  23086. }
  23087. }
  23088. break;
  23089. case 2:
  23090. while (charset.length <= length) {
  23091. id = bytes[pos++] << 8 | bytes[pos++];
  23092. count = bytes[pos++] << 8 | bytes[pos++];
  23093. for (i = 0; i <= count; i++) {
  23094. charset.push(cid ? id++ : strings.get(id++));
  23095. }
  23096. }
  23097. break;
  23098. default:
  23099. error('Unknown charset format');
  23100. }
  23101. var end = pos;
  23102. var raw = bytes.subarray(start, end);
  23103. return new CFFCharset(false, format, charset, raw);
  23104. },
  23105. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23106. var encoding = Object.create(null);
  23107. var bytes = this.bytes;
  23108. var predefined = false;
  23109. var format, i, ii;
  23110. var raw = null;
  23111. function readSupplement() {
  23112. var supplementsCount = bytes[pos++];
  23113. for (i = 0; i < supplementsCount; i++) {
  23114. var code = bytes[pos++];
  23115. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23116. encoding[code] = charset.indexOf(strings.get(sid));
  23117. }
  23118. }
  23119. if (pos === 0 || pos === 1) {
  23120. predefined = true;
  23121. format = pos;
  23122. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23123. for (i = 0, ii = charset.length; i < ii; i++) {
  23124. var index = baseEncoding.indexOf(charset[i]);
  23125. if (index !== -1) {
  23126. encoding[index] = i;
  23127. }
  23128. }
  23129. } else {
  23130. var dataStart = pos;
  23131. format = bytes[pos++];
  23132. switch (format & 0x7f) {
  23133. case 0:
  23134. var glyphsCount = bytes[pos++];
  23135. for (i = 1; i <= glyphsCount; i++) {
  23136. encoding[bytes[pos++]] = i;
  23137. }
  23138. break;
  23139. case 1:
  23140. var rangesCount = bytes[pos++];
  23141. var gid = 1;
  23142. for (i = 0; i < rangesCount; i++) {
  23143. var start = bytes[pos++];
  23144. var left = bytes[pos++];
  23145. for (var j = start; j <= start + left; j++) {
  23146. encoding[j] = gid++;
  23147. }
  23148. }
  23149. break;
  23150. default:
  23151. error('Unknown encoding format: ' + format + ' in CFF');
  23152. break;
  23153. }
  23154. var dataEnd = pos;
  23155. if (format & 0x80) {
  23156. bytes[dataStart] &= 0x7f;
  23157. readSupplement();
  23158. }
  23159. raw = bytes.subarray(dataStart, dataEnd);
  23160. }
  23161. format = format & 0x7f;
  23162. return new CFFEncoding(predefined, format, encoding, raw);
  23163. },
  23164. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23165. var start = pos;
  23166. var bytes = this.bytes;
  23167. var format = bytes[pos++];
  23168. var fdSelect = [], rawBytes;
  23169. var i, invalidFirstGID = false;
  23170. switch (format) {
  23171. case 0:
  23172. for (i = 0; i < length; ++i) {
  23173. var id = bytes[pos++];
  23174. fdSelect.push(id);
  23175. }
  23176. rawBytes = bytes.subarray(start, pos);
  23177. break;
  23178. case 3:
  23179. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23180. for (i = 0; i < rangesCount; ++i) {
  23181. var first = bytes[pos++] << 8 | bytes[pos++];
  23182. if (i === 0 && first !== 0) {
  23183. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23184. invalidFirstGID = true;
  23185. first = 0;
  23186. }
  23187. var fdIndex = bytes[pos++];
  23188. var next = bytes[pos] << 8 | bytes[pos + 1];
  23189. for (var j = first; j < next; ++j) {
  23190. fdSelect.push(fdIndex);
  23191. }
  23192. }
  23193. pos += 2;
  23194. rawBytes = bytes.subarray(start, pos);
  23195. if (invalidFirstGID) {
  23196. rawBytes[3] = rawBytes[4] = 0;
  23197. }
  23198. break;
  23199. default:
  23200. error('parseFDSelect: Unknown format "' + format + '".');
  23201. break;
  23202. }
  23203. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23204. return new CFFFDSelect(fdSelect, rawBytes);
  23205. }
  23206. };
  23207. return CFFParser;
  23208. }();
  23209. var CFF = function CFFClosure() {
  23210. function CFF() {
  23211. this.header = null;
  23212. this.names = [];
  23213. this.topDict = null;
  23214. this.strings = new CFFStrings();
  23215. this.globalSubrIndex = null;
  23216. this.encoding = null;
  23217. this.charset = null;
  23218. this.charStrings = null;
  23219. this.fdArray = [];
  23220. this.fdSelect = null;
  23221. this.isCIDFont = false;
  23222. }
  23223. return CFF;
  23224. }();
  23225. var CFFHeader = function CFFHeaderClosure() {
  23226. function CFFHeader(major, minor, hdrSize, offSize) {
  23227. this.major = major;
  23228. this.minor = minor;
  23229. this.hdrSize = hdrSize;
  23230. this.offSize = offSize;
  23231. }
  23232. return CFFHeader;
  23233. }();
  23234. var CFFStrings = function CFFStringsClosure() {
  23235. function CFFStrings() {
  23236. this.strings = [];
  23237. }
  23238. CFFStrings.prototype = {
  23239. get: function CFFStrings_get(index) {
  23240. if (index >= 0 && index <= 390) {
  23241. return CFFStandardStrings[index];
  23242. }
  23243. if (index - 391 <= this.strings.length) {
  23244. return this.strings[index - 391];
  23245. }
  23246. return CFFStandardStrings[0];
  23247. },
  23248. add: function CFFStrings_add(value) {
  23249. this.strings.push(value);
  23250. },
  23251. get count() {
  23252. return this.strings.length;
  23253. }
  23254. };
  23255. return CFFStrings;
  23256. }();
  23257. var CFFIndex = function CFFIndexClosure() {
  23258. function CFFIndex() {
  23259. this.objects = [];
  23260. this.length = 0;
  23261. }
  23262. CFFIndex.prototype = {
  23263. add: function CFFIndex_add(data) {
  23264. this.length += data.length;
  23265. this.objects.push(data);
  23266. },
  23267. set: function CFFIndex_set(index, data) {
  23268. this.length += data.length - this.objects[index].length;
  23269. this.objects[index] = data;
  23270. },
  23271. get: function CFFIndex_get(index) {
  23272. return this.objects[index];
  23273. },
  23274. get count() {
  23275. return this.objects.length;
  23276. }
  23277. };
  23278. return CFFIndex;
  23279. }();
  23280. var CFFDict = function CFFDictClosure() {
  23281. function CFFDict(tables, strings) {
  23282. this.keyToNameMap = tables.keyToNameMap;
  23283. this.nameToKeyMap = tables.nameToKeyMap;
  23284. this.defaults = tables.defaults;
  23285. this.types = tables.types;
  23286. this.opcodes = tables.opcodes;
  23287. this.order = tables.order;
  23288. this.strings = strings;
  23289. this.values = Object.create(null);
  23290. }
  23291. CFFDict.prototype = {
  23292. setByKey: function CFFDict_setByKey(key, value) {
  23293. if (!(key in this.keyToNameMap)) {
  23294. return false;
  23295. }
  23296. var valueLength = value.length;
  23297. if (valueLength === 0) {
  23298. return true;
  23299. }
  23300. for (var i = 0; i < valueLength; i++) {
  23301. if (isNaN(value[i])) {
  23302. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  23303. return true;
  23304. }
  23305. }
  23306. var type = this.types[key];
  23307. if (type === 'num' || type === 'sid' || type === 'offset') {
  23308. value = value[0];
  23309. }
  23310. this.values[key] = value;
  23311. return true;
  23312. },
  23313. setByName: function CFFDict_setByName(name, value) {
  23314. if (!(name in this.nameToKeyMap)) {
  23315. error('Invalid dictionary name "' + name + '"');
  23316. }
  23317. this.values[this.nameToKeyMap[name]] = value;
  23318. },
  23319. hasName: function CFFDict_hasName(name) {
  23320. return this.nameToKeyMap[name] in this.values;
  23321. },
  23322. getByName: function CFFDict_getByName(name) {
  23323. if (!(name in this.nameToKeyMap)) {
  23324. error('Invalid dictionary name "' + name + '"');
  23325. }
  23326. var key = this.nameToKeyMap[name];
  23327. if (!(key in this.values)) {
  23328. return this.defaults[key];
  23329. }
  23330. return this.values[key];
  23331. },
  23332. removeByName: function CFFDict_removeByName(name) {
  23333. delete this.values[this.nameToKeyMap[name]];
  23334. }
  23335. };
  23336. CFFDict.createTables = function CFFDict_createTables(layout) {
  23337. var tables = {
  23338. keyToNameMap: {},
  23339. nameToKeyMap: {},
  23340. defaults: {},
  23341. types: {},
  23342. opcodes: {},
  23343. order: []
  23344. };
  23345. for (var i = 0, ii = layout.length; i < ii; ++i) {
  23346. var entry = layout[i];
  23347. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  23348. tables.keyToNameMap[key] = entry[1];
  23349. tables.nameToKeyMap[entry[1]] = key;
  23350. tables.types[key] = entry[2];
  23351. tables.defaults[key] = entry[3];
  23352. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  23353. tables.order.push(key);
  23354. }
  23355. return tables;
  23356. };
  23357. return CFFDict;
  23358. }();
  23359. var CFFTopDict = function CFFTopDictClosure() {
  23360. var layout = [
  23361. [
  23362. [
  23363. 12,
  23364. 30
  23365. ],
  23366. 'ROS',
  23367. [
  23368. 'sid',
  23369. 'sid',
  23370. 'num'
  23371. ],
  23372. null
  23373. ],
  23374. [
  23375. [
  23376. 12,
  23377. 20
  23378. ],
  23379. 'SyntheticBase',
  23380. 'num',
  23381. null
  23382. ],
  23383. [
  23384. 0,
  23385. 'version',
  23386. 'sid',
  23387. null
  23388. ],
  23389. [
  23390. 1,
  23391. 'Notice',
  23392. 'sid',
  23393. null
  23394. ],
  23395. [
  23396. [
  23397. 12,
  23398. 0
  23399. ],
  23400. 'Copyright',
  23401. 'sid',
  23402. null
  23403. ],
  23404. [
  23405. 2,
  23406. 'FullName',
  23407. 'sid',
  23408. null
  23409. ],
  23410. [
  23411. 3,
  23412. 'FamilyName',
  23413. 'sid',
  23414. null
  23415. ],
  23416. [
  23417. 4,
  23418. 'Weight',
  23419. 'sid',
  23420. null
  23421. ],
  23422. [
  23423. [
  23424. 12,
  23425. 1
  23426. ],
  23427. 'isFixedPitch',
  23428. 'num',
  23429. 0
  23430. ],
  23431. [
  23432. [
  23433. 12,
  23434. 2
  23435. ],
  23436. 'ItalicAngle',
  23437. 'num',
  23438. 0
  23439. ],
  23440. [
  23441. [
  23442. 12,
  23443. 3
  23444. ],
  23445. 'UnderlinePosition',
  23446. 'num',
  23447. -100
  23448. ],
  23449. [
  23450. [
  23451. 12,
  23452. 4
  23453. ],
  23454. 'UnderlineThickness',
  23455. 'num',
  23456. 50
  23457. ],
  23458. [
  23459. [
  23460. 12,
  23461. 5
  23462. ],
  23463. 'PaintType',
  23464. 'num',
  23465. 0
  23466. ],
  23467. [
  23468. [
  23469. 12,
  23470. 6
  23471. ],
  23472. 'CharstringType',
  23473. 'num',
  23474. 2
  23475. ],
  23476. [
  23477. [
  23478. 12,
  23479. 7
  23480. ],
  23481. 'FontMatrix',
  23482. [
  23483. 'num',
  23484. 'num',
  23485. 'num',
  23486. 'num',
  23487. 'num',
  23488. 'num'
  23489. ],
  23490. [
  23491. 0.001,
  23492. 0,
  23493. 0,
  23494. 0.001,
  23495. 0,
  23496. 0
  23497. ]
  23498. ],
  23499. [
  23500. 13,
  23501. 'UniqueID',
  23502. 'num',
  23503. null
  23504. ],
  23505. [
  23506. 5,
  23507. 'FontBBox',
  23508. [
  23509. 'num',
  23510. 'num',
  23511. 'num',
  23512. 'num'
  23513. ],
  23514. [
  23515. 0,
  23516. 0,
  23517. 0,
  23518. 0
  23519. ]
  23520. ],
  23521. [
  23522. [
  23523. 12,
  23524. 8
  23525. ],
  23526. 'StrokeWidth',
  23527. 'num',
  23528. 0
  23529. ],
  23530. [
  23531. 14,
  23532. 'XUID',
  23533. 'array',
  23534. null
  23535. ],
  23536. [
  23537. 15,
  23538. 'charset',
  23539. 'offset',
  23540. 0
  23541. ],
  23542. [
  23543. 16,
  23544. 'Encoding',
  23545. 'offset',
  23546. 0
  23547. ],
  23548. [
  23549. 17,
  23550. 'CharStrings',
  23551. 'offset',
  23552. 0
  23553. ],
  23554. [
  23555. 18,
  23556. 'Private',
  23557. [
  23558. 'offset',
  23559. 'offset'
  23560. ],
  23561. null
  23562. ],
  23563. [
  23564. [
  23565. 12,
  23566. 21
  23567. ],
  23568. 'PostScript',
  23569. 'sid',
  23570. null
  23571. ],
  23572. [
  23573. [
  23574. 12,
  23575. 22
  23576. ],
  23577. 'BaseFontName',
  23578. 'sid',
  23579. null
  23580. ],
  23581. [
  23582. [
  23583. 12,
  23584. 23
  23585. ],
  23586. 'BaseFontBlend',
  23587. 'delta',
  23588. null
  23589. ],
  23590. [
  23591. [
  23592. 12,
  23593. 31
  23594. ],
  23595. 'CIDFontVersion',
  23596. 'num',
  23597. 0
  23598. ],
  23599. [
  23600. [
  23601. 12,
  23602. 32
  23603. ],
  23604. 'CIDFontRevision',
  23605. 'num',
  23606. 0
  23607. ],
  23608. [
  23609. [
  23610. 12,
  23611. 33
  23612. ],
  23613. 'CIDFontType',
  23614. 'num',
  23615. 0
  23616. ],
  23617. [
  23618. [
  23619. 12,
  23620. 34
  23621. ],
  23622. 'CIDCount',
  23623. 'num',
  23624. 8720
  23625. ],
  23626. [
  23627. [
  23628. 12,
  23629. 35
  23630. ],
  23631. 'UIDBase',
  23632. 'num',
  23633. null
  23634. ],
  23635. [
  23636. [
  23637. 12,
  23638. 37
  23639. ],
  23640. 'FDSelect',
  23641. 'offset',
  23642. null
  23643. ],
  23644. [
  23645. [
  23646. 12,
  23647. 36
  23648. ],
  23649. 'FDArray',
  23650. 'offset',
  23651. null
  23652. ],
  23653. [
  23654. [
  23655. 12,
  23656. 38
  23657. ],
  23658. 'FontName',
  23659. 'sid',
  23660. null
  23661. ]
  23662. ];
  23663. var tables = null;
  23664. function CFFTopDict(strings) {
  23665. if (tables === null) {
  23666. tables = CFFDict.createTables(layout);
  23667. }
  23668. CFFDict.call(this, tables, strings);
  23669. this.privateDict = null;
  23670. }
  23671. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  23672. return CFFTopDict;
  23673. }();
  23674. var CFFPrivateDict = function CFFPrivateDictClosure() {
  23675. var layout = [
  23676. [
  23677. 6,
  23678. 'BlueValues',
  23679. 'delta',
  23680. null
  23681. ],
  23682. [
  23683. 7,
  23684. 'OtherBlues',
  23685. 'delta',
  23686. null
  23687. ],
  23688. [
  23689. 8,
  23690. 'FamilyBlues',
  23691. 'delta',
  23692. null
  23693. ],
  23694. [
  23695. 9,
  23696. 'FamilyOtherBlues',
  23697. 'delta',
  23698. null
  23699. ],
  23700. [
  23701. [
  23702. 12,
  23703. 9
  23704. ],
  23705. 'BlueScale',
  23706. 'num',
  23707. 0.039625
  23708. ],
  23709. [
  23710. [
  23711. 12,
  23712. 10
  23713. ],
  23714. 'BlueShift',
  23715. 'num',
  23716. 7
  23717. ],
  23718. [
  23719. [
  23720. 12,
  23721. 11
  23722. ],
  23723. 'BlueFuzz',
  23724. 'num',
  23725. 1
  23726. ],
  23727. [
  23728. 10,
  23729. 'StdHW',
  23730. 'num',
  23731. null
  23732. ],
  23733. [
  23734. 11,
  23735. 'StdVW',
  23736. 'num',
  23737. null
  23738. ],
  23739. [
  23740. [
  23741. 12,
  23742. 12
  23743. ],
  23744. 'StemSnapH',
  23745. 'delta',
  23746. null
  23747. ],
  23748. [
  23749. [
  23750. 12,
  23751. 13
  23752. ],
  23753. 'StemSnapV',
  23754. 'delta',
  23755. null
  23756. ],
  23757. [
  23758. [
  23759. 12,
  23760. 14
  23761. ],
  23762. 'ForceBold',
  23763. 'num',
  23764. 0
  23765. ],
  23766. [
  23767. [
  23768. 12,
  23769. 17
  23770. ],
  23771. 'LanguageGroup',
  23772. 'num',
  23773. 0
  23774. ],
  23775. [
  23776. [
  23777. 12,
  23778. 18
  23779. ],
  23780. 'ExpansionFactor',
  23781. 'num',
  23782. 0.06
  23783. ],
  23784. [
  23785. [
  23786. 12,
  23787. 19
  23788. ],
  23789. 'initialRandomSeed',
  23790. 'num',
  23791. 0
  23792. ],
  23793. [
  23794. 20,
  23795. 'defaultWidthX',
  23796. 'num',
  23797. 0
  23798. ],
  23799. [
  23800. 21,
  23801. 'nominalWidthX',
  23802. 'num',
  23803. 0
  23804. ],
  23805. [
  23806. 19,
  23807. 'Subrs',
  23808. 'offset',
  23809. null
  23810. ]
  23811. ];
  23812. var tables = null;
  23813. function CFFPrivateDict(strings) {
  23814. if (tables === null) {
  23815. tables = CFFDict.createTables(layout);
  23816. }
  23817. CFFDict.call(this, tables, strings);
  23818. this.subrsIndex = null;
  23819. }
  23820. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  23821. return CFFPrivateDict;
  23822. }();
  23823. var CFFCharsetPredefinedTypes = {
  23824. ISO_ADOBE: 0,
  23825. EXPERT: 1,
  23826. EXPERT_SUBSET: 2
  23827. };
  23828. var CFFCharset = function CFFCharsetClosure() {
  23829. function CFFCharset(predefined, format, charset, raw) {
  23830. this.predefined = predefined;
  23831. this.format = format;
  23832. this.charset = charset;
  23833. this.raw = raw;
  23834. }
  23835. return CFFCharset;
  23836. }();
  23837. var CFFEncoding = function CFFEncodingClosure() {
  23838. function CFFEncoding(predefined, format, encoding, raw) {
  23839. this.predefined = predefined;
  23840. this.format = format;
  23841. this.encoding = encoding;
  23842. this.raw = raw;
  23843. }
  23844. return CFFEncoding;
  23845. }();
  23846. var CFFFDSelect = function CFFFDSelectClosure() {
  23847. function CFFFDSelect(fdSelect, raw) {
  23848. this.fdSelect = fdSelect;
  23849. this.raw = raw;
  23850. }
  23851. CFFFDSelect.prototype = {
  23852. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  23853. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  23854. return -1;
  23855. }
  23856. return this.fdSelect[glyphIndex];
  23857. }
  23858. };
  23859. return CFFFDSelect;
  23860. }();
  23861. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  23862. function CFFOffsetTracker() {
  23863. this.offsets = Object.create(null);
  23864. }
  23865. CFFOffsetTracker.prototype = {
  23866. isTracking: function CFFOffsetTracker_isTracking(key) {
  23867. return key in this.offsets;
  23868. },
  23869. track: function CFFOffsetTracker_track(key, location) {
  23870. if (key in this.offsets) {
  23871. error('Already tracking location of ' + key);
  23872. }
  23873. this.offsets[key] = location;
  23874. },
  23875. offset: function CFFOffsetTracker_offset(value) {
  23876. for (var key in this.offsets) {
  23877. this.offsets[key] += value;
  23878. }
  23879. },
  23880. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  23881. if (!(key in this.offsets)) {
  23882. error('Not tracking location of ' + key);
  23883. }
  23884. var data = output.data;
  23885. var dataOffset = this.offsets[key];
  23886. var size = 5;
  23887. for (var i = 0, ii = values.length; i < ii; ++i) {
  23888. var offset0 = i * size + dataOffset;
  23889. var offset1 = offset0 + 1;
  23890. var offset2 = offset0 + 2;
  23891. var offset3 = offset0 + 3;
  23892. var offset4 = offset0 + 4;
  23893. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  23894. error('writing to an offset that is not empty');
  23895. }
  23896. var value = values[i];
  23897. data[offset0] = 0x1d;
  23898. data[offset1] = value >> 24 & 0xFF;
  23899. data[offset2] = value >> 16 & 0xFF;
  23900. data[offset3] = value >> 8 & 0xFF;
  23901. data[offset4] = value & 0xFF;
  23902. }
  23903. }
  23904. };
  23905. return CFFOffsetTracker;
  23906. }();
  23907. var CFFCompiler = function CFFCompilerClosure() {
  23908. function CFFCompiler(cff) {
  23909. this.cff = cff;
  23910. }
  23911. CFFCompiler.prototype = {
  23912. compile: function CFFCompiler_compile() {
  23913. var cff = this.cff;
  23914. var output = {
  23915. data: [],
  23916. length: 0,
  23917. add: function CFFCompiler_add(data) {
  23918. this.data = this.data.concat(data);
  23919. this.length = this.data.length;
  23920. }
  23921. };
  23922. var header = this.compileHeader(cff.header);
  23923. output.add(header);
  23924. var nameIndex = this.compileNameIndex(cff.names);
  23925. output.add(nameIndex);
  23926. if (cff.isCIDFont) {
  23927. if (cff.topDict.hasName('FontMatrix')) {
  23928. var base = cff.topDict.getByName('FontMatrix');
  23929. cff.topDict.removeByName('FontMatrix');
  23930. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  23931. var subDict = cff.fdArray[i];
  23932. var matrix = base.slice(0);
  23933. if (subDict.hasName('FontMatrix')) {
  23934. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  23935. }
  23936. subDict.setByName('FontMatrix', matrix);
  23937. }
  23938. }
  23939. }
  23940. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  23941. output.add(compiled.output);
  23942. var topDictTracker = compiled.trackers[0];
  23943. var stringIndex = this.compileStringIndex(cff.strings.strings);
  23944. output.add(stringIndex);
  23945. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  23946. output.add(globalSubrIndex);
  23947. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  23948. if (cff.encoding.predefined) {
  23949. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  23950. } else {
  23951. var encoding = this.compileEncoding(cff.encoding);
  23952. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  23953. output.add(encoding);
  23954. }
  23955. }
  23956. if (cff.charset && cff.topDict.hasName('charset')) {
  23957. if (cff.charset.predefined) {
  23958. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  23959. } else {
  23960. var charset = this.compileCharset(cff.charset);
  23961. topDictTracker.setEntryLocation('charset', [output.length], output);
  23962. output.add(charset);
  23963. }
  23964. }
  23965. var charStrings = this.compileCharStrings(cff.charStrings);
  23966. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  23967. output.add(charStrings);
  23968. if (cff.isCIDFont) {
  23969. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  23970. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  23971. output.add(fdSelect);
  23972. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  23973. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  23974. output.add(compiled.output);
  23975. var fontDictTrackers = compiled.trackers;
  23976. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  23977. }
  23978. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  23979. output.add([0]);
  23980. return output.data;
  23981. },
  23982. encodeNumber: function CFFCompiler_encodeNumber(value) {
  23983. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  23984. return this.encodeInteger(value);
  23985. }
  23986. return this.encodeFloat(value);
  23987. },
  23988. encodeFloat: function CFFCompiler_encodeFloat(num) {
  23989. var value = num.toString();
  23990. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  23991. if (m) {
  23992. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  23993. value = (Math.round(num * epsilon) / epsilon).toString();
  23994. }
  23995. var nibbles = '';
  23996. var i, ii;
  23997. for (i = 0, ii = value.length; i < ii; ++i) {
  23998. var a = value[i];
  23999. if (a === 'e') {
  24000. nibbles += value[++i] === '-' ? 'c' : 'b';
  24001. } else if (a === '.') {
  24002. nibbles += 'a';
  24003. } else if (a === '-') {
  24004. nibbles += 'e';
  24005. } else {
  24006. nibbles += a;
  24007. }
  24008. }
  24009. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24010. var out = [30];
  24011. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24012. out.push(parseInt(nibbles.substr(i, 2), 16));
  24013. }
  24014. return out;
  24015. },
  24016. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24017. var code;
  24018. if (value >= -107 && value <= 107) {
  24019. code = [value + 139];
  24020. } else if (value >= 108 && value <= 1131) {
  24021. value = value - 108;
  24022. code = [
  24023. (value >> 8) + 247,
  24024. value & 0xFF
  24025. ];
  24026. } else if (value >= -1131 && value <= -108) {
  24027. value = -value - 108;
  24028. code = [
  24029. (value >> 8) + 251,
  24030. value & 0xFF
  24031. ];
  24032. } else if (value >= -32768 && value <= 32767) {
  24033. code = [
  24034. 0x1c,
  24035. value >> 8 & 0xFF,
  24036. value & 0xFF
  24037. ];
  24038. } else {
  24039. code = [
  24040. 0x1d,
  24041. value >> 24 & 0xFF,
  24042. value >> 16 & 0xFF,
  24043. value >> 8 & 0xFF,
  24044. value & 0xFF
  24045. ];
  24046. }
  24047. return code;
  24048. },
  24049. compileHeader: function CFFCompiler_compileHeader(header) {
  24050. return [
  24051. header.major,
  24052. header.minor,
  24053. header.hdrSize,
  24054. header.offSize
  24055. ];
  24056. },
  24057. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24058. var nameIndex = new CFFIndex();
  24059. for (var i = 0, ii = names.length; i < ii; ++i) {
  24060. nameIndex.add(stringToBytes(names[i]));
  24061. }
  24062. return this.compileIndex(nameIndex);
  24063. },
  24064. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24065. var fontDictTrackers = [];
  24066. var fdArrayIndex = new CFFIndex();
  24067. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24068. var fontDict = dicts[i];
  24069. if (removeCidKeys) {
  24070. fontDict.removeByName('CIDFontVersion');
  24071. fontDict.removeByName('CIDFontRevision');
  24072. fontDict.removeByName('CIDFontType');
  24073. fontDict.removeByName('CIDCount');
  24074. fontDict.removeByName('UIDBase');
  24075. }
  24076. var fontDictTracker = new CFFOffsetTracker();
  24077. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24078. fontDictTrackers.push(fontDictTracker);
  24079. fdArrayIndex.add(fontDictData);
  24080. fontDictTracker.offset(length);
  24081. }
  24082. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24083. return {
  24084. trackers: fontDictTrackers,
  24085. output: fdArrayIndex
  24086. };
  24087. },
  24088. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24089. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24090. var fontDict = dicts[i];
  24091. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24092. var privateDict = fontDict.privateDict;
  24093. var privateDictTracker = new CFFOffsetTracker();
  24094. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24095. var outputLength = output.length;
  24096. privateDictTracker.offset(outputLength);
  24097. if (!privateDictData.length) {
  24098. outputLength = 0;
  24099. }
  24100. trackers[i].setEntryLocation('Private', [
  24101. privateDictData.length,
  24102. outputLength
  24103. ], output);
  24104. output.add(privateDictData);
  24105. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24106. var subrs = this.compileIndex(privateDict.subrsIndex);
  24107. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24108. output.add(subrs);
  24109. }
  24110. }
  24111. },
  24112. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24113. var out = [];
  24114. var order = dict.order;
  24115. for (var i = 0; i < order.length; ++i) {
  24116. var key = order[i];
  24117. if (!(key in dict.values)) {
  24118. continue;
  24119. }
  24120. var values = dict.values[key];
  24121. var types = dict.types[key];
  24122. if (!isArray(types)) {
  24123. types = [types];
  24124. }
  24125. if (!isArray(values)) {
  24126. values = [values];
  24127. }
  24128. if (values.length === 0) {
  24129. continue;
  24130. }
  24131. for (var j = 0, jj = types.length; j < jj; ++j) {
  24132. var type = types[j];
  24133. var value = values[j];
  24134. switch (type) {
  24135. case 'num':
  24136. case 'sid':
  24137. out = out.concat(this.encodeNumber(value));
  24138. break;
  24139. case 'offset':
  24140. var name = dict.keyToNameMap[key];
  24141. if (!offsetTracker.isTracking(name)) {
  24142. offsetTracker.track(name, out.length);
  24143. }
  24144. out = out.concat([
  24145. 0x1d,
  24146. 0,
  24147. 0,
  24148. 0,
  24149. 0
  24150. ]);
  24151. break;
  24152. case 'array':
  24153. case 'delta':
  24154. out = out.concat(this.encodeNumber(value));
  24155. for (var k = 1, kk = values.length; k < kk; ++k) {
  24156. out = out.concat(this.encodeNumber(values[k]));
  24157. }
  24158. break;
  24159. default:
  24160. error('Unknown data type of ' + type);
  24161. break;
  24162. }
  24163. }
  24164. out = out.concat(dict.opcodes[key]);
  24165. }
  24166. return out;
  24167. },
  24168. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24169. var stringIndex = new CFFIndex();
  24170. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24171. stringIndex.add(stringToBytes(strings[i]));
  24172. }
  24173. return this.compileIndex(stringIndex);
  24174. },
  24175. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24176. var globalSubrIndex = this.cff.globalSubrIndex;
  24177. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24178. },
  24179. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24180. return this.compileIndex(charStrings);
  24181. },
  24182. compileCharset: function CFFCompiler_compileCharset(charset) {
  24183. return this.compileTypedArray(charset.raw);
  24184. },
  24185. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24186. return this.compileTypedArray(encoding.raw);
  24187. },
  24188. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24189. return this.compileTypedArray(fdSelect);
  24190. },
  24191. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24192. var out = [];
  24193. for (var i = 0, ii = data.length; i < ii; ++i) {
  24194. out[i] = data[i];
  24195. }
  24196. return out;
  24197. },
  24198. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24199. trackers = trackers || [];
  24200. var objects = index.objects;
  24201. var count = objects.length;
  24202. if (count === 0) {
  24203. return [
  24204. 0,
  24205. 0,
  24206. 0
  24207. ];
  24208. }
  24209. var data = [
  24210. count >> 8 & 0xFF,
  24211. count & 0xff
  24212. ];
  24213. var lastOffset = 1, i;
  24214. for (i = 0; i < count; ++i) {
  24215. lastOffset += objects[i].length;
  24216. }
  24217. var offsetSize;
  24218. if (lastOffset < 0x100) {
  24219. offsetSize = 1;
  24220. } else if (lastOffset < 0x10000) {
  24221. offsetSize = 2;
  24222. } else if (lastOffset < 0x1000000) {
  24223. offsetSize = 3;
  24224. } else {
  24225. offsetSize = 4;
  24226. }
  24227. data.push(offsetSize);
  24228. var relativeOffset = 1;
  24229. for (i = 0; i < count + 1; i++) {
  24230. if (offsetSize === 1) {
  24231. data.push(relativeOffset & 0xFF);
  24232. } else if (offsetSize === 2) {
  24233. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24234. } else if (offsetSize === 3) {
  24235. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24236. } else {
  24237. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24238. }
  24239. if (objects[i]) {
  24240. relativeOffset += objects[i].length;
  24241. }
  24242. }
  24243. for (i = 0; i < count; i++) {
  24244. if (trackers[i]) {
  24245. trackers[i].offset(data.length);
  24246. }
  24247. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24248. data.push(objects[i][j]);
  24249. }
  24250. }
  24251. return data;
  24252. }
  24253. };
  24254. return CFFCompiler;
  24255. }();
  24256. exports.CFFStandardStrings = CFFStandardStrings;
  24257. exports.CFFParser = CFFParser;
  24258. exports.CFF = CFF;
  24259. exports.CFFHeader = CFFHeader;
  24260. exports.CFFStrings = CFFStrings;
  24261. exports.CFFIndex = CFFIndex;
  24262. exports.CFFCharset = CFFCharset;
  24263. exports.CFFTopDict = CFFTopDict;
  24264. exports.CFFPrivateDict = CFFPrivateDict;
  24265. exports.CFFCompiler = CFFCompiler;
  24266. /***/ }),
  24267. /* 16 */
  24268. /***/ (function(module, exports, __w_pdfjs_require__) {
  24269. "use strict";
  24270. var sharedUtil = __w_pdfjs_require__(0);
  24271. var MissingDataException = sharedUtil.MissingDataException;
  24272. var arrayByteLength = sharedUtil.arrayByteLength;
  24273. var arraysToBytes = sharedUtil.arraysToBytes;
  24274. var assert = sharedUtil.assert;
  24275. var createPromiseCapability = sharedUtil.createPromiseCapability;
  24276. var isInt = sharedUtil.isInt;
  24277. var isEmptyObj = sharedUtil.isEmptyObj;
  24278. var ChunkedStream = function ChunkedStreamClosure() {
  24279. function ChunkedStream(length, chunkSize, manager) {
  24280. this.bytes = new Uint8Array(length);
  24281. this.start = 0;
  24282. this.pos = 0;
  24283. this.end = length;
  24284. this.chunkSize = chunkSize;
  24285. this.loadedChunks = [];
  24286. this.numChunksLoaded = 0;
  24287. this.numChunks = Math.ceil(length / chunkSize);
  24288. this.manager = manager;
  24289. this.progressiveDataLength = 0;
  24290. this.lastSuccessfulEnsureByteChunk = -1;
  24291. }
  24292. ChunkedStream.prototype = {
  24293. getMissingChunks: function ChunkedStream_getMissingChunks() {
  24294. var chunks = [];
  24295. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  24296. if (!this.loadedChunks[chunk]) {
  24297. chunks.push(chunk);
  24298. }
  24299. }
  24300. return chunks;
  24301. },
  24302. getBaseStreams: function ChunkedStream_getBaseStreams() {
  24303. return [this];
  24304. },
  24305. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  24306. return this.numChunksLoaded === this.numChunks;
  24307. },
  24308. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  24309. var end = begin + chunk.byteLength;
  24310. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  24311. var length = this.bytes.length;
  24312. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  24313. this.bytes.set(new Uint8Array(chunk), begin);
  24314. var chunkSize = this.chunkSize;
  24315. var beginChunk = Math.floor(begin / chunkSize);
  24316. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24317. var curChunk;
  24318. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24319. if (!this.loadedChunks[curChunk]) {
  24320. this.loadedChunks[curChunk] = true;
  24321. ++this.numChunksLoaded;
  24322. }
  24323. }
  24324. },
  24325. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  24326. var position = this.progressiveDataLength;
  24327. var beginChunk = Math.floor(position / this.chunkSize);
  24328. this.bytes.set(new Uint8Array(data), position);
  24329. position += data.byteLength;
  24330. this.progressiveDataLength = position;
  24331. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  24332. var curChunk;
  24333. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24334. if (!this.loadedChunks[curChunk]) {
  24335. this.loadedChunks[curChunk] = true;
  24336. ++this.numChunksLoaded;
  24337. }
  24338. }
  24339. },
  24340. ensureByte: function ChunkedStream_ensureByte(pos) {
  24341. var chunk = Math.floor(pos / this.chunkSize);
  24342. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  24343. return;
  24344. }
  24345. if (!this.loadedChunks[chunk]) {
  24346. throw new MissingDataException(pos, pos + 1);
  24347. }
  24348. this.lastSuccessfulEnsureByteChunk = chunk;
  24349. },
  24350. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  24351. if (begin >= end) {
  24352. return;
  24353. }
  24354. if (end <= this.progressiveDataLength) {
  24355. return;
  24356. }
  24357. var chunkSize = this.chunkSize;
  24358. var beginChunk = Math.floor(begin / chunkSize);
  24359. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24360. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24361. if (!this.loadedChunks[chunk]) {
  24362. throw new MissingDataException(begin, end);
  24363. }
  24364. }
  24365. },
  24366. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  24367. var chunk, numChunks = this.numChunks;
  24368. for (var i = 0; i < numChunks; ++i) {
  24369. chunk = (beginChunk + i) % numChunks;
  24370. if (!this.loadedChunks[chunk]) {
  24371. return chunk;
  24372. }
  24373. }
  24374. return null;
  24375. },
  24376. hasChunk: function ChunkedStream_hasChunk(chunk) {
  24377. return !!this.loadedChunks[chunk];
  24378. },
  24379. get length() {
  24380. return this.end - this.start;
  24381. },
  24382. get isEmpty() {
  24383. return this.length === 0;
  24384. },
  24385. getByte: function ChunkedStream_getByte() {
  24386. var pos = this.pos;
  24387. if (pos >= this.end) {
  24388. return -1;
  24389. }
  24390. this.ensureByte(pos);
  24391. return this.bytes[this.pos++];
  24392. },
  24393. getUint16: function ChunkedStream_getUint16() {
  24394. var b0 = this.getByte();
  24395. var b1 = this.getByte();
  24396. if (b0 === -1 || b1 === -1) {
  24397. return -1;
  24398. }
  24399. return (b0 << 8) + b1;
  24400. },
  24401. getInt32: function ChunkedStream_getInt32() {
  24402. var b0 = this.getByte();
  24403. var b1 = this.getByte();
  24404. var b2 = this.getByte();
  24405. var b3 = this.getByte();
  24406. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24407. },
  24408. getBytes: function ChunkedStream_getBytes(length) {
  24409. var bytes = this.bytes;
  24410. var pos = this.pos;
  24411. var strEnd = this.end;
  24412. if (!length) {
  24413. this.ensureRange(pos, strEnd);
  24414. return bytes.subarray(pos, strEnd);
  24415. }
  24416. var end = pos + length;
  24417. if (end > strEnd) {
  24418. end = strEnd;
  24419. }
  24420. this.ensureRange(pos, end);
  24421. this.pos = end;
  24422. return bytes.subarray(pos, end);
  24423. },
  24424. peekByte: function ChunkedStream_peekByte() {
  24425. var peekedByte = this.getByte();
  24426. this.pos--;
  24427. return peekedByte;
  24428. },
  24429. peekBytes: function ChunkedStream_peekBytes(length) {
  24430. var bytes = this.getBytes(length);
  24431. this.pos -= bytes.length;
  24432. return bytes;
  24433. },
  24434. getByteRange: function ChunkedStream_getBytes(begin, end) {
  24435. this.ensureRange(begin, end);
  24436. return this.bytes.subarray(begin, end);
  24437. },
  24438. skip: function ChunkedStream_skip(n) {
  24439. if (!n) {
  24440. n = 1;
  24441. }
  24442. this.pos += n;
  24443. },
  24444. reset: function ChunkedStream_reset() {
  24445. this.pos = this.start;
  24446. },
  24447. moveStart: function ChunkedStream_moveStart() {
  24448. this.start = this.pos;
  24449. },
  24450. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  24451. this.ensureRange(start, start + length);
  24452. function ChunkedStreamSubstream() {
  24453. }
  24454. ChunkedStreamSubstream.prototype = Object.create(this);
  24455. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  24456. var chunkSize = this.chunkSize;
  24457. var beginChunk = Math.floor(this.start / chunkSize);
  24458. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  24459. var missingChunks = [];
  24460. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24461. if (!this.loadedChunks[chunk]) {
  24462. missingChunks.push(chunk);
  24463. }
  24464. }
  24465. return missingChunks;
  24466. };
  24467. var subStream = new ChunkedStreamSubstream();
  24468. subStream.pos = subStream.start = start;
  24469. subStream.end = start + length || this.end;
  24470. subStream.dict = dict;
  24471. return subStream;
  24472. }
  24473. };
  24474. return ChunkedStream;
  24475. }();
  24476. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  24477. function ChunkedStreamManager(pdfNetworkStream, args) {
  24478. var chunkSize = args.rangeChunkSize;
  24479. var length = args.length;
  24480. this.stream = new ChunkedStream(length, chunkSize, this);
  24481. this.length = length;
  24482. this.chunkSize = chunkSize;
  24483. this.pdfNetworkStream = pdfNetworkStream;
  24484. this.url = args.url;
  24485. this.disableAutoFetch = args.disableAutoFetch;
  24486. this.msgHandler = args.msgHandler;
  24487. this.currRequestId = 0;
  24488. this.chunksNeededByRequest = Object.create(null);
  24489. this.requestsByChunk = Object.create(null);
  24490. this.promisesByRequest = Object.create(null);
  24491. this.progressiveDataLength = 0;
  24492. this.aborted = false;
  24493. this._loadedStreamCapability = createPromiseCapability();
  24494. }
  24495. ChunkedStreamManager.prototype = {
  24496. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  24497. return this._loadedStreamCapability.promise;
  24498. },
  24499. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  24500. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  24501. if (!rangeReader.isStreamingSupported) {
  24502. rangeReader.onProgress = this.onProgress.bind(this);
  24503. }
  24504. var chunks = [], loaded = 0;
  24505. var manager = this;
  24506. var promise = new Promise(function (resolve, reject) {
  24507. var readChunk = function (chunk) {
  24508. try {
  24509. if (!chunk.done) {
  24510. var data = chunk.value;
  24511. chunks.push(data);
  24512. loaded += arrayByteLength(data);
  24513. if (rangeReader.isStreamingSupported) {
  24514. manager.onProgress({ loaded: loaded });
  24515. }
  24516. rangeReader.read().then(readChunk, reject);
  24517. return;
  24518. }
  24519. var chunkData = arraysToBytes(chunks);
  24520. chunks = null;
  24521. resolve(chunkData);
  24522. } catch (e) {
  24523. reject(e);
  24524. }
  24525. };
  24526. rangeReader.read().then(readChunk, reject);
  24527. });
  24528. promise.then(function (data) {
  24529. if (this.aborted) {
  24530. return;
  24531. }
  24532. this.onReceiveData({
  24533. chunk: data,
  24534. begin: begin
  24535. });
  24536. }.bind(this));
  24537. },
  24538. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  24539. var missingChunks = this.stream.getMissingChunks();
  24540. this._requestChunks(missingChunks);
  24541. return this._loadedStreamCapability.promise;
  24542. },
  24543. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  24544. var requestId = this.currRequestId++;
  24545. var i, ii;
  24546. var chunksNeeded = Object.create(null);
  24547. this.chunksNeededByRequest[requestId] = chunksNeeded;
  24548. for (i = 0, ii = chunks.length; i < ii; i++) {
  24549. if (!this.stream.hasChunk(chunks[i])) {
  24550. chunksNeeded[chunks[i]] = true;
  24551. }
  24552. }
  24553. if (isEmptyObj(chunksNeeded)) {
  24554. return Promise.resolve();
  24555. }
  24556. var capability = createPromiseCapability();
  24557. this.promisesByRequest[requestId] = capability;
  24558. var chunksToRequest = [];
  24559. for (var chunk in chunksNeeded) {
  24560. chunk = chunk | 0;
  24561. if (!(chunk in this.requestsByChunk)) {
  24562. this.requestsByChunk[chunk] = [];
  24563. chunksToRequest.push(chunk);
  24564. }
  24565. this.requestsByChunk[chunk].push(requestId);
  24566. }
  24567. if (!chunksToRequest.length) {
  24568. return capability.promise;
  24569. }
  24570. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  24571. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  24572. var groupedChunk = groupedChunksToRequest[i];
  24573. var begin = groupedChunk.beginChunk * this.chunkSize;
  24574. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  24575. this.sendRequest(begin, end);
  24576. }
  24577. return capability.promise;
  24578. },
  24579. getStream: function ChunkedStreamManager_getStream() {
  24580. return this.stream;
  24581. },
  24582. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  24583. end = Math.min(end, this.length);
  24584. var beginChunk = this.getBeginChunk(begin);
  24585. var endChunk = this.getEndChunk(end);
  24586. var chunks = [];
  24587. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24588. chunks.push(chunk);
  24589. }
  24590. return this._requestChunks(chunks);
  24591. },
  24592. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  24593. ranges = ranges || [];
  24594. var chunksToRequest = [];
  24595. for (var i = 0; i < ranges.length; i++) {
  24596. var beginChunk = this.getBeginChunk(ranges[i].begin);
  24597. var endChunk = this.getEndChunk(ranges[i].end);
  24598. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24599. if (chunksToRequest.indexOf(chunk) < 0) {
  24600. chunksToRequest.push(chunk);
  24601. }
  24602. }
  24603. }
  24604. chunksToRequest.sort(function (a, b) {
  24605. return a - b;
  24606. });
  24607. return this._requestChunks(chunksToRequest);
  24608. },
  24609. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  24610. var groupedChunks = [];
  24611. var beginChunk = -1;
  24612. var prevChunk = -1;
  24613. for (var i = 0; i < chunks.length; ++i) {
  24614. var chunk = chunks[i];
  24615. if (beginChunk < 0) {
  24616. beginChunk = chunk;
  24617. }
  24618. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  24619. groupedChunks.push({
  24620. beginChunk: beginChunk,
  24621. endChunk: prevChunk + 1
  24622. });
  24623. beginChunk = chunk;
  24624. }
  24625. if (i + 1 === chunks.length) {
  24626. groupedChunks.push({
  24627. beginChunk: beginChunk,
  24628. endChunk: chunk + 1
  24629. });
  24630. }
  24631. prevChunk = chunk;
  24632. }
  24633. return groupedChunks;
  24634. },
  24635. onProgress: function ChunkedStreamManager_onProgress(args) {
  24636. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  24637. this.msgHandler.send('DocProgress', {
  24638. loaded: bytesLoaded,
  24639. total: this.length
  24640. });
  24641. },
  24642. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  24643. var chunk = args.chunk;
  24644. var isProgressive = args.begin === undefined;
  24645. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  24646. var end = begin + chunk.byteLength;
  24647. var beginChunk = Math.floor(begin / this.chunkSize);
  24648. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  24649. if (isProgressive) {
  24650. this.stream.onReceiveProgressiveData(chunk);
  24651. this.progressiveDataLength = end;
  24652. } else {
  24653. this.stream.onReceiveData(begin, chunk);
  24654. }
  24655. if (this.stream.allChunksLoaded()) {
  24656. this._loadedStreamCapability.resolve(this.stream);
  24657. }
  24658. var loadedRequests = [];
  24659. var i, requestId;
  24660. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  24661. var requestIds = this.requestsByChunk[chunk] || [];
  24662. delete this.requestsByChunk[chunk];
  24663. for (i = 0; i < requestIds.length; ++i) {
  24664. requestId = requestIds[i];
  24665. var chunksNeeded = this.chunksNeededByRequest[requestId];
  24666. if (chunk in chunksNeeded) {
  24667. delete chunksNeeded[chunk];
  24668. }
  24669. if (!isEmptyObj(chunksNeeded)) {
  24670. continue;
  24671. }
  24672. loadedRequests.push(requestId);
  24673. }
  24674. }
  24675. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  24676. var nextEmptyChunk;
  24677. if (this.stream.numChunksLoaded === 1) {
  24678. var lastChunk = this.stream.numChunks - 1;
  24679. if (!this.stream.hasChunk(lastChunk)) {
  24680. nextEmptyChunk = lastChunk;
  24681. }
  24682. } else {
  24683. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  24684. }
  24685. if (isInt(nextEmptyChunk)) {
  24686. this._requestChunks([nextEmptyChunk]);
  24687. }
  24688. }
  24689. for (i = 0; i < loadedRequests.length; ++i) {
  24690. requestId = loadedRequests[i];
  24691. var capability = this.promisesByRequest[requestId];
  24692. delete this.promisesByRequest[requestId];
  24693. capability.resolve();
  24694. }
  24695. this.msgHandler.send('DocProgress', {
  24696. loaded: this.stream.numChunksLoaded * this.chunkSize,
  24697. total: this.length
  24698. });
  24699. },
  24700. onError: function ChunkedStreamManager_onError(err) {
  24701. this._loadedStreamCapability.reject(err);
  24702. },
  24703. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  24704. var chunk = Math.floor(begin / this.chunkSize);
  24705. return chunk;
  24706. },
  24707. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  24708. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  24709. return chunk;
  24710. },
  24711. abort: function ChunkedStreamManager_abort() {
  24712. this.aborted = true;
  24713. if (this.pdfNetworkStream) {
  24714. this.pdfNetworkStream.cancelAllRequests('abort');
  24715. }
  24716. for (var requestId in this.promisesByRequest) {
  24717. var capability = this.promisesByRequest[requestId];
  24718. capability.reject(new Error('Request was aborted'));
  24719. }
  24720. }
  24721. };
  24722. return ChunkedStreamManager;
  24723. }();
  24724. exports.ChunkedStream = ChunkedStream;
  24725. exports.ChunkedStreamManager = ChunkedStreamManager;
  24726. /***/ }),
  24727. /* 17 */
  24728. /***/ (function(module, exports, __w_pdfjs_require__) {
  24729. "use strict";
  24730. var sharedUtil = __w_pdfjs_require__(0);
  24731. var corePrimitives = __w_pdfjs_require__(1);
  24732. var coreStream = __w_pdfjs_require__(2);
  24733. var PasswordException = sharedUtil.PasswordException;
  24734. var PasswordResponses = sharedUtil.PasswordResponses;
  24735. var bytesToString = sharedUtil.bytesToString;
  24736. var warn = sharedUtil.warn;
  24737. var error = sharedUtil.error;
  24738. var assert = sharedUtil.assert;
  24739. var isInt = sharedUtil.isInt;
  24740. var stringToBytes = sharedUtil.stringToBytes;
  24741. var utf8StringToString = sharedUtil.utf8StringToString;
  24742. var Name = corePrimitives.Name;
  24743. var isName = corePrimitives.isName;
  24744. var isDict = corePrimitives.isDict;
  24745. var DecryptStream = coreStream.DecryptStream;
  24746. var ARCFourCipher = function ARCFourCipherClosure() {
  24747. function ARCFourCipher(key) {
  24748. this.a = 0;
  24749. this.b = 0;
  24750. var s = new Uint8Array(256);
  24751. var i, j = 0, tmp, keyLength = key.length;
  24752. for (i = 0; i < 256; ++i) {
  24753. s[i] = i;
  24754. }
  24755. for (i = 0; i < 256; ++i) {
  24756. tmp = s[i];
  24757. j = j + tmp + key[i % keyLength] & 0xFF;
  24758. s[i] = s[j];
  24759. s[j] = tmp;
  24760. }
  24761. this.s = s;
  24762. }
  24763. ARCFourCipher.prototype = {
  24764. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  24765. var i, n = data.length, tmp, tmp2;
  24766. var a = this.a, b = this.b, s = this.s;
  24767. var output = new Uint8Array(n);
  24768. for (i = 0; i < n; ++i) {
  24769. a = a + 1 & 0xFF;
  24770. tmp = s[a];
  24771. b = b + tmp & 0xFF;
  24772. tmp2 = s[b];
  24773. s[a] = tmp2;
  24774. s[b] = tmp;
  24775. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  24776. }
  24777. this.a = a;
  24778. this.b = b;
  24779. return output;
  24780. }
  24781. };
  24782. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  24783. return ARCFourCipher;
  24784. }();
  24785. var calculateMD5 = function calculateMD5Closure() {
  24786. var r = new Uint8Array([
  24787. 7,
  24788. 12,
  24789. 17,
  24790. 22,
  24791. 7,
  24792. 12,
  24793. 17,
  24794. 22,
  24795. 7,
  24796. 12,
  24797. 17,
  24798. 22,
  24799. 7,
  24800. 12,
  24801. 17,
  24802. 22,
  24803. 5,
  24804. 9,
  24805. 14,
  24806. 20,
  24807. 5,
  24808. 9,
  24809. 14,
  24810. 20,
  24811. 5,
  24812. 9,
  24813. 14,
  24814. 20,
  24815. 5,
  24816. 9,
  24817. 14,
  24818. 20,
  24819. 4,
  24820. 11,
  24821. 16,
  24822. 23,
  24823. 4,
  24824. 11,
  24825. 16,
  24826. 23,
  24827. 4,
  24828. 11,
  24829. 16,
  24830. 23,
  24831. 4,
  24832. 11,
  24833. 16,
  24834. 23,
  24835. 6,
  24836. 10,
  24837. 15,
  24838. 21,
  24839. 6,
  24840. 10,
  24841. 15,
  24842. 21,
  24843. 6,
  24844. 10,
  24845. 15,
  24846. 21,
  24847. 6,
  24848. 10,
  24849. 15,
  24850. 21
  24851. ]);
  24852. var k = new Int32Array([
  24853. -680876936,
  24854. -389564586,
  24855. 606105819,
  24856. -1044525330,
  24857. -176418897,
  24858. 1200080426,
  24859. -1473231341,
  24860. -45705983,
  24861. 1770035416,
  24862. -1958414417,
  24863. -42063,
  24864. -1990404162,
  24865. 1804603682,
  24866. -40341101,
  24867. -1502002290,
  24868. 1236535329,
  24869. -165796510,
  24870. -1069501632,
  24871. 643717713,
  24872. -373897302,
  24873. -701558691,
  24874. 38016083,
  24875. -660478335,
  24876. -405537848,
  24877. 568446438,
  24878. -1019803690,
  24879. -187363961,
  24880. 1163531501,
  24881. -1444681467,
  24882. -51403784,
  24883. 1735328473,
  24884. -1926607734,
  24885. -378558,
  24886. -2022574463,
  24887. 1839030562,
  24888. -35309556,
  24889. -1530992060,
  24890. 1272893353,
  24891. -155497632,
  24892. -1094730640,
  24893. 681279174,
  24894. -358537222,
  24895. -722521979,
  24896. 76029189,
  24897. -640364487,
  24898. -421815835,
  24899. 530742520,
  24900. -995338651,
  24901. -198630844,
  24902. 1126891415,
  24903. -1416354905,
  24904. -57434055,
  24905. 1700485571,
  24906. -1894986606,
  24907. -1051523,
  24908. -2054922799,
  24909. 1873313359,
  24910. -30611744,
  24911. -1560198380,
  24912. 1309151649,
  24913. -145523070,
  24914. -1120210379,
  24915. 718787259,
  24916. -343485551
  24917. ]);
  24918. function hash(data, offset, length) {
  24919. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  24920. var paddedLength = length + 72 & ~63;
  24921. var padded = new Uint8Array(paddedLength);
  24922. var i, j, n;
  24923. for (i = 0; i < length; ++i) {
  24924. padded[i] = data[offset++];
  24925. }
  24926. padded[i++] = 0x80;
  24927. n = paddedLength - 8;
  24928. while (i < n) {
  24929. padded[i++] = 0;
  24930. }
  24931. padded[i++] = length << 3 & 0xFF;
  24932. padded[i++] = length >> 5 & 0xFF;
  24933. padded[i++] = length >> 13 & 0xFF;
  24934. padded[i++] = length >> 21 & 0xFF;
  24935. padded[i++] = length >>> 29 & 0xFF;
  24936. padded[i++] = 0;
  24937. padded[i++] = 0;
  24938. padded[i++] = 0;
  24939. var w = new Int32Array(16);
  24940. for (i = 0; i < paddedLength;) {
  24941. for (j = 0; j < 16; ++j, i += 4) {
  24942. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  24943. }
  24944. var a = h0, b = h1, c = h2, d = h3, f, g;
  24945. for (j = 0; j < 64; ++j) {
  24946. if (j < 16) {
  24947. f = b & c | ~b & d;
  24948. g = j;
  24949. } else if (j < 32) {
  24950. f = d & b | ~d & c;
  24951. g = 5 * j + 1 & 15;
  24952. } else if (j < 48) {
  24953. f = b ^ c ^ d;
  24954. g = 3 * j + 5 & 15;
  24955. } else {
  24956. f = c ^ (b | ~d);
  24957. g = 7 * j & 15;
  24958. }
  24959. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  24960. d = c;
  24961. c = b;
  24962. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  24963. a = tmp;
  24964. }
  24965. h0 = h0 + a | 0;
  24966. h1 = h1 + b | 0;
  24967. h2 = h2 + c | 0;
  24968. h3 = h3 + d | 0;
  24969. }
  24970. return new Uint8Array([
  24971. h0 & 0xFF,
  24972. h0 >> 8 & 0xFF,
  24973. h0 >> 16 & 0xFF,
  24974. h0 >>> 24 & 0xFF,
  24975. h1 & 0xFF,
  24976. h1 >> 8 & 0xFF,
  24977. h1 >> 16 & 0xFF,
  24978. h1 >>> 24 & 0xFF,
  24979. h2 & 0xFF,
  24980. h2 >> 8 & 0xFF,
  24981. h2 >> 16 & 0xFF,
  24982. h2 >>> 24 & 0xFF,
  24983. h3 & 0xFF,
  24984. h3 >> 8 & 0xFF,
  24985. h3 >> 16 & 0xFF,
  24986. h3 >>> 24 & 0xFF
  24987. ]);
  24988. }
  24989. return hash;
  24990. }();
  24991. var Word64 = function Word64Closure() {
  24992. function Word64(highInteger, lowInteger) {
  24993. this.high = highInteger | 0;
  24994. this.low = lowInteger | 0;
  24995. }
  24996. Word64.prototype = {
  24997. and: function Word64_and(word) {
  24998. this.high &= word.high;
  24999. this.low &= word.low;
  25000. },
  25001. xor: function Word64_xor(word) {
  25002. this.high ^= word.high;
  25003. this.low ^= word.low;
  25004. },
  25005. or: function Word64_or(word) {
  25006. this.high |= word.high;
  25007. this.low |= word.low;
  25008. },
  25009. shiftRight: function Word64_shiftRight(places) {
  25010. if (places >= 32) {
  25011. this.low = this.high >>> places - 32 | 0;
  25012. this.high = 0;
  25013. } else {
  25014. this.low = this.low >>> places | this.high << 32 - places;
  25015. this.high = this.high >>> places | 0;
  25016. }
  25017. },
  25018. shiftLeft: function Word64_shiftLeft(places) {
  25019. if (places >= 32) {
  25020. this.high = this.low << places - 32;
  25021. this.low = 0;
  25022. } else {
  25023. this.high = this.high << places | this.low >>> 32 - places;
  25024. this.low = this.low << places;
  25025. }
  25026. },
  25027. rotateRight: function Word64_rotateRight(places) {
  25028. var low, high;
  25029. if (places & 32) {
  25030. high = this.low;
  25031. low = this.high;
  25032. } else {
  25033. low = this.low;
  25034. high = this.high;
  25035. }
  25036. places &= 31;
  25037. this.low = low >>> places | high << 32 - places;
  25038. this.high = high >>> places | low << 32 - places;
  25039. },
  25040. not: function Word64_not() {
  25041. this.high = ~this.high;
  25042. this.low = ~this.low;
  25043. },
  25044. add: function Word64_add(word) {
  25045. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25046. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25047. if (lowAdd > 0xFFFFFFFF) {
  25048. highAdd += 1;
  25049. }
  25050. this.low = lowAdd | 0;
  25051. this.high = highAdd | 0;
  25052. },
  25053. copyTo: function Word64_copyTo(bytes, offset) {
  25054. bytes[offset] = this.high >>> 24 & 0xFF;
  25055. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25056. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25057. bytes[offset + 3] = this.high & 0xFF;
  25058. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25059. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25060. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25061. bytes[offset + 7] = this.low & 0xFF;
  25062. },
  25063. assign: function Word64_assign(word) {
  25064. this.high = word.high;
  25065. this.low = word.low;
  25066. }
  25067. };
  25068. return Word64;
  25069. }();
  25070. var calculateSHA256 = function calculateSHA256Closure() {
  25071. function rotr(x, n) {
  25072. return x >>> n | x << 32 - n;
  25073. }
  25074. function ch(x, y, z) {
  25075. return x & y ^ ~x & z;
  25076. }
  25077. function maj(x, y, z) {
  25078. return x & y ^ x & z ^ y & z;
  25079. }
  25080. function sigma(x) {
  25081. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25082. }
  25083. function sigmaPrime(x) {
  25084. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25085. }
  25086. function littleSigma(x) {
  25087. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25088. }
  25089. function littleSigmaPrime(x) {
  25090. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25091. }
  25092. var k = [
  25093. 0x428a2f98,
  25094. 0x71374491,
  25095. 0xb5c0fbcf,
  25096. 0xe9b5dba5,
  25097. 0x3956c25b,
  25098. 0x59f111f1,
  25099. 0x923f82a4,
  25100. 0xab1c5ed5,
  25101. 0xd807aa98,
  25102. 0x12835b01,
  25103. 0x243185be,
  25104. 0x550c7dc3,
  25105. 0x72be5d74,
  25106. 0x80deb1fe,
  25107. 0x9bdc06a7,
  25108. 0xc19bf174,
  25109. 0xe49b69c1,
  25110. 0xefbe4786,
  25111. 0x0fc19dc6,
  25112. 0x240ca1cc,
  25113. 0x2de92c6f,
  25114. 0x4a7484aa,
  25115. 0x5cb0a9dc,
  25116. 0x76f988da,
  25117. 0x983e5152,
  25118. 0xa831c66d,
  25119. 0xb00327c8,
  25120. 0xbf597fc7,
  25121. 0xc6e00bf3,
  25122. 0xd5a79147,
  25123. 0x06ca6351,
  25124. 0x14292967,
  25125. 0x27b70a85,
  25126. 0x2e1b2138,
  25127. 0x4d2c6dfc,
  25128. 0x53380d13,
  25129. 0x650a7354,
  25130. 0x766a0abb,
  25131. 0x81c2c92e,
  25132. 0x92722c85,
  25133. 0xa2bfe8a1,
  25134. 0xa81a664b,
  25135. 0xc24b8b70,
  25136. 0xc76c51a3,
  25137. 0xd192e819,
  25138. 0xd6990624,
  25139. 0xf40e3585,
  25140. 0x106aa070,
  25141. 0x19a4c116,
  25142. 0x1e376c08,
  25143. 0x2748774c,
  25144. 0x34b0bcb5,
  25145. 0x391c0cb3,
  25146. 0x4ed8aa4a,
  25147. 0x5b9cca4f,
  25148. 0x682e6ff3,
  25149. 0x748f82ee,
  25150. 0x78a5636f,
  25151. 0x84c87814,
  25152. 0x8cc70208,
  25153. 0x90befffa,
  25154. 0xa4506ceb,
  25155. 0xbef9a3f7,
  25156. 0xc67178f2
  25157. ];
  25158. function hash(data, offset, length) {
  25159. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25160. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25161. var padded = new Uint8Array(paddedLength);
  25162. var i, j, n;
  25163. for (i = 0; i < length; ++i) {
  25164. padded[i] = data[offset++];
  25165. }
  25166. padded[i++] = 0x80;
  25167. n = paddedLength - 8;
  25168. while (i < n) {
  25169. padded[i++] = 0;
  25170. }
  25171. padded[i++] = 0;
  25172. padded[i++] = 0;
  25173. padded[i++] = 0;
  25174. padded[i++] = length >>> 29 & 0xFF;
  25175. padded[i++] = length >> 21 & 0xFF;
  25176. padded[i++] = length >> 13 & 0xFF;
  25177. padded[i++] = length >> 5 & 0xFF;
  25178. padded[i++] = length << 3 & 0xFF;
  25179. var w = new Uint32Array(64);
  25180. for (i = 0; i < paddedLength;) {
  25181. for (j = 0; j < 16; ++j) {
  25182. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25183. i += 4;
  25184. }
  25185. for (j = 16; j < 64; ++j) {
  25186. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25187. }
  25188. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25189. for (j = 0; j < 64; ++j) {
  25190. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25191. t2 = sigma(a) + maj(a, b, c);
  25192. h = g;
  25193. g = f;
  25194. f = e;
  25195. e = d + t1 | 0;
  25196. d = c;
  25197. c = b;
  25198. b = a;
  25199. a = t1 + t2 | 0;
  25200. }
  25201. h0 = h0 + a | 0;
  25202. h1 = h1 + b | 0;
  25203. h2 = h2 + c | 0;
  25204. h3 = h3 + d | 0;
  25205. h4 = h4 + e | 0;
  25206. h5 = h5 + f | 0;
  25207. h6 = h6 + g | 0;
  25208. h7 = h7 + h | 0;
  25209. }
  25210. return new Uint8Array([
  25211. h0 >> 24 & 0xFF,
  25212. h0 >> 16 & 0xFF,
  25213. h0 >> 8 & 0xFF,
  25214. h0 & 0xFF,
  25215. h1 >> 24 & 0xFF,
  25216. h1 >> 16 & 0xFF,
  25217. h1 >> 8 & 0xFF,
  25218. h1 & 0xFF,
  25219. h2 >> 24 & 0xFF,
  25220. h2 >> 16 & 0xFF,
  25221. h2 >> 8 & 0xFF,
  25222. h2 & 0xFF,
  25223. h3 >> 24 & 0xFF,
  25224. h3 >> 16 & 0xFF,
  25225. h3 >> 8 & 0xFF,
  25226. h3 & 0xFF,
  25227. h4 >> 24 & 0xFF,
  25228. h4 >> 16 & 0xFF,
  25229. h4 >> 8 & 0xFF,
  25230. h4 & 0xFF,
  25231. h5 >> 24 & 0xFF,
  25232. h5 >> 16 & 0xFF,
  25233. h5 >> 8 & 0xFF,
  25234. h5 & 0xFF,
  25235. h6 >> 24 & 0xFF,
  25236. h6 >> 16 & 0xFF,
  25237. h6 >> 8 & 0xFF,
  25238. h6 & 0xFF,
  25239. h7 >> 24 & 0xFF,
  25240. h7 >> 16 & 0xFF,
  25241. h7 >> 8 & 0xFF,
  25242. h7 & 0xFF
  25243. ]);
  25244. }
  25245. return hash;
  25246. }();
  25247. var calculateSHA512 = function calculateSHA512Closure() {
  25248. function ch(result, x, y, z, tmp) {
  25249. result.assign(x);
  25250. result.and(y);
  25251. tmp.assign(x);
  25252. tmp.not();
  25253. tmp.and(z);
  25254. result.xor(tmp);
  25255. }
  25256. function maj(result, x, y, z, tmp) {
  25257. result.assign(x);
  25258. result.and(y);
  25259. tmp.assign(x);
  25260. tmp.and(z);
  25261. result.xor(tmp);
  25262. tmp.assign(y);
  25263. tmp.and(z);
  25264. result.xor(tmp);
  25265. }
  25266. function sigma(result, x, tmp) {
  25267. result.assign(x);
  25268. result.rotateRight(28);
  25269. tmp.assign(x);
  25270. tmp.rotateRight(34);
  25271. result.xor(tmp);
  25272. tmp.assign(x);
  25273. tmp.rotateRight(39);
  25274. result.xor(tmp);
  25275. }
  25276. function sigmaPrime(result, x, tmp) {
  25277. result.assign(x);
  25278. result.rotateRight(14);
  25279. tmp.assign(x);
  25280. tmp.rotateRight(18);
  25281. result.xor(tmp);
  25282. tmp.assign(x);
  25283. tmp.rotateRight(41);
  25284. result.xor(tmp);
  25285. }
  25286. function littleSigma(result, x, tmp) {
  25287. result.assign(x);
  25288. result.rotateRight(1);
  25289. tmp.assign(x);
  25290. tmp.rotateRight(8);
  25291. result.xor(tmp);
  25292. tmp.assign(x);
  25293. tmp.shiftRight(7);
  25294. result.xor(tmp);
  25295. }
  25296. function littleSigmaPrime(result, x, tmp) {
  25297. result.assign(x);
  25298. result.rotateRight(19);
  25299. tmp.assign(x);
  25300. tmp.rotateRight(61);
  25301. result.xor(tmp);
  25302. tmp.assign(x);
  25303. tmp.shiftRight(6);
  25304. result.xor(tmp);
  25305. }
  25306. var k = [
  25307. new Word64(0x428a2f98, 0xd728ae22),
  25308. new Word64(0x71374491, 0x23ef65cd),
  25309. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  25310. new Word64(0xe9b5dba5, 0x8189dbbc),
  25311. new Word64(0x3956c25b, 0xf348b538),
  25312. new Word64(0x59f111f1, 0xb605d019),
  25313. new Word64(0x923f82a4, 0xaf194f9b),
  25314. new Word64(0xab1c5ed5, 0xda6d8118),
  25315. new Word64(0xd807aa98, 0xa3030242),
  25316. new Word64(0x12835b01, 0x45706fbe),
  25317. new Word64(0x243185be, 0x4ee4b28c),
  25318. new Word64(0x550c7dc3, 0xd5ffb4e2),
  25319. new Word64(0x72be5d74, 0xf27b896f),
  25320. new Word64(0x80deb1fe, 0x3b1696b1),
  25321. new Word64(0x9bdc06a7, 0x25c71235),
  25322. new Word64(0xc19bf174, 0xcf692694),
  25323. new Word64(0xe49b69c1, 0x9ef14ad2),
  25324. new Word64(0xefbe4786, 0x384f25e3),
  25325. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  25326. new Word64(0x240ca1cc, 0x77ac9c65),
  25327. new Word64(0x2de92c6f, 0x592b0275),
  25328. new Word64(0x4a7484aa, 0x6ea6e483),
  25329. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  25330. new Word64(0x76f988da, 0x831153b5),
  25331. new Word64(0x983e5152, 0xee66dfab),
  25332. new Word64(0xa831c66d, 0x2db43210),
  25333. new Word64(0xb00327c8, 0x98fb213f),
  25334. new Word64(0xbf597fc7, 0xbeef0ee4),
  25335. new Word64(0xc6e00bf3, 0x3da88fc2),
  25336. new Word64(0xd5a79147, 0x930aa725),
  25337. new Word64(0x06ca6351, 0xe003826f),
  25338. new Word64(0x14292967, 0x0a0e6e70),
  25339. new Word64(0x27b70a85, 0x46d22ffc),
  25340. new Word64(0x2e1b2138, 0x5c26c926),
  25341. new Word64(0x4d2c6dfc, 0x5ac42aed),
  25342. new Word64(0x53380d13, 0x9d95b3df),
  25343. new Word64(0x650a7354, 0x8baf63de),
  25344. new Word64(0x766a0abb, 0x3c77b2a8),
  25345. new Word64(0x81c2c92e, 0x47edaee6),
  25346. new Word64(0x92722c85, 0x1482353b),
  25347. new Word64(0xa2bfe8a1, 0x4cf10364),
  25348. new Word64(0xa81a664b, 0xbc423001),
  25349. new Word64(0xc24b8b70, 0xd0f89791),
  25350. new Word64(0xc76c51a3, 0x0654be30),
  25351. new Word64(0xd192e819, 0xd6ef5218),
  25352. new Word64(0xd6990624, 0x5565a910),
  25353. new Word64(0xf40e3585, 0x5771202a),
  25354. new Word64(0x106aa070, 0x32bbd1b8),
  25355. new Word64(0x19a4c116, 0xb8d2d0c8),
  25356. new Word64(0x1e376c08, 0x5141ab53),
  25357. new Word64(0x2748774c, 0xdf8eeb99),
  25358. new Word64(0x34b0bcb5, 0xe19b48a8),
  25359. new Word64(0x391c0cb3, 0xc5c95a63),
  25360. new Word64(0x4ed8aa4a, 0xe3418acb),
  25361. new Word64(0x5b9cca4f, 0x7763e373),
  25362. new Word64(0x682e6ff3, 0xd6b2b8a3),
  25363. new Word64(0x748f82ee, 0x5defb2fc),
  25364. new Word64(0x78a5636f, 0x43172f60),
  25365. new Word64(0x84c87814, 0xa1f0ab72),
  25366. new Word64(0x8cc70208, 0x1a6439ec),
  25367. new Word64(0x90befffa, 0x23631e28),
  25368. new Word64(0xa4506ceb, 0xde82bde9),
  25369. new Word64(0xbef9a3f7, 0xb2c67915),
  25370. new Word64(0xc67178f2, 0xe372532b),
  25371. new Word64(0xca273ece, 0xea26619c),
  25372. new Word64(0xd186b8c7, 0x21c0c207),
  25373. new Word64(0xeada7dd6, 0xcde0eb1e),
  25374. new Word64(0xf57d4f7f, 0xee6ed178),
  25375. new Word64(0x06f067aa, 0x72176fba),
  25376. new Word64(0x0a637dc5, 0xa2c898a6),
  25377. new Word64(0x113f9804, 0xbef90dae),
  25378. new Word64(0x1b710b35, 0x131c471b),
  25379. new Word64(0x28db77f5, 0x23047d84),
  25380. new Word64(0x32caab7b, 0x40c72493),
  25381. new Word64(0x3c9ebe0a, 0x15c9bebc),
  25382. new Word64(0x431d67c4, 0x9c100d4c),
  25383. new Word64(0x4cc5d4be, 0xcb3e42b6),
  25384. new Word64(0x597f299c, 0xfc657e2a),
  25385. new Word64(0x5fcb6fab, 0x3ad6faec),
  25386. new Word64(0x6c44198c, 0x4a475817)
  25387. ];
  25388. function hash(data, offset, length, mode384) {
  25389. mode384 = !!mode384;
  25390. var h0, h1, h2, h3, h4, h5, h6, h7;
  25391. if (!mode384) {
  25392. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  25393. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  25394. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  25395. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  25396. h4 = new Word64(0x510e527f, 0xade682d1);
  25397. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  25398. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  25399. h7 = new Word64(0x5be0cd19, 0x137e2179);
  25400. } else {
  25401. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  25402. h1 = new Word64(0x629a292a, 0x367cd507);
  25403. h2 = new Word64(0x9159015a, 0x3070dd17);
  25404. h3 = new Word64(0x152fecd8, 0xf70e5939);
  25405. h4 = new Word64(0x67332667, 0xffc00b31);
  25406. h5 = new Word64(0x8eb44a87, 0x68581511);
  25407. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  25408. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  25409. }
  25410. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  25411. var padded = new Uint8Array(paddedLength);
  25412. var i, j, n;
  25413. for (i = 0; i < length; ++i) {
  25414. padded[i] = data[offset++];
  25415. }
  25416. padded[i++] = 0x80;
  25417. n = paddedLength - 16;
  25418. while (i < n) {
  25419. padded[i++] = 0;
  25420. }
  25421. padded[i++] = 0;
  25422. padded[i++] = 0;
  25423. padded[i++] = 0;
  25424. padded[i++] = 0;
  25425. padded[i++] = 0;
  25426. padded[i++] = 0;
  25427. padded[i++] = 0;
  25428. padded[i++] = 0;
  25429. padded[i++] = 0;
  25430. padded[i++] = 0;
  25431. padded[i++] = 0;
  25432. padded[i++] = length >>> 29 & 0xFF;
  25433. padded[i++] = length >> 21 & 0xFF;
  25434. padded[i++] = length >> 13 & 0xFF;
  25435. padded[i++] = length >> 5 & 0xFF;
  25436. padded[i++] = length << 3 & 0xFF;
  25437. var w = new Array(80);
  25438. for (i = 0; i < 80; i++) {
  25439. w[i] = new Word64(0, 0);
  25440. }
  25441. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  25442. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  25443. var g = new Word64(0, 0), h = new Word64(0, 0);
  25444. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  25445. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  25446. for (i = 0; i < paddedLength;) {
  25447. for (j = 0; j < 16; ++j) {
  25448. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25449. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  25450. i += 8;
  25451. }
  25452. for (j = 16; j < 80; ++j) {
  25453. tmp3 = w[j];
  25454. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  25455. tmp3.add(w[j - 7]);
  25456. littleSigma(tmp1, w[j - 15], tmp2);
  25457. tmp3.add(tmp1);
  25458. tmp3.add(w[j - 16]);
  25459. }
  25460. a.assign(h0);
  25461. b.assign(h1);
  25462. c.assign(h2);
  25463. d.assign(h3);
  25464. e.assign(h4);
  25465. f.assign(h5);
  25466. g.assign(h6);
  25467. h.assign(h7);
  25468. for (j = 0; j < 80; ++j) {
  25469. t1.assign(h);
  25470. sigmaPrime(tmp1, e, tmp2);
  25471. t1.add(tmp1);
  25472. ch(tmp1, e, f, g, tmp2);
  25473. t1.add(tmp1);
  25474. t1.add(k[j]);
  25475. t1.add(w[j]);
  25476. sigma(t2, a, tmp2);
  25477. maj(tmp1, a, b, c, tmp2);
  25478. t2.add(tmp1);
  25479. tmp3 = h;
  25480. h = g;
  25481. g = f;
  25482. f = e;
  25483. d.add(t1);
  25484. e = d;
  25485. d = c;
  25486. c = b;
  25487. b = a;
  25488. tmp3.assign(t1);
  25489. tmp3.add(t2);
  25490. a = tmp3;
  25491. }
  25492. h0.add(a);
  25493. h1.add(b);
  25494. h2.add(c);
  25495. h3.add(d);
  25496. h4.add(e);
  25497. h5.add(f);
  25498. h6.add(g);
  25499. h7.add(h);
  25500. }
  25501. var result;
  25502. if (!mode384) {
  25503. result = new Uint8Array(64);
  25504. h0.copyTo(result, 0);
  25505. h1.copyTo(result, 8);
  25506. h2.copyTo(result, 16);
  25507. h3.copyTo(result, 24);
  25508. h4.copyTo(result, 32);
  25509. h5.copyTo(result, 40);
  25510. h6.copyTo(result, 48);
  25511. h7.copyTo(result, 56);
  25512. } else {
  25513. result = new Uint8Array(48);
  25514. h0.copyTo(result, 0);
  25515. h1.copyTo(result, 8);
  25516. h2.copyTo(result, 16);
  25517. h3.copyTo(result, 24);
  25518. h4.copyTo(result, 32);
  25519. h5.copyTo(result, 40);
  25520. }
  25521. return result;
  25522. }
  25523. return hash;
  25524. }();
  25525. var calculateSHA384 = function calculateSHA384Closure() {
  25526. function hash(data, offset, length) {
  25527. return calculateSHA512(data, offset, length, true);
  25528. }
  25529. return hash;
  25530. }();
  25531. var NullCipher = function NullCipherClosure() {
  25532. function NullCipher() {
  25533. }
  25534. NullCipher.prototype = {
  25535. decryptBlock: function NullCipher_decryptBlock(data) {
  25536. return data;
  25537. }
  25538. };
  25539. return NullCipher;
  25540. }();
  25541. var AES128Cipher = function AES128CipherClosure() {
  25542. var rcon = new Uint8Array([
  25543. 0x8d,
  25544. 0x01,
  25545. 0x02,
  25546. 0x04,
  25547. 0x08,
  25548. 0x10,
  25549. 0x20,
  25550. 0x40,
  25551. 0x80,
  25552. 0x1b,
  25553. 0x36,
  25554. 0x6c,
  25555. 0xd8,
  25556. 0xab,
  25557. 0x4d,
  25558. 0x9a,
  25559. 0x2f,
  25560. 0x5e,
  25561. 0xbc,
  25562. 0x63,
  25563. 0xc6,
  25564. 0x97,
  25565. 0x35,
  25566. 0x6a,
  25567. 0xd4,
  25568. 0xb3,
  25569. 0x7d,
  25570. 0xfa,
  25571. 0xef,
  25572. 0xc5,
  25573. 0x91,
  25574. 0x39,
  25575. 0x72,
  25576. 0xe4,
  25577. 0xd3,
  25578. 0xbd,
  25579. 0x61,
  25580. 0xc2,
  25581. 0x9f,
  25582. 0x25,
  25583. 0x4a,
  25584. 0x94,
  25585. 0x33,
  25586. 0x66,
  25587. 0xcc,
  25588. 0x83,
  25589. 0x1d,
  25590. 0x3a,
  25591. 0x74,
  25592. 0xe8,
  25593. 0xcb,
  25594. 0x8d,
  25595. 0x01,
  25596. 0x02,
  25597. 0x04,
  25598. 0x08,
  25599. 0x10,
  25600. 0x20,
  25601. 0x40,
  25602. 0x80,
  25603. 0x1b,
  25604. 0x36,
  25605. 0x6c,
  25606. 0xd8,
  25607. 0xab,
  25608. 0x4d,
  25609. 0x9a,
  25610. 0x2f,
  25611. 0x5e,
  25612. 0xbc,
  25613. 0x63,
  25614. 0xc6,
  25615. 0x97,
  25616. 0x35,
  25617. 0x6a,
  25618. 0xd4,
  25619. 0xb3,
  25620. 0x7d,
  25621. 0xfa,
  25622. 0xef,
  25623. 0xc5,
  25624. 0x91,
  25625. 0x39,
  25626. 0x72,
  25627. 0xe4,
  25628. 0xd3,
  25629. 0xbd,
  25630. 0x61,
  25631. 0xc2,
  25632. 0x9f,
  25633. 0x25,
  25634. 0x4a,
  25635. 0x94,
  25636. 0x33,
  25637. 0x66,
  25638. 0xcc,
  25639. 0x83,
  25640. 0x1d,
  25641. 0x3a,
  25642. 0x74,
  25643. 0xe8,
  25644. 0xcb,
  25645. 0x8d,
  25646. 0x01,
  25647. 0x02,
  25648. 0x04,
  25649. 0x08,
  25650. 0x10,
  25651. 0x20,
  25652. 0x40,
  25653. 0x80,
  25654. 0x1b,
  25655. 0x36,
  25656. 0x6c,
  25657. 0xd8,
  25658. 0xab,
  25659. 0x4d,
  25660. 0x9a,
  25661. 0x2f,
  25662. 0x5e,
  25663. 0xbc,
  25664. 0x63,
  25665. 0xc6,
  25666. 0x97,
  25667. 0x35,
  25668. 0x6a,
  25669. 0xd4,
  25670. 0xb3,
  25671. 0x7d,
  25672. 0xfa,
  25673. 0xef,
  25674. 0xc5,
  25675. 0x91,
  25676. 0x39,
  25677. 0x72,
  25678. 0xe4,
  25679. 0xd3,
  25680. 0xbd,
  25681. 0x61,
  25682. 0xc2,
  25683. 0x9f,
  25684. 0x25,
  25685. 0x4a,
  25686. 0x94,
  25687. 0x33,
  25688. 0x66,
  25689. 0xcc,
  25690. 0x83,
  25691. 0x1d,
  25692. 0x3a,
  25693. 0x74,
  25694. 0xe8,
  25695. 0xcb,
  25696. 0x8d,
  25697. 0x01,
  25698. 0x02,
  25699. 0x04,
  25700. 0x08,
  25701. 0x10,
  25702. 0x20,
  25703. 0x40,
  25704. 0x80,
  25705. 0x1b,
  25706. 0x36,
  25707. 0x6c,
  25708. 0xd8,
  25709. 0xab,
  25710. 0x4d,
  25711. 0x9a,
  25712. 0x2f,
  25713. 0x5e,
  25714. 0xbc,
  25715. 0x63,
  25716. 0xc6,
  25717. 0x97,
  25718. 0x35,
  25719. 0x6a,
  25720. 0xd4,
  25721. 0xb3,
  25722. 0x7d,
  25723. 0xfa,
  25724. 0xef,
  25725. 0xc5,
  25726. 0x91,
  25727. 0x39,
  25728. 0x72,
  25729. 0xe4,
  25730. 0xd3,
  25731. 0xbd,
  25732. 0x61,
  25733. 0xc2,
  25734. 0x9f,
  25735. 0x25,
  25736. 0x4a,
  25737. 0x94,
  25738. 0x33,
  25739. 0x66,
  25740. 0xcc,
  25741. 0x83,
  25742. 0x1d,
  25743. 0x3a,
  25744. 0x74,
  25745. 0xe8,
  25746. 0xcb,
  25747. 0x8d,
  25748. 0x01,
  25749. 0x02,
  25750. 0x04,
  25751. 0x08,
  25752. 0x10,
  25753. 0x20,
  25754. 0x40,
  25755. 0x80,
  25756. 0x1b,
  25757. 0x36,
  25758. 0x6c,
  25759. 0xd8,
  25760. 0xab,
  25761. 0x4d,
  25762. 0x9a,
  25763. 0x2f,
  25764. 0x5e,
  25765. 0xbc,
  25766. 0x63,
  25767. 0xc6,
  25768. 0x97,
  25769. 0x35,
  25770. 0x6a,
  25771. 0xd4,
  25772. 0xb3,
  25773. 0x7d,
  25774. 0xfa,
  25775. 0xef,
  25776. 0xc5,
  25777. 0x91,
  25778. 0x39,
  25779. 0x72,
  25780. 0xe4,
  25781. 0xd3,
  25782. 0xbd,
  25783. 0x61,
  25784. 0xc2,
  25785. 0x9f,
  25786. 0x25,
  25787. 0x4a,
  25788. 0x94,
  25789. 0x33,
  25790. 0x66,
  25791. 0xcc,
  25792. 0x83,
  25793. 0x1d,
  25794. 0x3a,
  25795. 0x74,
  25796. 0xe8,
  25797. 0xcb,
  25798. 0x8d
  25799. ]);
  25800. var s = new Uint8Array([
  25801. 0x63,
  25802. 0x7c,
  25803. 0x77,
  25804. 0x7b,
  25805. 0xf2,
  25806. 0x6b,
  25807. 0x6f,
  25808. 0xc5,
  25809. 0x30,
  25810. 0x01,
  25811. 0x67,
  25812. 0x2b,
  25813. 0xfe,
  25814. 0xd7,
  25815. 0xab,
  25816. 0x76,
  25817. 0xca,
  25818. 0x82,
  25819. 0xc9,
  25820. 0x7d,
  25821. 0xfa,
  25822. 0x59,
  25823. 0x47,
  25824. 0xf0,
  25825. 0xad,
  25826. 0xd4,
  25827. 0xa2,
  25828. 0xaf,
  25829. 0x9c,
  25830. 0xa4,
  25831. 0x72,
  25832. 0xc0,
  25833. 0xb7,
  25834. 0xfd,
  25835. 0x93,
  25836. 0x26,
  25837. 0x36,
  25838. 0x3f,
  25839. 0xf7,
  25840. 0xcc,
  25841. 0x34,
  25842. 0xa5,
  25843. 0xe5,
  25844. 0xf1,
  25845. 0x71,
  25846. 0xd8,
  25847. 0x31,
  25848. 0x15,
  25849. 0x04,
  25850. 0xc7,
  25851. 0x23,
  25852. 0xc3,
  25853. 0x18,
  25854. 0x96,
  25855. 0x05,
  25856. 0x9a,
  25857. 0x07,
  25858. 0x12,
  25859. 0x80,
  25860. 0xe2,
  25861. 0xeb,
  25862. 0x27,
  25863. 0xb2,
  25864. 0x75,
  25865. 0x09,
  25866. 0x83,
  25867. 0x2c,
  25868. 0x1a,
  25869. 0x1b,
  25870. 0x6e,
  25871. 0x5a,
  25872. 0xa0,
  25873. 0x52,
  25874. 0x3b,
  25875. 0xd6,
  25876. 0xb3,
  25877. 0x29,
  25878. 0xe3,
  25879. 0x2f,
  25880. 0x84,
  25881. 0x53,
  25882. 0xd1,
  25883. 0x00,
  25884. 0xed,
  25885. 0x20,
  25886. 0xfc,
  25887. 0xb1,
  25888. 0x5b,
  25889. 0x6a,
  25890. 0xcb,
  25891. 0xbe,
  25892. 0x39,
  25893. 0x4a,
  25894. 0x4c,
  25895. 0x58,
  25896. 0xcf,
  25897. 0xd0,
  25898. 0xef,
  25899. 0xaa,
  25900. 0xfb,
  25901. 0x43,
  25902. 0x4d,
  25903. 0x33,
  25904. 0x85,
  25905. 0x45,
  25906. 0xf9,
  25907. 0x02,
  25908. 0x7f,
  25909. 0x50,
  25910. 0x3c,
  25911. 0x9f,
  25912. 0xa8,
  25913. 0x51,
  25914. 0xa3,
  25915. 0x40,
  25916. 0x8f,
  25917. 0x92,
  25918. 0x9d,
  25919. 0x38,
  25920. 0xf5,
  25921. 0xbc,
  25922. 0xb6,
  25923. 0xda,
  25924. 0x21,
  25925. 0x10,
  25926. 0xff,
  25927. 0xf3,
  25928. 0xd2,
  25929. 0xcd,
  25930. 0x0c,
  25931. 0x13,
  25932. 0xec,
  25933. 0x5f,
  25934. 0x97,
  25935. 0x44,
  25936. 0x17,
  25937. 0xc4,
  25938. 0xa7,
  25939. 0x7e,
  25940. 0x3d,
  25941. 0x64,
  25942. 0x5d,
  25943. 0x19,
  25944. 0x73,
  25945. 0x60,
  25946. 0x81,
  25947. 0x4f,
  25948. 0xdc,
  25949. 0x22,
  25950. 0x2a,
  25951. 0x90,
  25952. 0x88,
  25953. 0x46,
  25954. 0xee,
  25955. 0xb8,
  25956. 0x14,
  25957. 0xde,
  25958. 0x5e,
  25959. 0x0b,
  25960. 0xdb,
  25961. 0xe0,
  25962. 0x32,
  25963. 0x3a,
  25964. 0x0a,
  25965. 0x49,
  25966. 0x06,
  25967. 0x24,
  25968. 0x5c,
  25969. 0xc2,
  25970. 0xd3,
  25971. 0xac,
  25972. 0x62,
  25973. 0x91,
  25974. 0x95,
  25975. 0xe4,
  25976. 0x79,
  25977. 0xe7,
  25978. 0xc8,
  25979. 0x37,
  25980. 0x6d,
  25981. 0x8d,
  25982. 0xd5,
  25983. 0x4e,
  25984. 0xa9,
  25985. 0x6c,
  25986. 0x56,
  25987. 0xf4,
  25988. 0xea,
  25989. 0x65,
  25990. 0x7a,
  25991. 0xae,
  25992. 0x08,
  25993. 0xba,
  25994. 0x78,
  25995. 0x25,
  25996. 0x2e,
  25997. 0x1c,
  25998. 0xa6,
  25999. 0xb4,
  26000. 0xc6,
  26001. 0xe8,
  26002. 0xdd,
  26003. 0x74,
  26004. 0x1f,
  26005. 0x4b,
  26006. 0xbd,
  26007. 0x8b,
  26008. 0x8a,
  26009. 0x70,
  26010. 0x3e,
  26011. 0xb5,
  26012. 0x66,
  26013. 0x48,
  26014. 0x03,
  26015. 0xf6,
  26016. 0x0e,
  26017. 0x61,
  26018. 0x35,
  26019. 0x57,
  26020. 0xb9,
  26021. 0x86,
  26022. 0xc1,
  26023. 0x1d,
  26024. 0x9e,
  26025. 0xe1,
  26026. 0xf8,
  26027. 0x98,
  26028. 0x11,
  26029. 0x69,
  26030. 0xd9,
  26031. 0x8e,
  26032. 0x94,
  26033. 0x9b,
  26034. 0x1e,
  26035. 0x87,
  26036. 0xe9,
  26037. 0xce,
  26038. 0x55,
  26039. 0x28,
  26040. 0xdf,
  26041. 0x8c,
  26042. 0xa1,
  26043. 0x89,
  26044. 0x0d,
  26045. 0xbf,
  26046. 0xe6,
  26047. 0x42,
  26048. 0x68,
  26049. 0x41,
  26050. 0x99,
  26051. 0x2d,
  26052. 0x0f,
  26053. 0xb0,
  26054. 0x54,
  26055. 0xbb,
  26056. 0x16
  26057. ]);
  26058. var inv_s = new Uint8Array([
  26059. 0x52,
  26060. 0x09,
  26061. 0x6a,
  26062. 0xd5,
  26063. 0x30,
  26064. 0x36,
  26065. 0xa5,
  26066. 0x38,
  26067. 0xbf,
  26068. 0x40,
  26069. 0xa3,
  26070. 0x9e,
  26071. 0x81,
  26072. 0xf3,
  26073. 0xd7,
  26074. 0xfb,
  26075. 0x7c,
  26076. 0xe3,
  26077. 0x39,
  26078. 0x82,
  26079. 0x9b,
  26080. 0x2f,
  26081. 0xff,
  26082. 0x87,
  26083. 0x34,
  26084. 0x8e,
  26085. 0x43,
  26086. 0x44,
  26087. 0xc4,
  26088. 0xde,
  26089. 0xe9,
  26090. 0xcb,
  26091. 0x54,
  26092. 0x7b,
  26093. 0x94,
  26094. 0x32,
  26095. 0xa6,
  26096. 0xc2,
  26097. 0x23,
  26098. 0x3d,
  26099. 0xee,
  26100. 0x4c,
  26101. 0x95,
  26102. 0x0b,
  26103. 0x42,
  26104. 0xfa,
  26105. 0xc3,
  26106. 0x4e,
  26107. 0x08,
  26108. 0x2e,
  26109. 0xa1,
  26110. 0x66,
  26111. 0x28,
  26112. 0xd9,
  26113. 0x24,
  26114. 0xb2,
  26115. 0x76,
  26116. 0x5b,
  26117. 0xa2,
  26118. 0x49,
  26119. 0x6d,
  26120. 0x8b,
  26121. 0xd1,
  26122. 0x25,
  26123. 0x72,
  26124. 0xf8,
  26125. 0xf6,
  26126. 0x64,
  26127. 0x86,
  26128. 0x68,
  26129. 0x98,
  26130. 0x16,
  26131. 0xd4,
  26132. 0xa4,
  26133. 0x5c,
  26134. 0xcc,
  26135. 0x5d,
  26136. 0x65,
  26137. 0xb6,
  26138. 0x92,
  26139. 0x6c,
  26140. 0x70,
  26141. 0x48,
  26142. 0x50,
  26143. 0xfd,
  26144. 0xed,
  26145. 0xb9,
  26146. 0xda,
  26147. 0x5e,
  26148. 0x15,
  26149. 0x46,
  26150. 0x57,
  26151. 0xa7,
  26152. 0x8d,
  26153. 0x9d,
  26154. 0x84,
  26155. 0x90,
  26156. 0xd8,
  26157. 0xab,
  26158. 0x00,
  26159. 0x8c,
  26160. 0xbc,
  26161. 0xd3,
  26162. 0x0a,
  26163. 0xf7,
  26164. 0xe4,
  26165. 0x58,
  26166. 0x05,
  26167. 0xb8,
  26168. 0xb3,
  26169. 0x45,
  26170. 0x06,
  26171. 0xd0,
  26172. 0x2c,
  26173. 0x1e,
  26174. 0x8f,
  26175. 0xca,
  26176. 0x3f,
  26177. 0x0f,
  26178. 0x02,
  26179. 0xc1,
  26180. 0xaf,
  26181. 0xbd,
  26182. 0x03,
  26183. 0x01,
  26184. 0x13,
  26185. 0x8a,
  26186. 0x6b,
  26187. 0x3a,
  26188. 0x91,
  26189. 0x11,
  26190. 0x41,
  26191. 0x4f,
  26192. 0x67,
  26193. 0xdc,
  26194. 0xea,
  26195. 0x97,
  26196. 0xf2,
  26197. 0xcf,
  26198. 0xce,
  26199. 0xf0,
  26200. 0xb4,
  26201. 0xe6,
  26202. 0x73,
  26203. 0x96,
  26204. 0xac,
  26205. 0x74,
  26206. 0x22,
  26207. 0xe7,
  26208. 0xad,
  26209. 0x35,
  26210. 0x85,
  26211. 0xe2,
  26212. 0xf9,
  26213. 0x37,
  26214. 0xe8,
  26215. 0x1c,
  26216. 0x75,
  26217. 0xdf,
  26218. 0x6e,
  26219. 0x47,
  26220. 0xf1,
  26221. 0x1a,
  26222. 0x71,
  26223. 0x1d,
  26224. 0x29,
  26225. 0xc5,
  26226. 0x89,
  26227. 0x6f,
  26228. 0xb7,
  26229. 0x62,
  26230. 0x0e,
  26231. 0xaa,
  26232. 0x18,
  26233. 0xbe,
  26234. 0x1b,
  26235. 0xfc,
  26236. 0x56,
  26237. 0x3e,
  26238. 0x4b,
  26239. 0xc6,
  26240. 0xd2,
  26241. 0x79,
  26242. 0x20,
  26243. 0x9a,
  26244. 0xdb,
  26245. 0xc0,
  26246. 0xfe,
  26247. 0x78,
  26248. 0xcd,
  26249. 0x5a,
  26250. 0xf4,
  26251. 0x1f,
  26252. 0xdd,
  26253. 0xa8,
  26254. 0x33,
  26255. 0x88,
  26256. 0x07,
  26257. 0xc7,
  26258. 0x31,
  26259. 0xb1,
  26260. 0x12,
  26261. 0x10,
  26262. 0x59,
  26263. 0x27,
  26264. 0x80,
  26265. 0xec,
  26266. 0x5f,
  26267. 0x60,
  26268. 0x51,
  26269. 0x7f,
  26270. 0xa9,
  26271. 0x19,
  26272. 0xb5,
  26273. 0x4a,
  26274. 0x0d,
  26275. 0x2d,
  26276. 0xe5,
  26277. 0x7a,
  26278. 0x9f,
  26279. 0x93,
  26280. 0xc9,
  26281. 0x9c,
  26282. 0xef,
  26283. 0xa0,
  26284. 0xe0,
  26285. 0x3b,
  26286. 0x4d,
  26287. 0xae,
  26288. 0x2a,
  26289. 0xf5,
  26290. 0xb0,
  26291. 0xc8,
  26292. 0xeb,
  26293. 0xbb,
  26294. 0x3c,
  26295. 0x83,
  26296. 0x53,
  26297. 0x99,
  26298. 0x61,
  26299. 0x17,
  26300. 0x2b,
  26301. 0x04,
  26302. 0x7e,
  26303. 0xba,
  26304. 0x77,
  26305. 0xd6,
  26306. 0x26,
  26307. 0xe1,
  26308. 0x69,
  26309. 0x14,
  26310. 0x63,
  26311. 0x55,
  26312. 0x21,
  26313. 0x0c,
  26314. 0x7d
  26315. ]);
  26316. var mixCol = new Uint8Array(256);
  26317. for (var i = 0; i < 256; i++) {
  26318. if (i < 128) {
  26319. mixCol[i] = i << 1;
  26320. } else {
  26321. mixCol[i] = i << 1 ^ 0x1b;
  26322. }
  26323. }
  26324. var mix = new Uint32Array([
  26325. 0x00000000,
  26326. 0x0e090d0b,
  26327. 0x1c121a16,
  26328. 0x121b171d,
  26329. 0x3824342c,
  26330. 0x362d3927,
  26331. 0x24362e3a,
  26332. 0x2a3f2331,
  26333. 0x70486858,
  26334. 0x7e416553,
  26335. 0x6c5a724e,
  26336. 0x62537f45,
  26337. 0x486c5c74,
  26338. 0x4665517f,
  26339. 0x547e4662,
  26340. 0x5a774b69,
  26341. 0xe090d0b0,
  26342. 0xee99ddbb,
  26343. 0xfc82caa6,
  26344. 0xf28bc7ad,
  26345. 0xd8b4e49c,
  26346. 0xd6bde997,
  26347. 0xc4a6fe8a,
  26348. 0xcaaff381,
  26349. 0x90d8b8e8,
  26350. 0x9ed1b5e3,
  26351. 0x8ccaa2fe,
  26352. 0x82c3aff5,
  26353. 0xa8fc8cc4,
  26354. 0xa6f581cf,
  26355. 0xb4ee96d2,
  26356. 0xbae79bd9,
  26357. 0xdb3bbb7b,
  26358. 0xd532b670,
  26359. 0xc729a16d,
  26360. 0xc920ac66,
  26361. 0xe31f8f57,
  26362. 0xed16825c,
  26363. 0xff0d9541,
  26364. 0xf104984a,
  26365. 0xab73d323,
  26366. 0xa57ade28,
  26367. 0xb761c935,
  26368. 0xb968c43e,
  26369. 0x9357e70f,
  26370. 0x9d5eea04,
  26371. 0x8f45fd19,
  26372. 0x814cf012,
  26373. 0x3bab6bcb,
  26374. 0x35a266c0,
  26375. 0x27b971dd,
  26376. 0x29b07cd6,
  26377. 0x038f5fe7,
  26378. 0x0d8652ec,
  26379. 0x1f9d45f1,
  26380. 0x119448fa,
  26381. 0x4be30393,
  26382. 0x45ea0e98,
  26383. 0x57f11985,
  26384. 0x59f8148e,
  26385. 0x73c737bf,
  26386. 0x7dce3ab4,
  26387. 0x6fd52da9,
  26388. 0x61dc20a2,
  26389. 0xad766df6,
  26390. 0xa37f60fd,
  26391. 0xb16477e0,
  26392. 0xbf6d7aeb,
  26393. 0x955259da,
  26394. 0x9b5b54d1,
  26395. 0x894043cc,
  26396. 0x87494ec7,
  26397. 0xdd3e05ae,
  26398. 0xd33708a5,
  26399. 0xc12c1fb8,
  26400. 0xcf2512b3,
  26401. 0xe51a3182,
  26402. 0xeb133c89,
  26403. 0xf9082b94,
  26404. 0xf701269f,
  26405. 0x4de6bd46,
  26406. 0x43efb04d,
  26407. 0x51f4a750,
  26408. 0x5ffdaa5b,
  26409. 0x75c2896a,
  26410. 0x7bcb8461,
  26411. 0x69d0937c,
  26412. 0x67d99e77,
  26413. 0x3daed51e,
  26414. 0x33a7d815,
  26415. 0x21bccf08,
  26416. 0x2fb5c203,
  26417. 0x058ae132,
  26418. 0x0b83ec39,
  26419. 0x1998fb24,
  26420. 0x1791f62f,
  26421. 0x764dd68d,
  26422. 0x7844db86,
  26423. 0x6a5fcc9b,
  26424. 0x6456c190,
  26425. 0x4e69e2a1,
  26426. 0x4060efaa,
  26427. 0x527bf8b7,
  26428. 0x5c72f5bc,
  26429. 0x0605bed5,
  26430. 0x080cb3de,
  26431. 0x1a17a4c3,
  26432. 0x141ea9c8,
  26433. 0x3e218af9,
  26434. 0x302887f2,
  26435. 0x223390ef,
  26436. 0x2c3a9de4,
  26437. 0x96dd063d,
  26438. 0x98d40b36,
  26439. 0x8acf1c2b,
  26440. 0x84c61120,
  26441. 0xaef93211,
  26442. 0xa0f03f1a,
  26443. 0xb2eb2807,
  26444. 0xbce2250c,
  26445. 0xe6956e65,
  26446. 0xe89c636e,
  26447. 0xfa877473,
  26448. 0xf48e7978,
  26449. 0xdeb15a49,
  26450. 0xd0b85742,
  26451. 0xc2a3405f,
  26452. 0xccaa4d54,
  26453. 0x41ecdaf7,
  26454. 0x4fe5d7fc,
  26455. 0x5dfec0e1,
  26456. 0x53f7cdea,
  26457. 0x79c8eedb,
  26458. 0x77c1e3d0,
  26459. 0x65daf4cd,
  26460. 0x6bd3f9c6,
  26461. 0x31a4b2af,
  26462. 0x3fadbfa4,
  26463. 0x2db6a8b9,
  26464. 0x23bfa5b2,
  26465. 0x09808683,
  26466. 0x07898b88,
  26467. 0x15929c95,
  26468. 0x1b9b919e,
  26469. 0xa17c0a47,
  26470. 0xaf75074c,
  26471. 0xbd6e1051,
  26472. 0xb3671d5a,
  26473. 0x99583e6b,
  26474. 0x97513360,
  26475. 0x854a247d,
  26476. 0x8b432976,
  26477. 0xd134621f,
  26478. 0xdf3d6f14,
  26479. 0xcd267809,
  26480. 0xc32f7502,
  26481. 0xe9105633,
  26482. 0xe7195b38,
  26483. 0xf5024c25,
  26484. 0xfb0b412e,
  26485. 0x9ad7618c,
  26486. 0x94de6c87,
  26487. 0x86c57b9a,
  26488. 0x88cc7691,
  26489. 0xa2f355a0,
  26490. 0xacfa58ab,
  26491. 0xbee14fb6,
  26492. 0xb0e842bd,
  26493. 0xea9f09d4,
  26494. 0xe49604df,
  26495. 0xf68d13c2,
  26496. 0xf8841ec9,
  26497. 0xd2bb3df8,
  26498. 0xdcb230f3,
  26499. 0xcea927ee,
  26500. 0xc0a02ae5,
  26501. 0x7a47b13c,
  26502. 0x744ebc37,
  26503. 0x6655ab2a,
  26504. 0x685ca621,
  26505. 0x42638510,
  26506. 0x4c6a881b,
  26507. 0x5e719f06,
  26508. 0x5078920d,
  26509. 0x0a0fd964,
  26510. 0x0406d46f,
  26511. 0x161dc372,
  26512. 0x1814ce79,
  26513. 0x322bed48,
  26514. 0x3c22e043,
  26515. 0x2e39f75e,
  26516. 0x2030fa55,
  26517. 0xec9ab701,
  26518. 0xe293ba0a,
  26519. 0xf088ad17,
  26520. 0xfe81a01c,
  26521. 0xd4be832d,
  26522. 0xdab78e26,
  26523. 0xc8ac993b,
  26524. 0xc6a59430,
  26525. 0x9cd2df59,
  26526. 0x92dbd252,
  26527. 0x80c0c54f,
  26528. 0x8ec9c844,
  26529. 0xa4f6eb75,
  26530. 0xaaffe67e,
  26531. 0xb8e4f163,
  26532. 0xb6edfc68,
  26533. 0x0c0a67b1,
  26534. 0x02036aba,
  26535. 0x10187da7,
  26536. 0x1e1170ac,
  26537. 0x342e539d,
  26538. 0x3a275e96,
  26539. 0x283c498b,
  26540. 0x26354480,
  26541. 0x7c420fe9,
  26542. 0x724b02e2,
  26543. 0x605015ff,
  26544. 0x6e5918f4,
  26545. 0x44663bc5,
  26546. 0x4a6f36ce,
  26547. 0x587421d3,
  26548. 0x567d2cd8,
  26549. 0x37a10c7a,
  26550. 0x39a80171,
  26551. 0x2bb3166c,
  26552. 0x25ba1b67,
  26553. 0x0f853856,
  26554. 0x018c355d,
  26555. 0x13972240,
  26556. 0x1d9e2f4b,
  26557. 0x47e96422,
  26558. 0x49e06929,
  26559. 0x5bfb7e34,
  26560. 0x55f2733f,
  26561. 0x7fcd500e,
  26562. 0x71c45d05,
  26563. 0x63df4a18,
  26564. 0x6dd64713,
  26565. 0xd731dcca,
  26566. 0xd938d1c1,
  26567. 0xcb23c6dc,
  26568. 0xc52acbd7,
  26569. 0xef15e8e6,
  26570. 0xe11ce5ed,
  26571. 0xf307f2f0,
  26572. 0xfd0efffb,
  26573. 0xa779b492,
  26574. 0xa970b999,
  26575. 0xbb6bae84,
  26576. 0xb562a38f,
  26577. 0x9f5d80be,
  26578. 0x91548db5,
  26579. 0x834f9aa8,
  26580. 0x8d4697a3
  26581. ]);
  26582. function expandKey128(cipherKey) {
  26583. var b = 176, result = new Uint8Array(b);
  26584. result.set(cipherKey);
  26585. for (var j = 16, i = 1; j < b; ++i) {
  26586. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  26587. t1 = s[t1];
  26588. t2 = s[t2];
  26589. t3 = s[t3];
  26590. t4 = s[t4];
  26591. t1 = t1 ^ rcon[i];
  26592. for (var n = 0; n < 4; ++n) {
  26593. result[j] = t1 ^= result[j - 16];
  26594. j++;
  26595. result[j] = t2 ^= result[j - 16];
  26596. j++;
  26597. result[j] = t3 ^= result[j - 16];
  26598. j++;
  26599. result[j] = t4 ^= result[j - 16];
  26600. j++;
  26601. }
  26602. }
  26603. return result;
  26604. }
  26605. function decrypt128(input, key) {
  26606. var state = new Uint8Array(16);
  26607. state.set(input);
  26608. var i, j, k;
  26609. var t, u, v;
  26610. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26611. state[j] ^= key[k];
  26612. }
  26613. for (i = 9; i >= 1; --i) {
  26614. t = state[13];
  26615. state[13] = state[9];
  26616. state[9] = state[5];
  26617. state[5] = state[1];
  26618. state[1] = t;
  26619. t = state[14];
  26620. u = state[10];
  26621. state[14] = state[6];
  26622. state[10] = state[2];
  26623. state[6] = t;
  26624. state[2] = u;
  26625. t = state[15];
  26626. u = state[11];
  26627. v = state[7];
  26628. state[15] = state[3];
  26629. state[11] = t;
  26630. state[7] = u;
  26631. state[3] = v;
  26632. for (j = 0; j < 16; ++j) {
  26633. state[j] = inv_s[state[j]];
  26634. }
  26635. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26636. state[j] ^= key[k];
  26637. }
  26638. for (j = 0; j < 16; j += 4) {
  26639. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  26640. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  26641. state[j] = t >>> 24 & 0xFF;
  26642. state[j + 1] = t >> 16 & 0xFF;
  26643. state[j + 2] = t >> 8 & 0xFF;
  26644. state[j + 3] = t & 0xFF;
  26645. }
  26646. }
  26647. t = state[13];
  26648. state[13] = state[9];
  26649. state[9] = state[5];
  26650. state[5] = state[1];
  26651. state[1] = t;
  26652. t = state[14];
  26653. u = state[10];
  26654. state[14] = state[6];
  26655. state[10] = state[2];
  26656. state[6] = t;
  26657. state[2] = u;
  26658. t = state[15];
  26659. u = state[11];
  26660. v = state[7];
  26661. state[15] = state[3];
  26662. state[11] = t;
  26663. state[7] = u;
  26664. state[3] = v;
  26665. for (j = 0; j < 16; ++j) {
  26666. state[j] = inv_s[state[j]];
  26667. state[j] ^= key[j];
  26668. }
  26669. return state;
  26670. }
  26671. function encrypt128(input, key) {
  26672. var t, u, v, k;
  26673. var state = new Uint8Array(16);
  26674. state.set(input);
  26675. for (j = 0; j < 16; ++j) {
  26676. state[j] ^= key[j];
  26677. }
  26678. for (i = 1; i < 10; i++) {
  26679. for (j = 0; j < 16; ++j) {
  26680. state[j] = s[state[j]];
  26681. }
  26682. v = state[1];
  26683. state[1] = state[5];
  26684. state[5] = state[9];
  26685. state[9] = state[13];
  26686. state[13] = v;
  26687. v = state[2];
  26688. u = state[6];
  26689. state[2] = state[10];
  26690. state[6] = state[14];
  26691. state[10] = v;
  26692. state[14] = u;
  26693. v = state[3];
  26694. u = state[7];
  26695. t = state[11];
  26696. state[3] = state[15];
  26697. state[7] = v;
  26698. state[11] = u;
  26699. state[15] = t;
  26700. for (var j = 0; j < 16; j += 4) {
  26701. var s0 = state[j + 0], s1 = state[j + 1];
  26702. var s2 = state[j + 2], s3 = state[j + 3];
  26703. t = s0 ^ s1 ^ s2 ^ s3;
  26704. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  26705. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  26706. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  26707. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  26708. }
  26709. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26710. state[j] ^= key[k];
  26711. }
  26712. }
  26713. for (j = 0; j < 16; ++j) {
  26714. state[j] = s[state[j]];
  26715. }
  26716. v = state[1];
  26717. state[1] = state[5];
  26718. state[5] = state[9];
  26719. state[9] = state[13];
  26720. state[13] = v;
  26721. v = state[2];
  26722. u = state[6];
  26723. state[2] = state[10];
  26724. state[6] = state[14];
  26725. state[10] = v;
  26726. state[14] = u;
  26727. v = state[3];
  26728. u = state[7];
  26729. t = state[11];
  26730. state[3] = state[15];
  26731. state[7] = v;
  26732. state[11] = u;
  26733. state[15] = t;
  26734. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26735. state[j] ^= key[k];
  26736. }
  26737. return state;
  26738. }
  26739. function AES128Cipher(key) {
  26740. this.key = expandKey128(key);
  26741. this.buffer = new Uint8Array(16);
  26742. this.bufferPosition = 0;
  26743. }
  26744. function decryptBlock2(data, finalize) {
  26745. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  26746. for (i = 0; i < sourceLength; ++i) {
  26747. buffer[bufferLength] = data[i];
  26748. ++bufferLength;
  26749. if (bufferLength < 16) {
  26750. continue;
  26751. }
  26752. var plain = decrypt128(buffer, this.key);
  26753. for (j = 0; j < 16; ++j) {
  26754. plain[j] ^= iv[j];
  26755. }
  26756. iv = buffer;
  26757. result.push(plain);
  26758. buffer = new Uint8Array(16);
  26759. bufferLength = 0;
  26760. }
  26761. this.buffer = buffer;
  26762. this.bufferLength = bufferLength;
  26763. this.iv = iv;
  26764. if (result.length === 0) {
  26765. return new Uint8Array([]);
  26766. }
  26767. var outputLength = 16 * result.length;
  26768. if (finalize) {
  26769. var lastBlock = result[result.length - 1];
  26770. var psLen = lastBlock[15];
  26771. if (psLen <= 16) {
  26772. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  26773. if (lastBlock[i] !== psLen) {
  26774. psLen = 0;
  26775. break;
  26776. }
  26777. }
  26778. outputLength -= psLen;
  26779. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  26780. }
  26781. }
  26782. var output = new Uint8Array(outputLength);
  26783. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26784. output.set(result[i], j);
  26785. }
  26786. return output;
  26787. }
  26788. AES128Cipher.prototype = {
  26789. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  26790. var i, sourceLength = data.length;
  26791. var buffer = this.buffer, bufferLength = this.bufferPosition;
  26792. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  26793. buffer[bufferLength] = data[i];
  26794. }
  26795. if (bufferLength < 16) {
  26796. this.bufferLength = bufferLength;
  26797. return new Uint8Array([]);
  26798. }
  26799. this.iv = buffer;
  26800. this.buffer = new Uint8Array(16);
  26801. this.bufferLength = 0;
  26802. this.decryptBlock = decryptBlock2;
  26803. return this.decryptBlock(data.subarray(16), finalize);
  26804. },
  26805. encrypt: function AES128Cipher_encrypt(data, iv) {
  26806. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  26807. if (!iv) {
  26808. iv = new Uint8Array(16);
  26809. }
  26810. for (i = 0; i < sourceLength; ++i) {
  26811. buffer[bufferLength] = data[i];
  26812. ++bufferLength;
  26813. if (bufferLength < 16) {
  26814. continue;
  26815. }
  26816. for (j = 0; j < 16; ++j) {
  26817. buffer[j] ^= iv[j];
  26818. }
  26819. var cipher = encrypt128(buffer, this.key);
  26820. iv = cipher;
  26821. result.push(cipher);
  26822. buffer = new Uint8Array(16);
  26823. bufferLength = 0;
  26824. }
  26825. this.buffer = buffer;
  26826. this.bufferLength = bufferLength;
  26827. this.iv = iv;
  26828. if (result.length === 0) {
  26829. return new Uint8Array([]);
  26830. }
  26831. var outputLength = 16 * result.length;
  26832. var output = new Uint8Array(outputLength);
  26833. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26834. output.set(result[i], j);
  26835. }
  26836. return output;
  26837. }
  26838. };
  26839. return AES128Cipher;
  26840. }();
  26841. var AES256Cipher = function AES256CipherClosure() {
  26842. var s = new Uint8Array([
  26843. 0x63,
  26844. 0x7c,
  26845. 0x77,
  26846. 0x7b,
  26847. 0xf2,
  26848. 0x6b,
  26849. 0x6f,
  26850. 0xc5,
  26851. 0x30,
  26852. 0x01,
  26853. 0x67,
  26854. 0x2b,
  26855. 0xfe,
  26856. 0xd7,
  26857. 0xab,
  26858. 0x76,
  26859. 0xca,
  26860. 0x82,
  26861. 0xc9,
  26862. 0x7d,
  26863. 0xfa,
  26864. 0x59,
  26865. 0x47,
  26866. 0xf0,
  26867. 0xad,
  26868. 0xd4,
  26869. 0xa2,
  26870. 0xaf,
  26871. 0x9c,
  26872. 0xa4,
  26873. 0x72,
  26874. 0xc0,
  26875. 0xb7,
  26876. 0xfd,
  26877. 0x93,
  26878. 0x26,
  26879. 0x36,
  26880. 0x3f,
  26881. 0xf7,
  26882. 0xcc,
  26883. 0x34,
  26884. 0xa5,
  26885. 0xe5,
  26886. 0xf1,
  26887. 0x71,
  26888. 0xd8,
  26889. 0x31,
  26890. 0x15,
  26891. 0x04,
  26892. 0xc7,
  26893. 0x23,
  26894. 0xc3,
  26895. 0x18,
  26896. 0x96,
  26897. 0x05,
  26898. 0x9a,
  26899. 0x07,
  26900. 0x12,
  26901. 0x80,
  26902. 0xe2,
  26903. 0xeb,
  26904. 0x27,
  26905. 0xb2,
  26906. 0x75,
  26907. 0x09,
  26908. 0x83,
  26909. 0x2c,
  26910. 0x1a,
  26911. 0x1b,
  26912. 0x6e,
  26913. 0x5a,
  26914. 0xa0,
  26915. 0x52,
  26916. 0x3b,
  26917. 0xd6,
  26918. 0xb3,
  26919. 0x29,
  26920. 0xe3,
  26921. 0x2f,
  26922. 0x84,
  26923. 0x53,
  26924. 0xd1,
  26925. 0x00,
  26926. 0xed,
  26927. 0x20,
  26928. 0xfc,
  26929. 0xb1,
  26930. 0x5b,
  26931. 0x6a,
  26932. 0xcb,
  26933. 0xbe,
  26934. 0x39,
  26935. 0x4a,
  26936. 0x4c,
  26937. 0x58,
  26938. 0xcf,
  26939. 0xd0,
  26940. 0xef,
  26941. 0xaa,
  26942. 0xfb,
  26943. 0x43,
  26944. 0x4d,
  26945. 0x33,
  26946. 0x85,
  26947. 0x45,
  26948. 0xf9,
  26949. 0x02,
  26950. 0x7f,
  26951. 0x50,
  26952. 0x3c,
  26953. 0x9f,
  26954. 0xa8,
  26955. 0x51,
  26956. 0xa3,
  26957. 0x40,
  26958. 0x8f,
  26959. 0x92,
  26960. 0x9d,
  26961. 0x38,
  26962. 0xf5,
  26963. 0xbc,
  26964. 0xb6,
  26965. 0xda,
  26966. 0x21,
  26967. 0x10,
  26968. 0xff,
  26969. 0xf3,
  26970. 0xd2,
  26971. 0xcd,
  26972. 0x0c,
  26973. 0x13,
  26974. 0xec,
  26975. 0x5f,
  26976. 0x97,
  26977. 0x44,
  26978. 0x17,
  26979. 0xc4,
  26980. 0xa7,
  26981. 0x7e,
  26982. 0x3d,
  26983. 0x64,
  26984. 0x5d,
  26985. 0x19,
  26986. 0x73,
  26987. 0x60,
  26988. 0x81,
  26989. 0x4f,
  26990. 0xdc,
  26991. 0x22,
  26992. 0x2a,
  26993. 0x90,
  26994. 0x88,
  26995. 0x46,
  26996. 0xee,
  26997. 0xb8,
  26998. 0x14,
  26999. 0xde,
  27000. 0x5e,
  27001. 0x0b,
  27002. 0xdb,
  27003. 0xe0,
  27004. 0x32,
  27005. 0x3a,
  27006. 0x0a,
  27007. 0x49,
  27008. 0x06,
  27009. 0x24,
  27010. 0x5c,
  27011. 0xc2,
  27012. 0xd3,
  27013. 0xac,
  27014. 0x62,
  27015. 0x91,
  27016. 0x95,
  27017. 0xe4,
  27018. 0x79,
  27019. 0xe7,
  27020. 0xc8,
  27021. 0x37,
  27022. 0x6d,
  27023. 0x8d,
  27024. 0xd5,
  27025. 0x4e,
  27026. 0xa9,
  27027. 0x6c,
  27028. 0x56,
  27029. 0xf4,
  27030. 0xea,
  27031. 0x65,
  27032. 0x7a,
  27033. 0xae,
  27034. 0x08,
  27035. 0xba,
  27036. 0x78,
  27037. 0x25,
  27038. 0x2e,
  27039. 0x1c,
  27040. 0xa6,
  27041. 0xb4,
  27042. 0xc6,
  27043. 0xe8,
  27044. 0xdd,
  27045. 0x74,
  27046. 0x1f,
  27047. 0x4b,
  27048. 0xbd,
  27049. 0x8b,
  27050. 0x8a,
  27051. 0x70,
  27052. 0x3e,
  27053. 0xb5,
  27054. 0x66,
  27055. 0x48,
  27056. 0x03,
  27057. 0xf6,
  27058. 0x0e,
  27059. 0x61,
  27060. 0x35,
  27061. 0x57,
  27062. 0xb9,
  27063. 0x86,
  27064. 0xc1,
  27065. 0x1d,
  27066. 0x9e,
  27067. 0xe1,
  27068. 0xf8,
  27069. 0x98,
  27070. 0x11,
  27071. 0x69,
  27072. 0xd9,
  27073. 0x8e,
  27074. 0x94,
  27075. 0x9b,
  27076. 0x1e,
  27077. 0x87,
  27078. 0xe9,
  27079. 0xce,
  27080. 0x55,
  27081. 0x28,
  27082. 0xdf,
  27083. 0x8c,
  27084. 0xa1,
  27085. 0x89,
  27086. 0x0d,
  27087. 0xbf,
  27088. 0xe6,
  27089. 0x42,
  27090. 0x68,
  27091. 0x41,
  27092. 0x99,
  27093. 0x2d,
  27094. 0x0f,
  27095. 0xb0,
  27096. 0x54,
  27097. 0xbb,
  27098. 0x16
  27099. ]);
  27100. var inv_s = new Uint8Array([
  27101. 0x52,
  27102. 0x09,
  27103. 0x6a,
  27104. 0xd5,
  27105. 0x30,
  27106. 0x36,
  27107. 0xa5,
  27108. 0x38,
  27109. 0xbf,
  27110. 0x40,
  27111. 0xa3,
  27112. 0x9e,
  27113. 0x81,
  27114. 0xf3,
  27115. 0xd7,
  27116. 0xfb,
  27117. 0x7c,
  27118. 0xe3,
  27119. 0x39,
  27120. 0x82,
  27121. 0x9b,
  27122. 0x2f,
  27123. 0xff,
  27124. 0x87,
  27125. 0x34,
  27126. 0x8e,
  27127. 0x43,
  27128. 0x44,
  27129. 0xc4,
  27130. 0xde,
  27131. 0xe9,
  27132. 0xcb,
  27133. 0x54,
  27134. 0x7b,
  27135. 0x94,
  27136. 0x32,
  27137. 0xa6,
  27138. 0xc2,
  27139. 0x23,
  27140. 0x3d,
  27141. 0xee,
  27142. 0x4c,
  27143. 0x95,
  27144. 0x0b,
  27145. 0x42,
  27146. 0xfa,
  27147. 0xc3,
  27148. 0x4e,
  27149. 0x08,
  27150. 0x2e,
  27151. 0xa1,
  27152. 0x66,
  27153. 0x28,
  27154. 0xd9,
  27155. 0x24,
  27156. 0xb2,
  27157. 0x76,
  27158. 0x5b,
  27159. 0xa2,
  27160. 0x49,
  27161. 0x6d,
  27162. 0x8b,
  27163. 0xd1,
  27164. 0x25,
  27165. 0x72,
  27166. 0xf8,
  27167. 0xf6,
  27168. 0x64,
  27169. 0x86,
  27170. 0x68,
  27171. 0x98,
  27172. 0x16,
  27173. 0xd4,
  27174. 0xa4,
  27175. 0x5c,
  27176. 0xcc,
  27177. 0x5d,
  27178. 0x65,
  27179. 0xb6,
  27180. 0x92,
  27181. 0x6c,
  27182. 0x70,
  27183. 0x48,
  27184. 0x50,
  27185. 0xfd,
  27186. 0xed,
  27187. 0xb9,
  27188. 0xda,
  27189. 0x5e,
  27190. 0x15,
  27191. 0x46,
  27192. 0x57,
  27193. 0xa7,
  27194. 0x8d,
  27195. 0x9d,
  27196. 0x84,
  27197. 0x90,
  27198. 0xd8,
  27199. 0xab,
  27200. 0x00,
  27201. 0x8c,
  27202. 0xbc,
  27203. 0xd3,
  27204. 0x0a,
  27205. 0xf7,
  27206. 0xe4,
  27207. 0x58,
  27208. 0x05,
  27209. 0xb8,
  27210. 0xb3,
  27211. 0x45,
  27212. 0x06,
  27213. 0xd0,
  27214. 0x2c,
  27215. 0x1e,
  27216. 0x8f,
  27217. 0xca,
  27218. 0x3f,
  27219. 0x0f,
  27220. 0x02,
  27221. 0xc1,
  27222. 0xaf,
  27223. 0xbd,
  27224. 0x03,
  27225. 0x01,
  27226. 0x13,
  27227. 0x8a,
  27228. 0x6b,
  27229. 0x3a,
  27230. 0x91,
  27231. 0x11,
  27232. 0x41,
  27233. 0x4f,
  27234. 0x67,
  27235. 0xdc,
  27236. 0xea,
  27237. 0x97,
  27238. 0xf2,
  27239. 0xcf,
  27240. 0xce,
  27241. 0xf0,
  27242. 0xb4,
  27243. 0xe6,
  27244. 0x73,
  27245. 0x96,
  27246. 0xac,
  27247. 0x74,
  27248. 0x22,
  27249. 0xe7,
  27250. 0xad,
  27251. 0x35,
  27252. 0x85,
  27253. 0xe2,
  27254. 0xf9,
  27255. 0x37,
  27256. 0xe8,
  27257. 0x1c,
  27258. 0x75,
  27259. 0xdf,
  27260. 0x6e,
  27261. 0x47,
  27262. 0xf1,
  27263. 0x1a,
  27264. 0x71,
  27265. 0x1d,
  27266. 0x29,
  27267. 0xc5,
  27268. 0x89,
  27269. 0x6f,
  27270. 0xb7,
  27271. 0x62,
  27272. 0x0e,
  27273. 0xaa,
  27274. 0x18,
  27275. 0xbe,
  27276. 0x1b,
  27277. 0xfc,
  27278. 0x56,
  27279. 0x3e,
  27280. 0x4b,
  27281. 0xc6,
  27282. 0xd2,
  27283. 0x79,
  27284. 0x20,
  27285. 0x9a,
  27286. 0xdb,
  27287. 0xc0,
  27288. 0xfe,
  27289. 0x78,
  27290. 0xcd,
  27291. 0x5a,
  27292. 0xf4,
  27293. 0x1f,
  27294. 0xdd,
  27295. 0xa8,
  27296. 0x33,
  27297. 0x88,
  27298. 0x07,
  27299. 0xc7,
  27300. 0x31,
  27301. 0xb1,
  27302. 0x12,
  27303. 0x10,
  27304. 0x59,
  27305. 0x27,
  27306. 0x80,
  27307. 0xec,
  27308. 0x5f,
  27309. 0x60,
  27310. 0x51,
  27311. 0x7f,
  27312. 0xa9,
  27313. 0x19,
  27314. 0xb5,
  27315. 0x4a,
  27316. 0x0d,
  27317. 0x2d,
  27318. 0xe5,
  27319. 0x7a,
  27320. 0x9f,
  27321. 0x93,
  27322. 0xc9,
  27323. 0x9c,
  27324. 0xef,
  27325. 0xa0,
  27326. 0xe0,
  27327. 0x3b,
  27328. 0x4d,
  27329. 0xae,
  27330. 0x2a,
  27331. 0xf5,
  27332. 0xb0,
  27333. 0xc8,
  27334. 0xeb,
  27335. 0xbb,
  27336. 0x3c,
  27337. 0x83,
  27338. 0x53,
  27339. 0x99,
  27340. 0x61,
  27341. 0x17,
  27342. 0x2b,
  27343. 0x04,
  27344. 0x7e,
  27345. 0xba,
  27346. 0x77,
  27347. 0xd6,
  27348. 0x26,
  27349. 0xe1,
  27350. 0x69,
  27351. 0x14,
  27352. 0x63,
  27353. 0x55,
  27354. 0x21,
  27355. 0x0c,
  27356. 0x7d
  27357. ]);
  27358. var mixCol = new Uint8Array(256);
  27359. for (var i = 0; i < 256; i++) {
  27360. if (i < 128) {
  27361. mixCol[i] = i << 1;
  27362. } else {
  27363. mixCol[i] = i << 1 ^ 0x1b;
  27364. }
  27365. }
  27366. var mix = new Uint32Array([
  27367. 0x00000000,
  27368. 0x0e090d0b,
  27369. 0x1c121a16,
  27370. 0x121b171d,
  27371. 0x3824342c,
  27372. 0x362d3927,
  27373. 0x24362e3a,
  27374. 0x2a3f2331,
  27375. 0x70486858,
  27376. 0x7e416553,
  27377. 0x6c5a724e,
  27378. 0x62537f45,
  27379. 0x486c5c74,
  27380. 0x4665517f,
  27381. 0x547e4662,
  27382. 0x5a774b69,
  27383. 0xe090d0b0,
  27384. 0xee99ddbb,
  27385. 0xfc82caa6,
  27386. 0xf28bc7ad,
  27387. 0xd8b4e49c,
  27388. 0xd6bde997,
  27389. 0xc4a6fe8a,
  27390. 0xcaaff381,
  27391. 0x90d8b8e8,
  27392. 0x9ed1b5e3,
  27393. 0x8ccaa2fe,
  27394. 0x82c3aff5,
  27395. 0xa8fc8cc4,
  27396. 0xa6f581cf,
  27397. 0xb4ee96d2,
  27398. 0xbae79bd9,
  27399. 0xdb3bbb7b,
  27400. 0xd532b670,
  27401. 0xc729a16d,
  27402. 0xc920ac66,
  27403. 0xe31f8f57,
  27404. 0xed16825c,
  27405. 0xff0d9541,
  27406. 0xf104984a,
  27407. 0xab73d323,
  27408. 0xa57ade28,
  27409. 0xb761c935,
  27410. 0xb968c43e,
  27411. 0x9357e70f,
  27412. 0x9d5eea04,
  27413. 0x8f45fd19,
  27414. 0x814cf012,
  27415. 0x3bab6bcb,
  27416. 0x35a266c0,
  27417. 0x27b971dd,
  27418. 0x29b07cd6,
  27419. 0x038f5fe7,
  27420. 0x0d8652ec,
  27421. 0x1f9d45f1,
  27422. 0x119448fa,
  27423. 0x4be30393,
  27424. 0x45ea0e98,
  27425. 0x57f11985,
  27426. 0x59f8148e,
  27427. 0x73c737bf,
  27428. 0x7dce3ab4,
  27429. 0x6fd52da9,
  27430. 0x61dc20a2,
  27431. 0xad766df6,
  27432. 0xa37f60fd,
  27433. 0xb16477e0,
  27434. 0xbf6d7aeb,
  27435. 0x955259da,
  27436. 0x9b5b54d1,
  27437. 0x894043cc,
  27438. 0x87494ec7,
  27439. 0xdd3e05ae,
  27440. 0xd33708a5,
  27441. 0xc12c1fb8,
  27442. 0xcf2512b3,
  27443. 0xe51a3182,
  27444. 0xeb133c89,
  27445. 0xf9082b94,
  27446. 0xf701269f,
  27447. 0x4de6bd46,
  27448. 0x43efb04d,
  27449. 0x51f4a750,
  27450. 0x5ffdaa5b,
  27451. 0x75c2896a,
  27452. 0x7bcb8461,
  27453. 0x69d0937c,
  27454. 0x67d99e77,
  27455. 0x3daed51e,
  27456. 0x33a7d815,
  27457. 0x21bccf08,
  27458. 0x2fb5c203,
  27459. 0x058ae132,
  27460. 0x0b83ec39,
  27461. 0x1998fb24,
  27462. 0x1791f62f,
  27463. 0x764dd68d,
  27464. 0x7844db86,
  27465. 0x6a5fcc9b,
  27466. 0x6456c190,
  27467. 0x4e69e2a1,
  27468. 0x4060efaa,
  27469. 0x527bf8b7,
  27470. 0x5c72f5bc,
  27471. 0x0605bed5,
  27472. 0x080cb3de,
  27473. 0x1a17a4c3,
  27474. 0x141ea9c8,
  27475. 0x3e218af9,
  27476. 0x302887f2,
  27477. 0x223390ef,
  27478. 0x2c3a9de4,
  27479. 0x96dd063d,
  27480. 0x98d40b36,
  27481. 0x8acf1c2b,
  27482. 0x84c61120,
  27483. 0xaef93211,
  27484. 0xa0f03f1a,
  27485. 0xb2eb2807,
  27486. 0xbce2250c,
  27487. 0xe6956e65,
  27488. 0xe89c636e,
  27489. 0xfa877473,
  27490. 0xf48e7978,
  27491. 0xdeb15a49,
  27492. 0xd0b85742,
  27493. 0xc2a3405f,
  27494. 0xccaa4d54,
  27495. 0x41ecdaf7,
  27496. 0x4fe5d7fc,
  27497. 0x5dfec0e1,
  27498. 0x53f7cdea,
  27499. 0x79c8eedb,
  27500. 0x77c1e3d0,
  27501. 0x65daf4cd,
  27502. 0x6bd3f9c6,
  27503. 0x31a4b2af,
  27504. 0x3fadbfa4,
  27505. 0x2db6a8b9,
  27506. 0x23bfa5b2,
  27507. 0x09808683,
  27508. 0x07898b88,
  27509. 0x15929c95,
  27510. 0x1b9b919e,
  27511. 0xa17c0a47,
  27512. 0xaf75074c,
  27513. 0xbd6e1051,
  27514. 0xb3671d5a,
  27515. 0x99583e6b,
  27516. 0x97513360,
  27517. 0x854a247d,
  27518. 0x8b432976,
  27519. 0xd134621f,
  27520. 0xdf3d6f14,
  27521. 0xcd267809,
  27522. 0xc32f7502,
  27523. 0xe9105633,
  27524. 0xe7195b38,
  27525. 0xf5024c25,
  27526. 0xfb0b412e,
  27527. 0x9ad7618c,
  27528. 0x94de6c87,
  27529. 0x86c57b9a,
  27530. 0x88cc7691,
  27531. 0xa2f355a0,
  27532. 0xacfa58ab,
  27533. 0xbee14fb6,
  27534. 0xb0e842bd,
  27535. 0xea9f09d4,
  27536. 0xe49604df,
  27537. 0xf68d13c2,
  27538. 0xf8841ec9,
  27539. 0xd2bb3df8,
  27540. 0xdcb230f3,
  27541. 0xcea927ee,
  27542. 0xc0a02ae5,
  27543. 0x7a47b13c,
  27544. 0x744ebc37,
  27545. 0x6655ab2a,
  27546. 0x685ca621,
  27547. 0x42638510,
  27548. 0x4c6a881b,
  27549. 0x5e719f06,
  27550. 0x5078920d,
  27551. 0x0a0fd964,
  27552. 0x0406d46f,
  27553. 0x161dc372,
  27554. 0x1814ce79,
  27555. 0x322bed48,
  27556. 0x3c22e043,
  27557. 0x2e39f75e,
  27558. 0x2030fa55,
  27559. 0xec9ab701,
  27560. 0xe293ba0a,
  27561. 0xf088ad17,
  27562. 0xfe81a01c,
  27563. 0xd4be832d,
  27564. 0xdab78e26,
  27565. 0xc8ac993b,
  27566. 0xc6a59430,
  27567. 0x9cd2df59,
  27568. 0x92dbd252,
  27569. 0x80c0c54f,
  27570. 0x8ec9c844,
  27571. 0xa4f6eb75,
  27572. 0xaaffe67e,
  27573. 0xb8e4f163,
  27574. 0xb6edfc68,
  27575. 0x0c0a67b1,
  27576. 0x02036aba,
  27577. 0x10187da7,
  27578. 0x1e1170ac,
  27579. 0x342e539d,
  27580. 0x3a275e96,
  27581. 0x283c498b,
  27582. 0x26354480,
  27583. 0x7c420fe9,
  27584. 0x724b02e2,
  27585. 0x605015ff,
  27586. 0x6e5918f4,
  27587. 0x44663bc5,
  27588. 0x4a6f36ce,
  27589. 0x587421d3,
  27590. 0x567d2cd8,
  27591. 0x37a10c7a,
  27592. 0x39a80171,
  27593. 0x2bb3166c,
  27594. 0x25ba1b67,
  27595. 0x0f853856,
  27596. 0x018c355d,
  27597. 0x13972240,
  27598. 0x1d9e2f4b,
  27599. 0x47e96422,
  27600. 0x49e06929,
  27601. 0x5bfb7e34,
  27602. 0x55f2733f,
  27603. 0x7fcd500e,
  27604. 0x71c45d05,
  27605. 0x63df4a18,
  27606. 0x6dd64713,
  27607. 0xd731dcca,
  27608. 0xd938d1c1,
  27609. 0xcb23c6dc,
  27610. 0xc52acbd7,
  27611. 0xef15e8e6,
  27612. 0xe11ce5ed,
  27613. 0xf307f2f0,
  27614. 0xfd0efffb,
  27615. 0xa779b492,
  27616. 0xa970b999,
  27617. 0xbb6bae84,
  27618. 0xb562a38f,
  27619. 0x9f5d80be,
  27620. 0x91548db5,
  27621. 0x834f9aa8,
  27622. 0x8d4697a3
  27623. ]);
  27624. function expandKey256(cipherKey) {
  27625. var b = 240, result = new Uint8Array(b);
  27626. var r = 1;
  27627. result.set(cipherKey);
  27628. for (var j = 32, i = 1; j < b; ++i) {
  27629. if (j % 32 === 16) {
  27630. t1 = s[t1];
  27631. t2 = s[t2];
  27632. t3 = s[t3];
  27633. t4 = s[t4];
  27634. } else if (j % 32 === 0) {
  27635. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27636. t1 = s[t1];
  27637. t2 = s[t2];
  27638. t3 = s[t3];
  27639. t4 = s[t4];
  27640. t1 = t1 ^ r;
  27641. if ((r <<= 1) >= 256) {
  27642. r = (r ^ 0x1b) & 0xFF;
  27643. }
  27644. }
  27645. for (var n = 0; n < 4; ++n) {
  27646. result[j] = t1 ^= result[j - 32];
  27647. j++;
  27648. result[j] = t2 ^= result[j - 32];
  27649. j++;
  27650. result[j] = t3 ^= result[j - 32];
  27651. j++;
  27652. result[j] = t4 ^= result[j - 32];
  27653. j++;
  27654. }
  27655. }
  27656. return result;
  27657. }
  27658. function decrypt256(input, key) {
  27659. var state = new Uint8Array(16);
  27660. state.set(input);
  27661. var i, j, k;
  27662. var t, u, v;
  27663. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27664. state[j] ^= key[k];
  27665. }
  27666. for (i = 13; i >= 1; --i) {
  27667. t = state[13];
  27668. state[13] = state[9];
  27669. state[9] = state[5];
  27670. state[5] = state[1];
  27671. state[1] = t;
  27672. t = state[14];
  27673. u = state[10];
  27674. state[14] = state[6];
  27675. state[10] = state[2];
  27676. state[6] = t;
  27677. state[2] = u;
  27678. t = state[15];
  27679. u = state[11];
  27680. v = state[7];
  27681. state[15] = state[3];
  27682. state[11] = t;
  27683. state[7] = u;
  27684. state[3] = v;
  27685. for (j = 0; j < 16; ++j) {
  27686. state[j] = inv_s[state[j]];
  27687. }
  27688. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27689. state[j] ^= key[k];
  27690. }
  27691. for (j = 0; j < 16; j += 4) {
  27692. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27693. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27694. state[j] = t >>> 24 & 0xFF;
  27695. state[j + 1] = t >> 16 & 0xFF;
  27696. state[j + 2] = t >> 8 & 0xFF;
  27697. state[j + 3] = t & 0xFF;
  27698. }
  27699. }
  27700. t = state[13];
  27701. state[13] = state[9];
  27702. state[9] = state[5];
  27703. state[5] = state[1];
  27704. state[1] = t;
  27705. t = state[14];
  27706. u = state[10];
  27707. state[14] = state[6];
  27708. state[10] = state[2];
  27709. state[6] = t;
  27710. state[2] = u;
  27711. t = state[15];
  27712. u = state[11];
  27713. v = state[7];
  27714. state[15] = state[3];
  27715. state[11] = t;
  27716. state[7] = u;
  27717. state[3] = v;
  27718. for (j = 0; j < 16; ++j) {
  27719. state[j] = inv_s[state[j]];
  27720. state[j] ^= key[j];
  27721. }
  27722. return state;
  27723. }
  27724. function encrypt256(input, key) {
  27725. var t, u, v, k;
  27726. var state = new Uint8Array(16);
  27727. state.set(input);
  27728. for (j = 0; j < 16; ++j) {
  27729. state[j] ^= key[j];
  27730. }
  27731. for (i = 1; i < 14; i++) {
  27732. for (j = 0; j < 16; ++j) {
  27733. state[j] = s[state[j]];
  27734. }
  27735. v = state[1];
  27736. state[1] = state[5];
  27737. state[5] = state[9];
  27738. state[9] = state[13];
  27739. state[13] = v;
  27740. v = state[2];
  27741. u = state[6];
  27742. state[2] = state[10];
  27743. state[6] = state[14];
  27744. state[10] = v;
  27745. state[14] = u;
  27746. v = state[3];
  27747. u = state[7];
  27748. t = state[11];
  27749. state[3] = state[15];
  27750. state[7] = v;
  27751. state[11] = u;
  27752. state[15] = t;
  27753. for (var j = 0; j < 16; j += 4) {
  27754. var s0 = state[j + 0], s1 = state[j + 1];
  27755. var s2 = state[j + 2], s3 = state[j + 3];
  27756. t = s0 ^ s1 ^ s2 ^ s3;
  27757. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27758. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27759. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27760. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27761. }
  27762. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27763. state[j] ^= key[k];
  27764. }
  27765. }
  27766. for (j = 0; j < 16; ++j) {
  27767. state[j] = s[state[j]];
  27768. }
  27769. v = state[1];
  27770. state[1] = state[5];
  27771. state[5] = state[9];
  27772. state[9] = state[13];
  27773. state[13] = v;
  27774. v = state[2];
  27775. u = state[6];
  27776. state[2] = state[10];
  27777. state[6] = state[14];
  27778. state[10] = v;
  27779. state[14] = u;
  27780. v = state[3];
  27781. u = state[7];
  27782. t = state[11];
  27783. state[3] = state[15];
  27784. state[7] = v;
  27785. state[11] = u;
  27786. state[15] = t;
  27787. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27788. state[j] ^= key[k];
  27789. }
  27790. return state;
  27791. }
  27792. function AES256Cipher(key) {
  27793. this.key = expandKey256(key);
  27794. this.buffer = new Uint8Array(16);
  27795. this.bufferPosition = 0;
  27796. }
  27797. function decryptBlock2(data, finalize) {
  27798. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27799. for (i = 0; i < sourceLength; ++i) {
  27800. buffer[bufferLength] = data[i];
  27801. ++bufferLength;
  27802. if (bufferLength < 16) {
  27803. continue;
  27804. }
  27805. var plain = decrypt256(buffer, this.key);
  27806. for (j = 0; j < 16; ++j) {
  27807. plain[j] ^= iv[j];
  27808. }
  27809. iv = buffer;
  27810. result.push(plain);
  27811. buffer = new Uint8Array(16);
  27812. bufferLength = 0;
  27813. }
  27814. this.buffer = buffer;
  27815. this.bufferLength = bufferLength;
  27816. this.iv = iv;
  27817. if (result.length === 0) {
  27818. return new Uint8Array([]);
  27819. }
  27820. var outputLength = 16 * result.length;
  27821. if (finalize) {
  27822. var lastBlock = result[result.length - 1];
  27823. var psLen = lastBlock[15];
  27824. if (psLen <= 16) {
  27825. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27826. if (lastBlock[i] !== psLen) {
  27827. psLen = 0;
  27828. break;
  27829. }
  27830. }
  27831. outputLength -= psLen;
  27832. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27833. }
  27834. }
  27835. var output = new Uint8Array(outputLength);
  27836. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27837. output.set(result[i], j);
  27838. }
  27839. return output;
  27840. }
  27841. AES256Cipher.prototype = {
  27842. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  27843. var i, sourceLength = data.length;
  27844. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27845. if (iv) {
  27846. this.iv = iv;
  27847. } else {
  27848. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27849. buffer[bufferLength] = data[i];
  27850. }
  27851. if (bufferLength < 16) {
  27852. this.bufferLength = bufferLength;
  27853. return new Uint8Array([]);
  27854. }
  27855. this.iv = buffer;
  27856. data = data.subarray(16);
  27857. }
  27858. this.buffer = new Uint8Array(16);
  27859. this.bufferLength = 0;
  27860. this.decryptBlock = decryptBlock2;
  27861. return this.decryptBlock(data, finalize);
  27862. },
  27863. encrypt: function AES256Cipher_encrypt(data, iv) {
  27864. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27865. if (!iv) {
  27866. iv = new Uint8Array(16);
  27867. }
  27868. for (i = 0; i < sourceLength; ++i) {
  27869. buffer[bufferLength] = data[i];
  27870. ++bufferLength;
  27871. if (bufferLength < 16) {
  27872. continue;
  27873. }
  27874. for (j = 0; j < 16; ++j) {
  27875. buffer[j] ^= iv[j];
  27876. }
  27877. var cipher = encrypt256(buffer, this.key);
  27878. this.iv = cipher;
  27879. result.push(cipher);
  27880. buffer = new Uint8Array(16);
  27881. bufferLength = 0;
  27882. }
  27883. this.buffer = buffer;
  27884. this.bufferLength = bufferLength;
  27885. this.iv = iv;
  27886. if (result.length === 0) {
  27887. return new Uint8Array([]);
  27888. }
  27889. var outputLength = 16 * result.length;
  27890. var output = new Uint8Array(outputLength);
  27891. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27892. output.set(result[i], j);
  27893. }
  27894. return output;
  27895. }
  27896. };
  27897. return AES256Cipher;
  27898. }();
  27899. var PDF17 = function PDF17Closure() {
  27900. function compareByteArrays(array1, array2) {
  27901. if (array1.length !== array2.length) {
  27902. return false;
  27903. }
  27904. for (var i = 0; i < array1.length; i++) {
  27905. if (array1[i] !== array2[i]) {
  27906. return false;
  27907. }
  27908. }
  27909. return true;
  27910. }
  27911. function PDF17() {
  27912. }
  27913. PDF17.prototype = {
  27914. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27915. var hashData = new Uint8Array(password.length + 56);
  27916. hashData.set(password, 0);
  27917. hashData.set(ownerValidationSalt, password.length);
  27918. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27919. var result = calculateSHA256(hashData, 0, hashData.length);
  27920. return compareByteArrays(result, ownerPassword);
  27921. },
  27922. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  27923. var hashData = new Uint8Array(password.length + 8);
  27924. hashData.set(password, 0);
  27925. hashData.set(userValidationSalt, password.length);
  27926. var result = calculateSHA256(hashData, 0, hashData.length);
  27927. return compareByteArrays(result, userPassword);
  27928. },
  27929. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  27930. var hashData = new Uint8Array(password.length + 56);
  27931. hashData.set(password, 0);
  27932. hashData.set(ownerKeySalt, password.length);
  27933. hashData.set(userBytes, password.length + ownerKeySalt.length);
  27934. var key = calculateSHA256(hashData, 0, hashData.length);
  27935. var cipher = new AES256Cipher(key);
  27936. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  27937. },
  27938. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  27939. var hashData = new Uint8Array(password.length + 8);
  27940. hashData.set(password, 0);
  27941. hashData.set(userKeySalt, password.length);
  27942. var key = calculateSHA256(hashData, 0, hashData.length);
  27943. var cipher = new AES256Cipher(key);
  27944. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  27945. }
  27946. };
  27947. return PDF17;
  27948. }();
  27949. var PDF20 = function PDF20Closure() {
  27950. function concatArrays(array1, array2) {
  27951. var t = new Uint8Array(array1.length + array2.length);
  27952. t.set(array1, 0);
  27953. t.set(array2, array1.length);
  27954. return t;
  27955. }
  27956. function calculatePDF20Hash(password, input, userBytes) {
  27957. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  27958. var e = [0];
  27959. var i = 0;
  27960. while (i < 64 || e[e.length - 1] > i - 32) {
  27961. var arrayLength = password.length + k.length + userBytes.length;
  27962. var k1 = new Uint8Array(arrayLength * 64);
  27963. var array = concatArrays(password, k);
  27964. array = concatArrays(array, userBytes);
  27965. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  27966. k1.set(array, pos);
  27967. }
  27968. var cipher = new AES128Cipher(k.subarray(0, 16));
  27969. e = cipher.encrypt(k1, k.subarray(16, 32));
  27970. var remainder = 0;
  27971. for (var z = 0; z < 16; z++) {
  27972. remainder *= 256 % 3;
  27973. remainder %= 3;
  27974. remainder += (e[z] >>> 0) % 3;
  27975. remainder %= 3;
  27976. }
  27977. if (remainder === 0) {
  27978. k = calculateSHA256(e, 0, e.length);
  27979. } else if (remainder === 1) {
  27980. k = calculateSHA384(e, 0, e.length);
  27981. } else if (remainder === 2) {
  27982. k = calculateSHA512(e, 0, e.length);
  27983. }
  27984. i++;
  27985. }
  27986. return k.subarray(0, 32);
  27987. }
  27988. function PDF20() {
  27989. }
  27990. function compareByteArrays(array1, array2) {
  27991. if (array1.length !== array2.length) {
  27992. return false;
  27993. }
  27994. for (var i = 0; i < array1.length; i++) {
  27995. if (array1[i] !== array2[i]) {
  27996. return false;
  27997. }
  27998. }
  27999. return true;
  28000. }
  28001. PDF20.prototype = {
  28002. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28003. return calculatePDF20Hash(password, concatBytes, userBytes);
  28004. },
  28005. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28006. var hashData = new Uint8Array(password.length + 56);
  28007. hashData.set(password, 0);
  28008. hashData.set(ownerValidationSalt, password.length);
  28009. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28010. var result = calculatePDF20Hash(password, hashData, userBytes);
  28011. return compareByteArrays(result, ownerPassword);
  28012. },
  28013. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28014. var hashData = new Uint8Array(password.length + 8);
  28015. hashData.set(password, 0);
  28016. hashData.set(userValidationSalt, password.length);
  28017. var result = calculatePDF20Hash(password, hashData, []);
  28018. return compareByteArrays(result, userPassword);
  28019. },
  28020. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28021. var hashData = new Uint8Array(password.length + 56);
  28022. hashData.set(password, 0);
  28023. hashData.set(ownerKeySalt, password.length);
  28024. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28025. var key = calculatePDF20Hash(password, hashData, userBytes);
  28026. var cipher = new AES256Cipher(key);
  28027. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28028. },
  28029. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28030. var hashData = new Uint8Array(password.length + 8);
  28031. hashData.set(password, 0);
  28032. hashData.set(userKeySalt, password.length);
  28033. var key = calculatePDF20Hash(password, hashData, []);
  28034. var cipher = new AES256Cipher(key);
  28035. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28036. }
  28037. };
  28038. return PDF20;
  28039. }();
  28040. var CipherTransform = function CipherTransformClosure() {
  28041. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28042. this.StringCipherConstructor = stringCipherConstructor;
  28043. this.StreamCipherConstructor = streamCipherConstructor;
  28044. }
  28045. CipherTransform.prototype = {
  28046. createStream: function CipherTransform_createStream(stream, length) {
  28047. var cipher = new this.StreamCipherConstructor();
  28048. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28049. return cipher.decryptBlock(data, finalize);
  28050. });
  28051. },
  28052. decryptString: function CipherTransform_decryptString(s) {
  28053. var cipher = new this.StringCipherConstructor();
  28054. var data = stringToBytes(s);
  28055. data = cipher.decryptBlock(data, true);
  28056. return bytesToString(data);
  28057. }
  28058. };
  28059. return CipherTransform;
  28060. }();
  28061. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28062. var defaultPasswordBytes = new Uint8Array([
  28063. 0x28,
  28064. 0xBF,
  28065. 0x4E,
  28066. 0x5E,
  28067. 0x4E,
  28068. 0x75,
  28069. 0x8A,
  28070. 0x41,
  28071. 0x64,
  28072. 0x00,
  28073. 0x4E,
  28074. 0x56,
  28075. 0xFF,
  28076. 0xFA,
  28077. 0x01,
  28078. 0x08,
  28079. 0x2E,
  28080. 0x2E,
  28081. 0x00,
  28082. 0xB6,
  28083. 0xD0,
  28084. 0x68,
  28085. 0x3E,
  28086. 0x80,
  28087. 0x2F,
  28088. 0x0C,
  28089. 0xA9,
  28090. 0xFE,
  28091. 0x64,
  28092. 0x53,
  28093. 0x69,
  28094. 0x7A
  28095. ]);
  28096. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28097. if (password) {
  28098. var passwordLength = Math.min(127, password.length);
  28099. password = password.subarray(0, passwordLength);
  28100. } else {
  28101. password = [];
  28102. }
  28103. var pdfAlgorithm;
  28104. if (revision === 6) {
  28105. pdfAlgorithm = new PDF20();
  28106. } else {
  28107. pdfAlgorithm = new PDF17();
  28108. }
  28109. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28110. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28111. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28112. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28113. }
  28114. return null;
  28115. }
  28116. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28117. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28118. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28119. if (password) {
  28120. n = Math.min(32, password.length);
  28121. for (; i < n; ++i) {
  28122. hashData[i] = password[i];
  28123. }
  28124. }
  28125. j = 0;
  28126. while (i < 32) {
  28127. hashData[i++] = defaultPasswordBytes[j++];
  28128. }
  28129. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28130. hashData[i++] = ownerPassword[j];
  28131. }
  28132. hashData[i++] = flags & 0xFF;
  28133. hashData[i++] = flags >> 8 & 0xFF;
  28134. hashData[i++] = flags >> 16 & 0xFF;
  28135. hashData[i++] = flags >>> 24 & 0xFF;
  28136. for (j = 0, n = fileId.length; j < n; ++j) {
  28137. hashData[i++] = fileId[j];
  28138. }
  28139. if (revision >= 4 && !encryptMetadata) {
  28140. hashData[i++] = 0xFF;
  28141. hashData[i++] = 0xFF;
  28142. hashData[i++] = 0xFF;
  28143. hashData[i++] = 0xFF;
  28144. }
  28145. var hash = calculateMD5(hashData, 0, i);
  28146. var keyLengthInBytes = keyLength >> 3;
  28147. if (revision >= 3) {
  28148. for (j = 0; j < 50; ++j) {
  28149. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28150. }
  28151. }
  28152. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28153. var cipher, checkData;
  28154. if (revision >= 3) {
  28155. for (i = 0; i < 32; ++i) {
  28156. hashData[i] = defaultPasswordBytes[i];
  28157. }
  28158. for (j = 0, n = fileId.length; j < n; ++j) {
  28159. hashData[i++] = fileId[j];
  28160. }
  28161. cipher = new ARCFourCipher(encryptionKey);
  28162. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28163. n = encryptionKey.length;
  28164. var derivedKey = new Uint8Array(n), k;
  28165. for (j = 1; j <= 19; ++j) {
  28166. for (k = 0; k < n; ++k) {
  28167. derivedKey[k] = encryptionKey[k] ^ j;
  28168. }
  28169. cipher = new ARCFourCipher(derivedKey);
  28170. checkData = cipher.encryptBlock(checkData);
  28171. }
  28172. for (j = 0, n = checkData.length; j < n; ++j) {
  28173. if (userPassword[j] !== checkData[j]) {
  28174. return null;
  28175. }
  28176. }
  28177. } else {
  28178. cipher = new ARCFourCipher(encryptionKey);
  28179. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28180. for (j = 0, n = checkData.length; j < n; ++j) {
  28181. if (userPassword[j] !== checkData[j]) {
  28182. return null;
  28183. }
  28184. }
  28185. }
  28186. return encryptionKey;
  28187. }
  28188. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28189. var hashData = new Uint8Array(32), i = 0, j, n;
  28190. n = Math.min(32, password.length);
  28191. for (; i < n; ++i) {
  28192. hashData[i] = password[i];
  28193. }
  28194. j = 0;
  28195. while (i < 32) {
  28196. hashData[i++] = defaultPasswordBytes[j++];
  28197. }
  28198. var hash = calculateMD5(hashData, 0, i);
  28199. var keyLengthInBytes = keyLength >> 3;
  28200. if (revision >= 3) {
  28201. for (j = 0; j < 50; ++j) {
  28202. hash = calculateMD5(hash, 0, hash.length);
  28203. }
  28204. }
  28205. var cipher, userPassword;
  28206. if (revision >= 3) {
  28207. userPassword = ownerPassword;
  28208. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28209. for (j = 19; j >= 0; j--) {
  28210. for (k = 0; k < keyLengthInBytes; ++k) {
  28211. derivedKey[k] = hash[k] ^ j;
  28212. }
  28213. cipher = new ARCFourCipher(derivedKey);
  28214. userPassword = cipher.encryptBlock(userPassword);
  28215. }
  28216. } else {
  28217. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28218. userPassword = cipher.encryptBlock(ownerPassword);
  28219. }
  28220. return userPassword;
  28221. }
  28222. var identityName = Name.get('Identity');
  28223. function CipherTransformFactory(dict, fileId, password) {
  28224. var filter = dict.get('Filter');
  28225. if (!isName(filter, 'Standard')) {
  28226. error('unknown encryption method');
  28227. }
  28228. this.dict = dict;
  28229. var algorithm = dict.get('V');
  28230. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28231. error('unsupported encryption algorithm');
  28232. }
  28233. this.algorithm = algorithm;
  28234. var keyLength = dict.get('Length');
  28235. if (!keyLength) {
  28236. if (algorithm <= 3) {
  28237. keyLength = 40;
  28238. } else {
  28239. var cfDict = dict.get('CF');
  28240. var streamCryptoName = dict.get('StmF');
  28241. if (isDict(cfDict) && isName(streamCryptoName)) {
  28242. cfDict.suppressEncryption = true;
  28243. var handlerDict = cfDict.get(streamCryptoName.name);
  28244. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28245. if (keyLength < 40) {
  28246. keyLength <<= 3;
  28247. }
  28248. }
  28249. }
  28250. }
  28251. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28252. error('invalid key length');
  28253. }
  28254. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28255. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28256. var flags = dict.get('P');
  28257. var revision = dict.get('R');
  28258. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28259. this.encryptMetadata = encryptMetadata;
  28260. var fileIdBytes = stringToBytes(fileId);
  28261. var passwordBytes;
  28262. if (password) {
  28263. if (revision === 6) {
  28264. try {
  28265. password = utf8StringToString(password);
  28266. } catch (ex) {
  28267. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  28268. }
  28269. }
  28270. passwordBytes = stringToBytes(password);
  28271. }
  28272. var encryptionKey;
  28273. if (algorithm !== 5) {
  28274. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28275. } else {
  28276. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  28277. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  28278. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  28279. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  28280. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  28281. var ownerEncryption = stringToBytes(dict.get('OE'));
  28282. var userEncryption = stringToBytes(dict.get('UE'));
  28283. var perms = stringToBytes(dict.get('Perms'));
  28284. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  28285. }
  28286. if (!encryptionKey && !password) {
  28287. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  28288. } else if (!encryptionKey && password) {
  28289. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  28290. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28291. }
  28292. if (!encryptionKey) {
  28293. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  28294. }
  28295. this.encryptionKey = encryptionKey;
  28296. if (algorithm >= 4) {
  28297. var cf = dict.get('CF');
  28298. if (isDict(cf)) {
  28299. cf.suppressEncryption = true;
  28300. }
  28301. this.cf = cf;
  28302. this.stmf = dict.get('StmF') || identityName;
  28303. this.strf = dict.get('StrF') || identityName;
  28304. this.eff = dict.get('EFF') || this.stmf;
  28305. }
  28306. }
  28307. function buildObjectKey(num, gen, encryptionKey, isAes) {
  28308. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  28309. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  28310. key[i] = encryptionKey[i];
  28311. }
  28312. key[i++] = num & 0xFF;
  28313. key[i++] = num >> 8 & 0xFF;
  28314. key[i++] = num >> 16 & 0xFF;
  28315. key[i++] = gen & 0xFF;
  28316. key[i++] = gen >> 8 & 0xFF;
  28317. if (isAes) {
  28318. key[i++] = 0x73;
  28319. key[i++] = 0x41;
  28320. key[i++] = 0x6C;
  28321. key[i++] = 0x54;
  28322. }
  28323. var hash = calculateMD5(key, 0, i);
  28324. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  28325. }
  28326. function buildCipherConstructor(cf, name, num, gen, key) {
  28327. assert(isName(name), 'Invalid crypt filter name.');
  28328. var cryptFilter = cf.get(name.name);
  28329. var cfm;
  28330. if (cryptFilter !== null && cryptFilter !== undefined) {
  28331. cfm = cryptFilter.get('CFM');
  28332. }
  28333. if (!cfm || cfm.name === 'None') {
  28334. return function cipherTransformFactoryBuildCipherConstructorNone() {
  28335. return new NullCipher();
  28336. };
  28337. }
  28338. if (cfm.name === 'V2') {
  28339. return function cipherTransformFactoryBuildCipherConstructorV2() {
  28340. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  28341. };
  28342. }
  28343. if (cfm.name === 'AESV2') {
  28344. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  28345. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  28346. };
  28347. }
  28348. if (cfm.name === 'AESV3') {
  28349. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  28350. return new AES256Cipher(key);
  28351. };
  28352. }
  28353. error('Unknown crypto method');
  28354. }
  28355. CipherTransformFactory.prototype = {
  28356. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  28357. if (this.algorithm === 4 || this.algorithm === 5) {
  28358. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  28359. }
  28360. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  28361. var cipherConstructor = function buildCipherCipherConstructor() {
  28362. return new ARCFourCipher(key);
  28363. };
  28364. return new CipherTransform(cipherConstructor, cipherConstructor);
  28365. }
  28366. };
  28367. return CipherTransformFactory;
  28368. }();
  28369. exports.AES128Cipher = AES128Cipher;
  28370. exports.AES256Cipher = AES256Cipher;
  28371. exports.ARCFourCipher = ARCFourCipher;
  28372. exports.CipherTransformFactory = CipherTransformFactory;
  28373. exports.PDF17 = PDF17;
  28374. exports.PDF20 = PDF20;
  28375. exports.calculateMD5 = calculateMD5;
  28376. exports.calculateSHA256 = calculateSHA256;
  28377. exports.calculateSHA384 = calculateSHA384;
  28378. exports.calculateSHA512 = calculateSHA512;
  28379. /***/ }),
  28380. /* 18 */
  28381. /***/ (function(module, exports, __w_pdfjs_require__) {
  28382. "use strict";
  28383. var sharedUtil = __w_pdfjs_require__(0);
  28384. var corePrimitives = __w_pdfjs_require__(1);
  28385. var coreStream = __w_pdfjs_require__(2);
  28386. var coreParser = __w_pdfjs_require__(6);
  28387. var coreImage = __w_pdfjs_require__(34);
  28388. var coreColorSpace = __w_pdfjs_require__(4);
  28389. var coreMurmurHash3 = __w_pdfjs_require__(38);
  28390. var coreFonts = __w_pdfjs_require__(33);
  28391. var coreFunction = __w_pdfjs_require__(7);
  28392. var corePattern = __w_pdfjs_require__(40);
  28393. var coreCMap = __w_pdfjs_require__(30);
  28394. var coreMetrics = __w_pdfjs_require__(37);
  28395. var coreBidi = __w_pdfjs_require__(28);
  28396. var coreEncodings = __w_pdfjs_require__(5);
  28397. var coreStandardFonts = __w_pdfjs_require__(21);
  28398. var coreUnicode = __w_pdfjs_require__(22);
  28399. var coreGlyphList = __w_pdfjs_require__(8);
  28400. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  28401. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  28402. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  28403. var ImageKind = sharedUtil.ImageKind;
  28404. var OPS = sharedUtil.OPS;
  28405. var TextRenderingMode = sharedUtil.TextRenderingMode;
  28406. var CMapCompressionType = sharedUtil.CMapCompressionType;
  28407. var Util = sharedUtil.Util;
  28408. var assert = sharedUtil.assert;
  28409. var createPromiseCapability = sharedUtil.createPromiseCapability;
  28410. var error = sharedUtil.error;
  28411. var info = sharedUtil.info;
  28412. var isArray = sharedUtil.isArray;
  28413. var isNum = sharedUtil.isNum;
  28414. var isString = sharedUtil.isString;
  28415. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  28416. var warn = sharedUtil.warn;
  28417. var Dict = corePrimitives.Dict;
  28418. var Name = corePrimitives.Name;
  28419. var isEOF = corePrimitives.isEOF;
  28420. var isCmd = corePrimitives.isCmd;
  28421. var isDict = corePrimitives.isDict;
  28422. var isName = corePrimitives.isName;
  28423. var isRef = corePrimitives.isRef;
  28424. var isStream = corePrimitives.isStream;
  28425. var DecodeStream = coreStream.DecodeStream;
  28426. var JpegStream = coreStream.JpegStream;
  28427. var Stream = coreStream.Stream;
  28428. var Lexer = coreParser.Lexer;
  28429. var Parser = coreParser.Parser;
  28430. var PDFImage = coreImage.PDFImage;
  28431. var ColorSpace = coreColorSpace.ColorSpace;
  28432. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  28433. var ErrorFont = coreFonts.ErrorFont;
  28434. var FontFlags = coreFonts.FontFlags;
  28435. var Font = coreFonts.Font;
  28436. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  28437. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  28438. var getFontType = coreFonts.getFontType;
  28439. var isPDFFunction = coreFunction.isPDFFunction;
  28440. var PDFFunction = coreFunction.PDFFunction;
  28441. var Pattern = corePattern.Pattern;
  28442. var getTilingPatternIR = corePattern.getTilingPatternIR;
  28443. var CMapFactory = coreCMap.CMapFactory;
  28444. var IdentityCMap = coreCMap.IdentityCMap;
  28445. var getMetrics = coreMetrics.getMetrics;
  28446. var bidi = coreBidi.bidi;
  28447. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  28448. var StandardEncoding = coreEncodings.StandardEncoding;
  28449. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  28450. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  28451. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  28452. var getEncoding = coreEncodings.getEncoding;
  28453. var getStdFontMap = coreStandardFonts.getStdFontMap;
  28454. var getSerifFonts = coreStandardFonts.getSerifFonts;
  28455. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  28456. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  28457. var reverseIfRtl = coreUnicode.reverseIfRtl;
  28458. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  28459. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  28460. var PartialEvaluator = function PartialEvaluatorClosure() {
  28461. var DefaultPartialEvaluatorOptions = {
  28462. forceDataSchema: false,
  28463. maxImageSize: -1,
  28464. disableFontFace: false,
  28465. disableNativeImageDecoder: false
  28466. };
  28467. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  28468. this.xref = xref;
  28469. this.resources = resources;
  28470. this.handler = handler;
  28471. this.forceDataSchema = forceDataSchema;
  28472. }
  28473. NativeImageDecoder.prototype = {
  28474. canDecode: function (image) {
  28475. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  28476. },
  28477. decode: function (image) {
  28478. var dict = image.dict;
  28479. var colorSpace = dict.get('ColorSpace', 'CS');
  28480. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  28481. var numComps = colorSpace.numComps;
  28482. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  28483. image.getIR(this.forceDataSchema),
  28484. numComps
  28485. ]);
  28486. return decodePromise.then(function (message) {
  28487. var data = message.data;
  28488. return new Stream(data, 0, data.length, image.dict);
  28489. });
  28490. }
  28491. };
  28492. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  28493. var dict = image.dict;
  28494. if (dict.has('DecodeParms') || dict.has('DP')) {
  28495. return false;
  28496. }
  28497. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28498. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28499. };
  28500. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  28501. var dict = image.dict;
  28502. if (dict.has('DecodeParms') || dict.has('DP')) {
  28503. return false;
  28504. }
  28505. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28506. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28507. };
  28508. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  28509. this.pdfManager = pdfManager;
  28510. this.xref = xref;
  28511. this.handler = handler;
  28512. this.pageIndex = pageIndex;
  28513. this.idFactory = idFactory;
  28514. this.fontCache = fontCache;
  28515. this.builtInCMapCache = builtInCMapCache;
  28516. this.options = options || DefaultPartialEvaluatorOptions;
  28517. this.fetchBuiltInCMap = function (name) {
  28518. var cachedCMap = builtInCMapCache[name];
  28519. if (cachedCMap) {
  28520. return Promise.resolve(cachedCMap);
  28521. }
  28522. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  28523. if (data.compressionType !== CMapCompressionType.NONE) {
  28524. builtInCMapCache[name] = data;
  28525. }
  28526. return data;
  28527. });
  28528. };
  28529. }
  28530. var TIME_SLOT_DURATION_MS = 20;
  28531. var CHECK_TIME_EVERY = 100;
  28532. function TimeSlotManager() {
  28533. this.reset();
  28534. }
  28535. TimeSlotManager.prototype = {
  28536. check: function TimeSlotManager_check() {
  28537. if (++this.checked < CHECK_TIME_EVERY) {
  28538. return false;
  28539. }
  28540. this.checked = 0;
  28541. return this.endTime <= Date.now();
  28542. },
  28543. reset: function TimeSlotManager_reset() {
  28544. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  28545. this.checked = 0;
  28546. }
  28547. };
  28548. var deferred = Promise.resolve();
  28549. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  28550. PartialEvaluator.prototype = {
  28551. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  28552. if (!isDict(resources)) {
  28553. return false;
  28554. }
  28555. var processed = Object.create(null);
  28556. if (resources.objId) {
  28557. processed[resources.objId] = true;
  28558. }
  28559. var nodes = [resources], xref = this.xref;
  28560. while (nodes.length) {
  28561. var key, i, ii;
  28562. var node = nodes.shift();
  28563. var graphicStates = node.get('ExtGState');
  28564. if (isDict(graphicStates)) {
  28565. var graphicStatesKeys = graphicStates.getKeys();
  28566. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  28567. key = graphicStatesKeys[i];
  28568. var graphicState = graphicStates.get(key);
  28569. var bm = graphicState.get('BM');
  28570. if (isName(bm) && bm.name !== 'Normal') {
  28571. return true;
  28572. }
  28573. }
  28574. }
  28575. var xObjects = node.get('XObject');
  28576. if (!isDict(xObjects)) {
  28577. continue;
  28578. }
  28579. var xObjectsKeys = xObjects.getKeys();
  28580. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  28581. key = xObjectsKeys[i];
  28582. var xObject = xObjects.getRaw(key);
  28583. if (isRef(xObject)) {
  28584. if (processed[xObject.toString()]) {
  28585. continue;
  28586. }
  28587. xObject = xref.fetch(xObject);
  28588. }
  28589. if (!isStream(xObject)) {
  28590. continue;
  28591. }
  28592. if (xObject.dict.objId) {
  28593. if (processed[xObject.dict.objId]) {
  28594. continue;
  28595. }
  28596. processed[xObject.dict.objId] = true;
  28597. }
  28598. var xResources = xObject.dict.get('Resources');
  28599. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  28600. nodes.push(xResources);
  28601. if (xResources.objId) {
  28602. processed[xResources.objId] = true;
  28603. }
  28604. }
  28605. }
  28606. }
  28607. return false;
  28608. },
  28609. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  28610. var matrix = xobj.dict.getArray('Matrix');
  28611. var bbox = xobj.dict.getArray('BBox');
  28612. var group = xobj.dict.get('Group');
  28613. if (group) {
  28614. var groupOptions = {
  28615. matrix: matrix,
  28616. bbox: bbox,
  28617. smask: smask,
  28618. isolated: false,
  28619. knockout: false
  28620. };
  28621. var groupSubtype = group.get('S');
  28622. var colorSpace;
  28623. if (isName(groupSubtype, 'Transparency')) {
  28624. groupOptions.isolated = group.get('I') || false;
  28625. groupOptions.knockout = group.get('K') || false;
  28626. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  28627. }
  28628. if (smask && smask.backdrop) {
  28629. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  28630. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  28631. }
  28632. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  28633. }
  28634. operatorList.addOp(OPS.paintFormXObjectBegin, [
  28635. matrix,
  28636. bbox
  28637. ]);
  28638. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  28639. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  28640. if (group) {
  28641. operatorList.addOp(OPS.endGroup, [groupOptions]);
  28642. }
  28643. });
  28644. },
  28645. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  28646. var self = this;
  28647. var dict = image.dict;
  28648. var w = dict.get('Width', 'W');
  28649. var h = dict.get('Height', 'H');
  28650. if (!(w && isNum(w)) || !(h && isNum(h))) {
  28651. warn('Image dimensions are missing, or not numbers.');
  28652. return;
  28653. }
  28654. var maxImageSize = this.options.maxImageSize;
  28655. if (maxImageSize !== -1 && w * h > maxImageSize) {
  28656. warn('Image exceeded maximum allowed size and was removed.');
  28657. return;
  28658. }
  28659. var imageMask = dict.get('ImageMask', 'IM') || false;
  28660. var imgData, args;
  28661. if (imageMask) {
  28662. var width = dict.get('Width', 'W');
  28663. var height = dict.get('Height', 'H');
  28664. var bitStrideLength = width + 7 >> 3;
  28665. var imgArray = image.getBytes(bitStrideLength * height);
  28666. var decode = dict.getArray('Decode', 'D');
  28667. var inverseDecode = !!decode && decode[0] > 0;
  28668. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  28669. imgData.cached = true;
  28670. args = [imgData];
  28671. operatorList.addOp(OPS.paintImageMaskXObject, args);
  28672. if (cacheKey) {
  28673. imageCache[cacheKey] = {
  28674. fn: OPS.paintImageMaskXObject,
  28675. args: args
  28676. };
  28677. }
  28678. return;
  28679. }
  28680. var softMask = dict.get('SMask', 'SM') || false;
  28681. var mask = dict.get('Mask') || false;
  28682. var SMALL_IMAGE_DIMENSIONS = 200;
  28683. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  28684. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  28685. imgData = imageObj.createImageData(true);
  28686. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  28687. return;
  28688. }
  28689. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  28690. var objId = 'img_' + this.idFactory.createObjId();
  28691. operatorList.addDependency(objId);
  28692. args = [
  28693. objId,
  28694. w,
  28695. h
  28696. ];
  28697. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  28698. operatorList.addOp(OPS.paintJpegXObject, args);
  28699. this.handler.send('obj', [
  28700. objId,
  28701. this.pageIndex,
  28702. 'JpegStream',
  28703. image.getIR(this.options.forceDataSchema)
  28704. ]);
  28705. return;
  28706. }
  28707. var nativeImageDecoder = null;
  28708. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  28709. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  28710. }
  28711. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  28712. var imgData = imageObj.createImageData(false);
  28713. self.handler.send('obj', [
  28714. objId,
  28715. self.pageIndex,
  28716. 'Image',
  28717. imgData
  28718. ], [imgData.data.buffer]);
  28719. }).then(undefined, function (reason) {
  28720. warn('Unable to decode image: ' + reason);
  28721. self.handler.send('obj', [
  28722. objId,
  28723. self.pageIndex,
  28724. 'Image',
  28725. null
  28726. ]);
  28727. });
  28728. operatorList.addOp(OPS.paintImageXObject, args);
  28729. if (cacheKey) {
  28730. imageCache[cacheKey] = {
  28731. fn: OPS.paintImageXObject,
  28732. args: args
  28733. };
  28734. }
  28735. },
  28736. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  28737. var smaskContent = smask.get('G');
  28738. var smaskOptions = {
  28739. subtype: smask.get('S').name,
  28740. backdrop: smask.get('BC')
  28741. };
  28742. var transferObj = smask.get('TR');
  28743. if (isPDFFunction(transferObj)) {
  28744. var transferFn = PDFFunction.parse(this.xref, transferObj);
  28745. var transferMap = new Uint8Array(256);
  28746. var tmp = new Float32Array(1);
  28747. for (var i = 0; i < 256; i++) {
  28748. tmp[0] = i / 255;
  28749. transferFn(tmp, 0, tmp, 0);
  28750. transferMap[i] = tmp[0] * 255 | 0;
  28751. }
  28752. smaskOptions.transferMap = transferMap;
  28753. }
  28754. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  28755. },
  28756. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  28757. var tilingOpList = new OperatorList();
  28758. var resourcesArray = [
  28759. patternDict.get('Resources'),
  28760. resources
  28761. ];
  28762. var patternResources = Dict.merge(this.xref, resourcesArray);
  28763. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  28764. operatorList.addDependencies(tilingOpList.dependencies);
  28765. operatorList.addOp(fn, getTilingPatternIR({
  28766. fnArray: tilingOpList.fnArray,
  28767. argsArray: tilingOpList.argsArray
  28768. }, patternDict, args));
  28769. });
  28770. },
  28771. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  28772. var fontName;
  28773. if (fontArgs) {
  28774. fontArgs = fontArgs.slice();
  28775. fontName = fontArgs[0].name;
  28776. }
  28777. var self = this;
  28778. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  28779. if (!translated.font.isType3Font) {
  28780. return translated;
  28781. }
  28782. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  28783. return translated;
  28784. }, function (reason) {
  28785. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28786. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  28787. });
  28788. }).then(function (translated) {
  28789. state.font = translated.font;
  28790. translated.send(self.handler);
  28791. return translated.loadedName;
  28792. });
  28793. },
  28794. handleText: function PartialEvaluator_handleText(chars, state) {
  28795. var font = state.font;
  28796. var glyphs = font.charsToGlyphs(chars);
  28797. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  28798. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  28799. var buildPath = function (fontChar) {
  28800. if (!font.renderer.hasBuiltPath(fontChar)) {
  28801. var path = font.renderer.getPathJs(fontChar);
  28802. this.handler.send('commonobj', [
  28803. font.loadedName + '_path_' + fontChar,
  28804. 'FontPath',
  28805. path
  28806. ]);
  28807. }
  28808. }.bind(this);
  28809. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  28810. var glyph = glyphs[i];
  28811. buildPath(glyph.fontChar);
  28812. var accent = glyph.accent;
  28813. if (accent && accent.fontChar) {
  28814. buildPath(accent.fontChar);
  28815. }
  28816. }
  28817. }
  28818. return glyphs;
  28819. },
  28820. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  28821. var gStateObj = [];
  28822. var gStateKeys = gState.getKeys();
  28823. var self = this;
  28824. var promise = Promise.resolve();
  28825. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  28826. var key = gStateKeys[i];
  28827. var value = gState.get(key);
  28828. switch (key) {
  28829. case 'Type':
  28830. break;
  28831. case 'LW':
  28832. case 'LC':
  28833. case 'LJ':
  28834. case 'ML':
  28835. case 'D':
  28836. case 'RI':
  28837. case 'FL':
  28838. case 'CA':
  28839. case 'ca':
  28840. gStateObj.push([
  28841. key,
  28842. value
  28843. ]);
  28844. break;
  28845. case 'Font':
  28846. promise = promise.then(function () {
  28847. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  28848. operatorList.addDependency(loadedName);
  28849. gStateObj.push([
  28850. key,
  28851. [
  28852. loadedName,
  28853. value[1]
  28854. ]
  28855. ]);
  28856. });
  28857. });
  28858. break;
  28859. case 'BM':
  28860. gStateObj.push([
  28861. key,
  28862. value
  28863. ]);
  28864. break;
  28865. case 'SMask':
  28866. if (isName(value, 'None')) {
  28867. gStateObj.push([
  28868. key,
  28869. false
  28870. ]);
  28871. break;
  28872. }
  28873. if (isDict(value)) {
  28874. promise = promise.then(function (dict) {
  28875. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  28876. }.bind(this, value));
  28877. gStateObj.push([
  28878. key,
  28879. true
  28880. ]);
  28881. } else {
  28882. warn('Unsupported SMask type');
  28883. }
  28884. break;
  28885. case 'OP':
  28886. case 'op':
  28887. case 'OPM':
  28888. case 'BG':
  28889. case 'BG2':
  28890. case 'UCR':
  28891. case 'UCR2':
  28892. case 'TR':
  28893. case 'TR2':
  28894. case 'HT':
  28895. case 'SM':
  28896. case 'SA':
  28897. case 'AIS':
  28898. case 'TK':
  28899. info('graphic state operator ' + key);
  28900. break;
  28901. default:
  28902. info('Unknown graphic state operator ' + key);
  28903. break;
  28904. }
  28905. }
  28906. return promise.then(function () {
  28907. if (gStateObj.length > 0) {
  28908. operatorList.addOp(OPS.setGState, [gStateObj]);
  28909. }
  28910. });
  28911. },
  28912. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  28913. function errorFont() {
  28914. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  28915. }
  28916. var fontRef;
  28917. if (font) {
  28918. assert(isRef(font));
  28919. fontRef = font;
  28920. } else {
  28921. var fontRes = resources.get('Font');
  28922. if (fontRes) {
  28923. fontRef = fontRes.getRaw(fontName);
  28924. } else {
  28925. warn('fontRes not available');
  28926. return errorFont();
  28927. }
  28928. }
  28929. if (!fontRef) {
  28930. warn('fontRef not available');
  28931. return errorFont();
  28932. }
  28933. if (this.fontCache.has(fontRef)) {
  28934. return this.fontCache.get(fontRef);
  28935. }
  28936. font = xref.fetchIfRef(fontRef);
  28937. if (!isDict(font)) {
  28938. return errorFont();
  28939. }
  28940. if (font.translated) {
  28941. return font.translated;
  28942. }
  28943. var fontCapability = createPromiseCapability();
  28944. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  28945. var descriptor = preEvaluatedFont.descriptor;
  28946. var fontRefIsRef = isRef(fontRef), fontID;
  28947. if (fontRefIsRef) {
  28948. fontID = fontRef.toString();
  28949. }
  28950. if (isDict(descriptor)) {
  28951. if (!descriptor.fontAliases) {
  28952. descriptor.fontAliases = Object.create(null);
  28953. }
  28954. var fontAliases = descriptor.fontAliases;
  28955. var hash = preEvaluatedFont.hash;
  28956. if (fontAliases[hash]) {
  28957. var aliasFontRef = fontAliases[hash].aliasRef;
  28958. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  28959. this.fontCache.putAlias(fontRef, aliasFontRef);
  28960. return this.fontCache.get(fontRef);
  28961. }
  28962. } else {
  28963. fontAliases[hash] = { fontID: Font.getFontID() };
  28964. }
  28965. if (fontRefIsRef) {
  28966. fontAliases[hash].aliasRef = fontRef;
  28967. }
  28968. fontID = fontAliases[hash].fontID;
  28969. }
  28970. if (fontRefIsRef) {
  28971. this.fontCache.put(fontRef, fontCapability.promise);
  28972. } else {
  28973. if (!fontID) {
  28974. fontID = this.idFactory.createObjId();
  28975. }
  28976. this.fontCache.put('id_' + fontID, fontCapability.promise);
  28977. }
  28978. assert(fontID, 'The "fontID" must be defined.');
  28979. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  28980. font.translated = fontCapability.promise;
  28981. var translatedPromise;
  28982. try {
  28983. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  28984. } catch (e) {
  28985. translatedPromise = Promise.reject(e);
  28986. }
  28987. var self = this;
  28988. translatedPromise.then(function (translatedFont) {
  28989. if (translatedFont.fontType !== undefined) {
  28990. var xrefFontStats = xref.stats.fontTypes;
  28991. xrefFontStats[translatedFont.fontType] = true;
  28992. }
  28993. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  28994. }, function (reason) {
  28995. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28996. try {
  28997. var descriptor = preEvaluatedFont.descriptor;
  28998. var fontFile3 = descriptor && descriptor.get('FontFile3');
  28999. var subtype = fontFile3 && fontFile3.get('Subtype');
  29000. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29001. var xrefFontStats = xref.stats.fontTypes;
  29002. xrefFontStats[fontType] = true;
  29003. } catch (ex) {
  29004. }
  29005. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29006. });
  29007. return fontCapability.promise;
  29008. },
  29009. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29010. var lastIndex = operatorList.length - 1;
  29011. if (!args) {
  29012. args = [];
  29013. }
  29014. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29015. operatorList.addOp(OPS.constructPath, [
  29016. [fn],
  29017. args
  29018. ]);
  29019. } else {
  29020. var opArgs = operatorList.argsArray[lastIndex];
  29021. opArgs[0].push(fn);
  29022. Array.prototype.push.apply(opArgs[1], args);
  29023. }
  29024. },
  29025. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29026. var patternName = args[args.length - 1];
  29027. var pattern;
  29028. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29029. var dict = isStream(pattern) ? pattern.dict : pattern;
  29030. var typeNum = dict.get('PatternType');
  29031. if (typeNum === TILING_PATTERN) {
  29032. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29033. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29034. } else if (typeNum === SHADING_PATTERN) {
  29035. var shading = dict.get('Shading');
  29036. var matrix = dict.getArray('Matrix');
  29037. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29038. operatorList.addOp(fn, pattern.getIR());
  29039. return Promise.resolve();
  29040. }
  29041. return Promise.reject('Unknown PatternType: ' + typeNum);
  29042. }
  29043. operatorList.addOp(fn, args);
  29044. return Promise.resolve();
  29045. },
  29046. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29047. var self = this;
  29048. var xref = this.xref;
  29049. var imageCache = Object.create(null);
  29050. assert(operatorList);
  29051. resources = resources || Dict.empty;
  29052. var xobjs = resources.get('XObject') || Dict.empty;
  29053. var patterns = resources.get('Pattern') || Dict.empty;
  29054. var stateManager = new StateManager(initialState || new EvalState());
  29055. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29056. var timeSlotManager = new TimeSlotManager();
  29057. return new Promise(function promiseBody(resolve, reject) {
  29058. var next = function (promise) {
  29059. promise.then(function () {
  29060. try {
  29061. promiseBody(resolve, reject);
  29062. } catch (ex) {
  29063. reject(ex);
  29064. }
  29065. }, reject);
  29066. };
  29067. task.ensureNotTerminated();
  29068. timeSlotManager.reset();
  29069. var stop, operation = {}, i, ii, cs;
  29070. while (!(stop = timeSlotManager.check())) {
  29071. operation.args = null;
  29072. if (!preprocessor.read(operation)) {
  29073. break;
  29074. }
  29075. var args = operation.args;
  29076. var fn = operation.fn;
  29077. switch (fn | 0) {
  29078. case OPS.paintXObject:
  29079. if (args[0].code) {
  29080. break;
  29081. }
  29082. var name = args[0].name;
  29083. if (!name) {
  29084. warn('XObject must be referred to by name.');
  29085. continue;
  29086. }
  29087. if (imageCache[name] !== undefined) {
  29088. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29089. args = null;
  29090. continue;
  29091. }
  29092. var xobj = xobjs.get(name);
  29093. if (xobj) {
  29094. assert(isStream(xobj), 'XObject should be a stream');
  29095. var type = xobj.dict.get('Subtype');
  29096. assert(isName(type), 'XObject should have a Name subtype');
  29097. if (type.name === 'Form') {
  29098. stateManager.save();
  29099. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29100. stateManager.restore();
  29101. }));
  29102. return;
  29103. } else if (type.name === 'Image') {
  29104. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29105. args = null;
  29106. continue;
  29107. } else if (type.name === 'PS') {
  29108. info('Ignored XObject subtype PS');
  29109. continue;
  29110. } else {
  29111. error('Unhandled XObject subtype ' + type.name);
  29112. }
  29113. }
  29114. break;
  29115. case OPS.setFont:
  29116. var fontSize = args[1];
  29117. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29118. operatorList.addDependency(loadedName);
  29119. operatorList.addOp(OPS.setFont, [
  29120. loadedName,
  29121. fontSize
  29122. ]);
  29123. }));
  29124. return;
  29125. case OPS.endInlineImage:
  29126. var cacheKey = args[0].cacheKey;
  29127. if (cacheKey) {
  29128. var cacheEntry = imageCache[cacheKey];
  29129. if (cacheEntry !== undefined) {
  29130. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29131. args = null;
  29132. continue;
  29133. }
  29134. }
  29135. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29136. args = null;
  29137. continue;
  29138. case OPS.showText:
  29139. args[0] = self.handleText(args[0], stateManager.state);
  29140. break;
  29141. case OPS.showSpacedText:
  29142. var arr = args[0];
  29143. var combinedGlyphs = [];
  29144. var arrLength = arr.length;
  29145. var state = stateManager.state;
  29146. for (i = 0; i < arrLength; ++i) {
  29147. var arrItem = arr[i];
  29148. if (isString(arrItem)) {
  29149. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29150. } else if (isNum(arrItem)) {
  29151. combinedGlyphs.push(arrItem);
  29152. }
  29153. }
  29154. args[0] = combinedGlyphs;
  29155. fn = OPS.showText;
  29156. break;
  29157. case OPS.nextLineShowText:
  29158. operatorList.addOp(OPS.nextLine);
  29159. args[0] = self.handleText(args[0], stateManager.state);
  29160. fn = OPS.showText;
  29161. break;
  29162. case OPS.nextLineSetSpacingShowText:
  29163. operatorList.addOp(OPS.nextLine);
  29164. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29165. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29166. args[0] = self.handleText(args[0], stateManager.state);
  29167. fn = OPS.showText;
  29168. break;
  29169. case OPS.setTextRenderingMode:
  29170. stateManager.state.textRenderingMode = args[0];
  29171. break;
  29172. case OPS.setFillColorSpace:
  29173. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29174. continue;
  29175. case OPS.setStrokeColorSpace:
  29176. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29177. continue;
  29178. case OPS.setFillColor:
  29179. cs = stateManager.state.fillColorSpace;
  29180. args = cs.getRgb(args, 0);
  29181. fn = OPS.setFillRGBColor;
  29182. break;
  29183. case OPS.setStrokeColor:
  29184. cs = stateManager.state.strokeColorSpace;
  29185. args = cs.getRgb(args, 0);
  29186. fn = OPS.setStrokeRGBColor;
  29187. break;
  29188. case OPS.setFillGray:
  29189. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29190. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29191. fn = OPS.setFillRGBColor;
  29192. break;
  29193. case OPS.setStrokeGray:
  29194. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29195. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29196. fn = OPS.setStrokeRGBColor;
  29197. break;
  29198. case OPS.setFillCMYKColor:
  29199. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29200. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29201. fn = OPS.setFillRGBColor;
  29202. break;
  29203. case OPS.setStrokeCMYKColor:
  29204. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29205. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29206. fn = OPS.setStrokeRGBColor;
  29207. break;
  29208. case OPS.setFillRGBColor:
  29209. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29210. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29211. break;
  29212. case OPS.setStrokeRGBColor:
  29213. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29214. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29215. break;
  29216. case OPS.setFillColorN:
  29217. cs = stateManager.state.fillColorSpace;
  29218. if (cs.name === 'Pattern') {
  29219. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29220. return;
  29221. }
  29222. args = cs.getRgb(args, 0);
  29223. fn = OPS.setFillRGBColor;
  29224. break;
  29225. case OPS.setStrokeColorN:
  29226. cs = stateManager.state.strokeColorSpace;
  29227. if (cs.name === 'Pattern') {
  29228. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29229. return;
  29230. }
  29231. args = cs.getRgb(args, 0);
  29232. fn = OPS.setStrokeRGBColor;
  29233. break;
  29234. case OPS.shadingFill:
  29235. var shadingRes = resources.get('Shading');
  29236. if (!shadingRes) {
  29237. error('No shading resource found');
  29238. }
  29239. var shading = shadingRes.get(args[0].name);
  29240. if (!shading) {
  29241. error('No shading object found');
  29242. }
  29243. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29244. var patternIR = shadingFill.getIR();
  29245. args = [patternIR];
  29246. fn = OPS.shadingFill;
  29247. break;
  29248. case OPS.setGState:
  29249. var dictName = args[0];
  29250. var extGState = resources.get('ExtGState');
  29251. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29252. break;
  29253. }
  29254. var gState = extGState.get(dictName.name);
  29255. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29256. return;
  29257. case OPS.moveTo:
  29258. case OPS.lineTo:
  29259. case OPS.curveTo:
  29260. case OPS.curveTo2:
  29261. case OPS.curveTo3:
  29262. case OPS.closePath:
  29263. self.buildPath(operatorList, fn, args);
  29264. continue;
  29265. case OPS.rectangle:
  29266. self.buildPath(operatorList, fn, args);
  29267. continue;
  29268. case OPS.markPoint:
  29269. case OPS.markPointProps:
  29270. case OPS.beginMarkedContent:
  29271. case OPS.beginMarkedContentProps:
  29272. case OPS.endMarkedContent:
  29273. case OPS.beginCompat:
  29274. case OPS.endCompat:
  29275. continue;
  29276. default:
  29277. if (args !== null) {
  29278. for (i = 0, ii = args.length; i < ii; i++) {
  29279. if (args[i] instanceof Dict) {
  29280. break;
  29281. }
  29282. }
  29283. if (i < ii) {
  29284. warn('getOperatorList - ignoring operator: ' + fn);
  29285. continue;
  29286. }
  29287. }
  29288. }
  29289. operatorList.addOp(fn, args);
  29290. }
  29291. if (stop) {
  29292. next(deferred);
  29293. return;
  29294. }
  29295. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  29296. operatorList.addOp(OPS.restore, []);
  29297. }
  29298. resolve();
  29299. });
  29300. },
  29301. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  29302. stateManager = stateManager || new StateManager(new TextState());
  29303. var WhitespaceRegexp = /\s/g;
  29304. var textContent = {
  29305. items: [],
  29306. styles: Object.create(null)
  29307. };
  29308. var textContentItem = {
  29309. initialized: false,
  29310. str: [],
  29311. width: 0,
  29312. height: 0,
  29313. vertical: false,
  29314. lastAdvanceWidth: 0,
  29315. lastAdvanceHeight: 0,
  29316. textAdvanceScale: 0,
  29317. spaceWidth: 0,
  29318. fakeSpaceMin: Infinity,
  29319. fakeMultiSpaceMin: Infinity,
  29320. fakeMultiSpaceMax: -0,
  29321. textRunBreakAllowed: false,
  29322. transform: null,
  29323. fontName: null
  29324. };
  29325. var SPACE_FACTOR = 0.3;
  29326. var MULTI_SPACE_FACTOR = 1.5;
  29327. var MULTI_SPACE_FACTOR_MAX = 4;
  29328. var self = this;
  29329. var xref = this.xref;
  29330. resources = xref.fetchIfRef(resources) || Dict.empty;
  29331. var xobjs = null;
  29332. var xobjsCache = Object.create(null);
  29333. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29334. var textState;
  29335. function ensureTextContentItem() {
  29336. if (textContentItem.initialized) {
  29337. return textContentItem;
  29338. }
  29339. var font = textState.font;
  29340. if (!(font.loadedName in textContent.styles)) {
  29341. textContent.styles[font.loadedName] = {
  29342. fontFamily: font.fallbackName,
  29343. ascent: font.ascent,
  29344. descent: font.descent,
  29345. vertical: font.vertical
  29346. };
  29347. }
  29348. textContentItem.fontName = font.loadedName;
  29349. var tsm = [
  29350. textState.fontSize * textState.textHScale,
  29351. 0,
  29352. 0,
  29353. textState.fontSize,
  29354. 0,
  29355. textState.textRise
  29356. ];
  29357. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  29358. var glyphHeight = font.bbox[3] - font.bbox[1];
  29359. if (glyphHeight > 0) {
  29360. glyphHeight = glyphHeight * textState.fontMatrix[3];
  29361. tsm[3] *= glyphHeight;
  29362. }
  29363. }
  29364. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  29365. textContentItem.transform = trm;
  29366. if (!font.vertical) {
  29367. textContentItem.width = 0;
  29368. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  29369. textContentItem.vertical = false;
  29370. } else {
  29371. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  29372. textContentItem.height = 0;
  29373. textContentItem.vertical = true;
  29374. }
  29375. var a = textState.textLineMatrix[0];
  29376. var b = textState.textLineMatrix[1];
  29377. var scaleLineX = Math.sqrt(a * a + b * b);
  29378. a = textState.ctm[0];
  29379. b = textState.ctm[1];
  29380. var scaleCtmX = Math.sqrt(a * a + b * b);
  29381. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  29382. textContentItem.lastAdvanceWidth = 0;
  29383. textContentItem.lastAdvanceHeight = 0;
  29384. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  29385. if (spaceWidth) {
  29386. textContentItem.spaceWidth = spaceWidth;
  29387. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  29388. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  29389. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  29390. textContentItem.textRunBreakAllowed = !font.isMonospace;
  29391. } else {
  29392. textContentItem.spaceWidth = 0;
  29393. textContentItem.fakeSpaceMin = Infinity;
  29394. textContentItem.fakeMultiSpaceMin = Infinity;
  29395. textContentItem.fakeMultiSpaceMax = 0;
  29396. textContentItem.textRunBreakAllowed = false;
  29397. }
  29398. textContentItem.initialized = true;
  29399. return textContentItem;
  29400. }
  29401. function replaceWhitespace(str) {
  29402. var i = 0, ii = str.length, code;
  29403. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  29404. i++;
  29405. }
  29406. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  29407. }
  29408. function runBidiTransform(textChunk) {
  29409. var str = textChunk.str.join('');
  29410. var bidiResult = bidi(str, -1, textChunk.vertical);
  29411. return {
  29412. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  29413. dir: bidiResult.dir,
  29414. width: textChunk.width,
  29415. height: textChunk.height,
  29416. transform: textChunk.transform,
  29417. fontName: textChunk.fontName
  29418. };
  29419. }
  29420. function handleSetFont(fontName, fontRef) {
  29421. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  29422. textState.font = translated.font;
  29423. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  29424. });
  29425. }
  29426. function buildTextContentItem(chars) {
  29427. var font = textState.font;
  29428. var textChunk = ensureTextContentItem();
  29429. var width = 0;
  29430. var height = 0;
  29431. var glyphs = font.charsToGlyphs(chars);
  29432. for (var i = 0; i < glyphs.length; i++) {
  29433. var glyph = glyphs[i];
  29434. var glyphWidth = null;
  29435. if (font.vertical && glyph.vmetric) {
  29436. glyphWidth = glyph.vmetric[0];
  29437. } else {
  29438. glyphWidth = glyph.width;
  29439. }
  29440. var glyphUnicode = glyph.unicode;
  29441. var NormalizedUnicodes = getNormalizedUnicodes();
  29442. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  29443. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  29444. }
  29445. glyphUnicode = reverseIfRtl(glyphUnicode);
  29446. var charSpacing = textState.charSpacing;
  29447. if (glyph.isSpace) {
  29448. var wordSpacing = textState.wordSpacing;
  29449. charSpacing += wordSpacing;
  29450. if (wordSpacing > 0) {
  29451. addFakeSpaces(wordSpacing, textChunk.str);
  29452. }
  29453. }
  29454. var tx = 0;
  29455. var ty = 0;
  29456. if (!font.vertical) {
  29457. var w0 = glyphWidth * textState.fontMatrix[0];
  29458. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  29459. width += tx;
  29460. } else {
  29461. var w1 = glyphWidth * textState.fontMatrix[0];
  29462. ty = w1 * textState.fontSize + charSpacing;
  29463. height += ty;
  29464. }
  29465. textState.translateTextMatrix(tx, ty);
  29466. textChunk.str.push(glyphUnicode);
  29467. }
  29468. if (!font.vertical) {
  29469. textChunk.lastAdvanceWidth = width;
  29470. textChunk.width += width;
  29471. } else {
  29472. textChunk.lastAdvanceHeight = height;
  29473. textChunk.height += Math.abs(height);
  29474. }
  29475. return textChunk;
  29476. }
  29477. function addFakeSpaces(width, strBuf) {
  29478. if (width < textContentItem.fakeSpaceMin) {
  29479. return;
  29480. }
  29481. if (width < textContentItem.fakeMultiSpaceMin) {
  29482. strBuf.push(' ');
  29483. return;
  29484. }
  29485. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  29486. while (fakeSpaces-- > 0) {
  29487. strBuf.push(' ');
  29488. }
  29489. }
  29490. function flushTextContentItem() {
  29491. if (!textContentItem.initialized) {
  29492. return;
  29493. }
  29494. textContentItem.width *= textContentItem.textAdvanceScale;
  29495. textContentItem.height *= textContentItem.textAdvanceScale;
  29496. textContent.items.push(runBidiTransform(textContentItem));
  29497. textContentItem.initialized = false;
  29498. textContentItem.str.length = 0;
  29499. }
  29500. var timeSlotManager = new TimeSlotManager();
  29501. return new Promise(function promiseBody(resolve, reject) {
  29502. var next = function (promise) {
  29503. promise.then(function () {
  29504. try {
  29505. promiseBody(resolve, reject);
  29506. } catch (ex) {
  29507. reject(ex);
  29508. }
  29509. }, reject);
  29510. };
  29511. task.ensureNotTerminated();
  29512. timeSlotManager.reset();
  29513. var stop, operation = {}, args = [];
  29514. while (!(stop = timeSlotManager.check())) {
  29515. args.length = 0;
  29516. operation.args = args;
  29517. if (!preprocessor.read(operation)) {
  29518. break;
  29519. }
  29520. textState = stateManager.state;
  29521. var fn = operation.fn;
  29522. args = operation.args;
  29523. var advance, diff;
  29524. switch (fn | 0) {
  29525. case OPS.setFont:
  29526. var fontNameArg = args[0].name, fontSizeArg = args[1];
  29527. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  29528. break;
  29529. }
  29530. flushTextContentItem();
  29531. textState.fontName = fontNameArg;
  29532. textState.fontSize = fontSizeArg;
  29533. next(handleSetFont(fontNameArg, null));
  29534. return;
  29535. case OPS.setTextRise:
  29536. flushTextContentItem();
  29537. textState.textRise = args[0];
  29538. break;
  29539. case OPS.setHScale:
  29540. flushTextContentItem();
  29541. textState.textHScale = args[0] / 100;
  29542. break;
  29543. case OPS.setLeading:
  29544. flushTextContentItem();
  29545. textState.leading = args[0];
  29546. break;
  29547. case OPS.moveText:
  29548. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  29549. advance = args[0] - args[1];
  29550. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  29551. textState.translateTextLineMatrix(args[0], args[1]);
  29552. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  29553. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  29554. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  29555. addFakeSpaces(diff, textContentItem.str);
  29556. break;
  29557. }
  29558. flushTextContentItem();
  29559. textState.translateTextLineMatrix(args[0], args[1]);
  29560. textState.textMatrix = textState.textLineMatrix.slice();
  29561. break;
  29562. case OPS.setLeadingMoveText:
  29563. flushTextContentItem();
  29564. textState.leading = -args[1];
  29565. textState.translateTextLineMatrix(args[0], args[1]);
  29566. textState.textMatrix = textState.textLineMatrix.slice();
  29567. break;
  29568. case OPS.nextLine:
  29569. flushTextContentItem();
  29570. textState.carriageReturn();
  29571. break;
  29572. case OPS.setTextMatrix:
  29573. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  29574. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  29575. textState.translateTextLineMatrix(advance.width, advance.height);
  29576. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  29577. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  29578. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  29579. addFakeSpaces(diff, textContentItem.str);
  29580. break;
  29581. }
  29582. flushTextContentItem();
  29583. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29584. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29585. break;
  29586. case OPS.setCharSpacing:
  29587. textState.charSpacing = args[0];
  29588. break;
  29589. case OPS.setWordSpacing:
  29590. textState.wordSpacing = args[0];
  29591. break;
  29592. case OPS.beginText:
  29593. flushTextContentItem();
  29594. textState.textMatrix = IDENTITY_MATRIX.slice();
  29595. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  29596. break;
  29597. case OPS.showSpacedText:
  29598. var items = args[0];
  29599. var offset;
  29600. for (var j = 0, jj = items.length; j < jj; j++) {
  29601. if (typeof items[j] === 'string') {
  29602. buildTextContentItem(items[j]);
  29603. } else if (isNum(items[j])) {
  29604. ensureTextContentItem();
  29605. advance = items[j] * textState.fontSize / 1000;
  29606. var breakTextRun = false;
  29607. if (textState.font.vertical) {
  29608. offset = advance;
  29609. textState.translateTextMatrix(0, offset);
  29610. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29611. if (!breakTextRun) {
  29612. textContentItem.height += offset;
  29613. }
  29614. } else {
  29615. advance = -advance;
  29616. offset = advance * textState.textHScale;
  29617. textState.translateTextMatrix(offset, 0);
  29618. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29619. if (!breakTextRun) {
  29620. textContentItem.width += offset;
  29621. }
  29622. }
  29623. if (breakTextRun) {
  29624. flushTextContentItem();
  29625. } else if (advance > 0) {
  29626. addFakeSpaces(advance, textContentItem.str);
  29627. }
  29628. }
  29629. }
  29630. break;
  29631. case OPS.showText:
  29632. buildTextContentItem(args[0]);
  29633. break;
  29634. case OPS.nextLineShowText:
  29635. flushTextContentItem();
  29636. textState.carriageReturn();
  29637. buildTextContentItem(args[0]);
  29638. break;
  29639. case OPS.nextLineSetSpacingShowText:
  29640. flushTextContentItem();
  29641. textState.wordSpacing = args[0];
  29642. textState.charSpacing = args[1];
  29643. textState.carriageReturn();
  29644. buildTextContentItem(args[2]);
  29645. break;
  29646. case OPS.paintXObject:
  29647. flushTextContentItem();
  29648. if (args[0].code) {
  29649. break;
  29650. }
  29651. if (!xobjs) {
  29652. xobjs = resources.get('XObject') || Dict.empty;
  29653. }
  29654. var name = args[0].name;
  29655. if (xobjsCache.key === name) {
  29656. if (xobjsCache.texts) {
  29657. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  29658. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  29659. }
  29660. break;
  29661. }
  29662. var xobj = xobjs.get(name);
  29663. if (!xobj) {
  29664. break;
  29665. }
  29666. assert(isStream(xobj), 'XObject should be a stream');
  29667. var type = xobj.dict.get('Subtype');
  29668. assert(isName(type), 'XObject should have a Name subtype');
  29669. if ('Form' !== type.name) {
  29670. xobjsCache.key = name;
  29671. xobjsCache.texts = null;
  29672. break;
  29673. }
  29674. stateManager.save();
  29675. var matrix = xobj.dict.getArray('Matrix');
  29676. if (isArray(matrix) && matrix.length === 6) {
  29677. stateManager.transform(matrix);
  29678. }
  29679. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  29680. Util.appendToArray(textContent.items, formTextContent.items);
  29681. Util.extendObj(textContent.styles, formTextContent.styles);
  29682. stateManager.restore();
  29683. xobjsCache.key = name;
  29684. xobjsCache.texts = formTextContent;
  29685. }));
  29686. return;
  29687. case OPS.setGState:
  29688. flushTextContentItem();
  29689. var dictName = args[0];
  29690. var extGState = resources.get('ExtGState');
  29691. if (!isDict(extGState) || !isName(dictName)) {
  29692. break;
  29693. }
  29694. var gState = extGState.get(dictName.name);
  29695. if (!isDict(gState)) {
  29696. break;
  29697. }
  29698. var gStateFont = gState.get('Font');
  29699. if (gStateFont) {
  29700. textState.fontName = null;
  29701. textState.fontSize = gStateFont[1];
  29702. next(handleSetFont(null, gStateFont[0]));
  29703. return;
  29704. }
  29705. break;
  29706. }
  29707. }
  29708. if (stop) {
  29709. next(deferred);
  29710. return;
  29711. }
  29712. flushTextContentItem();
  29713. resolve(textContent);
  29714. });
  29715. },
  29716. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  29717. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  29718. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  29719. if (properties.composite) {
  29720. var cidSystemInfo = dict.get('CIDSystemInfo');
  29721. if (isDict(cidSystemInfo)) {
  29722. properties.cidSystemInfo = {
  29723. registry: cidSystemInfo.get('Registry'),
  29724. ordering: cidSystemInfo.get('Ordering'),
  29725. supplement: cidSystemInfo.get('Supplement')
  29726. };
  29727. }
  29728. var cidToGidMap = dict.get('CIDToGIDMap');
  29729. if (isStream(cidToGidMap)) {
  29730. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  29731. }
  29732. }
  29733. var differences = [];
  29734. var baseEncodingName = null;
  29735. var encoding;
  29736. if (dict.has('Encoding')) {
  29737. encoding = dict.get('Encoding');
  29738. if (isDict(encoding)) {
  29739. baseEncodingName = encoding.get('BaseEncoding');
  29740. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  29741. if (encoding.has('Differences')) {
  29742. var diffEncoding = encoding.get('Differences');
  29743. var index = 0;
  29744. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  29745. var data = xref.fetchIfRef(diffEncoding[j]);
  29746. if (isNum(data)) {
  29747. index = data;
  29748. } else if (isName(data)) {
  29749. differences[index++] = data.name;
  29750. } else {
  29751. error('Invalid entry in \'Differences\' array: ' + data);
  29752. }
  29753. }
  29754. }
  29755. } else if (isName(encoding)) {
  29756. baseEncodingName = encoding.name;
  29757. } else {
  29758. error('Encoding is not a Name nor a Dict');
  29759. }
  29760. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  29761. baseEncodingName = null;
  29762. }
  29763. }
  29764. if (baseEncodingName) {
  29765. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  29766. } else {
  29767. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  29768. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  29769. encoding = StandardEncoding;
  29770. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  29771. encoding = WinAnsiEncoding;
  29772. }
  29773. if (isSymbolicFont) {
  29774. encoding = MacRomanEncoding;
  29775. if (!properties.file) {
  29776. if (/Symbol/i.test(properties.name)) {
  29777. encoding = SymbolSetEncoding;
  29778. } else if (/Dingbats/i.test(properties.name)) {
  29779. encoding = ZapfDingbatsEncoding;
  29780. }
  29781. }
  29782. }
  29783. properties.defaultEncoding = encoding;
  29784. }
  29785. properties.differences = differences;
  29786. properties.baseEncodingName = baseEncodingName;
  29787. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  29788. properties.dict = dict;
  29789. return toUnicodePromise.then(function (toUnicode) {
  29790. properties.toUnicode = toUnicode;
  29791. return this.buildToUnicode(properties);
  29792. }.bind(this)).then(function (toUnicode) {
  29793. properties.toUnicode = toUnicode;
  29794. return properties;
  29795. });
  29796. },
  29797. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  29798. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  29799. if (properties.hasIncludedToUnicodeMap) {
  29800. return Promise.resolve(properties.toUnicode);
  29801. }
  29802. var toUnicode, charcode, glyphName;
  29803. if (!properties.composite) {
  29804. toUnicode = [];
  29805. var encoding = properties.defaultEncoding.slice();
  29806. var baseEncodingName = properties.baseEncodingName;
  29807. var differences = properties.differences;
  29808. for (charcode in differences) {
  29809. glyphName = differences[charcode];
  29810. if (glyphName === '.notdef') {
  29811. continue;
  29812. }
  29813. encoding[charcode] = glyphName;
  29814. }
  29815. var glyphsUnicodeMap = getGlyphsUnicode();
  29816. for (charcode in encoding) {
  29817. glyphName = encoding[charcode];
  29818. if (glyphName === '') {
  29819. continue;
  29820. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  29821. var code = 0;
  29822. switch (glyphName[0]) {
  29823. case 'G':
  29824. if (glyphName.length === 3) {
  29825. code = parseInt(glyphName.substr(1), 16);
  29826. }
  29827. break;
  29828. case 'g':
  29829. if (glyphName.length === 5) {
  29830. code = parseInt(glyphName.substr(1), 16);
  29831. }
  29832. break;
  29833. case 'C':
  29834. case 'c':
  29835. if (glyphName.length >= 3) {
  29836. code = +glyphName.substr(1);
  29837. }
  29838. break;
  29839. default:
  29840. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  29841. if (unicode !== -1) {
  29842. code = unicode;
  29843. }
  29844. }
  29845. if (code) {
  29846. if (baseEncodingName && code === +charcode) {
  29847. var baseEncoding = getEncoding(baseEncodingName);
  29848. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  29849. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29850. continue;
  29851. }
  29852. }
  29853. toUnicode[charcode] = String.fromCharCode(code);
  29854. }
  29855. continue;
  29856. }
  29857. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29858. }
  29859. return Promise.resolve(new ToUnicodeMap(toUnicode));
  29860. }
  29861. 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'))) {
  29862. var registry = properties.cidSystemInfo.registry;
  29863. var ordering = properties.cidSystemInfo.ordering;
  29864. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  29865. return CMapFactory.create({
  29866. encoding: ucs2CMapName,
  29867. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29868. useCMap: null
  29869. }).then(function (ucs2CMap) {
  29870. var cMap = properties.cMap;
  29871. toUnicode = [];
  29872. cMap.forEach(function (charcode, cid) {
  29873. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  29874. var ucs2 = ucs2CMap.lookup(cid);
  29875. if (ucs2) {
  29876. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  29877. }
  29878. });
  29879. return new ToUnicodeMap(toUnicode);
  29880. });
  29881. }
  29882. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  29883. },
  29884. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  29885. var cmapObj = toUnicode;
  29886. if (isName(cmapObj)) {
  29887. return CMapFactory.create({
  29888. encoding: cmapObj,
  29889. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29890. useCMap: null
  29891. }).then(function (cmap) {
  29892. if (cmap instanceof IdentityCMap) {
  29893. return new IdentityToUnicodeMap(0, 0xFFFF);
  29894. }
  29895. return new ToUnicodeMap(cmap.getMap());
  29896. });
  29897. } else if (isStream(cmapObj)) {
  29898. return CMapFactory.create({
  29899. encoding: cmapObj,
  29900. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29901. useCMap: null
  29902. }).then(function (cmap) {
  29903. if (cmap instanceof IdentityCMap) {
  29904. return new IdentityToUnicodeMap(0, 0xFFFF);
  29905. }
  29906. var map = new Array(cmap.length);
  29907. cmap.forEach(function (charCode, token) {
  29908. var str = [];
  29909. for (var k = 0; k < token.length; k += 2) {
  29910. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29911. if ((w1 & 0xF800) !== 0xD800) {
  29912. str.push(w1);
  29913. continue;
  29914. }
  29915. k += 2;
  29916. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29917. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  29918. }
  29919. map[charCode] = String.fromCharCode.apply(String, str);
  29920. });
  29921. return new ToUnicodeMap(map);
  29922. });
  29923. }
  29924. return Promise.resolve(null);
  29925. },
  29926. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  29927. var glyphsData = cidToGidStream.getBytes();
  29928. var result = [];
  29929. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  29930. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  29931. if (glyphID === 0) {
  29932. continue;
  29933. }
  29934. var code = j >> 1;
  29935. result[code] = glyphID;
  29936. }
  29937. return result;
  29938. },
  29939. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  29940. var glyphsWidths = [];
  29941. var defaultWidth = 0;
  29942. var glyphsVMetrics = [];
  29943. var defaultVMetrics;
  29944. var i, ii, j, jj, start, code, widths;
  29945. if (properties.composite) {
  29946. defaultWidth = dict.get('DW') || 1000;
  29947. widths = dict.get('W');
  29948. if (widths) {
  29949. for (i = 0, ii = widths.length; i < ii; i++) {
  29950. start = xref.fetchIfRef(widths[i++]);
  29951. code = xref.fetchIfRef(widths[i]);
  29952. if (isArray(code)) {
  29953. for (j = 0, jj = code.length; j < jj; j++) {
  29954. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  29955. }
  29956. } else {
  29957. var width = xref.fetchIfRef(widths[++i]);
  29958. for (j = start; j <= code; j++) {
  29959. glyphsWidths[j] = width;
  29960. }
  29961. }
  29962. }
  29963. }
  29964. if (properties.vertical) {
  29965. var vmetrics = dict.getArray('DW2') || [
  29966. 880,
  29967. -1000
  29968. ];
  29969. defaultVMetrics = [
  29970. vmetrics[1],
  29971. defaultWidth * 0.5,
  29972. vmetrics[0]
  29973. ];
  29974. vmetrics = dict.get('W2');
  29975. if (vmetrics) {
  29976. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  29977. start = xref.fetchIfRef(vmetrics[i++]);
  29978. code = xref.fetchIfRef(vmetrics[i]);
  29979. if (isArray(code)) {
  29980. for (j = 0, jj = code.length; j < jj; j++) {
  29981. glyphsVMetrics[start++] = [
  29982. xref.fetchIfRef(code[j++]),
  29983. xref.fetchIfRef(code[j++]),
  29984. xref.fetchIfRef(code[j])
  29985. ];
  29986. }
  29987. } else {
  29988. var vmetric = [
  29989. xref.fetchIfRef(vmetrics[++i]),
  29990. xref.fetchIfRef(vmetrics[++i]),
  29991. xref.fetchIfRef(vmetrics[++i])
  29992. ];
  29993. for (j = start; j <= code; j++) {
  29994. glyphsVMetrics[j] = vmetric;
  29995. }
  29996. }
  29997. }
  29998. }
  29999. }
  30000. } else {
  30001. var firstChar = properties.firstChar;
  30002. widths = dict.get('Widths');
  30003. if (widths) {
  30004. j = firstChar;
  30005. for (i = 0, ii = widths.length; i < ii; i++) {
  30006. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30007. }
  30008. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30009. } else {
  30010. var baseFontName = dict.get('BaseFont');
  30011. if (isName(baseFontName)) {
  30012. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30013. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30014. defaultWidth = metrics.defaultWidth;
  30015. }
  30016. }
  30017. }
  30018. var isMonospace = true;
  30019. var firstWidth = defaultWidth;
  30020. for (var glyph in glyphsWidths) {
  30021. var glyphWidth = glyphsWidths[glyph];
  30022. if (!glyphWidth) {
  30023. continue;
  30024. }
  30025. if (!firstWidth) {
  30026. firstWidth = glyphWidth;
  30027. continue;
  30028. }
  30029. if (firstWidth !== glyphWidth) {
  30030. isMonospace = false;
  30031. break;
  30032. }
  30033. }
  30034. if (isMonospace) {
  30035. properties.flags |= FontFlags.FixedPitch;
  30036. }
  30037. properties.defaultWidth = defaultWidth;
  30038. properties.widths = glyphsWidths;
  30039. properties.defaultVMetrics = defaultVMetrics;
  30040. properties.vmetrics = glyphsVMetrics;
  30041. },
  30042. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30043. var fontNameWoStyle = baseFontName.split('-')[0];
  30044. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30045. },
  30046. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30047. var defaultWidth = 0;
  30048. var widths = [];
  30049. var monospace = false;
  30050. var stdFontMap = getStdFontMap();
  30051. var lookupName = stdFontMap[name] || name;
  30052. var Metrics = getMetrics();
  30053. if (!(lookupName in Metrics)) {
  30054. if (this.isSerifFont(name)) {
  30055. lookupName = 'Times-Roman';
  30056. } else {
  30057. lookupName = 'Helvetica';
  30058. }
  30059. }
  30060. var glyphWidths = Metrics[lookupName];
  30061. if (isNum(glyphWidths)) {
  30062. defaultWidth = glyphWidths;
  30063. monospace = true;
  30064. } else {
  30065. widths = glyphWidths();
  30066. }
  30067. return {
  30068. defaultWidth: defaultWidth,
  30069. monospace: monospace,
  30070. widths: widths
  30071. };
  30072. },
  30073. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30074. var widths = Object.create(null);
  30075. var differences = properties.differences;
  30076. var encoding = properties.defaultEncoding;
  30077. for (var charCode = 0; charCode < 256; charCode++) {
  30078. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30079. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30080. continue;
  30081. }
  30082. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30083. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30084. continue;
  30085. }
  30086. }
  30087. return widths;
  30088. },
  30089. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30090. var baseDict = dict;
  30091. var type = dict.get('Subtype');
  30092. assert(isName(type), 'invalid font Subtype');
  30093. var composite = false;
  30094. var uint8array;
  30095. if (type.name === 'Type0') {
  30096. var df = dict.get('DescendantFonts');
  30097. if (!df) {
  30098. error('Descendant fonts are not specified');
  30099. }
  30100. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30101. type = dict.get('Subtype');
  30102. assert(isName(type), 'invalid font Subtype');
  30103. composite = true;
  30104. }
  30105. var descriptor = dict.get('FontDescriptor');
  30106. if (descriptor) {
  30107. var hash = new MurmurHash3_64();
  30108. var encoding = baseDict.getRaw('Encoding');
  30109. if (isName(encoding)) {
  30110. hash.update(encoding.name);
  30111. } else if (isRef(encoding)) {
  30112. hash.update(encoding.toString());
  30113. } else if (isDict(encoding)) {
  30114. var keys = encoding.getKeys();
  30115. for (var i = 0, ii = keys.length; i < ii; i++) {
  30116. var entry = encoding.getRaw(keys[i]);
  30117. if (isName(entry)) {
  30118. hash.update(entry.name);
  30119. } else if (isRef(entry)) {
  30120. hash.update(entry.toString());
  30121. } else if (isArray(entry)) {
  30122. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30123. for (var j = 0; j < diffLength; j++) {
  30124. var diffEntry = entry[j];
  30125. if (isName(diffEntry)) {
  30126. diffBuf[j] = diffEntry.name;
  30127. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30128. diffBuf[j] = diffEntry.toString();
  30129. }
  30130. }
  30131. hash.update(diffBuf.join());
  30132. }
  30133. }
  30134. }
  30135. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30136. if (isStream(toUnicode)) {
  30137. var stream = toUnicode.str || toUnicode;
  30138. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30139. hash.update(uint8array);
  30140. } else if (isName(toUnicode)) {
  30141. hash.update(toUnicode.name);
  30142. }
  30143. var widths = dict.get('Widths') || baseDict.get('Widths');
  30144. if (widths) {
  30145. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30146. hash.update(uint8array);
  30147. }
  30148. }
  30149. return {
  30150. descriptor: descriptor,
  30151. dict: dict,
  30152. baseDict: baseDict,
  30153. composite: composite,
  30154. type: type.name,
  30155. hash: hash ? hash.hexdigest() : ''
  30156. };
  30157. },
  30158. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30159. var baseDict = preEvaluatedFont.baseDict;
  30160. var dict = preEvaluatedFont.dict;
  30161. var composite = preEvaluatedFont.composite;
  30162. var descriptor = preEvaluatedFont.descriptor;
  30163. var type = preEvaluatedFont.type;
  30164. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30165. var properties;
  30166. if (!descriptor) {
  30167. if (type === 'Type3') {
  30168. descriptor = new Dict(null);
  30169. descriptor.set('FontName', Name.get(type));
  30170. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30171. } else {
  30172. var baseFontName = dict.get('BaseFont');
  30173. if (!isName(baseFontName)) {
  30174. error('Base font is not specified');
  30175. }
  30176. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30177. var metrics = this.getBaseFontMetrics(baseFontName);
  30178. var fontNameWoStyle = baseFontName.split('-')[0];
  30179. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30180. properties = {
  30181. type: type,
  30182. name: baseFontName,
  30183. widths: metrics.widths,
  30184. defaultWidth: metrics.defaultWidth,
  30185. flags: flags,
  30186. firstChar: 0,
  30187. lastChar: maxCharIndex
  30188. };
  30189. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30190. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30191. return new Font(baseFontName, null, properties);
  30192. }.bind(this));
  30193. }
  30194. }
  30195. var firstChar = dict.get('FirstChar') || 0;
  30196. var lastChar = dict.get('LastChar') || maxCharIndex;
  30197. var fontName = descriptor.get('FontName');
  30198. var baseFont = dict.get('BaseFont');
  30199. if (isString(fontName)) {
  30200. fontName = Name.get(fontName);
  30201. }
  30202. if (isString(baseFont)) {
  30203. baseFont = Name.get(baseFont);
  30204. }
  30205. if (type !== 'Type3') {
  30206. var fontNameStr = fontName && fontName.name;
  30207. var baseFontStr = baseFont && baseFont.name;
  30208. if (fontNameStr !== baseFontStr) {
  30209. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30210. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30211. fontName = baseFont;
  30212. }
  30213. }
  30214. }
  30215. fontName = fontName || baseFont;
  30216. assert(isName(fontName), 'invalid font name');
  30217. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30218. if (fontFile) {
  30219. if (fontFile.dict) {
  30220. var subtype = fontFile.dict.get('Subtype');
  30221. if (subtype) {
  30222. subtype = subtype.name;
  30223. }
  30224. var length1 = fontFile.dict.get('Length1');
  30225. var length2 = fontFile.dict.get('Length2');
  30226. var length3 = fontFile.dict.get('Length3');
  30227. }
  30228. }
  30229. properties = {
  30230. type: type,
  30231. name: fontName.name,
  30232. subtype: subtype,
  30233. file: fontFile,
  30234. length1: length1,
  30235. length2: length2,
  30236. length3: length3,
  30237. loadedName: baseDict.loadedName,
  30238. composite: composite,
  30239. wideChars: composite,
  30240. fixedPitch: false,
  30241. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30242. firstChar: firstChar || 0,
  30243. lastChar: lastChar || maxCharIndex,
  30244. bbox: descriptor.getArray('FontBBox'),
  30245. ascent: descriptor.get('Ascent'),
  30246. descent: descriptor.get('Descent'),
  30247. xHeight: descriptor.get('XHeight'),
  30248. capHeight: descriptor.get('CapHeight'),
  30249. flags: descriptor.get('Flags'),
  30250. italicAngle: descriptor.get('ItalicAngle'),
  30251. coded: false
  30252. };
  30253. var cMapPromise;
  30254. if (composite) {
  30255. var cidEncoding = baseDict.get('Encoding');
  30256. if (isName(cidEncoding)) {
  30257. properties.cidEncoding = cidEncoding.name;
  30258. }
  30259. cMapPromise = CMapFactory.create({
  30260. encoding: cidEncoding,
  30261. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30262. useCMap: null
  30263. }).then(function (cMap) {
  30264. properties.cMap = cMap;
  30265. properties.vertical = properties.cMap.vertical;
  30266. });
  30267. } else {
  30268. cMapPromise = Promise.resolve(undefined);
  30269. }
  30270. return cMapPromise.then(function () {
  30271. return this.extractDataStructures(dict, baseDict, xref, properties);
  30272. }.bind(this)).then(function (properties) {
  30273. this.extractWidths(dict, xref, descriptor, properties);
  30274. if (type === 'Type3') {
  30275. properties.isType3Font = true;
  30276. }
  30277. return new Font(fontName.name, fontFile, properties);
  30278. }.bind(this));
  30279. }
  30280. };
  30281. return PartialEvaluator;
  30282. }();
  30283. var TranslatedFont = function TranslatedFontClosure() {
  30284. function TranslatedFont(loadedName, font, dict) {
  30285. this.loadedName = loadedName;
  30286. this.font = font;
  30287. this.dict = dict;
  30288. this.type3Loaded = null;
  30289. this.sent = false;
  30290. }
  30291. TranslatedFont.prototype = {
  30292. send: function (handler) {
  30293. if (this.sent) {
  30294. return;
  30295. }
  30296. var fontData = this.font.exportData();
  30297. handler.send('commonobj', [
  30298. this.loadedName,
  30299. 'Font',
  30300. fontData
  30301. ]);
  30302. this.sent = true;
  30303. },
  30304. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  30305. assert(this.font.isType3Font);
  30306. if (this.type3Loaded) {
  30307. return this.type3Loaded;
  30308. }
  30309. var translatedFont = this.font;
  30310. var loadCharProcsPromise = Promise.resolve();
  30311. var charProcs = this.dict.get('CharProcs');
  30312. var fontResources = this.dict.get('Resources') || resources;
  30313. var charProcKeys = charProcs.getKeys();
  30314. var charProcOperatorList = Object.create(null);
  30315. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  30316. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  30317. var glyphStream = charProcs.get(key);
  30318. var operatorList = new OperatorList();
  30319. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  30320. charProcOperatorList[key] = operatorList.getIR();
  30321. parentOperatorList.addDependencies(operatorList.dependencies);
  30322. }, function (reason) {
  30323. warn('Type3 font resource \"' + key + '\" is not available');
  30324. var operatorList = new OperatorList();
  30325. charProcOperatorList[key] = operatorList.getIR();
  30326. });
  30327. }.bind(this, charProcKeys[i]));
  30328. }
  30329. this.type3Loaded = loadCharProcsPromise.then(function () {
  30330. translatedFont.charProcOperatorList = charProcOperatorList;
  30331. });
  30332. return this.type3Loaded;
  30333. }
  30334. };
  30335. return TranslatedFont;
  30336. }();
  30337. var OperatorList = function OperatorListClosure() {
  30338. var CHUNK_SIZE = 1000;
  30339. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  30340. function getTransfers(queue) {
  30341. var transfers = [];
  30342. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  30343. for (var i = 0, ii = queue.length; i < ii; i++) {
  30344. switch (fnArray[i]) {
  30345. case OPS.paintInlineImageXObject:
  30346. case OPS.paintInlineImageXObjectGroup:
  30347. case OPS.paintImageMaskXObject:
  30348. var arg = argsArray[i][0];
  30349. if (!arg.cached) {
  30350. transfers.push(arg.data.buffer);
  30351. }
  30352. break;
  30353. }
  30354. }
  30355. return transfers;
  30356. }
  30357. function OperatorList(intent, messageHandler, pageIndex) {
  30358. this.messageHandler = messageHandler;
  30359. this.fnArray = [];
  30360. this.argsArray = [];
  30361. this.dependencies = Object.create(null);
  30362. this._totalLength = 0;
  30363. this.pageIndex = pageIndex;
  30364. this.intent = intent;
  30365. }
  30366. OperatorList.prototype = {
  30367. get length() {
  30368. return this.argsArray.length;
  30369. },
  30370. get totalLength() {
  30371. return this._totalLength + this.length;
  30372. },
  30373. addOp: function (fn, args) {
  30374. this.fnArray.push(fn);
  30375. this.argsArray.push(args);
  30376. if (this.messageHandler) {
  30377. if (this.fnArray.length >= CHUNK_SIZE) {
  30378. this.flush();
  30379. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  30380. this.flush();
  30381. }
  30382. }
  30383. },
  30384. addDependency: function (dependency) {
  30385. if (dependency in this.dependencies) {
  30386. return;
  30387. }
  30388. this.dependencies[dependency] = true;
  30389. this.addOp(OPS.dependency, [dependency]);
  30390. },
  30391. addDependencies: function (dependencies) {
  30392. for (var key in dependencies) {
  30393. this.addDependency(key);
  30394. }
  30395. },
  30396. addOpList: function (opList) {
  30397. Util.extendObj(this.dependencies, opList.dependencies);
  30398. for (var i = 0, ii = opList.length; i < ii; i++) {
  30399. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  30400. }
  30401. },
  30402. getIR: function () {
  30403. return {
  30404. fnArray: this.fnArray,
  30405. argsArray: this.argsArray,
  30406. length: this.length
  30407. };
  30408. },
  30409. flush: function (lastChunk) {
  30410. if (this.intent !== 'oplist') {
  30411. new QueueOptimizer().optimize(this);
  30412. }
  30413. var transfers = getTransfers(this);
  30414. var length = this.length;
  30415. this._totalLength += length;
  30416. this.messageHandler.send('RenderPageChunk', {
  30417. operatorList: {
  30418. fnArray: this.fnArray,
  30419. argsArray: this.argsArray,
  30420. lastChunk: lastChunk,
  30421. length: length
  30422. },
  30423. pageIndex: this.pageIndex,
  30424. intent: this.intent
  30425. }, transfers);
  30426. this.dependencies = Object.create(null);
  30427. this.fnArray.length = 0;
  30428. this.argsArray.length = 0;
  30429. }
  30430. };
  30431. return OperatorList;
  30432. }();
  30433. var StateManager = function StateManagerClosure() {
  30434. function StateManager(initialState) {
  30435. this.state = initialState;
  30436. this.stateStack = [];
  30437. }
  30438. StateManager.prototype = {
  30439. save: function () {
  30440. var old = this.state;
  30441. this.stateStack.push(this.state);
  30442. this.state = old.clone();
  30443. },
  30444. restore: function () {
  30445. var prev = this.stateStack.pop();
  30446. if (prev) {
  30447. this.state = prev;
  30448. }
  30449. },
  30450. transform: function (args) {
  30451. this.state.ctm = Util.transform(this.state.ctm, args);
  30452. }
  30453. };
  30454. return StateManager;
  30455. }();
  30456. var TextState = function TextStateClosure() {
  30457. function TextState() {
  30458. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30459. this.fontName = null;
  30460. this.fontSize = 0;
  30461. this.font = null;
  30462. this.fontMatrix = FONT_IDENTITY_MATRIX;
  30463. this.textMatrix = IDENTITY_MATRIX.slice();
  30464. this.textLineMatrix = IDENTITY_MATRIX.slice();
  30465. this.charSpacing = 0;
  30466. this.wordSpacing = 0;
  30467. this.leading = 0;
  30468. this.textHScale = 1;
  30469. this.textRise = 0;
  30470. }
  30471. TextState.prototype = {
  30472. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30473. var m = this.textMatrix;
  30474. m[0] = a;
  30475. m[1] = b;
  30476. m[2] = c;
  30477. m[3] = d;
  30478. m[4] = e;
  30479. m[5] = f;
  30480. },
  30481. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30482. var m = this.textLineMatrix;
  30483. m[0] = a;
  30484. m[1] = b;
  30485. m[2] = c;
  30486. m[3] = d;
  30487. m[4] = e;
  30488. m[5] = f;
  30489. },
  30490. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  30491. var m = this.textMatrix;
  30492. m[4] = m[0] * x + m[2] * y + m[4];
  30493. m[5] = m[1] * x + m[3] * y + m[5];
  30494. },
  30495. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  30496. var m = this.textLineMatrix;
  30497. m[4] = m[0] * x + m[2] * y + m[4];
  30498. m[5] = m[1] * x + m[3] * y + m[5];
  30499. },
  30500. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  30501. var font = this.font;
  30502. if (!font) {
  30503. return null;
  30504. }
  30505. var m = this.textLineMatrix;
  30506. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  30507. return null;
  30508. }
  30509. var txDiff = e - m[4], tyDiff = f - m[5];
  30510. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  30511. return null;
  30512. }
  30513. var tx, ty, denominator = a * d - b * c;
  30514. if (font.vertical) {
  30515. tx = -tyDiff * c / denominator;
  30516. ty = tyDiff * a / denominator;
  30517. } else {
  30518. tx = txDiff * d / denominator;
  30519. ty = -txDiff * b / denominator;
  30520. }
  30521. return {
  30522. width: tx,
  30523. height: ty,
  30524. value: font.vertical ? ty : tx
  30525. };
  30526. },
  30527. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  30528. var tsm = [
  30529. this.fontSize * this.textHScale,
  30530. 0,
  30531. 0,
  30532. this.fontSize,
  30533. 0,
  30534. this.textRise
  30535. ];
  30536. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  30537. },
  30538. carriageReturn: function TextState_carriageReturn() {
  30539. this.translateTextLineMatrix(0, -this.leading);
  30540. this.textMatrix = this.textLineMatrix.slice();
  30541. },
  30542. clone: function TextState_clone() {
  30543. var clone = Object.create(this);
  30544. clone.textMatrix = this.textMatrix.slice();
  30545. clone.textLineMatrix = this.textLineMatrix.slice();
  30546. clone.fontMatrix = this.fontMatrix.slice();
  30547. return clone;
  30548. }
  30549. };
  30550. return TextState;
  30551. }();
  30552. var EvalState = function EvalStateClosure() {
  30553. function EvalState() {
  30554. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30555. this.font = null;
  30556. this.textRenderingMode = TextRenderingMode.FILL;
  30557. this.fillColorSpace = ColorSpace.singletons.gray;
  30558. this.strokeColorSpace = ColorSpace.singletons.gray;
  30559. }
  30560. EvalState.prototype = {
  30561. clone: function CanvasExtraState_clone() {
  30562. return Object.create(this);
  30563. }
  30564. };
  30565. return EvalState;
  30566. }();
  30567. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  30568. var getOPMap = getLookupTableFactory(function (t) {
  30569. t['w'] = {
  30570. id: OPS.setLineWidth,
  30571. numArgs: 1,
  30572. variableArgs: false
  30573. };
  30574. t['J'] = {
  30575. id: OPS.setLineCap,
  30576. numArgs: 1,
  30577. variableArgs: false
  30578. };
  30579. t['j'] = {
  30580. id: OPS.setLineJoin,
  30581. numArgs: 1,
  30582. variableArgs: false
  30583. };
  30584. t['M'] = {
  30585. id: OPS.setMiterLimit,
  30586. numArgs: 1,
  30587. variableArgs: false
  30588. };
  30589. t['d'] = {
  30590. id: OPS.setDash,
  30591. numArgs: 2,
  30592. variableArgs: false
  30593. };
  30594. t['ri'] = {
  30595. id: OPS.setRenderingIntent,
  30596. numArgs: 1,
  30597. variableArgs: false
  30598. };
  30599. t['i'] = {
  30600. id: OPS.setFlatness,
  30601. numArgs: 1,
  30602. variableArgs: false
  30603. };
  30604. t['gs'] = {
  30605. id: OPS.setGState,
  30606. numArgs: 1,
  30607. variableArgs: false
  30608. };
  30609. t['q'] = {
  30610. id: OPS.save,
  30611. numArgs: 0,
  30612. variableArgs: false
  30613. };
  30614. t['Q'] = {
  30615. id: OPS.restore,
  30616. numArgs: 0,
  30617. variableArgs: false
  30618. };
  30619. t['cm'] = {
  30620. id: OPS.transform,
  30621. numArgs: 6,
  30622. variableArgs: false
  30623. };
  30624. t['m'] = {
  30625. id: OPS.moveTo,
  30626. numArgs: 2,
  30627. variableArgs: false
  30628. };
  30629. t['l'] = {
  30630. id: OPS.lineTo,
  30631. numArgs: 2,
  30632. variableArgs: false
  30633. };
  30634. t['c'] = {
  30635. id: OPS.curveTo,
  30636. numArgs: 6,
  30637. variableArgs: false
  30638. };
  30639. t['v'] = {
  30640. id: OPS.curveTo2,
  30641. numArgs: 4,
  30642. variableArgs: false
  30643. };
  30644. t['y'] = {
  30645. id: OPS.curveTo3,
  30646. numArgs: 4,
  30647. variableArgs: false
  30648. };
  30649. t['h'] = {
  30650. id: OPS.closePath,
  30651. numArgs: 0,
  30652. variableArgs: false
  30653. };
  30654. t['re'] = {
  30655. id: OPS.rectangle,
  30656. numArgs: 4,
  30657. variableArgs: false
  30658. };
  30659. t['S'] = {
  30660. id: OPS.stroke,
  30661. numArgs: 0,
  30662. variableArgs: false
  30663. };
  30664. t['s'] = {
  30665. id: OPS.closeStroke,
  30666. numArgs: 0,
  30667. variableArgs: false
  30668. };
  30669. t['f'] = {
  30670. id: OPS.fill,
  30671. numArgs: 0,
  30672. variableArgs: false
  30673. };
  30674. t['F'] = {
  30675. id: OPS.fill,
  30676. numArgs: 0,
  30677. variableArgs: false
  30678. };
  30679. t['f*'] = {
  30680. id: OPS.eoFill,
  30681. numArgs: 0,
  30682. variableArgs: false
  30683. };
  30684. t['B'] = {
  30685. id: OPS.fillStroke,
  30686. numArgs: 0,
  30687. variableArgs: false
  30688. };
  30689. t['B*'] = {
  30690. id: OPS.eoFillStroke,
  30691. numArgs: 0,
  30692. variableArgs: false
  30693. };
  30694. t['b'] = {
  30695. id: OPS.closeFillStroke,
  30696. numArgs: 0,
  30697. variableArgs: false
  30698. };
  30699. t['b*'] = {
  30700. id: OPS.closeEOFillStroke,
  30701. numArgs: 0,
  30702. variableArgs: false
  30703. };
  30704. t['n'] = {
  30705. id: OPS.endPath,
  30706. numArgs: 0,
  30707. variableArgs: false
  30708. };
  30709. t['W'] = {
  30710. id: OPS.clip,
  30711. numArgs: 0,
  30712. variableArgs: false
  30713. };
  30714. t['W*'] = {
  30715. id: OPS.eoClip,
  30716. numArgs: 0,
  30717. variableArgs: false
  30718. };
  30719. t['BT'] = {
  30720. id: OPS.beginText,
  30721. numArgs: 0,
  30722. variableArgs: false
  30723. };
  30724. t['ET'] = {
  30725. id: OPS.endText,
  30726. numArgs: 0,
  30727. variableArgs: false
  30728. };
  30729. t['Tc'] = {
  30730. id: OPS.setCharSpacing,
  30731. numArgs: 1,
  30732. variableArgs: false
  30733. };
  30734. t['Tw'] = {
  30735. id: OPS.setWordSpacing,
  30736. numArgs: 1,
  30737. variableArgs: false
  30738. };
  30739. t['Tz'] = {
  30740. id: OPS.setHScale,
  30741. numArgs: 1,
  30742. variableArgs: false
  30743. };
  30744. t['TL'] = {
  30745. id: OPS.setLeading,
  30746. numArgs: 1,
  30747. variableArgs: false
  30748. };
  30749. t['Tf'] = {
  30750. id: OPS.setFont,
  30751. numArgs: 2,
  30752. variableArgs: false
  30753. };
  30754. t['Tr'] = {
  30755. id: OPS.setTextRenderingMode,
  30756. numArgs: 1,
  30757. variableArgs: false
  30758. };
  30759. t['Ts'] = {
  30760. id: OPS.setTextRise,
  30761. numArgs: 1,
  30762. variableArgs: false
  30763. };
  30764. t['Td'] = {
  30765. id: OPS.moveText,
  30766. numArgs: 2,
  30767. variableArgs: false
  30768. };
  30769. t['TD'] = {
  30770. id: OPS.setLeadingMoveText,
  30771. numArgs: 2,
  30772. variableArgs: false
  30773. };
  30774. t['Tm'] = {
  30775. id: OPS.setTextMatrix,
  30776. numArgs: 6,
  30777. variableArgs: false
  30778. };
  30779. t['T*'] = {
  30780. id: OPS.nextLine,
  30781. numArgs: 0,
  30782. variableArgs: false
  30783. };
  30784. t['Tj'] = {
  30785. id: OPS.showText,
  30786. numArgs: 1,
  30787. variableArgs: false
  30788. };
  30789. t['TJ'] = {
  30790. id: OPS.showSpacedText,
  30791. numArgs: 1,
  30792. variableArgs: false
  30793. };
  30794. t['\''] = {
  30795. id: OPS.nextLineShowText,
  30796. numArgs: 1,
  30797. variableArgs: false
  30798. };
  30799. t['"'] = {
  30800. id: OPS.nextLineSetSpacingShowText,
  30801. numArgs: 3,
  30802. variableArgs: false
  30803. };
  30804. t['d0'] = {
  30805. id: OPS.setCharWidth,
  30806. numArgs: 2,
  30807. variableArgs: false
  30808. };
  30809. t['d1'] = {
  30810. id: OPS.setCharWidthAndBounds,
  30811. numArgs: 6,
  30812. variableArgs: false
  30813. };
  30814. t['CS'] = {
  30815. id: OPS.setStrokeColorSpace,
  30816. numArgs: 1,
  30817. variableArgs: false
  30818. };
  30819. t['cs'] = {
  30820. id: OPS.setFillColorSpace,
  30821. numArgs: 1,
  30822. variableArgs: false
  30823. };
  30824. t['SC'] = {
  30825. id: OPS.setStrokeColor,
  30826. numArgs: 4,
  30827. variableArgs: true
  30828. };
  30829. t['SCN'] = {
  30830. id: OPS.setStrokeColorN,
  30831. numArgs: 33,
  30832. variableArgs: true
  30833. };
  30834. t['sc'] = {
  30835. id: OPS.setFillColor,
  30836. numArgs: 4,
  30837. variableArgs: true
  30838. };
  30839. t['scn'] = {
  30840. id: OPS.setFillColorN,
  30841. numArgs: 33,
  30842. variableArgs: true
  30843. };
  30844. t['G'] = {
  30845. id: OPS.setStrokeGray,
  30846. numArgs: 1,
  30847. variableArgs: false
  30848. };
  30849. t['g'] = {
  30850. id: OPS.setFillGray,
  30851. numArgs: 1,
  30852. variableArgs: false
  30853. };
  30854. t['RG'] = {
  30855. id: OPS.setStrokeRGBColor,
  30856. numArgs: 3,
  30857. variableArgs: false
  30858. };
  30859. t['rg'] = {
  30860. id: OPS.setFillRGBColor,
  30861. numArgs: 3,
  30862. variableArgs: false
  30863. };
  30864. t['K'] = {
  30865. id: OPS.setStrokeCMYKColor,
  30866. numArgs: 4,
  30867. variableArgs: false
  30868. };
  30869. t['k'] = {
  30870. id: OPS.setFillCMYKColor,
  30871. numArgs: 4,
  30872. variableArgs: false
  30873. };
  30874. t['sh'] = {
  30875. id: OPS.shadingFill,
  30876. numArgs: 1,
  30877. variableArgs: false
  30878. };
  30879. t['BI'] = {
  30880. id: OPS.beginInlineImage,
  30881. numArgs: 0,
  30882. variableArgs: false
  30883. };
  30884. t['ID'] = {
  30885. id: OPS.beginImageData,
  30886. numArgs: 0,
  30887. variableArgs: false
  30888. };
  30889. t['EI'] = {
  30890. id: OPS.endInlineImage,
  30891. numArgs: 1,
  30892. variableArgs: false
  30893. };
  30894. t['Do'] = {
  30895. id: OPS.paintXObject,
  30896. numArgs: 1,
  30897. variableArgs: false
  30898. };
  30899. t['MP'] = {
  30900. id: OPS.markPoint,
  30901. numArgs: 1,
  30902. variableArgs: false
  30903. };
  30904. t['DP'] = {
  30905. id: OPS.markPointProps,
  30906. numArgs: 2,
  30907. variableArgs: false
  30908. };
  30909. t['BMC'] = {
  30910. id: OPS.beginMarkedContent,
  30911. numArgs: 1,
  30912. variableArgs: false
  30913. };
  30914. t['BDC'] = {
  30915. id: OPS.beginMarkedContentProps,
  30916. numArgs: 2,
  30917. variableArgs: false
  30918. };
  30919. t['EMC'] = {
  30920. id: OPS.endMarkedContent,
  30921. numArgs: 0,
  30922. variableArgs: false
  30923. };
  30924. t['BX'] = {
  30925. id: OPS.beginCompat,
  30926. numArgs: 0,
  30927. variableArgs: false
  30928. };
  30929. t['EX'] = {
  30930. id: OPS.endCompat,
  30931. numArgs: 0,
  30932. variableArgs: false
  30933. };
  30934. t['BM'] = null;
  30935. t['BD'] = null;
  30936. t['true'] = null;
  30937. t['fa'] = null;
  30938. t['fal'] = null;
  30939. t['fals'] = null;
  30940. t['false'] = null;
  30941. t['nu'] = null;
  30942. t['nul'] = null;
  30943. t['null'] = null;
  30944. });
  30945. function EvaluatorPreprocessor(stream, xref, stateManager) {
  30946. this.opMap = getOPMap();
  30947. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  30948. this.stateManager = stateManager;
  30949. this.nonProcessedArgs = [];
  30950. }
  30951. EvaluatorPreprocessor.prototype = {
  30952. get savedStatesDepth() {
  30953. return this.stateManager.stateStack.length;
  30954. },
  30955. read: function EvaluatorPreprocessor_read(operation) {
  30956. var args = operation.args;
  30957. while (true) {
  30958. var obj = this.parser.getObj();
  30959. if (isCmd(obj)) {
  30960. var cmd = obj.cmd;
  30961. var opSpec = this.opMap[cmd];
  30962. if (!opSpec) {
  30963. warn('Unknown command "' + cmd + '"');
  30964. continue;
  30965. }
  30966. var fn = opSpec.id;
  30967. var numArgs = opSpec.numArgs;
  30968. var argsLength = args !== null ? args.length : 0;
  30969. if (!opSpec.variableArgs) {
  30970. if (argsLength !== numArgs) {
  30971. var nonProcessedArgs = this.nonProcessedArgs;
  30972. while (argsLength > numArgs) {
  30973. nonProcessedArgs.push(args.shift());
  30974. argsLength--;
  30975. }
  30976. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  30977. if (args === null) {
  30978. args = [];
  30979. }
  30980. args.unshift(nonProcessedArgs.pop());
  30981. argsLength++;
  30982. }
  30983. }
  30984. if (argsLength < numArgs) {
  30985. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  30986. if (args !== null) {
  30987. args.length = 0;
  30988. }
  30989. continue;
  30990. }
  30991. } else if (argsLength > numArgs) {
  30992. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  30993. }
  30994. this.preprocessCommand(fn, args);
  30995. operation.fn = fn;
  30996. operation.args = args;
  30997. return true;
  30998. }
  30999. if (isEOF(obj)) {
  31000. return false;
  31001. }
  31002. if (obj !== null) {
  31003. if (args === null) {
  31004. args = [];
  31005. }
  31006. args.push(obj);
  31007. assert(args.length <= 33, 'Too many arguments');
  31008. }
  31009. }
  31010. },
  31011. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31012. switch (fn | 0) {
  31013. case OPS.save:
  31014. this.stateManager.save();
  31015. break;
  31016. case OPS.restore:
  31017. this.stateManager.restore();
  31018. break;
  31019. case OPS.transform:
  31020. this.stateManager.transform(args);
  31021. break;
  31022. }
  31023. }
  31024. };
  31025. return EvaluatorPreprocessor;
  31026. }();
  31027. var QueueOptimizer = function QueueOptimizerClosure() {
  31028. function addState(parentState, pattern, fn) {
  31029. var state = parentState;
  31030. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31031. var item = pattern[i];
  31032. state = state[item] || (state[item] = []);
  31033. }
  31034. state[pattern[pattern.length - 1]] = fn;
  31035. }
  31036. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31037. var iFirstPIMXO = iFirstSave + 2;
  31038. for (var i = 0; i < count; i++) {
  31039. var arg = argsArray[iFirstPIMXO + 4 * i];
  31040. var imageMask = arg.length === 1 && arg[0];
  31041. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31042. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31043. continue;
  31044. }
  31045. break;
  31046. }
  31047. return count - i;
  31048. }
  31049. var InitialState = [];
  31050. addState(InitialState, [
  31051. OPS.save,
  31052. OPS.transform,
  31053. OPS.paintInlineImageXObject,
  31054. OPS.restore
  31055. ], function foundInlineImageGroup(context) {
  31056. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31057. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31058. var MAX_WIDTH = 1000;
  31059. var IMAGE_PADDING = 1;
  31060. var fnArray = context.fnArray, argsArray = context.argsArray;
  31061. var curr = context.iCurr;
  31062. var iFirstSave = curr - 3;
  31063. var iFirstTransform = curr - 2;
  31064. var iFirstPIIXO = curr - 1;
  31065. var i = iFirstSave + 4;
  31066. var ii = fnArray.length;
  31067. while (i + 3 < ii) {
  31068. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31069. break;
  31070. }
  31071. i += 4;
  31072. }
  31073. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31074. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31075. return i;
  31076. }
  31077. var maxX = 0;
  31078. var map = [], maxLineHeight = 0;
  31079. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31080. var q;
  31081. for (q = 0; q < count; q++) {
  31082. var transform = argsArray[iFirstTransform + (q << 2)];
  31083. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31084. if (currentX + img.width > MAX_WIDTH) {
  31085. maxX = Math.max(maxX, currentX);
  31086. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31087. currentX = 0;
  31088. maxLineHeight = 0;
  31089. }
  31090. map.push({
  31091. transform: transform,
  31092. x: currentX,
  31093. y: currentY,
  31094. w: img.width,
  31095. h: img.height
  31096. });
  31097. currentX += img.width + 2 * IMAGE_PADDING;
  31098. maxLineHeight = Math.max(maxLineHeight, img.height);
  31099. }
  31100. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31101. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31102. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31103. var imgRowSize = imgWidth << 2;
  31104. for (q = 0; q < count; q++) {
  31105. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31106. var rowSize = map[q].w << 2;
  31107. var dataOffset = 0;
  31108. var offset = map[q].x + map[q].y * imgWidth << 2;
  31109. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31110. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31111. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31112. dataOffset += rowSize;
  31113. offset += imgRowSize;
  31114. }
  31115. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31116. while (offset >= 0) {
  31117. data[offset - 4] = data[offset];
  31118. data[offset - 3] = data[offset + 1];
  31119. data[offset - 2] = data[offset + 2];
  31120. data[offset - 1] = data[offset + 3];
  31121. data[offset + rowSize] = data[offset + rowSize - 4];
  31122. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31123. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31124. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31125. offset -= imgRowSize;
  31126. }
  31127. }
  31128. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31129. argsArray.splice(iFirstSave, count * 4, [
  31130. {
  31131. width: imgWidth,
  31132. height: imgHeight,
  31133. kind: ImageKind.RGBA_32BPP,
  31134. data: imgData
  31135. },
  31136. map
  31137. ]);
  31138. return iFirstSave + 1;
  31139. });
  31140. addState(InitialState, [
  31141. OPS.save,
  31142. OPS.transform,
  31143. OPS.paintImageMaskXObject,
  31144. OPS.restore
  31145. ], function foundImageMaskGroup(context) {
  31146. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31147. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31148. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31149. var fnArray = context.fnArray, argsArray = context.argsArray;
  31150. var curr = context.iCurr;
  31151. var iFirstSave = curr - 3;
  31152. var iFirstTransform = curr - 2;
  31153. var iFirstPIMXO = curr - 1;
  31154. var i = iFirstSave + 4;
  31155. var ii = fnArray.length;
  31156. while (i + 3 < ii) {
  31157. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31158. break;
  31159. }
  31160. i += 4;
  31161. }
  31162. var count = (i - iFirstSave) / 4;
  31163. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31164. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31165. return i;
  31166. }
  31167. var q;
  31168. var isSameImage = false;
  31169. var iTransform, transformArgs;
  31170. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31171. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31172. isSameImage = true;
  31173. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31174. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31175. iTransform = iFirstTransform + 4;
  31176. var iPIMXO = iFirstPIMXO + 4;
  31177. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31178. transformArgs = argsArray[iTransform];
  31179. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31180. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31181. isSameImage = false;
  31182. } else {
  31183. count = q;
  31184. }
  31185. break;
  31186. }
  31187. }
  31188. }
  31189. if (isSameImage) {
  31190. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31191. var positions = new Float32Array(count * 2);
  31192. iTransform = iFirstTransform;
  31193. for (q = 0; q < count; q++, iTransform += 4) {
  31194. transformArgs = argsArray[iTransform];
  31195. positions[q << 1] = transformArgs[4];
  31196. positions[(q << 1) + 1] = transformArgs[5];
  31197. }
  31198. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31199. argsArray.splice(iFirstSave, count * 4, [
  31200. firstPIMXOArg0,
  31201. firstTransformArg0,
  31202. firstTransformArg3,
  31203. positions
  31204. ]);
  31205. } else {
  31206. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31207. var images = [];
  31208. for (q = 0; q < count; q++) {
  31209. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31210. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31211. images.push({
  31212. data: maskParams.data,
  31213. width: maskParams.width,
  31214. height: maskParams.height,
  31215. transform: transformArgs
  31216. });
  31217. }
  31218. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31219. argsArray.splice(iFirstSave, count * 4, [images]);
  31220. }
  31221. return iFirstSave + 1;
  31222. });
  31223. addState(InitialState, [
  31224. OPS.save,
  31225. OPS.transform,
  31226. OPS.paintImageXObject,
  31227. OPS.restore
  31228. ], function (context) {
  31229. var MIN_IMAGES_IN_BLOCK = 3;
  31230. var MAX_IMAGES_IN_BLOCK = 1000;
  31231. var fnArray = context.fnArray, argsArray = context.argsArray;
  31232. var curr = context.iCurr;
  31233. var iFirstSave = curr - 3;
  31234. var iFirstTransform = curr - 2;
  31235. var iFirstPIXO = curr - 1;
  31236. var iFirstRestore = curr;
  31237. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31238. return iFirstRestore + 1;
  31239. }
  31240. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31241. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31242. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31243. var i = iFirstSave + 4;
  31244. var ii = fnArray.length;
  31245. while (i + 3 < ii) {
  31246. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31247. break;
  31248. }
  31249. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31250. break;
  31251. }
  31252. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31253. break;
  31254. }
  31255. i += 4;
  31256. }
  31257. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31258. if (count < MIN_IMAGES_IN_BLOCK) {
  31259. return i;
  31260. }
  31261. var positions = new Float32Array(count * 2);
  31262. var iTransform = iFirstTransform;
  31263. for (var q = 0; q < count; q++, iTransform += 4) {
  31264. var transformArgs = argsArray[iTransform];
  31265. positions[q << 1] = transformArgs[4];
  31266. positions[(q << 1) + 1] = transformArgs[5];
  31267. }
  31268. var args = [
  31269. firstPIXOArg0,
  31270. firstTransformArg0,
  31271. firstTransformArg3,
  31272. positions
  31273. ];
  31274. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31275. argsArray.splice(iFirstSave, count * 4, args);
  31276. return iFirstSave + 1;
  31277. });
  31278. addState(InitialState, [
  31279. OPS.beginText,
  31280. OPS.setFont,
  31281. OPS.setTextMatrix,
  31282. OPS.showText,
  31283. OPS.endText
  31284. ], function (context) {
  31285. var MIN_CHARS_IN_BLOCK = 3;
  31286. var MAX_CHARS_IN_BLOCK = 1000;
  31287. var fnArray = context.fnArray, argsArray = context.argsArray;
  31288. var curr = context.iCurr;
  31289. var iFirstBeginText = curr - 4;
  31290. var iFirstSetFont = curr - 3;
  31291. var iFirstSetTextMatrix = curr - 2;
  31292. var iFirstShowText = curr - 1;
  31293. var iFirstEndText = curr;
  31294. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  31295. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  31296. var i = iFirstBeginText + 5;
  31297. var ii = fnArray.length;
  31298. while (i + 4 < ii) {
  31299. 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) {
  31300. break;
  31301. }
  31302. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  31303. break;
  31304. }
  31305. i += 5;
  31306. }
  31307. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  31308. if (count < MIN_CHARS_IN_BLOCK) {
  31309. return i;
  31310. }
  31311. var iFirst = iFirstBeginText;
  31312. 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) {
  31313. count++;
  31314. iFirst -= 5;
  31315. }
  31316. var iEndText = iFirst + 4;
  31317. for (var q = 1; q < count; q++) {
  31318. fnArray.splice(iEndText, 3);
  31319. argsArray.splice(iEndText, 3);
  31320. iEndText += 2;
  31321. }
  31322. return iEndText + 1;
  31323. });
  31324. function QueueOptimizer() {
  31325. }
  31326. QueueOptimizer.prototype = {
  31327. optimize: function QueueOptimizer_optimize(queue) {
  31328. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31329. var context = {
  31330. iCurr: 0,
  31331. fnArray: fnArray,
  31332. argsArray: argsArray
  31333. };
  31334. var state;
  31335. var i = 0, ii = fnArray.length;
  31336. while (i < ii) {
  31337. state = (state || InitialState)[fnArray[i]];
  31338. if (typeof state === 'function') {
  31339. context.iCurr = i;
  31340. i = state(context);
  31341. state = undefined;
  31342. ii = context.fnArray.length;
  31343. } else {
  31344. i++;
  31345. }
  31346. }
  31347. }
  31348. };
  31349. return QueueOptimizer;
  31350. }();
  31351. exports.OperatorList = OperatorList;
  31352. exports.PartialEvaluator = PartialEvaluator;
  31353. /***/ }),
  31354. /* 19 */
  31355. /***/ (function(module, exports, __w_pdfjs_require__) {
  31356. "use strict";
  31357. var sharedUtil = __w_pdfjs_require__(0);
  31358. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  31359. var info = sharedUtil.info;
  31360. var warn = sharedUtil.warn;
  31361. var error = sharedUtil.error;
  31362. var log2 = sharedUtil.log2;
  31363. var readUint16 = sharedUtil.readUint16;
  31364. var readUint32 = sharedUtil.readUint32;
  31365. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  31366. var JpxImage = function JpxImageClosure() {
  31367. var SubbandsGainLog2 = {
  31368. 'LL': 0,
  31369. 'LH': 1,
  31370. 'HL': 1,
  31371. 'HH': 2
  31372. };
  31373. function JpxImage() {
  31374. this.failOnCorruptedImage = false;
  31375. }
  31376. JpxImage.prototype = {
  31377. parse: function JpxImage_parse(data) {
  31378. var head = readUint16(data, 0);
  31379. if (head === 0xFF4F) {
  31380. this.parseCodestream(data, 0, data.length);
  31381. return;
  31382. }
  31383. var position = 0, length = data.length;
  31384. while (position < length) {
  31385. var headerSize = 8;
  31386. var lbox = readUint32(data, position);
  31387. var tbox = readUint32(data, position + 4);
  31388. position += headerSize;
  31389. if (lbox === 1) {
  31390. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  31391. position += 8;
  31392. headerSize += 8;
  31393. }
  31394. if (lbox === 0) {
  31395. lbox = length - position + headerSize;
  31396. }
  31397. if (lbox < headerSize) {
  31398. error('JPX Error: Invalid box field size');
  31399. }
  31400. var dataLength = lbox - headerSize;
  31401. var jumpDataLength = true;
  31402. switch (tbox) {
  31403. case 0x6A703268:
  31404. jumpDataLength = false;
  31405. break;
  31406. case 0x636F6C72:
  31407. var method = data[position];
  31408. if (method === 1) {
  31409. var colorspace = readUint32(data, position + 3);
  31410. switch (colorspace) {
  31411. case 16:
  31412. case 17:
  31413. case 18:
  31414. break;
  31415. default:
  31416. warn('Unknown colorspace ' + colorspace);
  31417. break;
  31418. }
  31419. } else if (method === 2) {
  31420. info('ICC profile not supported');
  31421. }
  31422. break;
  31423. case 0x6A703263:
  31424. this.parseCodestream(data, position, position + dataLength);
  31425. break;
  31426. case 0x6A502020:
  31427. if (0x0d0a870a !== readUint32(data, position)) {
  31428. warn('Invalid JP2 signature');
  31429. }
  31430. break;
  31431. case 0x6A501A1A:
  31432. case 0x66747970:
  31433. case 0x72726571:
  31434. case 0x72657320:
  31435. case 0x69686472:
  31436. break;
  31437. default:
  31438. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  31439. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  31440. break;
  31441. }
  31442. if (jumpDataLength) {
  31443. position += dataLength;
  31444. }
  31445. }
  31446. },
  31447. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  31448. var newByte = stream.getByte();
  31449. while (newByte >= 0) {
  31450. var oldByte = newByte;
  31451. newByte = stream.getByte();
  31452. var code = oldByte << 8 | newByte;
  31453. if (code === 0xFF51) {
  31454. stream.skip(4);
  31455. var Xsiz = stream.getInt32() >>> 0;
  31456. var Ysiz = stream.getInt32() >>> 0;
  31457. var XOsiz = stream.getInt32() >>> 0;
  31458. var YOsiz = stream.getInt32() >>> 0;
  31459. stream.skip(16);
  31460. var Csiz = stream.getUint16();
  31461. this.width = Xsiz - XOsiz;
  31462. this.height = Ysiz - YOsiz;
  31463. this.componentsCount = Csiz;
  31464. this.bitsPerComponent = 8;
  31465. return;
  31466. }
  31467. }
  31468. error('JPX Error: No size marker found in JPX stream');
  31469. },
  31470. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  31471. var context = {};
  31472. var doNotRecover = false;
  31473. try {
  31474. var position = start;
  31475. while (position + 1 < end) {
  31476. var code = readUint16(data, position);
  31477. position += 2;
  31478. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  31479. switch (code) {
  31480. case 0xFF4F:
  31481. context.mainHeader = true;
  31482. break;
  31483. case 0xFFD9:
  31484. break;
  31485. case 0xFF51:
  31486. length = readUint16(data, position);
  31487. var siz = {};
  31488. siz.Xsiz = readUint32(data, position + 4);
  31489. siz.Ysiz = readUint32(data, position + 8);
  31490. siz.XOsiz = readUint32(data, position + 12);
  31491. siz.YOsiz = readUint32(data, position + 16);
  31492. siz.XTsiz = readUint32(data, position + 20);
  31493. siz.YTsiz = readUint32(data, position + 24);
  31494. siz.XTOsiz = readUint32(data, position + 28);
  31495. siz.YTOsiz = readUint32(data, position + 32);
  31496. var componentsCount = readUint16(data, position + 36);
  31497. siz.Csiz = componentsCount;
  31498. var components = [];
  31499. j = position + 38;
  31500. for (var i = 0; i < componentsCount; i++) {
  31501. var component = {
  31502. precision: (data[j] & 0x7F) + 1,
  31503. isSigned: !!(data[j] & 0x80),
  31504. XRsiz: data[j + 1],
  31505. YRsiz: data[j + 1]
  31506. };
  31507. calculateComponentDimensions(component, siz);
  31508. components.push(component);
  31509. }
  31510. context.SIZ = siz;
  31511. context.components = components;
  31512. calculateTileGrids(context, components);
  31513. context.QCC = [];
  31514. context.COC = [];
  31515. break;
  31516. case 0xFF5C:
  31517. length = readUint16(data, position);
  31518. var qcd = {};
  31519. j = position + 2;
  31520. sqcd = data[j++];
  31521. switch (sqcd & 0x1F) {
  31522. case 0:
  31523. spqcdSize = 8;
  31524. scalarExpounded = true;
  31525. break;
  31526. case 1:
  31527. spqcdSize = 16;
  31528. scalarExpounded = false;
  31529. break;
  31530. case 2:
  31531. spqcdSize = 16;
  31532. scalarExpounded = true;
  31533. break;
  31534. default:
  31535. throw new Error('Invalid SQcd value ' + sqcd);
  31536. }
  31537. qcd.noQuantization = spqcdSize === 8;
  31538. qcd.scalarExpounded = scalarExpounded;
  31539. qcd.guardBits = sqcd >> 5;
  31540. spqcds = [];
  31541. while (j < length + position) {
  31542. var spqcd = {};
  31543. if (spqcdSize === 8) {
  31544. spqcd.epsilon = data[j++] >> 3;
  31545. spqcd.mu = 0;
  31546. } else {
  31547. spqcd.epsilon = data[j] >> 3;
  31548. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31549. j += 2;
  31550. }
  31551. spqcds.push(spqcd);
  31552. }
  31553. qcd.SPqcds = spqcds;
  31554. if (context.mainHeader) {
  31555. context.QCD = qcd;
  31556. } else {
  31557. context.currentTile.QCD = qcd;
  31558. context.currentTile.QCC = [];
  31559. }
  31560. break;
  31561. case 0xFF5D:
  31562. length = readUint16(data, position);
  31563. var qcc = {};
  31564. j = position + 2;
  31565. var cqcc;
  31566. if (context.SIZ.Csiz < 257) {
  31567. cqcc = data[j++];
  31568. } else {
  31569. cqcc = readUint16(data, j);
  31570. j += 2;
  31571. }
  31572. sqcd = data[j++];
  31573. switch (sqcd & 0x1F) {
  31574. case 0:
  31575. spqcdSize = 8;
  31576. scalarExpounded = true;
  31577. break;
  31578. case 1:
  31579. spqcdSize = 16;
  31580. scalarExpounded = false;
  31581. break;
  31582. case 2:
  31583. spqcdSize = 16;
  31584. scalarExpounded = true;
  31585. break;
  31586. default:
  31587. throw new Error('Invalid SQcd value ' + sqcd);
  31588. }
  31589. qcc.noQuantization = spqcdSize === 8;
  31590. qcc.scalarExpounded = scalarExpounded;
  31591. qcc.guardBits = sqcd >> 5;
  31592. spqcds = [];
  31593. while (j < length + position) {
  31594. spqcd = {};
  31595. if (spqcdSize === 8) {
  31596. spqcd.epsilon = data[j++] >> 3;
  31597. spqcd.mu = 0;
  31598. } else {
  31599. spqcd.epsilon = data[j] >> 3;
  31600. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31601. j += 2;
  31602. }
  31603. spqcds.push(spqcd);
  31604. }
  31605. qcc.SPqcds = spqcds;
  31606. if (context.mainHeader) {
  31607. context.QCC[cqcc] = qcc;
  31608. } else {
  31609. context.currentTile.QCC[cqcc] = qcc;
  31610. }
  31611. break;
  31612. case 0xFF52:
  31613. length = readUint16(data, position);
  31614. var cod = {};
  31615. j = position + 2;
  31616. var scod = data[j++];
  31617. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  31618. cod.sopMarkerUsed = !!(scod & 2);
  31619. cod.ephMarkerUsed = !!(scod & 4);
  31620. cod.progressionOrder = data[j++];
  31621. cod.layersCount = readUint16(data, j);
  31622. j += 2;
  31623. cod.multipleComponentTransform = data[j++];
  31624. cod.decompositionLevelsCount = data[j++];
  31625. cod.xcb = (data[j++] & 0xF) + 2;
  31626. cod.ycb = (data[j++] & 0xF) + 2;
  31627. var blockStyle = data[j++];
  31628. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  31629. cod.resetContextProbabilities = !!(blockStyle & 2);
  31630. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  31631. cod.verticalyStripe = !!(blockStyle & 8);
  31632. cod.predictableTermination = !!(blockStyle & 16);
  31633. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  31634. cod.reversibleTransformation = data[j++];
  31635. if (cod.entropyCoderWithCustomPrecincts) {
  31636. var precinctsSizes = [];
  31637. while (j < length + position) {
  31638. var precinctsSize = data[j++];
  31639. precinctsSizes.push({
  31640. PPx: precinctsSize & 0xF,
  31641. PPy: precinctsSize >> 4
  31642. });
  31643. }
  31644. cod.precinctsSizes = precinctsSizes;
  31645. }
  31646. var unsupported = [];
  31647. if (cod.selectiveArithmeticCodingBypass) {
  31648. unsupported.push('selectiveArithmeticCodingBypass');
  31649. }
  31650. if (cod.resetContextProbabilities) {
  31651. unsupported.push('resetContextProbabilities');
  31652. }
  31653. if (cod.terminationOnEachCodingPass) {
  31654. unsupported.push('terminationOnEachCodingPass');
  31655. }
  31656. if (cod.verticalyStripe) {
  31657. unsupported.push('verticalyStripe');
  31658. }
  31659. if (cod.predictableTermination) {
  31660. unsupported.push('predictableTermination');
  31661. }
  31662. if (unsupported.length > 0) {
  31663. doNotRecover = true;
  31664. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  31665. }
  31666. if (context.mainHeader) {
  31667. context.COD = cod;
  31668. } else {
  31669. context.currentTile.COD = cod;
  31670. context.currentTile.COC = [];
  31671. }
  31672. break;
  31673. case 0xFF90:
  31674. length = readUint16(data, position);
  31675. tile = {};
  31676. tile.index = readUint16(data, position + 2);
  31677. tile.length = readUint32(data, position + 4);
  31678. tile.dataEnd = tile.length + position - 2;
  31679. tile.partIndex = data[position + 8];
  31680. tile.partsCount = data[position + 9];
  31681. context.mainHeader = false;
  31682. if (tile.partIndex === 0) {
  31683. tile.COD = context.COD;
  31684. tile.COC = context.COC.slice(0);
  31685. tile.QCD = context.QCD;
  31686. tile.QCC = context.QCC.slice(0);
  31687. }
  31688. context.currentTile = tile;
  31689. break;
  31690. case 0xFF93:
  31691. tile = context.currentTile;
  31692. if (tile.partIndex === 0) {
  31693. initializeTile(context, tile.index);
  31694. buildPackets(context);
  31695. }
  31696. length = tile.dataEnd - position;
  31697. parseTilePackets(context, data, position, length);
  31698. break;
  31699. case 0xFF55:
  31700. case 0xFF57:
  31701. case 0xFF58:
  31702. case 0xFF64:
  31703. length = readUint16(data, position);
  31704. break;
  31705. case 0xFF53:
  31706. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  31707. default:
  31708. throw new Error('Unknown codestream code: ' + code.toString(16));
  31709. }
  31710. position += length;
  31711. }
  31712. } catch (e) {
  31713. if (doNotRecover || this.failOnCorruptedImage) {
  31714. error('JPX Error: ' + e.message);
  31715. } else {
  31716. warn('JPX: Trying to recover from: ' + e.message);
  31717. }
  31718. }
  31719. this.tiles = transformComponents(context);
  31720. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  31721. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  31722. this.componentsCount = context.SIZ.Csiz;
  31723. }
  31724. };
  31725. function calculateComponentDimensions(component, siz) {
  31726. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  31727. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  31728. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  31729. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  31730. component.width = component.x1 - component.x0;
  31731. component.height = component.y1 - component.y0;
  31732. }
  31733. function calculateTileGrids(context, components) {
  31734. var siz = context.SIZ;
  31735. var tile, tiles = [];
  31736. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  31737. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  31738. for (var q = 0; q < numYtiles; q++) {
  31739. for (var p = 0; p < numXtiles; p++) {
  31740. tile = {};
  31741. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  31742. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  31743. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  31744. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  31745. tile.width = tile.tx1 - tile.tx0;
  31746. tile.height = tile.ty1 - tile.ty0;
  31747. tile.components = [];
  31748. tiles.push(tile);
  31749. }
  31750. }
  31751. context.tiles = tiles;
  31752. var componentsCount = siz.Csiz;
  31753. for (var i = 0, ii = componentsCount; i < ii; i++) {
  31754. var component = components[i];
  31755. for (var j = 0, jj = tiles.length; j < jj; j++) {
  31756. var tileComponent = {};
  31757. tile = tiles[j];
  31758. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  31759. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  31760. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  31761. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  31762. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  31763. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  31764. tile.components[i] = tileComponent;
  31765. }
  31766. }
  31767. }
  31768. function getBlocksDimensions(context, component, r) {
  31769. var codOrCoc = component.codingStyleParameters;
  31770. var result = {};
  31771. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  31772. result.PPx = 15;
  31773. result.PPy = 15;
  31774. } else {
  31775. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  31776. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  31777. }
  31778. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  31779. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  31780. return result;
  31781. }
  31782. function buildPrecincts(context, resolution, dimensions) {
  31783. var precinctWidth = 1 << dimensions.PPx;
  31784. var precinctHeight = 1 << dimensions.PPy;
  31785. var isZeroRes = resolution.resLevel === 0;
  31786. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  31787. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  31788. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  31789. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  31790. var numprecincts = numprecinctswide * numprecinctshigh;
  31791. resolution.precinctParameters = {
  31792. precinctWidth: precinctWidth,
  31793. precinctHeight: precinctHeight,
  31794. numprecinctswide: numprecinctswide,
  31795. numprecinctshigh: numprecinctshigh,
  31796. numprecincts: numprecincts,
  31797. precinctWidthInSubband: precinctWidthInSubband,
  31798. precinctHeightInSubband: precinctHeightInSubband
  31799. };
  31800. }
  31801. function buildCodeblocks(context, subband, dimensions) {
  31802. var xcb_ = dimensions.xcb_;
  31803. var ycb_ = dimensions.ycb_;
  31804. var codeblockWidth = 1 << xcb_;
  31805. var codeblockHeight = 1 << ycb_;
  31806. var cbx0 = subband.tbx0 >> xcb_;
  31807. var cby0 = subband.tby0 >> ycb_;
  31808. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  31809. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  31810. var precinctParameters = subband.resolution.precinctParameters;
  31811. var codeblocks = [];
  31812. var precincts = [];
  31813. var i, j, codeblock, precinctNumber;
  31814. for (j = cby0; j < cby1; j++) {
  31815. for (i = cbx0; i < cbx1; i++) {
  31816. codeblock = {
  31817. cbx: i,
  31818. cby: j,
  31819. tbx0: codeblockWidth * i,
  31820. tby0: codeblockHeight * j,
  31821. tbx1: codeblockWidth * (i + 1),
  31822. tby1: codeblockHeight * (j + 1)
  31823. };
  31824. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  31825. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  31826. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  31827. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  31828. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  31829. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  31830. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  31831. codeblock.precinctNumber = precinctNumber;
  31832. codeblock.subbandType = subband.type;
  31833. codeblock.Lblock = 3;
  31834. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  31835. continue;
  31836. }
  31837. codeblocks.push(codeblock);
  31838. var precinct = precincts[precinctNumber];
  31839. if (precinct !== undefined) {
  31840. if (i < precinct.cbxMin) {
  31841. precinct.cbxMin = i;
  31842. } else if (i > precinct.cbxMax) {
  31843. precinct.cbxMax = i;
  31844. }
  31845. if (j < precinct.cbyMin) {
  31846. precinct.cbxMin = j;
  31847. } else if (j > precinct.cbyMax) {
  31848. precinct.cbyMax = j;
  31849. }
  31850. } else {
  31851. precincts[precinctNumber] = precinct = {
  31852. cbxMin: i,
  31853. cbyMin: j,
  31854. cbxMax: i,
  31855. cbyMax: j
  31856. };
  31857. }
  31858. codeblock.precinct = precinct;
  31859. }
  31860. }
  31861. subband.codeblockParameters = {
  31862. codeblockWidth: xcb_,
  31863. codeblockHeight: ycb_,
  31864. numcodeblockwide: cbx1 - cbx0 + 1,
  31865. numcodeblockhigh: cby1 - cby0 + 1
  31866. };
  31867. subband.codeblocks = codeblocks;
  31868. subband.precincts = precincts;
  31869. }
  31870. function createPacket(resolution, precinctNumber, layerNumber) {
  31871. var precinctCodeblocks = [];
  31872. var subbands = resolution.subbands;
  31873. for (var i = 0, ii = subbands.length; i < ii; i++) {
  31874. var subband = subbands[i];
  31875. var codeblocks = subband.codeblocks;
  31876. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  31877. var codeblock = codeblocks[j];
  31878. if (codeblock.precinctNumber !== precinctNumber) {
  31879. continue;
  31880. }
  31881. precinctCodeblocks.push(codeblock);
  31882. }
  31883. }
  31884. return {
  31885. layerNumber: layerNumber,
  31886. codeblocks: precinctCodeblocks
  31887. };
  31888. }
  31889. function LayerResolutionComponentPositionIterator(context) {
  31890. var siz = context.SIZ;
  31891. var tileIndex = context.currentTile.index;
  31892. var tile = context.tiles[tileIndex];
  31893. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31894. var componentsCount = siz.Csiz;
  31895. var maxDecompositionLevelsCount = 0;
  31896. for (var q = 0; q < componentsCount; q++) {
  31897. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31898. }
  31899. var l = 0, r = 0, i = 0, k = 0;
  31900. this.nextPacket = function JpxImage_nextPacket() {
  31901. for (; l < layersCount; l++) {
  31902. for (; r <= maxDecompositionLevelsCount; r++) {
  31903. for (; i < componentsCount; i++) {
  31904. var component = tile.components[i];
  31905. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31906. continue;
  31907. }
  31908. var resolution = component.resolutions[r];
  31909. var numprecincts = resolution.precinctParameters.numprecincts;
  31910. for (; k < numprecincts;) {
  31911. var packet = createPacket(resolution, k, l);
  31912. k++;
  31913. return packet;
  31914. }
  31915. k = 0;
  31916. }
  31917. i = 0;
  31918. }
  31919. r = 0;
  31920. }
  31921. error('JPX Error: Out of packets');
  31922. };
  31923. }
  31924. function ResolutionLayerComponentPositionIterator(context) {
  31925. var siz = context.SIZ;
  31926. var tileIndex = context.currentTile.index;
  31927. var tile = context.tiles[tileIndex];
  31928. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31929. var componentsCount = siz.Csiz;
  31930. var maxDecompositionLevelsCount = 0;
  31931. for (var q = 0; q < componentsCount; q++) {
  31932. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31933. }
  31934. var r = 0, l = 0, i = 0, k = 0;
  31935. this.nextPacket = function JpxImage_nextPacket() {
  31936. for (; r <= maxDecompositionLevelsCount; r++) {
  31937. for (; l < layersCount; l++) {
  31938. for (; i < componentsCount; i++) {
  31939. var component = tile.components[i];
  31940. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31941. continue;
  31942. }
  31943. var resolution = component.resolutions[r];
  31944. var numprecincts = resolution.precinctParameters.numprecincts;
  31945. for (; k < numprecincts;) {
  31946. var packet = createPacket(resolution, k, l);
  31947. k++;
  31948. return packet;
  31949. }
  31950. k = 0;
  31951. }
  31952. i = 0;
  31953. }
  31954. l = 0;
  31955. }
  31956. error('JPX Error: Out of packets');
  31957. };
  31958. }
  31959. function ResolutionPositionComponentLayerIterator(context) {
  31960. var siz = context.SIZ;
  31961. var tileIndex = context.currentTile.index;
  31962. var tile = context.tiles[tileIndex];
  31963. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31964. var componentsCount = siz.Csiz;
  31965. var l, r, c, p;
  31966. var maxDecompositionLevelsCount = 0;
  31967. for (c = 0; c < componentsCount; c++) {
  31968. var component = tile.components[c];
  31969. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  31970. }
  31971. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  31972. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  31973. var maxNumPrecincts = 0;
  31974. for (c = 0; c < componentsCount; ++c) {
  31975. var resolutions = tile.components[c].resolutions;
  31976. if (r < resolutions.length) {
  31977. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  31978. }
  31979. }
  31980. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  31981. }
  31982. l = 0;
  31983. r = 0;
  31984. c = 0;
  31985. p = 0;
  31986. this.nextPacket = function JpxImage_nextPacket() {
  31987. for (; r <= maxDecompositionLevelsCount; r++) {
  31988. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  31989. for (; c < componentsCount; c++) {
  31990. var component = tile.components[c];
  31991. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31992. continue;
  31993. }
  31994. var resolution = component.resolutions[r];
  31995. var numprecincts = resolution.precinctParameters.numprecincts;
  31996. if (p >= numprecincts) {
  31997. continue;
  31998. }
  31999. for (; l < layersCount;) {
  32000. var packet = createPacket(resolution, p, l);
  32001. l++;
  32002. return packet;
  32003. }
  32004. l = 0;
  32005. }
  32006. c = 0;
  32007. }
  32008. p = 0;
  32009. }
  32010. error('JPX Error: Out of packets');
  32011. };
  32012. }
  32013. function PositionComponentResolutionLayerIterator(context) {
  32014. var siz = context.SIZ;
  32015. var tileIndex = context.currentTile.index;
  32016. var tile = context.tiles[tileIndex];
  32017. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32018. var componentsCount = siz.Csiz;
  32019. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32020. var precinctsIterationSizes = precinctsSizes;
  32021. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32022. this.nextPacket = function JpxImage_nextPacket() {
  32023. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32024. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32025. for (; c < componentsCount; c++) {
  32026. var component = tile.components[c];
  32027. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32028. for (; r <= decompositionLevelsCount; r++) {
  32029. var resolution = component.resolutions[r];
  32030. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32031. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32032. if (k === null) {
  32033. continue;
  32034. }
  32035. for (; l < layersCount;) {
  32036. var packet = createPacket(resolution, k, l);
  32037. l++;
  32038. return packet;
  32039. }
  32040. l = 0;
  32041. }
  32042. r = 0;
  32043. }
  32044. c = 0;
  32045. }
  32046. px = 0;
  32047. }
  32048. error('JPX Error: Out of packets');
  32049. };
  32050. }
  32051. function ComponentPositionResolutionLayerIterator(context) {
  32052. var siz = context.SIZ;
  32053. var tileIndex = context.currentTile.index;
  32054. var tile = context.tiles[tileIndex];
  32055. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32056. var componentsCount = siz.Csiz;
  32057. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32058. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32059. this.nextPacket = function JpxImage_nextPacket() {
  32060. for (; c < componentsCount; ++c) {
  32061. var component = tile.components[c];
  32062. var precinctsIterationSizes = precinctsSizes.components[c];
  32063. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32064. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32065. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32066. for (; r <= decompositionLevelsCount; r++) {
  32067. var resolution = component.resolutions[r];
  32068. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32069. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32070. if (k === null) {
  32071. continue;
  32072. }
  32073. for (; l < layersCount;) {
  32074. var packet = createPacket(resolution, k, l);
  32075. l++;
  32076. return packet;
  32077. }
  32078. l = 0;
  32079. }
  32080. r = 0;
  32081. }
  32082. px = 0;
  32083. }
  32084. py = 0;
  32085. }
  32086. error('JPX Error: Out of packets');
  32087. };
  32088. }
  32089. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32090. var posX = pxIndex * precinctIterationSizes.minWidth;
  32091. var posY = pyIndex * precinctIterationSizes.minHeight;
  32092. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32093. return null;
  32094. }
  32095. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32096. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32097. }
  32098. function getPrecinctSizesInImageScale(tile) {
  32099. var componentsCount = tile.components.length;
  32100. var minWidth = Number.MAX_VALUE;
  32101. var minHeight = Number.MAX_VALUE;
  32102. var maxNumWide = 0;
  32103. var maxNumHigh = 0;
  32104. var sizePerComponent = new Array(componentsCount);
  32105. for (var c = 0; c < componentsCount; c++) {
  32106. var component = tile.components[c];
  32107. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32108. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32109. var minWidthCurrentComponent = Number.MAX_VALUE;
  32110. var minHeightCurrentComponent = Number.MAX_VALUE;
  32111. var maxNumWideCurrentComponent = 0;
  32112. var maxNumHighCurrentComponent = 0;
  32113. var scale = 1;
  32114. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32115. var resolution = component.resolutions[r];
  32116. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32117. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32118. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32119. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32120. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32121. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32122. sizePerResolution[r] = {
  32123. width: widthCurrentResolution,
  32124. height: heightCurrentResolution
  32125. };
  32126. scale <<= 1;
  32127. }
  32128. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32129. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32130. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32131. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32132. sizePerComponent[c] = {
  32133. resolutions: sizePerResolution,
  32134. minWidth: minWidthCurrentComponent,
  32135. minHeight: minHeightCurrentComponent,
  32136. maxNumWide: maxNumWideCurrentComponent,
  32137. maxNumHigh: maxNumHighCurrentComponent
  32138. };
  32139. }
  32140. return {
  32141. components: sizePerComponent,
  32142. minWidth: minWidth,
  32143. minHeight: minHeight,
  32144. maxNumWide: maxNumWide,
  32145. maxNumHigh: maxNumHigh
  32146. };
  32147. }
  32148. function buildPackets(context) {
  32149. var siz = context.SIZ;
  32150. var tileIndex = context.currentTile.index;
  32151. var tile = context.tiles[tileIndex];
  32152. var componentsCount = siz.Csiz;
  32153. for (var c = 0; c < componentsCount; c++) {
  32154. var component = tile.components[c];
  32155. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32156. var resolutions = [];
  32157. var subbands = [];
  32158. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32159. var blocksDimensions = getBlocksDimensions(context, component, r);
  32160. var resolution = {};
  32161. var scale = 1 << decompositionLevelsCount - r;
  32162. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32163. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32164. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32165. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32166. resolution.resLevel = r;
  32167. buildPrecincts(context, resolution, blocksDimensions);
  32168. resolutions.push(resolution);
  32169. var subband;
  32170. if (r === 0) {
  32171. subband = {};
  32172. subband.type = 'LL';
  32173. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32174. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32175. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32176. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32177. subband.resolution = resolution;
  32178. buildCodeblocks(context, subband, blocksDimensions);
  32179. subbands.push(subband);
  32180. resolution.subbands = [subband];
  32181. } else {
  32182. var bscale = 1 << decompositionLevelsCount - r + 1;
  32183. var resolutionSubbands = [];
  32184. subband = {};
  32185. subband.type = 'HL';
  32186. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32187. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32188. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32189. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32190. subband.resolution = resolution;
  32191. buildCodeblocks(context, subband, blocksDimensions);
  32192. subbands.push(subband);
  32193. resolutionSubbands.push(subband);
  32194. subband = {};
  32195. subband.type = 'LH';
  32196. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32197. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32198. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32199. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32200. subband.resolution = resolution;
  32201. buildCodeblocks(context, subband, blocksDimensions);
  32202. subbands.push(subband);
  32203. resolutionSubbands.push(subband);
  32204. subband = {};
  32205. subband.type = 'HH';
  32206. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32207. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32208. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32209. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32210. subband.resolution = resolution;
  32211. buildCodeblocks(context, subband, blocksDimensions);
  32212. subbands.push(subband);
  32213. resolutionSubbands.push(subband);
  32214. resolution.subbands = resolutionSubbands;
  32215. }
  32216. }
  32217. component.resolutions = resolutions;
  32218. component.subbands = subbands;
  32219. }
  32220. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32221. switch (progressionOrder) {
  32222. case 0:
  32223. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32224. break;
  32225. case 1:
  32226. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32227. break;
  32228. case 2:
  32229. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32230. break;
  32231. case 3:
  32232. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32233. break;
  32234. case 4:
  32235. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32236. break;
  32237. default:
  32238. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32239. }
  32240. }
  32241. function parseTilePackets(context, data, offset, dataLength) {
  32242. var position = 0;
  32243. var buffer, bufferSize = 0, skipNextBit = false;
  32244. function readBits(count) {
  32245. while (bufferSize < count) {
  32246. var b = data[offset + position];
  32247. position++;
  32248. if (skipNextBit) {
  32249. buffer = buffer << 7 | b;
  32250. bufferSize += 7;
  32251. skipNextBit = false;
  32252. } else {
  32253. buffer = buffer << 8 | b;
  32254. bufferSize += 8;
  32255. }
  32256. if (b === 0xFF) {
  32257. skipNextBit = true;
  32258. }
  32259. }
  32260. bufferSize -= count;
  32261. return buffer >>> bufferSize & (1 << count) - 1;
  32262. }
  32263. function skipMarkerIfEqual(value) {
  32264. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32265. skipBytes(1);
  32266. return true;
  32267. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32268. skipBytes(2);
  32269. return true;
  32270. }
  32271. return false;
  32272. }
  32273. function skipBytes(count) {
  32274. position += count;
  32275. }
  32276. function alignToByte() {
  32277. bufferSize = 0;
  32278. if (skipNextBit) {
  32279. position++;
  32280. skipNextBit = false;
  32281. }
  32282. }
  32283. function readCodingpasses() {
  32284. if (readBits(1) === 0) {
  32285. return 1;
  32286. }
  32287. if (readBits(1) === 0) {
  32288. return 2;
  32289. }
  32290. var value = readBits(2);
  32291. if (value < 3) {
  32292. return value + 3;
  32293. }
  32294. value = readBits(5);
  32295. if (value < 31) {
  32296. return value + 6;
  32297. }
  32298. value = readBits(7);
  32299. return value + 37;
  32300. }
  32301. var tileIndex = context.currentTile.index;
  32302. var tile = context.tiles[tileIndex];
  32303. var sopMarkerUsed = context.COD.sopMarkerUsed;
  32304. var ephMarkerUsed = context.COD.ephMarkerUsed;
  32305. var packetsIterator = tile.packetsIterator;
  32306. while (position < dataLength) {
  32307. alignToByte();
  32308. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  32309. skipBytes(4);
  32310. }
  32311. var packet = packetsIterator.nextPacket();
  32312. if (!readBits(1)) {
  32313. continue;
  32314. }
  32315. var layerNumber = packet.layerNumber;
  32316. var queue = [], codeblock;
  32317. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  32318. codeblock = packet.codeblocks[i];
  32319. var precinct = codeblock.precinct;
  32320. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  32321. var codeblockRow = codeblock.cby - precinct.cbyMin;
  32322. var codeblockIncluded = false;
  32323. var firstTimeInclusion = false;
  32324. var valueReady;
  32325. if (codeblock['included'] !== undefined) {
  32326. codeblockIncluded = !!readBits(1);
  32327. } else {
  32328. precinct = codeblock.precinct;
  32329. var inclusionTree, zeroBitPlanesTree;
  32330. if (precinct['inclusionTree'] !== undefined) {
  32331. inclusionTree = precinct.inclusionTree;
  32332. } else {
  32333. var width = precinct.cbxMax - precinct.cbxMin + 1;
  32334. var height = precinct.cbyMax - precinct.cbyMin + 1;
  32335. inclusionTree = new InclusionTree(width, height, layerNumber);
  32336. zeroBitPlanesTree = new TagTree(width, height);
  32337. precinct.inclusionTree = inclusionTree;
  32338. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  32339. }
  32340. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  32341. while (true) {
  32342. if (readBits(1)) {
  32343. valueReady = !inclusionTree.nextLevel();
  32344. if (valueReady) {
  32345. codeblock.included = true;
  32346. codeblockIncluded = firstTimeInclusion = true;
  32347. break;
  32348. }
  32349. } else {
  32350. inclusionTree.incrementValue(layerNumber);
  32351. break;
  32352. }
  32353. }
  32354. }
  32355. }
  32356. if (!codeblockIncluded) {
  32357. continue;
  32358. }
  32359. if (firstTimeInclusion) {
  32360. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  32361. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  32362. while (true) {
  32363. if (readBits(1)) {
  32364. valueReady = !zeroBitPlanesTree.nextLevel();
  32365. if (valueReady) {
  32366. break;
  32367. }
  32368. } else {
  32369. zeroBitPlanesTree.incrementValue();
  32370. }
  32371. }
  32372. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  32373. }
  32374. var codingpasses = readCodingpasses();
  32375. while (readBits(1)) {
  32376. codeblock.Lblock++;
  32377. }
  32378. var codingpassesLog2 = log2(codingpasses);
  32379. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  32380. var codedDataLength = readBits(bits);
  32381. queue.push({
  32382. codeblock: codeblock,
  32383. codingpasses: codingpasses,
  32384. dataLength: codedDataLength
  32385. });
  32386. }
  32387. alignToByte();
  32388. if (ephMarkerUsed) {
  32389. skipMarkerIfEqual(0x92);
  32390. }
  32391. while (queue.length > 0) {
  32392. var packetItem = queue.shift();
  32393. codeblock = packetItem.codeblock;
  32394. if (codeblock['data'] === undefined) {
  32395. codeblock.data = [];
  32396. }
  32397. codeblock.data.push({
  32398. data: data,
  32399. start: offset + position,
  32400. end: offset + position + packetItem.dataLength,
  32401. codingpasses: packetItem.codingpasses
  32402. });
  32403. position += packetItem.dataLength;
  32404. }
  32405. }
  32406. return position;
  32407. }
  32408. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  32409. var x0 = subband.tbx0;
  32410. var y0 = subband.tby0;
  32411. var width = subband.tbx1 - subband.tbx0;
  32412. var codeblocks = subband.codeblocks;
  32413. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  32414. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  32415. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  32416. var codeblock = codeblocks[i];
  32417. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  32418. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  32419. if (blockWidth === 0 || blockHeight === 0) {
  32420. continue;
  32421. }
  32422. if (codeblock['data'] === undefined) {
  32423. continue;
  32424. }
  32425. var bitModel, currentCodingpassType;
  32426. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  32427. currentCodingpassType = 2;
  32428. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  32429. var j, jj, dataItem;
  32430. for (j = 0, jj = data.length; j < jj; j++) {
  32431. dataItem = data[j];
  32432. totalLength += dataItem.end - dataItem.start;
  32433. codingpasses += dataItem.codingpasses;
  32434. }
  32435. var encodedData = new Uint8Array(totalLength);
  32436. var position = 0;
  32437. for (j = 0, jj = data.length; j < jj; j++) {
  32438. dataItem = data[j];
  32439. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  32440. encodedData.set(chunk, position);
  32441. position += chunk.length;
  32442. }
  32443. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  32444. bitModel.setDecoder(decoder);
  32445. for (j = 0; j < codingpasses; j++) {
  32446. switch (currentCodingpassType) {
  32447. case 0:
  32448. bitModel.runSignificancePropagationPass();
  32449. break;
  32450. case 1:
  32451. bitModel.runMagnitudeRefinementPass();
  32452. break;
  32453. case 2:
  32454. bitModel.runCleanupPass();
  32455. if (segmentationSymbolUsed) {
  32456. bitModel.checkSegmentationSymbol();
  32457. }
  32458. break;
  32459. }
  32460. currentCodingpassType = (currentCodingpassType + 1) % 3;
  32461. }
  32462. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  32463. var sign = bitModel.coefficentsSign;
  32464. var magnitude = bitModel.coefficentsMagnitude;
  32465. var bitsDecoded = bitModel.bitsDecoded;
  32466. var magnitudeCorrection = reversible ? 0 : 0.5;
  32467. var k, n, nb;
  32468. position = 0;
  32469. var interleave = subband.type !== 'LL';
  32470. for (j = 0; j < blockHeight; j++) {
  32471. var row = offset / width | 0;
  32472. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  32473. for (k = 0; k < blockWidth; k++) {
  32474. n = magnitude[position];
  32475. if (n !== 0) {
  32476. n = (n + magnitudeCorrection) * delta;
  32477. if (sign[position] !== 0) {
  32478. n = -n;
  32479. }
  32480. nb = bitsDecoded[position];
  32481. var pos = interleave ? levelOffset + (offset << 1) : offset;
  32482. if (reversible && nb >= mb) {
  32483. coefficients[pos] = n;
  32484. } else {
  32485. coefficients[pos] = n * (1 << mb - nb);
  32486. }
  32487. }
  32488. offset++;
  32489. position++;
  32490. }
  32491. offset += width - blockWidth;
  32492. }
  32493. }
  32494. }
  32495. function transformTile(context, tile, c) {
  32496. var component = tile.components[c];
  32497. var codingStyleParameters = component.codingStyleParameters;
  32498. var quantizationParameters = component.quantizationParameters;
  32499. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  32500. var spqcds = quantizationParameters.SPqcds;
  32501. var scalarExpounded = quantizationParameters.scalarExpounded;
  32502. var guardBits = quantizationParameters.guardBits;
  32503. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  32504. var precision = context.components[c].precision;
  32505. var reversible = codingStyleParameters.reversibleTransformation;
  32506. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  32507. var subbandCoefficients = [];
  32508. var b = 0;
  32509. for (var i = 0; i <= decompositionLevelsCount; i++) {
  32510. var resolution = component.resolutions[i];
  32511. var width = resolution.trx1 - resolution.trx0;
  32512. var height = resolution.try1 - resolution.try0;
  32513. var coefficients = new Float32Array(width * height);
  32514. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  32515. var mu, epsilon;
  32516. if (!scalarExpounded) {
  32517. mu = spqcds[0].mu;
  32518. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  32519. } else {
  32520. mu = spqcds[b].mu;
  32521. epsilon = spqcds[b].epsilon;
  32522. b++;
  32523. }
  32524. var subband = resolution.subbands[j];
  32525. var gainLog2 = SubbandsGainLog2[subband.type];
  32526. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  32527. var mb = guardBits + epsilon - 1;
  32528. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  32529. }
  32530. subbandCoefficients.push({
  32531. width: width,
  32532. height: height,
  32533. items: coefficients
  32534. });
  32535. }
  32536. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  32537. return {
  32538. left: component.tcx0,
  32539. top: component.tcy0,
  32540. width: result.width,
  32541. height: result.height,
  32542. items: result.items
  32543. };
  32544. }
  32545. function transformComponents(context) {
  32546. var siz = context.SIZ;
  32547. var components = context.components;
  32548. var componentsCount = siz.Csiz;
  32549. var resultImages = [];
  32550. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  32551. var tile = context.tiles[i];
  32552. var transformedTiles = [];
  32553. var c;
  32554. for (c = 0; c < componentsCount; c++) {
  32555. transformedTiles[c] = transformTile(context, tile, c);
  32556. }
  32557. var tile0 = transformedTiles[0];
  32558. var out = new Uint8Array(tile0.items.length * componentsCount);
  32559. var result = {
  32560. left: tile0.left,
  32561. top: tile0.top,
  32562. width: tile0.width,
  32563. height: tile0.height,
  32564. items: out
  32565. };
  32566. var shift, offset, max, min, maxK;
  32567. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  32568. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  32569. var fourComponents = componentsCount === 4;
  32570. var y0items = transformedTiles[0].items;
  32571. var y1items = transformedTiles[1].items;
  32572. var y2items = transformedTiles[2].items;
  32573. var y3items = fourComponents ? transformedTiles[3].items : null;
  32574. shift = components[0].precision - 8;
  32575. offset = (128 << shift) + 0.5;
  32576. max = 255 * (1 << shift);
  32577. maxK = max * 0.5;
  32578. min = -maxK;
  32579. var component0 = tile.components[0];
  32580. var alpha01 = componentsCount - 3;
  32581. jj = y0items.length;
  32582. if (!component0.codingStyleParameters.reversibleTransformation) {
  32583. for (j = 0; j < jj; j++, pos += alpha01) {
  32584. y0 = y0items[j] + offset;
  32585. y1 = y1items[j];
  32586. y2 = y2items[j];
  32587. r = y0 + 1.402 * y2;
  32588. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  32589. b = y0 + 1.772 * y1;
  32590. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32591. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32592. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32593. }
  32594. } else {
  32595. for (j = 0; j < jj; j++, pos += alpha01) {
  32596. y0 = y0items[j] + offset;
  32597. y1 = y1items[j];
  32598. y2 = y2items[j];
  32599. g = y0 - (y2 + y1 >> 2);
  32600. r = g + y2;
  32601. b = g + y1;
  32602. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32603. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32604. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32605. }
  32606. }
  32607. if (fourComponents) {
  32608. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  32609. k = y3items[j];
  32610. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  32611. }
  32612. }
  32613. } else {
  32614. for (c = 0; c < componentsCount; c++) {
  32615. var items = transformedTiles[c].items;
  32616. shift = components[c].precision - 8;
  32617. offset = (128 << shift) + 0.5;
  32618. max = 127.5 * (1 << shift);
  32619. min = -max;
  32620. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  32621. val = items[j];
  32622. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  32623. pos += componentsCount;
  32624. }
  32625. }
  32626. }
  32627. resultImages.push(result);
  32628. }
  32629. return resultImages;
  32630. }
  32631. function initializeTile(context, tileIndex) {
  32632. var siz = context.SIZ;
  32633. var componentsCount = siz.Csiz;
  32634. var tile = context.tiles[tileIndex];
  32635. for (var c = 0; c < componentsCount; c++) {
  32636. var component = tile.components[c];
  32637. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  32638. component.quantizationParameters = qcdOrQcc;
  32639. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  32640. component.codingStyleParameters = codOrCoc;
  32641. }
  32642. tile.codingStyleDefaultParameters = context.currentTile.COD;
  32643. }
  32644. var TagTree = function TagTreeClosure() {
  32645. function TagTree(width, height) {
  32646. var levelsLength = log2(Math.max(width, height)) + 1;
  32647. this.levels = [];
  32648. for (var i = 0; i < levelsLength; i++) {
  32649. var level = {
  32650. width: width,
  32651. height: height,
  32652. items: []
  32653. };
  32654. this.levels.push(level);
  32655. width = Math.ceil(width / 2);
  32656. height = Math.ceil(height / 2);
  32657. }
  32658. }
  32659. TagTree.prototype = {
  32660. reset: function TagTree_reset(i, j) {
  32661. var currentLevel = 0, value = 0, level;
  32662. while (currentLevel < this.levels.length) {
  32663. level = this.levels[currentLevel];
  32664. var index = i + j * level.width;
  32665. if (level.items[index] !== undefined) {
  32666. value = level.items[index];
  32667. break;
  32668. }
  32669. level.index = index;
  32670. i >>= 1;
  32671. j >>= 1;
  32672. currentLevel++;
  32673. }
  32674. currentLevel--;
  32675. level = this.levels[currentLevel];
  32676. level.items[level.index] = value;
  32677. this.currentLevel = currentLevel;
  32678. delete this.value;
  32679. },
  32680. incrementValue: function TagTree_incrementValue() {
  32681. var level = this.levels[this.currentLevel];
  32682. level.items[level.index]++;
  32683. },
  32684. nextLevel: function TagTree_nextLevel() {
  32685. var currentLevel = this.currentLevel;
  32686. var level = this.levels[currentLevel];
  32687. var value = level.items[level.index];
  32688. currentLevel--;
  32689. if (currentLevel < 0) {
  32690. this.value = value;
  32691. return false;
  32692. }
  32693. this.currentLevel = currentLevel;
  32694. level = this.levels[currentLevel];
  32695. level.items[level.index] = value;
  32696. return true;
  32697. }
  32698. };
  32699. return TagTree;
  32700. }();
  32701. var InclusionTree = function InclusionTreeClosure() {
  32702. function InclusionTree(width, height, defaultValue) {
  32703. var levelsLength = log2(Math.max(width, height)) + 1;
  32704. this.levels = [];
  32705. for (var i = 0; i < levelsLength; i++) {
  32706. var items = new Uint8Array(width * height);
  32707. for (var j = 0, jj = items.length; j < jj; j++) {
  32708. items[j] = defaultValue;
  32709. }
  32710. var level = {
  32711. width: width,
  32712. height: height,
  32713. items: items
  32714. };
  32715. this.levels.push(level);
  32716. width = Math.ceil(width / 2);
  32717. height = Math.ceil(height / 2);
  32718. }
  32719. }
  32720. InclusionTree.prototype = {
  32721. reset: function InclusionTree_reset(i, j, stopValue) {
  32722. var currentLevel = 0;
  32723. while (currentLevel < this.levels.length) {
  32724. var level = this.levels[currentLevel];
  32725. var index = i + j * level.width;
  32726. level.index = index;
  32727. var value = level.items[index];
  32728. if (value === 0xFF) {
  32729. break;
  32730. }
  32731. if (value > stopValue) {
  32732. this.currentLevel = currentLevel;
  32733. this.propagateValues();
  32734. return false;
  32735. }
  32736. i >>= 1;
  32737. j >>= 1;
  32738. currentLevel++;
  32739. }
  32740. this.currentLevel = currentLevel - 1;
  32741. return true;
  32742. },
  32743. incrementValue: function InclusionTree_incrementValue(stopValue) {
  32744. var level = this.levels[this.currentLevel];
  32745. level.items[level.index] = stopValue + 1;
  32746. this.propagateValues();
  32747. },
  32748. propagateValues: function InclusionTree_propagateValues() {
  32749. var levelIndex = this.currentLevel;
  32750. var level = this.levels[levelIndex];
  32751. var currentValue = level.items[level.index];
  32752. while (--levelIndex >= 0) {
  32753. level = this.levels[levelIndex];
  32754. level.items[level.index] = currentValue;
  32755. }
  32756. },
  32757. nextLevel: function InclusionTree_nextLevel() {
  32758. var currentLevel = this.currentLevel;
  32759. var level = this.levels[currentLevel];
  32760. var value = level.items[level.index];
  32761. level.items[level.index] = 0xFF;
  32762. currentLevel--;
  32763. if (currentLevel < 0) {
  32764. return false;
  32765. }
  32766. this.currentLevel = currentLevel;
  32767. level = this.levels[currentLevel];
  32768. level.items[level.index] = value;
  32769. return true;
  32770. }
  32771. };
  32772. return InclusionTree;
  32773. }();
  32774. var BitModel = function BitModelClosure() {
  32775. var UNIFORM_CONTEXT = 17;
  32776. var RUNLENGTH_CONTEXT = 18;
  32777. var LLAndLHContextsLabel = new Uint8Array([
  32778. 0,
  32779. 5,
  32780. 8,
  32781. 0,
  32782. 3,
  32783. 7,
  32784. 8,
  32785. 0,
  32786. 4,
  32787. 7,
  32788. 8,
  32789. 0,
  32790. 0,
  32791. 0,
  32792. 0,
  32793. 0,
  32794. 1,
  32795. 6,
  32796. 8,
  32797. 0,
  32798. 3,
  32799. 7,
  32800. 8,
  32801. 0,
  32802. 4,
  32803. 7,
  32804. 8,
  32805. 0,
  32806. 0,
  32807. 0,
  32808. 0,
  32809. 0,
  32810. 2,
  32811. 6,
  32812. 8,
  32813. 0,
  32814. 3,
  32815. 7,
  32816. 8,
  32817. 0,
  32818. 4,
  32819. 7,
  32820. 8,
  32821. 0,
  32822. 0,
  32823. 0,
  32824. 0,
  32825. 0,
  32826. 2,
  32827. 6,
  32828. 8,
  32829. 0,
  32830. 3,
  32831. 7,
  32832. 8,
  32833. 0,
  32834. 4,
  32835. 7,
  32836. 8,
  32837. 0,
  32838. 0,
  32839. 0,
  32840. 0,
  32841. 0,
  32842. 2,
  32843. 6,
  32844. 8,
  32845. 0,
  32846. 3,
  32847. 7,
  32848. 8,
  32849. 0,
  32850. 4,
  32851. 7,
  32852. 8
  32853. ]);
  32854. var HLContextLabel = new Uint8Array([
  32855. 0,
  32856. 3,
  32857. 4,
  32858. 0,
  32859. 5,
  32860. 7,
  32861. 7,
  32862. 0,
  32863. 8,
  32864. 8,
  32865. 8,
  32866. 0,
  32867. 0,
  32868. 0,
  32869. 0,
  32870. 0,
  32871. 1,
  32872. 3,
  32873. 4,
  32874. 0,
  32875. 6,
  32876. 7,
  32877. 7,
  32878. 0,
  32879. 8,
  32880. 8,
  32881. 8,
  32882. 0,
  32883. 0,
  32884. 0,
  32885. 0,
  32886. 0,
  32887. 2,
  32888. 3,
  32889. 4,
  32890. 0,
  32891. 6,
  32892. 7,
  32893. 7,
  32894. 0,
  32895. 8,
  32896. 8,
  32897. 8,
  32898. 0,
  32899. 0,
  32900. 0,
  32901. 0,
  32902. 0,
  32903. 2,
  32904. 3,
  32905. 4,
  32906. 0,
  32907. 6,
  32908. 7,
  32909. 7,
  32910. 0,
  32911. 8,
  32912. 8,
  32913. 8,
  32914. 0,
  32915. 0,
  32916. 0,
  32917. 0,
  32918. 0,
  32919. 2,
  32920. 3,
  32921. 4,
  32922. 0,
  32923. 6,
  32924. 7,
  32925. 7,
  32926. 0,
  32927. 8,
  32928. 8,
  32929. 8
  32930. ]);
  32931. var HHContextLabel = new Uint8Array([
  32932. 0,
  32933. 1,
  32934. 2,
  32935. 0,
  32936. 1,
  32937. 2,
  32938. 2,
  32939. 0,
  32940. 2,
  32941. 2,
  32942. 2,
  32943. 0,
  32944. 0,
  32945. 0,
  32946. 0,
  32947. 0,
  32948. 3,
  32949. 4,
  32950. 5,
  32951. 0,
  32952. 4,
  32953. 5,
  32954. 5,
  32955. 0,
  32956. 5,
  32957. 5,
  32958. 5,
  32959. 0,
  32960. 0,
  32961. 0,
  32962. 0,
  32963. 0,
  32964. 6,
  32965. 7,
  32966. 7,
  32967. 0,
  32968. 7,
  32969. 7,
  32970. 7,
  32971. 0,
  32972. 7,
  32973. 7,
  32974. 7,
  32975. 0,
  32976. 0,
  32977. 0,
  32978. 0,
  32979. 0,
  32980. 8,
  32981. 8,
  32982. 8,
  32983. 0,
  32984. 8,
  32985. 8,
  32986. 8,
  32987. 0,
  32988. 8,
  32989. 8,
  32990. 8,
  32991. 0,
  32992. 0,
  32993. 0,
  32994. 0,
  32995. 0,
  32996. 8,
  32997. 8,
  32998. 8,
  32999. 0,
  33000. 8,
  33001. 8,
  33002. 8,
  33003. 0,
  33004. 8,
  33005. 8,
  33006. 8
  33007. ]);
  33008. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33009. this.width = width;
  33010. this.height = height;
  33011. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33012. var coefficientCount = width * height;
  33013. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33014. this.coefficentsSign = new Uint8Array(coefficientCount);
  33015. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33016. this.processingFlags = new Uint8Array(coefficientCount);
  33017. var bitsDecoded = new Uint8Array(coefficientCount);
  33018. if (zeroBitPlanes !== 0) {
  33019. for (var i = 0; i < coefficientCount; i++) {
  33020. bitsDecoded[i] = zeroBitPlanes;
  33021. }
  33022. }
  33023. this.bitsDecoded = bitsDecoded;
  33024. this.reset();
  33025. }
  33026. BitModel.prototype = {
  33027. setDecoder: function BitModel_setDecoder(decoder) {
  33028. this.decoder = decoder;
  33029. },
  33030. reset: function BitModel_reset() {
  33031. this.contexts = new Int8Array(19);
  33032. this.contexts[0] = 4 << 1 | 0;
  33033. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33034. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33035. },
  33036. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33037. var neighborsSignificance = this.neighborsSignificance;
  33038. var width = this.width, height = this.height;
  33039. var left = column > 0;
  33040. var right = column + 1 < width;
  33041. var i;
  33042. if (row > 0) {
  33043. i = index - width;
  33044. if (left) {
  33045. neighborsSignificance[i - 1] += 0x10;
  33046. }
  33047. if (right) {
  33048. neighborsSignificance[i + 1] += 0x10;
  33049. }
  33050. neighborsSignificance[i] += 0x04;
  33051. }
  33052. if (row + 1 < height) {
  33053. i = index + width;
  33054. if (left) {
  33055. neighborsSignificance[i - 1] += 0x10;
  33056. }
  33057. if (right) {
  33058. neighborsSignificance[i + 1] += 0x10;
  33059. }
  33060. neighborsSignificance[i] += 0x04;
  33061. }
  33062. if (left) {
  33063. neighborsSignificance[index - 1] += 0x01;
  33064. }
  33065. if (right) {
  33066. neighborsSignificance[index + 1] += 0x01;
  33067. }
  33068. neighborsSignificance[index] |= 0x80;
  33069. },
  33070. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33071. var decoder = this.decoder;
  33072. var width = this.width, height = this.height;
  33073. var coefficentsMagnitude = this.coefficentsMagnitude;
  33074. var coefficentsSign = this.coefficentsSign;
  33075. var neighborsSignificance = this.neighborsSignificance;
  33076. var processingFlags = this.processingFlags;
  33077. var contexts = this.contexts;
  33078. var labels = this.contextLabelTable;
  33079. var bitsDecoded = this.bitsDecoded;
  33080. var processedInverseMask = ~1;
  33081. var processedMask = 1;
  33082. var firstMagnitudeBitMask = 2;
  33083. for (var i0 = 0; i0 < height; i0 += 4) {
  33084. for (var j = 0; j < width; j++) {
  33085. var index = i0 * width + j;
  33086. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33087. var i = i0 + i1;
  33088. if (i >= height) {
  33089. break;
  33090. }
  33091. processingFlags[index] &= processedInverseMask;
  33092. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33093. continue;
  33094. }
  33095. var contextLabel = labels[neighborsSignificance[index]];
  33096. var decision = decoder.readBit(contexts, contextLabel);
  33097. if (decision) {
  33098. var sign = this.decodeSignBit(i, j, index);
  33099. coefficentsSign[index] = sign;
  33100. coefficentsMagnitude[index] = 1;
  33101. this.setNeighborsSignificance(i, j, index);
  33102. processingFlags[index] |= firstMagnitudeBitMask;
  33103. }
  33104. bitsDecoded[index]++;
  33105. processingFlags[index] |= processedMask;
  33106. }
  33107. }
  33108. }
  33109. },
  33110. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33111. var width = this.width, height = this.height;
  33112. var coefficentsMagnitude = this.coefficentsMagnitude;
  33113. var coefficentsSign = this.coefficentsSign;
  33114. var contribution, sign0, sign1, significance1;
  33115. var contextLabel, decoded;
  33116. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33117. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33118. sign1 = coefficentsSign[index + 1];
  33119. if (significance1) {
  33120. sign0 = coefficentsSign[index - 1];
  33121. contribution = 1 - sign1 - sign0;
  33122. } else {
  33123. contribution = 1 - sign1 - sign1;
  33124. }
  33125. } else if (significance1) {
  33126. sign0 = coefficentsSign[index - 1];
  33127. contribution = 1 - sign0 - sign0;
  33128. } else {
  33129. contribution = 0;
  33130. }
  33131. var horizontalContribution = 3 * contribution;
  33132. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33133. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33134. sign1 = coefficentsSign[index + width];
  33135. if (significance1) {
  33136. sign0 = coefficentsSign[index - width];
  33137. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33138. } else {
  33139. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33140. }
  33141. } else if (significance1) {
  33142. sign0 = coefficentsSign[index - width];
  33143. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33144. } else {
  33145. contribution = horizontalContribution;
  33146. }
  33147. if (contribution >= 0) {
  33148. contextLabel = 9 + contribution;
  33149. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33150. } else {
  33151. contextLabel = 9 - contribution;
  33152. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33153. }
  33154. return decoded;
  33155. },
  33156. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33157. var decoder = this.decoder;
  33158. var width = this.width, height = this.height;
  33159. var coefficentsMagnitude = this.coefficentsMagnitude;
  33160. var neighborsSignificance = this.neighborsSignificance;
  33161. var contexts = this.contexts;
  33162. var bitsDecoded = this.bitsDecoded;
  33163. var processingFlags = this.processingFlags;
  33164. var processedMask = 1;
  33165. var firstMagnitudeBitMask = 2;
  33166. var length = width * height;
  33167. var width4 = width * 4;
  33168. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33169. indexNext = Math.min(length, index0 + width4);
  33170. for (var j = 0; j < width; j++) {
  33171. for (var index = index0 + j; index < indexNext; index += width) {
  33172. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33173. continue;
  33174. }
  33175. var contextLabel = 16;
  33176. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33177. processingFlags[index] ^= firstMagnitudeBitMask;
  33178. var significance = neighborsSignificance[index] & 127;
  33179. contextLabel = significance === 0 ? 15 : 14;
  33180. }
  33181. var bit = decoder.readBit(contexts, contextLabel);
  33182. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33183. bitsDecoded[index]++;
  33184. processingFlags[index] |= processedMask;
  33185. }
  33186. }
  33187. }
  33188. },
  33189. runCleanupPass: function BitModel_runCleanupPass() {
  33190. var decoder = this.decoder;
  33191. var width = this.width, height = this.height;
  33192. var neighborsSignificance = this.neighborsSignificance;
  33193. var coefficentsMagnitude = this.coefficentsMagnitude;
  33194. var coefficentsSign = this.coefficentsSign;
  33195. var contexts = this.contexts;
  33196. var labels = this.contextLabelTable;
  33197. var bitsDecoded = this.bitsDecoded;
  33198. var processingFlags = this.processingFlags;
  33199. var processedMask = 1;
  33200. var firstMagnitudeBitMask = 2;
  33201. var oneRowDown = width;
  33202. var twoRowsDown = width * 2;
  33203. var threeRowsDown = width * 3;
  33204. var iNext;
  33205. for (var i0 = 0; i0 < height; i0 = iNext) {
  33206. iNext = Math.min(i0 + 4, height);
  33207. var indexBase = i0 * width;
  33208. var checkAllEmpty = i0 + 3 < height;
  33209. for (var j = 0; j < width; j++) {
  33210. var index0 = indexBase + j;
  33211. 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;
  33212. var i1 = 0, index = index0;
  33213. var i = i0, sign;
  33214. if (allEmpty) {
  33215. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33216. if (!hasSignificantCoefficent) {
  33217. bitsDecoded[index0]++;
  33218. bitsDecoded[index0 + oneRowDown]++;
  33219. bitsDecoded[index0 + twoRowsDown]++;
  33220. bitsDecoded[index0 + threeRowsDown]++;
  33221. continue;
  33222. }
  33223. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33224. if (i1 !== 0) {
  33225. i = i0 + i1;
  33226. index += i1 * width;
  33227. }
  33228. sign = this.decodeSignBit(i, j, index);
  33229. coefficentsSign[index] = sign;
  33230. coefficentsMagnitude[index] = 1;
  33231. this.setNeighborsSignificance(i, j, index);
  33232. processingFlags[index] |= firstMagnitudeBitMask;
  33233. index = index0;
  33234. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33235. bitsDecoded[index]++;
  33236. }
  33237. i1++;
  33238. }
  33239. for (i = i0 + i1; i < iNext; i++, index += width) {
  33240. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33241. continue;
  33242. }
  33243. var contextLabel = labels[neighborsSignificance[index]];
  33244. var decision = decoder.readBit(contexts, contextLabel);
  33245. if (decision === 1) {
  33246. sign = this.decodeSignBit(i, j, index);
  33247. coefficentsSign[index] = sign;
  33248. coefficentsMagnitude[index] = 1;
  33249. this.setNeighborsSignificance(i, j, index);
  33250. processingFlags[index] |= firstMagnitudeBitMask;
  33251. }
  33252. bitsDecoded[index]++;
  33253. }
  33254. }
  33255. }
  33256. },
  33257. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33258. var decoder = this.decoder;
  33259. var contexts = this.contexts;
  33260. 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);
  33261. if (symbol !== 0xA) {
  33262. error('JPX Error: Invalid segmentation symbol');
  33263. }
  33264. }
  33265. };
  33266. return BitModel;
  33267. }();
  33268. var Transform = function TransformClosure() {
  33269. function Transform() {
  33270. }
  33271. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33272. var ll = subbands[0];
  33273. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33274. ll = this.iterate(ll, subbands[i], u0, v0);
  33275. }
  33276. return ll;
  33277. };
  33278. Transform.prototype.extend = function extend(buffer, offset, size) {
  33279. var i1 = offset - 1, j1 = offset + 1;
  33280. var i2 = offset + size - 2, j2 = offset + size;
  33281. buffer[i1--] = buffer[j1++];
  33282. buffer[j2++] = buffer[i2--];
  33283. buffer[i1--] = buffer[j1++];
  33284. buffer[j2++] = buffer[i2--];
  33285. buffer[i1--] = buffer[j1++];
  33286. buffer[j2++] = buffer[i2--];
  33287. buffer[i1] = buffer[j1];
  33288. buffer[j2] = buffer[i2];
  33289. };
  33290. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  33291. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  33292. var width = hl_lh_hh.width;
  33293. var height = hl_lh_hh.height;
  33294. var items = hl_lh_hh.items;
  33295. var i, j, k, l, u, v;
  33296. for (k = 0, i = 0; i < llHeight; i++) {
  33297. l = i * 2 * width;
  33298. for (j = 0; j < llWidth; j++, k++, l += 2) {
  33299. items[l] = llItems[k];
  33300. }
  33301. }
  33302. llItems = ll.items = null;
  33303. var bufferPadding = 4;
  33304. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  33305. if (width === 1) {
  33306. if ((u0 & 1) !== 0) {
  33307. for (v = 0, k = 0; v < height; v++, k += width) {
  33308. items[k] *= 0.5;
  33309. }
  33310. }
  33311. } else {
  33312. for (v = 0, k = 0; v < height; v++, k += width) {
  33313. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  33314. this.extend(rowBuffer, bufferPadding, width);
  33315. this.filter(rowBuffer, bufferPadding, width);
  33316. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  33317. }
  33318. }
  33319. var numBuffers = 16;
  33320. var colBuffers = [];
  33321. for (i = 0; i < numBuffers; i++) {
  33322. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  33323. }
  33324. var b, currentBuffer = 0;
  33325. ll = bufferPadding + height;
  33326. if (height === 1) {
  33327. if ((v0 & 1) !== 0) {
  33328. for (u = 0; u < width; u++) {
  33329. items[u] *= 0.5;
  33330. }
  33331. }
  33332. } else {
  33333. for (u = 0; u < width; u++) {
  33334. if (currentBuffer === 0) {
  33335. numBuffers = Math.min(width - u, numBuffers);
  33336. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  33337. for (b = 0; b < numBuffers; b++) {
  33338. colBuffers[b][l] = items[k + b];
  33339. }
  33340. }
  33341. currentBuffer = numBuffers;
  33342. }
  33343. currentBuffer--;
  33344. var buffer = colBuffers[currentBuffer];
  33345. this.extend(buffer, bufferPadding, height);
  33346. this.filter(buffer, bufferPadding, height);
  33347. if (currentBuffer === 0) {
  33348. k = u - numBuffers + 1;
  33349. for (l = bufferPadding; l < ll; k += width, l++) {
  33350. for (b = 0; b < numBuffers; b++) {
  33351. items[k + b] = colBuffers[b][l];
  33352. }
  33353. }
  33354. }
  33355. }
  33356. }
  33357. return {
  33358. width: width,
  33359. height: height,
  33360. items: items
  33361. };
  33362. };
  33363. return Transform;
  33364. }();
  33365. var IrreversibleTransform = function IrreversibleTransformClosure() {
  33366. function IrreversibleTransform() {
  33367. Transform.call(this);
  33368. }
  33369. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  33370. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  33371. var len = length >> 1;
  33372. offset = offset | 0;
  33373. var j, n, current, next;
  33374. var alpha = -1.586134342059924;
  33375. var beta = -0.052980118572961;
  33376. var gamma = 0.882911075530934;
  33377. var delta = 0.443506852043971;
  33378. var K = 1.230174104914001;
  33379. var K_ = 1 / K;
  33380. j = offset - 3;
  33381. for (n = len + 4; n--; j += 2) {
  33382. x[j] *= K_;
  33383. }
  33384. j = offset - 2;
  33385. current = delta * x[j - 1];
  33386. for (n = len + 3; n--; j += 2) {
  33387. next = delta * x[j + 1];
  33388. x[j] = K * x[j] - current - next;
  33389. if (n--) {
  33390. j += 2;
  33391. current = delta * x[j + 1];
  33392. x[j] = K * x[j] - current - next;
  33393. } else {
  33394. break;
  33395. }
  33396. }
  33397. j = offset - 1;
  33398. current = gamma * x[j - 1];
  33399. for (n = len + 2; n--; j += 2) {
  33400. next = gamma * x[j + 1];
  33401. x[j] -= current + next;
  33402. if (n--) {
  33403. j += 2;
  33404. current = gamma * x[j + 1];
  33405. x[j] -= current + next;
  33406. } else {
  33407. break;
  33408. }
  33409. }
  33410. j = offset;
  33411. current = beta * x[j - 1];
  33412. for (n = len + 1; n--; j += 2) {
  33413. next = beta * x[j + 1];
  33414. x[j] -= current + next;
  33415. if (n--) {
  33416. j += 2;
  33417. current = beta * x[j + 1];
  33418. x[j] -= current + next;
  33419. } else {
  33420. break;
  33421. }
  33422. }
  33423. if (len !== 0) {
  33424. j = offset + 1;
  33425. current = alpha * x[j - 1];
  33426. for (n = len; n--; j += 2) {
  33427. next = alpha * x[j + 1];
  33428. x[j] -= current + next;
  33429. if (n--) {
  33430. j += 2;
  33431. current = alpha * x[j + 1];
  33432. x[j] -= current + next;
  33433. } else {
  33434. break;
  33435. }
  33436. }
  33437. }
  33438. };
  33439. return IrreversibleTransform;
  33440. }();
  33441. var ReversibleTransform = function ReversibleTransformClosure() {
  33442. function ReversibleTransform() {
  33443. Transform.call(this);
  33444. }
  33445. ReversibleTransform.prototype = Object.create(Transform.prototype);
  33446. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  33447. var len = length >> 1;
  33448. offset = offset | 0;
  33449. var j, n;
  33450. for (j = offset, n = len + 1; n--; j += 2) {
  33451. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  33452. }
  33453. for (j = offset + 1, n = len; n--; j += 2) {
  33454. x[j] += x[j - 1] + x[j + 1] >> 1;
  33455. }
  33456. };
  33457. return ReversibleTransform;
  33458. }();
  33459. return JpxImage;
  33460. }();
  33461. exports.JpxImage = JpxImage;
  33462. /***/ }),
  33463. /* 20 */
  33464. /***/ (function(module, exports, __w_pdfjs_require__) {
  33465. "use strict";
  33466. var sharedUtil = __w_pdfjs_require__(0);
  33467. var corePrimitives = __w_pdfjs_require__(1);
  33468. var coreCrypto = __w_pdfjs_require__(17);
  33469. var coreParser = __w_pdfjs_require__(6);
  33470. var coreChunkedStream = __w_pdfjs_require__(16);
  33471. var coreColorSpace = __w_pdfjs_require__(4);
  33472. var InvalidPDFException = sharedUtil.InvalidPDFException;
  33473. var MissingDataException = sharedUtil.MissingDataException;
  33474. var XRefParseException = sharedUtil.XRefParseException;
  33475. var assert = sharedUtil.assert;
  33476. var bytesToString = sharedUtil.bytesToString;
  33477. var createPromiseCapability = sharedUtil.createPromiseCapability;
  33478. var error = sharedUtil.error;
  33479. var info = sharedUtil.info;
  33480. var isArray = sharedUtil.isArray;
  33481. var isBool = sharedUtil.isBool;
  33482. var isInt = sharedUtil.isInt;
  33483. var isString = sharedUtil.isString;
  33484. var shadow = sharedUtil.shadow;
  33485. var stringToPDFString = sharedUtil.stringToPDFString;
  33486. var stringToUTF8String = sharedUtil.stringToUTF8String;
  33487. var warn = sharedUtil.warn;
  33488. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  33489. var Util = sharedUtil.Util;
  33490. var Ref = corePrimitives.Ref;
  33491. var RefSet = corePrimitives.RefSet;
  33492. var RefSetCache = corePrimitives.RefSetCache;
  33493. var isName = corePrimitives.isName;
  33494. var isCmd = corePrimitives.isCmd;
  33495. var isDict = corePrimitives.isDict;
  33496. var isRef = corePrimitives.isRef;
  33497. var isRefsEqual = corePrimitives.isRefsEqual;
  33498. var isStream = corePrimitives.isStream;
  33499. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  33500. var Lexer = coreParser.Lexer;
  33501. var Parser = coreParser.Parser;
  33502. var ChunkedStream = coreChunkedStream.ChunkedStream;
  33503. var ColorSpace = coreColorSpace.ColorSpace;
  33504. var Catalog = function CatalogClosure() {
  33505. function Catalog(pdfManager, xref, pageFactory) {
  33506. this.pdfManager = pdfManager;
  33507. this.xref = xref;
  33508. this.catDict = xref.getCatalogObj();
  33509. this.fontCache = new RefSetCache();
  33510. this.builtInCMapCache = Object.create(null);
  33511. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  33512. this.pageFactory = pageFactory;
  33513. this.pagePromises = [];
  33514. }
  33515. Catalog.prototype = {
  33516. get metadata() {
  33517. var streamRef = this.catDict.getRaw('Metadata');
  33518. if (!isRef(streamRef)) {
  33519. return shadow(this, 'metadata', null);
  33520. }
  33521. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  33522. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  33523. var metadata;
  33524. if (stream && isDict(stream.dict)) {
  33525. var type = stream.dict.get('Type');
  33526. var subtype = stream.dict.get('Subtype');
  33527. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  33528. try {
  33529. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  33530. } catch (e) {
  33531. info('Skipping invalid metadata.');
  33532. }
  33533. }
  33534. }
  33535. return shadow(this, 'metadata', metadata);
  33536. },
  33537. get toplevelPagesDict() {
  33538. var pagesObj = this.catDict.get('Pages');
  33539. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  33540. return shadow(this, 'toplevelPagesDict', pagesObj);
  33541. },
  33542. get documentOutline() {
  33543. var obj = null;
  33544. try {
  33545. obj = this.readDocumentOutline();
  33546. } catch (ex) {
  33547. if (ex instanceof MissingDataException) {
  33548. throw ex;
  33549. }
  33550. warn('Unable to read document outline');
  33551. }
  33552. return shadow(this, 'documentOutline', obj);
  33553. },
  33554. readDocumentOutline: function Catalog_readDocumentOutline() {
  33555. var obj = this.catDict.get('Outlines');
  33556. if (!isDict(obj)) {
  33557. return null;
  33558. }
  33559. obj = obj.getRaw('First');
  33560. if (!isRef(obj)) {
  33561. return null;
  33562. }
  33563. var root = { items: [] };
  33564. var queue = [{
  33565. obj: obj,
  33566. parent: root
  33567. }];
  33568. var processed = new RefSet();
  33569. processed.put(obj);
  33570. var xref = this.xref, blackColor = new Uint8Array(3);
  33571. while (queue.length > 0) {
  33572. var i = queue.shift();
  33573. var outlineDict = xref.fetchIfRef(i.obj);
  33574. if (outlineDict === null) {
  33575. continue;
  33576. }
  33577. assert(outlineDict.has('Title'), 'Invalid outline item');
  33578. var data = {
  33579. url: null,
  33580. dest: null
  33581. };
  33582. Catalog.parseDestDictionary({
  33583. destDict: outlineDict,
  33584. resultObj: data,
  33585. docBaseUrl: this.pdfManager.docBaseUrl
  33586. });
  33587. var title = outlineDict.get('Title');
  33588. var flags = outlineDict.get('F') || 0;
  33589. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  33590. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  33591. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  33592. }
  33593. var outlineItem = {
  33594. dest: data.dest,
  33595. url: data.url,
  33596. unsafeUrl: data.unsafeUrl,
  33597. newWindow: data.newWindow,
  33598. title: stringToPDFString(title),
  33599. color: rgbColor,
  33600. count: outlineDict.get('Count'),
  33601. bold: !!(flags & 2),
  33602. italic: !!(flags & 1),
  33603. items: []
  33604. };
  33605. i.parent.items.push(outlineItem);
  33606. obj = outlineDict.getRaw('First');
  33607. if (isRef(obj) && !processed.has(obj)) {
  33608. queue.push({
  33609. obj: obj,
  33610. parent: outlineItem
  33611. });
  33612. processed.put(obj);
  33613. }
  33614. obj = outlineDict.getRaw('Next');
  33615. if (isRef(obj) && !processed.has(obj)) {
  33616. queue.push({
  33617. obj: obj,
  33618. parent: i.parent
  33619. });
  33620. processed.put(obj);
  33621. }
  33622. }
  33623. return root.items.length > 0 ? root.items : null;
  33624. },
  33625. get numPages() {
  33626. var obj = this.toplevelPagesDict.get('Count');
  33627. assert(isInt(obj), 'page count in top level pages object is not an integer');
  33628. return shadow(this, 'num', obj);
  33629. },
  33630. get destinations() {
  33631. function fetchDestination(dest) {
  33632. return isDict(dest) ? dest.get('D') : dest;
  33633. }
  33634. var xref = this.xref;
  33635. var dests = {}, nameTreeRef, nameDictionaryRef;
  33636. var obj = this.catDict.get('Names');
  33637. if (obj && obj.has('Dests')) {
  33638. nameTreeRef = obj.getRaw('Dests');
  33639. } else if (this.catDict.has('Dests')) {
  33640. nameDictionaryRef = this.catDict.get('Dests');
  33641. }
  33642. if (nameDictionaryRef) {
  33643. obj = nameDictionaryRef;
  33644. obj.forEach(function catalogForEach(key, value) {
  33645. if (!value) {
  33646. return;
  33647. }
  33648. dests[key] = fetchDestination(value);
  33649. });
  33650. }
  33651. if (nameTreeRef) {
  33652. var nameTree = new NameTree(nameTreeRef, xref);
  33653. var names = nameTree.getAll();
  33654. for (var name in names) {
  33655. dests[name] = fetchDestination(names[name]);
  33656. }
  33657. }
  33658. return shadow(this, 'destinations', dests);
  33659. },
  33660. getDestination: function Catalog_getDestination(destinationId) {
  33661. function fetchDestination(dest) {
  33662. return isDict(dest) ? dest.get('D') : dest;
  33663. }
  33664. var xref = this.xref;
  33665. var dest = null, nameTreeRef, nameDictionaryRef;
  33666. var obj = this.catDict.get('Names');
  33667. if (obj && obj.has('Dests')) {
  33668. nameTreeRef = obj.getRaw('Dests');
  33669. } else if (this.catDict.has('Dests')) {
  33670. nameDictionaryRef = this.catDict.get('Dests');
  33671. }
  33672. if (nameDictionaryRef) {
  33673. var value = nameDictionaryRef.get(destinationId);
  33674. if (value) {
  33675. dest = fetchDestination(value);
  33676. }
  33677. }
  33678. if (nameTreeRef) {
  33679. var nameTree = new NameTree(nameTreeRef, xref);
  33680. dest = fetchDestination(nameTree.get(destinationId));
  33681. }
  33682. return dest;
  33683. },
  33684. get pageLabels() {
  33685. var obj = null;
  33686. try {
  33687. obj = this.readPageLabels();
  33688. } catch (ex) {
  33689. if (ex instanceof MissingDataException) {
  33690. throw ex;
  33691. }
  33692. warn('Unable to read page labels.');
  33693. }
  33694. return shadow(this, 'pageLabels', obj);
  33695. },
  33696. readPageLabels: function Catalog_readPageLabels() {
  33697. var obj = this.catDict.getRaw('PageLabels');
  33698. if (!obj) {
  33699. return null;
  33700. }
  33701. var pageLabels = new Array(this.numPages);
  33702. var style = null;
  33703. var prefix = '';
  33704. var numberTree = new NumberTree(obj, this.xref);
  33705. var nums = numberTree.getAll();
  33706. var currentLabel = '', currentIndex = 1;
  33707. for (var i = 0, ii = this.numPages; i < ii; i++) {
  33708. if (i in nums) {
  33709. var labelDict = nums[i];
  33710. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  33711. var type = labelDict.get('Type');
  33712. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  33713. var s = labelDict.get('S');
  33714. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  33715. style = s ? s.name : null;
  33716. var p = labelDict.get('P');
  33717. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  33718. prefix = p ? stringToPDFString(p) : '';
  33719. var st = labelDict.get('St');
  33720. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  33721. currentIndex = st || 1;
  33722. }
  33723. switch (style) {
  33724. case 'D':
  33725. currentLabel = currentIndex;
  33726. break;
  33727. case 'R':
  33728. case 'r':
  33729. currentLabel = Util.toRoman(currentIndex, style === 'r');
  33730. break;
  33731. case 'A':
  33732. case 'a':
  33733. var LIMIT = 26;
  33734. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  33735. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  33736. var letterIndex = currentIndex - 1;
  33737. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  33738. var charBuf = [];
  33739. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  33740. charBuf.push(character);
  33741. }
  33742. currentLabel = charBuf.join('');
  33743. break;
  33744. default:
  33745. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  33746. }
  33747. pageLabels[i] = prefix + currentLabel;
  33748. currentLabel = '';
  33749. currentIndex++;
  33750. }
  33751. return pageLabels;
  33752. },
  33753. get attachments() {
  33754. var xref = this.xref;
  33755. var attachments = null, nameTreeRef;
  33756. var obj = this.catDict.get('Names');
  33757. if (obj) {
  33758. nameTreeRef = obj.getRaw('EmbeddedFiles');
  33759. }
  33760. if (nameTreeRef) {
  33761. var nameTree = new NameTree(nameTreeRef, xref);
  33762. var names = nameTree.getAll();
  33763. for (var name in names) {
  33764. var fs = new FileSpec(names[name], xref);
  33765. if (!attachments) {
  33766. attachments = Object.create(null);
  33767. }
  33768. attachments[stringToPDFString(name)] = fs.serializable;
  33769. }
  33770. }
  33771. return shadow(this, 'attachments', attachments);
  33772. },
  33773. get javaScript() {
  33774. var xref = this.xref;
  33775. var obj = this.catDict.get('Names');
  33776. var javaScript = [];
  33777. function appendIfJavaScriptDict(jsDict) {
  33778. var type = jsDict.get('S');
  33779. if (!isName(type, 'JavaScript')) {
  33780. return;
  33781. }
  33782. var js = jsDict.get('JS');
  33783. if (isStream(js)) {
  33784. js = bytesToString(js.getBytes());
  33785. } else if (!isString(js)) {
  33786. return;
  33787. }
  33788. javaScript.push(stringToPDFString(js));
  33789. }
  33790. if (obj && obj.has('JavaScript')) {
  33791. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  33792. var names = nameTree.getAll();
  33793. for (var name in names) {
  33794. var jsDict = names[name];
  33795. if (isDict(jsDict)) {
  33796. appendIfJavaScriptDict(jsDict);
  33797. }
  33798. }
  33799. }
  33800. var openactionDict = this.catDict.get('OpenAction');
  33801. if (isDict(openactionDict, 'Action')) {
  33802. var actionType = openactionDict.get('S');
  33803. if (isName(actionType, 'Named')) {
  33804. var action = openactionDict.get('N');
  33805. if (isName(action, 'Print')) {
  33806. javaScript.push('print({});');
  33807. }
  33808. } else {
  33809. appendIfJavaScriptDict(openactionDict);
  33810. }
  33811. }
  33812. return shadow(this, 'javaScript', javaScript);
  33813. },
  33814. cleanup: function Catalog_cleanup() {
  33815. var promises = [];
  33816. this.fontCache.forEach(function (promise) {
  33817. promises.push(promise);
  33818. });
  33819. return Promise.all(promises).then(function (translatedFonts) {
  33820. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  33821. var font = translatedFonts[i].dict;
  33822. delete font.translated;
  33823. }
  33824. this.fontCache.clear();
  33825. this.builtInCMapCache = Object.create(null);
  33826. }.bind(this));
  33827. },
  33828. getPage: function Catalog_getPage(pageIndex) {
  33829. if (!(pageIndex in this.pagePromises)) {
  33830. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  33831. var dict = a[0];
  33832. var ref = a[1];
  33833. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  33834. }.bind(this));
  33835. }
  33836. return this.pagePromises[pageIndex];
  33837. },
  33838. getPageDict: function Catalog_getPageDict(pageIndex) {
  33839. var capability = createPromiseCapability();
  33840. var nodesToVisit = [this.catDict.getRaw('Pages')];
  33841. var currentPageIndex = 0;
  33842. var xref = this.xref;
  33843. function next() {
  33844. while (nodesToVisit.length) {
  33845. var currentNode = nodesToVisit.pop();
  33846. if (isRef(currentNode)) {
  33847. xref.fetchAsync(currentNode).then(function (obj) {
  33848. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  33849. if (pageIndex === currentPageIndex) {
  33850. capability.resolve([
  33851. obj,
  33852. currentNode
  33853. ]);
  33854. } else {
  33855. currentPageIndex++;
  33856. next();
  33857. }
  33858. return;
  33859. }
  33860. nodesToVisit.push(obj);
  33861. next();
  33862. }, capability.reject);
  33863. return;
  33864. }
  33865. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  33866. var count = currentNode.get('Count');
  33867. if (currentPageIndex + count <= pageIndex) {
  33868. currentPageIndex += count;
  33869. continue;
  33870. }
  33871. var kids = currentNode.get('Kids');
  33872. assert(isArray(kids), 'page dictionary kids object is not an array');
  33873. for (var last = kids.length - 1; last >= 0; last--) {
  33874. nodesToVisit.push(kids[last]);
  33875. }
  33876. }
  33877. capability.reject('Page index ' + pageIndex + ' not found.');
  33878. }
  33879. next();
  33880. return capability.promise;
  33881. },
  33882. getPageIndex: function Catalog_getPageIndex(pageRef) {
  33883. var xref = this.xref;
  33884. function pagesBeforeRef(kidRef) {
  33885. var total = 0;
  33886. var parentRef;
  33887. return xref.fetchAsync(kidRef).then(function (node) {
  33888. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  33889. throw new Error('The reference does not point to a /Page Dict.');
  33890. }
  33891. if (!node) {
  33892. return null;
  33893. }
  33894. assert(isDict(node), 'node must be a Dict.');
  33895. parentRef = node.getRaw('Parent');
  33896. return node.getAsync('Parent');
  33897. }).then(function (parent) {
  33898. if (!parent) {
  33899. return null;
  33900. }
  33901. assert(isDict(parent), 'parent must be a Dict.');
  33902. return parent.getAsync('Kids');
  33903. }).then(function (kids) {
  33904. if (!kids) {
  33905. return null;
  33906. }
  33907. var kidPromises = [];
  33908. var found = false;
  33909. for (var i = 0; i < kids.length; i++) {
  33910. var kid = kids[i];
  33911. assert(isRef(kid), 'kid must be a Ref.');
  33912. if (kid.num === kidRef.num) {
  33913. found = true;
  33914. break;
  33915. }
  33916. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  33917. if (kid.has('Count')) {
  33918. var count = kid.get('Count');
  33919. total += count;
  33920. } else {
  33921. total++;
  33922. }
  33923. }));
  33924. }
  33925. if (!found) {
  33926. error('kid ref not found in parents kids');
  33927. }
  33928. return Promise.all(kidPromises).then(function () {
  33929. return [
  33930. total,
  33931. parentRef
  33932. ];
  33933. });
  33934. });
  33935. }
  33936. var total = 0;
  33937. function next(ref) {
  33938. return pagesBeforeRef(ref).then(function (args) {
  33939. if (!args) {
  33940. return total;
  33941. }
  33942. var count = args[0];
  33943. var parentRef = args[1];
  33944. total += count;
  33945. return next(parentRef);
  33946. });
  33947. }
  33948. return next(pageRef);
  33949. }
  33950. };
  33951. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  33952. function addDefaultProtocolToUrl(url) {
  33953. if (url.indexOf('www.') === 0) {
  33954. return 'http://' + url;
  33955. }
  33956. return url;
  33957. }
  33958. function tryConvertUrlEncoding(url) {
  33959. try {
  33960. return stringToUTF8String(url);
  33961. } catch (e) {
  33962. return url;
  33963. }
  33964. }
  33965. var destDict = params.destDict;
  33966. if (!isDict(destDict)) {
  33967. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  33968. return;
  33969. }
  33970. var resultObj = params.resultObj;
  33971. if (typeof resultObj !== 'object') {
  33972. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  33973. return;
  33974. }
  33975. var docBaseUrl = params.docBaseUrl || null;
  33976. var action = destDict.get('A'), url, dest;
  33977. if (isDict(action)) {
  33978. var linkType = action.get('S').name;
  33979. switch (linkType) {
  33980. case 'URI':
  33981. url = action.get('URI');
  33982. if (isName(url)) {
  33983. url = '/' + url.name;
  33984. } else if (isString(url)) {
  33985. url = addDefaultProtocolToUrl(url);
  33986. }
  33987. break;
  33988. case 'GoTo':
  33989. dest = action.get('D');
  33990. break;
  33991. case 'Launch':
  33992. case 'GoToR':
  33993. var urlDict = action.get('F');
  33994. if (isDict(urlDict)) {
  33995. url = urlDict.get('F') || null;
  33996. } else if (isString(urlDict)) {
  33997. url = urlDict;
  33998. }
  33999. var remoteDest = action.get('D');
  34000. if (remoteDest) {
  34001. if (isName(remoteDest)) {
  34002. remoteDest = remoteDest.name;
  34003. }
  34004. if (isString(url)) {
  34005. var baseUrl = url.split('#')[0];
  34006. if (isString(remoteDest)) {
  34007. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34008. } else if (isArray(remoteDest)) {
  34009. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34010. }
  34011. }
  34012. }
  34013. var newWindow = action.get('NewWindow');
  34014. if (isBool(newWindow)) {
  34015. resultObj.newWindow = newWindow;
  34016. }
  34017. break;
  34018. case 'Named':
  34019. var namedAction = action.get('N');
  34020. if (isName(namedAction)) {
  34021. resultObj.action = namedAction.name;
  34022. }
  34023. break;
  34024. case 'JavaScript':
  34025. var jsAction = action.get('JS'), js;
  34026. if (isStream(jsAction)) {
  34027. js = bytesToString(jsAction.getBytes());
  34028. } else if (isString(jsAction)) {
  34029. js = jsAction;
  34030. }
  34031. if (js) {
  34032. var URL_OPEN_METHODS = [
  34033. 'app.launchURL',
  34034. 'window.open'
  34035. ];
  34036. var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
  34037. var jsUrl = regex.exec(stringToPDFString(js));
  34038. if (jsUrl && jsUrl[2]) {
  34039. url = jsUrl[2];
  34040. if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
  34041. resultObj.newWindow = true;
  34042. }
  34043. break;
  34044. }
  34045. }
  34046. default:
  34047. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34048. break;
  34049. }
  34050. } else if (destDict.has('Dest')) {
  34051. dest = destDict.get('Dest');
  34052. }
  34053. if (isString(url)) {
  34054. url = tryConvertUrlEncoding(url);
  34055. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34056. if (absoluteUrl) {
  34057. resultObj.url = absoluteUrl.href;
  34058. }
  34059. resultObj.unsafeUrl = url;
  34060. }
  34061. if (dest) {
  34062. if (isName(dest)) {
  34063. dest = dest.name;
  34064. }
  34065. if (isString(dest) || isArray(dest)) {
  34066. resultObj.dest = dest;
  34067. }
  34068. }
  34069. };
  34070. return Catalog;
  34071. }();
  34072. var XRef = function XRefClosure() {
  34073. function XRef(stream, pdfManager) {
  34074. this.stream = stream;
  34075. this.pdfManager = pdfManager;
  34076. this.entries = [];
  34077. this.xrefstms = Object.create(null);
  34078. this.cache = [];
  34079. this.stats = {
  34080. streamTypes: [],
  34081. fontTypes: []
  34082. };
  34083. }
  34084. XRef.prototype = {
  34085. setStartXRef: function XRef_setStartXRef(startXRef) {
  34086. this.startXRefQueue = [startXRef];
  34087. },
  34088. parse: function XRef_parse(recoveryMode) {
  34089. var trailerDict;
  34090. if (!recoveryMode) {
  34091. trailerDict = this.readXRef();
  34092. } else {
  34093. warn('Indexing all PDF objects');
  34094. trailerDict = this.indexObjects();
  34095. }
  34096. trailerDict.assignXref(this);
  34097. this.trailer = trailerDict;
  34098. var encrypt = trailerDict.get('Encrypt');
  34099. if (isDict(encrypt)) {
  34100. var ids = trailerDict.get('ID');
  34101. var fileId = ids && ids.length ? ids[0] : '';
  34102. encrypt.suppressEncryption = true;
  34103. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34104. }
  34105. if (!(this.root = trailerDict.get('Root'))) {
  34106. error('Invalid root reference');
  34107. }
  34108. },
  34109. processXRefTable: function XRef_processXRefTable(parser) {
  34110. if (!('tableState' in this)) {
  34111. this.tableState = {
  34112. entryNum: 0,
  34113. streamPos: parser.lexer.stream.pos,
  34114. parserBuf1: parser.buf1,
  34115. parserBuf2: parser.buf2
  34116. };
  34117. }
  34118. var obj = this.readXRefTable(parser);
  34119. if (!isCmd(obj, 'trailer')) {
  34120. error('Invalid XRef table: could not find trailer dictionary');
  34121. }
  34122. var dict = parser.getObj();
  34123. if (!isDict(dict) && dict.dict) {
  34124. dict = dict.dict;
  34125. }
  34126. if (!isDict(dict)) {
  34127. error('Invalid XRef table: could not parse trailer dictionary');
  34128. }
  34129. delete this.tableState;
  34130. return dict;
  34131. },
  34132. readXRefTable: function XRef_readXRefTable(parser) {
  34133. var stream = parser.lexer.stream;
  34134. var tableState = this.tableState;
  34135. stream.pos = tableState.streamPos;
  34136. parser.buf1 = tableState.parserBuf1;
  34137. parser.buf2 = tableState.parserBuf2;
  34138. var obj;
  34139. while (true) {
  34140. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34141. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34142. break;
  34143. }
  34144. tableState.firstEntryNum = obj;
  34145. tableState.entryCount = parser.getObj();
  34146. }
  34147. var first = tableState.firstEntryNum;
  34148. var count = tableState.entryCount;
  34149. if (!isInt(first) || !isInt(count)) {
  34150. error('Invalid XRef table: wrong types in subsection header');
  34151. }
  34152. for (var i = tableState.entryNum; i < count; i++) {
  34153. tableState.streamPos = stream.pos;
  34154. tableState.entryNum = i;
  34155. tableState.parserBuf1 = parser.buf1;
  34156. tableState.parserBuf2 = parser.buf2;
  34157. var entry = {};
  34158. entry.offset = parser.getObj();
  34159. entry.gen = parser.getObj();
  34160. var type = parser.getObj();
  34161. if (isCmd(type, 'f')) {
  34162. entry.free = true;
  34163. } else if (isCmd(type, 'n')) {
  34164. entry.uncompressed = true;
  34165. }
  34166. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34167. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34168. }
  34169. if (i === 0 && entry.free && first === 1) {
  34170. first = 0;
  34171. }
  34172. if (!this.entries[i + first]) {
  34173. this.entries[i + first] = entry;
  34174. }
  34175. }
  34176. tableState.entryNum = 0;
  34177. tableState.streamPos = stream.pos;
  34178. tableState.parserBuf1 = parser.buf1;
  34179. tableState.parserBuf2 = parser.buf2;
  34180. delete tableState.firstEntryNum;
  34181. delete tableState.entryCount;
  34182. }
  34183. if (this.entries[0] && !this.entries[0].free) {
  34184. error('Invalid XRef table: unexpected first object');
  34185. }
  34186. return obj;
  34187. },
  34188. processXRefStream: function XRef_processXRefStream(stream) {
  34189. if (!('streamState' in this)) {
  34190. var streamParameters = stream.dict;
  34191. var byteWidths = streamParameters.get('W');
  34192. var range = streamParameters.get('Index');
  34193. if (!range) {
  34194. range = [
  34195. 0,
  34196. streamParameters.get('Size')
  34197. ];
  34198. }
  34199. this.streamState = {
  34200. entryRanges: range,
  34201. byteWidths: byteWidths,
  34202. entryNum: 0,
  34203. streamPos: stream.pos
  34204. };
  34205. }
  34206. this.readXRefStream(stream);
  34207. delete this.streamState;
  34208. return stream.dict;
  34209. },
  34210. readXRefStream: function XRef_readXRefStream(stream) {
  34211. var i, j;
  34212. var streamState = this.streamState;
  34213. stream.pos = streamState.streamPos;
  34214. var byteWidths = streamState.byteWidths;
  34215. var typeFieldWidth = byteWidths[0];
  34216. var offsetFieldWidth = byteWidths[1];
  34217. var generationFieldWidth = byteWidths[2];
  34218. var entryRanges = streamState.entryRanges;
  34219. while (entryRanges.length > 0) {
  34220. var first = entryRanges[0];
  34221. var n = entryRanges[1];
  34222. if (!isInt(first) || !isInt(n)) {
  34223. error('Invalid XRef range fields: ' + first + ', ' + n);
  34224. }
  34225. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34226. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34227. }
  34228. for (i = streamState.entryNum; i < n; ++i) {
  34229. streamState.entryNum = i;
  34230. streamState.streamPos = stream.pos;
  34231. var type = 0, offset = 0, generation = 0;
  34232. for (j = 0; j < typeFieldWidth; ++j) {
  34233. type = type << 8 | stream.getByte();
  34234. }
  34235. if (typeFieldWidth === 0) {
  34236. type = 1;
  34237. }
  34238. for (j = 0; j < offsetFieldWidth; ++j) {
  34239. offset = offset << 8 | stream.getByte();
  34240. }
  34241. for (j = 0; j < generationFieldWidth; ++j) {
  34242. generation = generation << 8 | stream.getByte();
  34243. }
  34244. var entry = {};
  34245. entry.offset = offset;
  34246. entry.gen = generation;
  34247. switch (type) {
  34248. case 0:
  34249. entry.free = true;
  34250. break;
  34251. case 1:
  34252. entry.uncompressed = true;
  34253. break;
  34254. case 2:
  34255. break;
  34256. default:
  34257. error('Invalid XRef entry type: ' + type);
  34258. }
  34259. if (!this.entries[first + i]) {
  34260. this.entries[first + i] = entry;
  34261. }
  34262. }
  34263. streamState.entryNum = 0;
  34264. streamState.streamPos = stream.pos;
  34265. entryRanges.splice(0, 2);
  34266. }
  34267. },
  34268. indexObjects: function XRef_indexObjects() {
  34269. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34270. var PERCENT = 0x25, LT = 0x3C;
  34271. function readToken(data, offset) {
  34272. var token = '', ch = data[offset];
  34273. while (ch !== LF && ch !== CR && ch !== LT) {
  34274. if (++offset >= data.length) {
  34275. break;
  34276. }
  34277. token += String.fromCharCode(ch);
  34278. ch = data[offset];
  34279. }
  34280. return token;
  34281. }
  34282. function skipUntil(data, offset, what) {
  34283. var length = what.length, dataLength = data.length;
  34284. var skipped = 0;
  34285. while (offset < dataLength) {
  34286. var i = 0;
  34287. while (i < length && data[offset + i] === what[i]) {
  34288. ++i;
  34289. }
  34290. if (i >= length) {
  34291. break;
  34292. }
  34293. offset++;
  34294. skipped++;
  34295. }
  34296. return skipped;
  34297. }
  34298. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34299. var trailerBytes = new Uint8Array([
  34300. 116,
  34301. 114,
  34302. 97,
  34303. 105,
  34304. 108,
  34305. 101,
  34306. 114
  34307. ]);
  34308. var startxrefBytes = new Uint8Array([
  34309. 115,
  34310. 116,
  34311. 97,
  34312. 114,
  34313. 116,
  34314. 120,
  34315. 114,
  34316. 101,
  34317. 102
  34318. ]);
  34319. var endobjBytes = new Uint8Array([
  34320. 101,
  34321. 110,
  34322. 100,
  34323. 111,
  34324. 98,
  34325. 106
  34326. ]);
  34327. var xrefBytes = new Uint8Array([
  34328. 47,
  34329. 88,
  34330. 82,
  34331. 101,
  34332. 102
  34333. ]);
  34334. this.entries.length = 0;
  34335. var stream = this.stream;
  34336. stream.pos = 0;
  34337. var buffer = stream.getBytes();
  34338. var position = stream.start, length = buffer.length;
  34339. var trailers = [], xrefStms = [];
  34340. while (position < length) {
  34341. var ch = buffer[position];
  34342. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34343. ++position;
  34344. continue;
  34345. }
  34346. if (ch === PERCENT) {
  34347. do {
  34348. ++position;
  34349. if (position >= length) {
  34350. break;
  34351. }
  34352. ch = buffer[position];
  34353. } while (ch !== LF && ch !== CR);
  34354. continue;
  34355. }
  34356. var token = readToken(buffer, position);
  34357. var m;
  34358. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34359. position += skipUntil(buffer, position, trailerBytes);
  34360. trailers.push(position);
  34361. position += skipUntil(buffer, position, startxrefBytes);
  34362. } else if (m = objRegExp.exec(token)) {
  34363. if (typeof this.entries[m[1]] === 'undefined') {
  34364. this.entries[m[1]] = {
  34365. offset: position - stream.start,
  34366. gen: m[2] | 0,
  34367. uncompressed: true
  34368. };
  34369. }
  34370. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34371. var content = buffer.subarray(position, position + contentLength);
  34372. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34373. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34374. xrefStms.push(position - stream.start);
  34375. this.xrefstms[position - stream.start] = 1;
  34376. }
  34377. position += contentLength;
  34378. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34379. trailers.push(position);
  34380. position += skipUntil(buffer, position, startxrefBytes);
  34381. } else {
  34382. position += token.length + 1;
  34383. }
  34384. }
  34385. var i, ii;
  34386. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34387. this.startXRefQueue.push(xrefStms[i]);
  34388. this.readXRef(true);
  34389. }
  34390. var dict;
  34391. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34392. stream.pos = trailers[i];
  34393. var parser = new Parser(new Lexer(stream), true, this, true);
  34394. var obj = parser.getObj();
  34395. if (!isCmd(obj, 'trailer')) {
  34396. continue;
  34397. }
  34398. dict = parser.getObj();
  34399. if (!isDict(dict)) {
  34400. continue;
  34401. }
  34402. if (dict.has('ID')) {
  34403. return dict;
  34404. }
  34405. }
  34406. if (dict) {
  34407. return dict;
  34408. }
  34409. throw new InvalidPDFException('Invalid PDF structure');
  34410. },
  34411. readXRef: function XRef_readXRef(recoveryMode) {
  34412. var stream = this.stream;
  34413. try {
  34414. while (this.startXRefQueue.length) {
  34415. var startXRef = this.startXRefQueue[0];
  34416. stream.pos = startXRef + stream.start;
  34417. var parser = new Parser(new Lexer(stream), true, this);
  34418. var obj = parser.getObj();
  34419. var dict;
  34420. if (isCmd(obj, 'xref')) {
  34421. dict = this.processXRefTable(parser);
  34422. if (!this.topDict) {
  34423. this.topDict = dict;
  34424. }
  34425. obj = dict.get('XRefStm');
  34426. if (isInt(obj)) {
  34427. var pos = obj;
  34428. if (!(pos in this.xrefstms)) {
  34429. this.xrefstms[pos] = 1;
  34430. this.startXRefQueue.push(pos);
  34431. }
  34432. }
  34433. } else if (isInt(obj)) {
  34434. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34435. error('Invalid XRef stream');
  34436. }
  34437. dict = this.processXRefStream(obj);
  34438. if (!this.topDict) {
  34439. this.topDict = dict;
  34440. }
  34441. if (!dict) {
  34442. error('Failed to read XRef stream');
  34443. }
  34444. } else {
  34445. error('Invalid XRef stream header');
  34446. }
  34447. obj = dict.get('Prev');
  34448. if (isInt(obj)) {
  34449. this.startXRefQueue.push(obj);
  34450. } else if (isRef(obj)) {
  34451. this.startXRefQueue.push(obj.num);
  34452. }
  34453. this.startXRefQueue.shift();
  34454. }
  34455. return this.topDict;
  34456. } catch (e) {
  34457. if (e instanceof MissingDataException) {
  34458. throw e;
  34459. }
  34460. info('(while reading XRef): ' + e);
  34461. }
  34462. if (recoveryMode) {
  34463. return;
  34464. }
  34465. throw new XRefParseException();
  34466. },
  34467. getEntry: function XRef_getEntry(i) {
  34468. var xrefEntry = this.entries[i];
  34469. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34470. return xrefEntry;
  34471. }
  34472. return null;
  34473. },
  34474. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34475. if (!isRef(obj)) {
  34476. return obj;
  34477. }
  34478. return this.fetch(obj, suppressEncryption);
  34479. },
  34480. fetch: function XRef_fetch(ref, suppressEncryption) {
  34481. assert(isRef(ref), 'ref object is not a reference');
  34482. var num = ref.num;
  34483. if (num in this.cache) {
  34484. var cacheEntry = this.cache[num];
  34485. if (isDict(cacheEntry) && !cacheEntry.objId) {
  34486. cacheEntry.objId = ref.toString();
  34487. }
  34488. return cacheEntry;
  34489. }
  34490. var xrefEntry = this.getEntry(num);
  34491. if (xrefEntry === null) {
  34492. return this.cache[num] = null;
  34493. }
  34494. if (xrefEntry.uncompressed) {
  34495. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34496. } else {
  34497. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34498. }
  34499. if (isDict(xrefEntry)) {
  34500. xrefEntry.objId = ref.toString();
  34501. } else if (isStream(xrefEntry)) {
  34502. xrefEntry.dict.objId = ref.toString();
  34503. }
  34504. return xrefEntry;
  34505. },
  34506. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34507. var gen = ref.gen;
  34508. var num = ref.num;
  34509. if (xrefEntry.gen !== gen) {
  34510. error('inconsistent generation in XRef');
  34511. }
  34512. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34513. var parser = new Parser(new Lexer(stream), true, this);
  34514. var obj1 = parser.getObj();
  34515. var obj2 = parser.getObj();
  34516. var obj3 = parser.getObj();
  34517. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34518. error('bad XRef entry');
  34519. }
  34520. if (!isCmd(obj3, 'obj')) {
  34521. if (obj3.cmd.indexOf('obj') === 0) {
  34522. num = parseInt(obj3.cmd.substring(3), 10);
  34523. if (!isNaN(num)) {
  34524. return num;
  34525. }
  34526. }
  34527. error('bad XRef entry');
  34528. }
  34529. if (this.encrypt && !suppressEncryption) {
  34530. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34531. } else {
  34532. xrefEntry = parser.getObj();
  34533. }
  34534. if (!isStream(xrefEntry)) {
  34535. this.cache[num] = xrefEntry;
  34536. }
  34537. return xrefEntry;
  34538. },
  34539. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34540. var tableOffset = xrefEntry.offset;
  34541. var stream = this.fetch(new Ref(tableOffset, 0));
  34542. if (!isStream(stream)) {
  34543. error('bad ObjStm stream');
  34544. }
  34545. var first = stream.dict.get('First');
  34546. var n = stream.dict.get('N');
  34547. if (!isInt(first) || !isInt(n)) {
  34548. error('invalid first and n parameters for ObjStm stream');
  34549. }
  34550. var parser = new Parser(new Lexer(stream), false, this);
  34551. parser.allowStreams = true;
  34552. var i, entries = [], num, nums = [];
  34553. for (i = 0; i < n; ++i) {
  34554. num = parser.getObj();
  34555. if (!isInt(num)) {
  34556. error('invalid object number in the ObjStm stream: ' + num);
  34557. }
  34558. nums.push(num);
  34559. var offset = parser.getObj();
  34560. if (!isInt(offset)) {
  34561. error('invalid object offset in the ObjStm stream: ' + offset);
  34562. }
  34563. }
  34564. for (i = 0; i < n; ++i) {
  34565. entries.push(parser.getObj());
  34566. if (isCmd(parser.buf1, 'endobj')) {
  34567. parser.shift();
  34568. }
  34569. num = nums[i];
  34570. var entry = this.entries[num];
  34571. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34572. this.cache[num] = entries[i];
  34573. }
  34574. }
  34575. xrefEntry = entries[xrefEntry.gen];
  34576. if (xrefEntry === undefined) {
  34577. error('bad XRef entry for compressed object');
  34578. }
  34579. return xrefEntry;
  34580. },
  34581. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34582. if (!isRef(obj)) {
  34583. return Promise.resolve(obj);
  34584. }
  34585. return this.fetchAsync(obj, suppressEncryption);
  34586. },
  34587. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34588. var streamManager = this.stream.manager;
  34589. var xref = this;
  34590. return new Promise(function tryFetch(resolve, reject) {
  34591. try {
  34592. resolve(xref.fetch(ref, suppressEncryption));
  34593. } catch (e) {
  34594. if (e instanceof MissingDataException) {
  34595. streamManager.requestRange(e.begin, e.end).then(function () {
  34596. tryFetch(resolve, reject);
  34597. }, reject);
  34598. return;
  34599. }
  34600. reject(e);
  34601. }
  34602. });
  34603. },
  34604. getCatalogObj: function XRef_getCatalogObj() {
  34605. return this.root;
  34606. }
  34607. };
  34608. return XRef;
  34609. }();
  34610. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34611. function NameOrNumberTree(root, xref) {
  34612. throw new Error('Cannot initialize NameOrNumberTree.');
  34613. }
  34614. NameOrNumberTree.prototype = {
  34615. getAll: function NameOrNumberTree_getAll() {
  34616. var dict = Object.create(null);
  34617. if (!this.root) {
  34618. return dict;
  34619. }
  34620. var xref = this.xref;
  34621. var processed = new RefSet();
  34622. processed.put(this.root);
  34623. var queue = [this.root];
  34624. while (queue.length > 0) {
  34625. var i, n;
  34626. var obj = xref.fetchIfRef(queue.shift());
  34627. if (!isDict(obj)) {
  34628. continue;
  34629. }
  34630. if (obj.has('Kids')) {
  34631. var kids = obj.get('Kids');
  34632. for (i = 0, n = kids.length; i < n; i++) {
  34633. var kid = kids[i];
  34634. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34635. queue.push(kid);
  34636. processed.put(kid);
  34637. }
  34638. continue;
  34639. }
  34640. var entries = obj.get(this._type);
  34641. if (isArray(entries)) {
  34642. for (i = 0, n = entries.length; i < n; i += 2) {
  34643. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34644. }
  34645. }
  34646. }
  34647. return dict;
  34648. },
  34649. get: function NameOrNumberTree_get(key) {
  34650. if (!this.root) {
  34651. return null;
  34652. }
  34653. var xref = this.xref;
  34654. var kidsOrEntries = xref.fetchIfRef(this.root);
  34655. var loopCount = 0;
  34656. var MAX_LEVELS = 10;
  34657. var l, r, m;
  34658. while (kidsOrEntries.has('Kids')) {
  34659. if (++loopCount > MAX_LEVELS) {
  34660. warn('Search depth limit reached for "' + this._type + '" tree.');
  34661. return null;
  34662. }
  34663. var kids = kidsOrEntries.get('Kids');
  34664. if (!isArray(kids)) {
  34665. return null;
  34666. }
  34667. l = 0;
  34668. r = kids.length - 1;
  34669. while (l <= r) {
  34670. m = l + r >> 1;
  34671. var kid = xref.fetchIfRef(kids[m]);
  34672. var limits = kid.get('Limits');
  34673. if (key < xref.fetchIfRef(limits[0])) {
  34674. r = m - 1;
  34675. } else if (key > xref.fetchIfRef(limits[1])) {
  34676. l = m + 1;
  34677. } else {
  34678. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34679. break;
  34680. }
  34681. }
  34682. if (l > r) {
  34683. return null;
  34684. }
  34685. }
  34686. var entries = kidsOrEntries.get(this._type);
  34687. if (isArray(entries)) {
  34688. l = 0;
  34689. r = entries.length - 2;
  34690. while (l <= r) {
  34691. m = l + r & ~1;
  34692. var currentKey = xref.fetchIfRef(entries[m]);
  34693. if (key < currentKey) {
  34694. r = m - 2;
  34695. } else if (key > currentKey) {
  34696. l = m + 2;
  34697. } else {
  34698. return xref.fetchIfRef(entries[m + 1]);
  34699. }
  34700. }
  34701. }
  34702. return null;
  34703. }
  34704. };
  34705. return NameOrNumberTree;
  34706. }();
  34707. var NameTree = function NameTreeClosure() {
  34708. function NameTree(root, xref) {
  34709. this.root = root;
  34710. this.xref = xref;
  34711. this._type = 'Names';
  34712. }
  34713. Util.inherit(NameTree, NameOrNumberTree, {});
  34714. return NameTree;
  34715. }();
  34716. var NumberTree = function NumberTreeClosure() {
  34717. function NumberTree(root, xref) {
  34718. this.root = root;
  34719. this.xref = xref;
  34720. this._type = 'Nums';
  34721. }
  34722. Util.inherit(NumberTree, NameOrNumberTree, {});
  34723. return NumberTree;
  34724. }();
  34725. var FileSpec = function FileSpecClosure() {
  34726. function FileSpec(root, xref) {
  34727. if (!root || !isDict(root)) {
  34728. return;
  34729. }
  34730. this.xref = xref;
  34731. this.root = root;
  34732. if (root.has('FS')) {
  34733. this.fs = root.get('FS');
  34734. }
  34735. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34736. if (root.has('RF')) {
  34737. warn('Related file specifications are not supported');
  34738. }
  34739. this.contentAvailable = true;
  34740. if (!root.has('EF')) {
  34741. this.contentAvailable = false;
  34742. warn('Non-embedded file specifications are not supported');
  34743. }
  34744. }
  34745. function pickPlatformItem(dict) {
  34746. if (dict.has('UF')) {
  34747. return dict.get('UF');
  34748. } else if (dict.has('F')) {
  34749. return dict.get('F');
  34750. } else if (dict.has('Unix')) {
  34751. return dict.get('Unix');
  34752. } else if (dict.has('Mac')) {
  34753. return dict.get('Mac');
  34754. } else if (dict.has('DOS')) {
  34755. return dict.get('DOS');
  34756. }
  34757. return null;
  34758. }
  34759. FileSpec.prototype = {
  34760. get filename() {
  34761. if (!this._filename && this.root) {
  34762. var filename = pickPlatformItem(this.root) || 'unnamed';
  34763. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34764. }
  34765. return this._filename;
  34766. },
  34767. get content() {
  34768. if (!this.contentAvailable) {
  34769. return null;
  34770. }
  34771. if (!this.contentRef && this.root) {
  34772. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34773. }
  34774. var content = null;
  34775. if (this.contentRef) {
  34776. var xref = this.xref;
  34777. var fileObj = xref.fetchIfRef(this.contentRef);
  34778. if (fileObj && isStream(fileObj)) {
  34779. content = fileObj.getBytes();
  34780. } else {
  34781. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34782. }
  34783. } else {
  34784. warn('Embedded file specification does not have a content');
  34785. }
  34786. return content;
  34787. },
  34788. get serializable() {
  34789. return {
  34790. filename: this.filename,
  34791. content: this.content
  34792. };
  34793. }
  34794. };
  34795. return FileSpec;
  34796. }();
  34797. var ObjectLoader = function () {
  34798. function mayHaveChildren(value) {
  34799. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34800. }
  34801. function addChildren(node, nodesToVisit) {
  34802. var value;
  34803. if (isDict(node) || isStream(node)) {
  34804. var map;
  34805. if (isDict(node)) {
  34806. map = node.map;
  34807. } else {
  34808. map = node.dict.map;
  34809. }
  34810. for (var key in map) {
  34811. value = map[key];
  34812. if (mayHaveChildren(value)) {
  34813. nodesToVisit.push(value);
  34814. }
  34815. }
  34816. } else if (isArray(node)) {
  34817. for (var i = 0, ii = node.length; i < ii; i++) {
  34818. value = node[i];
  34819. if (mayHaveChildren(value)) {
  34820. nodesToVisit.push(value);
  34821. }
  34822. }
  34823. }
  34824. }
  34825. function ObjectLoader(obj, keys, xref) {
  34826. this.obj = obj;
  34827. this.keys = keys;
  34828. this.xref = xref;
  34829. this.refSet = null;
  34830. this.capability = null;
  34831. }
  34832. ObjectLoader.prototype = {
  34833. load: function ObjectLoader_load() {
  34834. var keys = this.keys;
  34835. this.capability = createPromiseCapability();
  34836. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34837. this.capability.resolve();
  34838. return this.capability.promise;
  34839. }
  34840. this.refSet = new RefSet();
  34841. var nodesToVisit = [];
  34842. for (var i = 0; i < keys.length; i++) {
  34843. nodesToVisit.push(this.obj[keys[i]]);
  34844. }
  34845. this._walk(nodesToVisit);
  34846. return this.capability.promise;
  34847. },
  34848. _walk: function ObjectLoader_walk(nodesToVisit) {
  34849. var nodesToRevisit = [];
  34850. var pendingRequests = [];
  34851. while (nodesToVisit.length) {
  34852. var currentNode = nodesToVisit.pop();
  34853. if (isRef(currentNode)) {
  34854. if (this.refSet.has(currentNode)) {
  34855. continue;
  34856. }
  34857. try {
  34858. var ref = currentNode;
  34859. this.refSet.put(ref);
  34860. currentNode = this.xref.fetch(currentNode);
  34861. } catch (e) {
  34862. if (!(e instanceof MissingDataException)) {
  34863. throw e;
  34864. }
  34865. nodesToRevisit.push(currentNode);
  34866. pendingRequests.push({
  34867. begin: e.begin,
  34868. end: e.end
  34869. });
  34870. }
  34871. }
  34872. if (currentNode && currentNode.getBaseStreams) {
  34873. var baseStreams = currentNode.getBaseStreams();
  34874. var foundMissingData = false;
  34875. for (var i = 0; i < baseStreams.length; i++) {
  34876. var stream = baseStreams[i];
  34877. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34878. foundMissingData = true;
  34879. pendingRequests.push({
  34880. begin: stream.start,
  34881. end: stream.end
  34882. });
  34883. }
  34884. }
  34885. if (foundMissingData) {
  34886. nodesToRevisit.push(currentNode);
  34887. }
  34888. }
  34889. addChildren(currentNode, nodesToVisit);
  34890. }
  34891. if (pendingRequests.length) {
  34892. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34893. nodesToVisit = nodesToRevisit;
  34894. for (var i = 0; i < nodesToRevisit.length; i++) {
  34895. var node = nodesToRevisit[i];
  34896. if (isRef(node)) {
  34897. this.refSet.remove(node);
  34898. }
  34899. }
  34900. this._walk(nodesToVisit);
  34901. }.bind(this), this.capability.reject);
  34902. return;
  34903. }
  34904. this.refSet = null;
  34905. this.capability.resolve();
  34906. }
  34907. };
  34908. return ObjectLoader;
  34909. }();
  34910. exports.Catalog = Catalog;
  34911. exports.ObjectLoader = ObjectLoader;
  34912. exports.XRef = XRef;
  34913. exports.FileSpec = FileSpec;
  34914. /***/ }),
  34915. /* 21 */
  34916. /***/ (function(module, exports, __w_pdfjs_require__) {
  34917. "use strict";
  34918. var sharedUtil = __w_pdfjs_require__(0);
  34919. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34920. var getStdFontMap = getLookupTableFactory(function (t) {
  34921. t['ArialNarrow'] = 'Helvetica';
  34922. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34923. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34924. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34925. t['ArialBlack'] = 'Helvetica';
  34926. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34927. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34928. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34929. t['Arial-Black'] = 'Helvetica';
  34930. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34931. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34932. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34933. t['Arial'] = 'Helvetica';
  34934. t['Arial-Bold'] = 'Helvetica-Bold';
  34935. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34936. t['Arial-Italic'] = 'Helvetica-Oblique';
  34937. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34938. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34939. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34940. t['ArialMT'] = 'Helvetica';
  34941. t['Courier-Bold'] = 'Courier-Bold';
  34942. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34943. t['Courier-Italic'] = 'Courier-Oblique';
  34944. t['CourierNew'] = 'Courier';
  34945. t['CourierNew-Bold'] = 'Courier-Bold';
  34946. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34947. t['CourierNew-Italic'] = 'Courier-Oblique';
  34948. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34949. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34950. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34951. t['CourierNewPSMT'] = 'Courier';
  34952. t['Helvetica'] = 'Helvetica';
  34953. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34954. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34955. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34956. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34957. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34958. t['Symbol-Bold'] = 'Symbol';
  34959. t['Symbol-BoldItalic'] = 'Symbol';
  34960. t['Symbol-Italic'] = 'Symbol';
  34961. t['TimesNewRoman'] = 'Times-Roman';
  34962. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34963. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34964. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34965. t['TimesNewRomanPS'] = 'Times-Roman';
  34966. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34967. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34968. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34969. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34970. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34971. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34972. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34973. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34974. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34975. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34976. });
  34977. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34978. t['CenturyGothic'] = 'Helvetica';
  34979. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34980. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34981. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34982. t['ComicSansMS'] = 'Comic Sans MS';
  34983. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34984. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  34985. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  34986. t['LucidaConsole'] = 'Courier';
  34987. t['LucidaConsole-Bold'] = 'Courier-Bold';
  34988. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  34989. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  34990. t['MS-Gothic'] = 'MS Gothic';
  34991. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  34992. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  34993. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  34994. t['MS-Mincho'] = 'MS Mincho';
  34995. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  34996. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  34997. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  34998. t['MS-PGothic'] = 'MS PGothic';
  34999. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35000. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35001. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35002. t['MS-PMincho'] = 'MS PMincho';
  35003. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35004. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35005. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35006. t['NuptialScript'] = 'Times-Italic';
  35007. t['Wingdings'] = 'ZapfDingbats';
  35008. });
  35009. var getSerifFonts = getLookupTableFactory(function (t) {
  35010. t['Adobe Jenson'] = true;
  35011. t['Adobe Text'] = true;
  35012. t['Albertus'] = true;
  35013. t['Aldus'] = true;
  35014. t['Alexandria'] = true;
  35015. t['Algerian'] = true;
  35016. t['American Typewriter'] = true;
  35017. t['Antiqua'] = true;
  35018. t['Apex'] = true;
  35019. t['Arno'] = true;
  35020. t['Aster'] = true;
  35021. t['Aurora'] = true;
  35022. t['Baskerville'] = true;
  35023. t['Bell'] = true;
  35024. t['Bembo'] = true;
  35025. t['Bembo Schoolbook'] = true;
  35026. t['Benguiat'] = true;
  35027. t['Berkeley Old Style'] = true;
  35028. t['Bernhard Modern'] = true;
  35029. t['Berthold City'] = true;
  35030. t['Bodoni'] = true;
  35031. t['Bauer Bodoni'] = true;
  35032. t['Book Antiqua'] = true;
  35033. t['Bookman'] = true;
  35034. t['Bordeaux Roman'] = true;
  35035. t['Californian FB'] = true;
  35036. t['Calisto'] = true;
  35037. t['Calvert'] = true;
  35038. t['Capitals'] = true;
  35039. t['Cambria'] = true;
  35040. t['Cartier'] = true;
  35041. t['Caslon'] = true;
  35042. t['Catull'] = true;
  35043. t['Centaur'] = true;
  35044. t['Century Old Style'] = true;
  35045. t['Century Schoolbook'] = true;
  35046. t['Chaparral'] = true;
  35047. t['Charis SIL'] = true;
  35048. t['Cheltenham'] = true;
  35049. t['Cholla Slab'] = true;
  35050. t['Clarendon'] = true;
  35051. t['Clearface'] = true;
  35052. t['Cochin'] = true;
  35053. t['Colonna'] = true;
  35054. t['Computer Modern'] = true;
  35055. t['Concrete Roman'] = true;
  35056. t['Constantia'] = true;
  35057. t['Cooper Black'] = true;
  35058. t['Corona'] = true;
  35059. t['Ecotype'] = true;
  35060. t['Egyptienne'] = true;
  35061. t['Elephant'] = true;
  35062. t['Excelsior'] = true;
  35063. t['Fairfield'] = true;
  35064. t['FF Scala'] = true;
  35065. t['Folkard'] = true;
  35066. t['Footlight'] = true;
  35067. t['FreeSerif'] = true;
  35068. t['Friz Quadrata'] = true;
  35069. t['Garamond'] = true;
  35070. t['Gentium'] = true;
  35071. t['Georgia'] = true;
  35072. t['Gloucester'] = true;
  35073. t['Goudy Old Style'] = true;
  35074. t['Goudy Schoolbook'] = true;
  35075. t['Goudy Pro Font'] = true;
  35076. t['Granjon'] = true;
  35077. t['Guardian Egyptian'] = true;
  35078. t['Heather'] = true;
  35079. t['Hercules'] = true;
  35080. t['High Tower Text'] = true;
  35081. t['Hiroshige'] = true;
  35082. t['Hoefler Text'] = true;
  35083. t['Humana Serif'] = true;
  35084. t['Imprint'] = true;
  35085. t['Ionic No. 5'] = true;
  35086. t['Janson'] = true;
  35087. t['Joanna'] = true;
  35088. t['Korinna'] = true;
  35089. t['Lexicon'] = true;
  35090. t['Liberation Serif'] = true;
  35091. t['Linux Libertine'] = true;
  35092. t['Literaturnaya'] = true;
  35093. t['Lucida'] = true;
  35094. t['Lucida Bright'] = true;
  35095. t['Melior'] = true;
  35096. t['Memphis'] = true;
  35097. t['Miller'] = true;
  35098. t['Minion'] = true;
  35099. t['Modern'] = true;
  35100. t['Mona Lisa'] = true;
  35101. t['Mrs Eaves'] = true;
  35102. t['MS Serif'] = true;
  35103. t['Museo Slab'] = true;
  35104. t['New York'] = true;
  35105. t['Nimbus Roman'] = true;
  35106. t['NPS Rawlinson Roadway'] = true;
  35107. t['NuptialScript'] = true;
  35108. t['Palatino'] = true;
  35109. t['Perpetua'] = true;
  35110. t['Plantin'] = true;
  35111. t['Plantin Schoolbook'] = true;
  35112. t['Playbill'] = true;
  35113. t['Poor Richard'] = true;
  35114. t['Rawlinson Roadway'] = true;
  35115. t['Renault'] = true;
  35116. t['Requiem'] = true;
  35117. t['Rockwell'] = true;
  35118. t['Roman'] = true;
  35119. t['Rotis Serif'] = true;
  35120. t['Sabon'] = true;
  35121. t['Scala'] = true;
  35122. t['Seagull'] = true;
  35123. t['Sistina'] = true;
  35124. t['Souvenir'] = true;
  35125. t['STIX'] = true;
  35126. t['Stone Informal'] = true;
  35127. t['Stone Serif'] = true;
  35128. t['Sylfaen'] = true;
  35129. t['Times'] = true;
  35130. t['Trajan'] = true;
  35131. t['Trinité'] = true;
  35132. t['Trump Mediaeval'] = true;
  35133. t['Utopia'] = true;
  35134. t['Vale Type'] = true;
  35135. t['Bitstream Vera'] = true;
  35136. t['Vera Serif'] = true;
  35137. t['Versailles'] = true;
  35138. t['Wanted'] = true;
  35139. t['Weiss'] = true;
  35140. t['Wide Latin'] = true;
  35141. t['Windsor'] = true;
  35142. t['XITS'] = true;
  35143. });
  35144. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35145. t['Dingbats'] = true;
  35146. t['Symbol'] = true;
  35147. t['ZapfDingbats'] = true;
  35148. });
  35149. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35150. t[2] = 10;
  35151. t[3] = 32;
  35152. t[4] = 33;
  35153. t[5] = 34;
  35154. t[6] = 35;
  35155. t[7] = 36;
  35156. t[8] = 37;
  35157. t[9] = 38;
  35158. t[10] = 39;
  35159. t[11] = 40;
  35160. t[12] = 41;
  35161. t[13] = 42;
  35162. t[14] = 43;
  35163. t[15] = 44;
  35164. t[16] = 45;
  35165. t[17] = 46;
  35166. t[18] = 47;
  35167. t[19] = 48;
  35168. t[20] = 49;
  35169. t[21] = 50;
  35170. t[22] = 51;
  35171. t[23] = 52;
  35172. t[24] = 53;
  35173. t[25] = 54;
  35174. t[26] = 55;
  35175. t[27] = 56;
  35176. t[28] = 57;
  35177. t[29] = 58;
  35178. t[30] = 894;
  35179. t[31] = 60;
  35180. t[32] = 61;
  35181. t[33] = 62;
  35182. t[34] = 63;
  35183. t[35] = 64;
  35184. t[36] = 65;
  35185. t[37] = 66;
  35186. t[38] = 67;
  35187. t[39] = 68;
  35188. t[40] = 69;
  35189. t[41] = 70;
  35190. t[42] = 71;
  35191. t[43] = 72;
  35192. t[44] = 73;
  35193. t[45] = 74;
  35194. t[46] = 75;
  35195. t[47] = 76;
  35196. t[48] = 77;
  35197. t[49] = 78;
  35198. t[50] = 79;
  35199. t[51] = 80;
  35200. t[52] = 81;
  35201. t[53] = 82;
  35202. t[54] = 83;
  35203. t[55] = 84;
  35204. t[56] = 85;
  35205. t[57] = 86;
  35206. t[58] = 87;
  35207. t[59] = 88;
  35208. t[60] = 89;
  35209. t[61] = 90;
  35210. t[62] = 91;
  35211. t[63] = 92;
  35212. t[64] = 93;
  35213. t[65] = 94;
  35214. t[66] = 95;
  35215. t[67] = 96;
  35216. t[68] = 97;
  35217. t[69] = 98;
  35218. t[70] = 99;
  35219. t[71] = 100;
  35220. t[72] = 101;
  35221. t[73] = 102;
  35222. t[74] = 103;
  35223. t[75] = 104;
  35224. t[76] = 105;
  35225. t[77] = 106;
  35226. t[78] = 107;
  35227. t[79] = 108;
  35228. t[80] = 109;
  35229. t[81] = 110;
  35230. t[82] = 111;
  35231. t[83] = 112;
  35232. t[84] = 113;
  35233. t[85] = 114;
  35234. t[86] = 115;
  35235. t[87] = 116;
  35236. t[88] = 117;
  35237. t[89] = 118;
  35238. t[90] = 119;
  35239. t[91] = 120;
  35240. t[92] = 121;
  35241. t[93] = 122;
  35242. t[94] = 123;
  35243. t[95] = 124;
  35244. t[96] = 125;
  35245. t[97] = 126;
  35246. t[98] = 196;
  35247. t[99] = 197;
  35248. t[100] = 199;
  35249. t[101] = 201;
  35250. t[102] = 209;
  35251. t[103] = 214;
  35252. t[104] = 220;
  35253. t[105] = 225;
  35254. t[106] = 224;
  35255. t[107] = 226;
  35256. t[108] = 228;
  35257. t[109] = 227;
  35258. t[110] = 229;
  35259. t[111] = 231;
  35260. t[112] = 233;
  35261. t[113] = 232;
  35262. t[114] = 234;
  35263. t[115] = 235;
  35264. t[116] = 237;
  35265. t[117] = 236;
  35266. t[118] = 238;
  35267. t[119] = 239;
  35268. t[120] = 241;
  35269. t[121] = 243;
  35270. t[122] = 242;
  35271. t[123] = 244;
  35272. t[124] = 246;
  35273. t[125] = 245;
  35274. t[126] = 250;
  35275. t[127] = 249;
  35276. t[128] = 251;
  35277. t[129] = 252;
  35278. t[130] = 8224;
  35279. t[131] = 176;
  35280. t[132] = 162;
  35281. t[133] = 163;
  35282. t[134] = 167;
  35283. t[135] = 8226;
  35284. t[136] = 182;
  35285. t[137] = 223;
  35286. t[138] = 174;
  35287. t[139] = 169;
  35288. t[140] = 8482;
  35289. t[141] = 180;
  35290. t[142] = 168;
  35291. t[143] = 8800;
  35292. t[144] = 198;
  35293. t[145] = 216;
  35294. t[146] = 8734;
  35295. t[147] = 177;
  35296. t[148] = 8804;
  35297. t[149] = 8805;
  35298. t[150] = 165;
  35299. t[151] = 181;
  35300. t[152] = 8706;
  35301. t[153] = 8721;
  35302. t[154] = 8719;
  35303. t[156] = 8747;
  35304. t[157] = 170;
  35305. t[158] = 186;
  35306. t[159] = 8486;
  35307. t[160] = 230;
  35308. t[161] = 248;
  35309. t[162] = 191;
  35310. t[163] = 161;
  35311. t[164] = 172;
  35312. t[165] = 8730;
  35313. t[166] = 402;
  35314. t[167] = 8776;
  35315. t[168] = 8710;
  35316. t[169] = 171;
  35317. t[170] = 187;
  35318. t[171] = 8230;
  35319. t[210] = 218;
  35320. t[223] = 711;
  35321. t[224] = 321;
  35322. t[225] = 322;
  35323. t[227] = 353;
  35324. t[229] = 382;
  35325. t[234] = 253;
  35326. t[252] = 263;
  35327. t[253] = 268;
  35328. t[254] = 269;
  35329. t[258] = 258;
  35330. t[260] = 260;
  35331. t[261] = 261;
  35332. t[265] = 280;
  35333. t[266] = 281;
  35334. t[268] = 283;
  35335. t[269] = 313;
  35336. t[275] = 323;
  35337. t[276] = 324;
  35338. t[278] = 328;
  35339. t[284] = 345;
  35340. t[285] = 346;
  35341. t[286] = 347;
  35342. t[292] = 367;
  35343. t[295] = 377;
  35344. t[296] = 378;
  35345. t[298] = 380;
  35346. t[305] = 963;
  35347. t[306] = 964;
  35348. t[307] = 966;
  35349. t[308] = 8215;
  35350. t[309] = 8252;
  35351. t[310] = 8319;
  35352. t[311] = 8359;
  35353. t[312] = 8592;
  35354. t[313] = 8593;
  35355. t[337] = 9552;
  35356. t[493] = 1039;
  35357. t[494] = 1040;
  35358. t[705] = 1524;
  35359. t[706] = 8362;
  35360. t[710] = 64288;
  35361. t[711] = 64298;
  35362. t[759] = 1617;
  35363. t[761] = 1776;
  35364. t[763] = 1778;
  35365. t[775] = 1652;
  35366. t[777] = 1764;
  35367. t[778] = 1780;
  35368. t[779] = 1781;
  35369. t[780] = 1782;
  35370. t[782] = 771;
  35371. t[783] = 64726;
  35372. t[786] = 8363;
  35373. t[788] = 8532;
  35374. t[790] = 768;
  35375. t[791] = 769;
  35376. t[792] = 768;
  35377. t[795] = 803;
  35378. t[797] = 64336;
  35379. t[798] = 64337;
  35380. t[799] = 64342;
  35381. t[800] = 64343;
  35382. t[801] = 64344;
  35383. t[802] = 64345;
  35384. t[803] = 64362;
  35385. t[804] = 64363;
  35386. t[805] = 64364;
  35387. t[2424] = 7821;
  35388. t[2425] = 7822;
  35389. t[2426] = 7823;
  35390. t[2427] = 7824;
  35391. t[2428] = 7825;
  35392. t[2429] = 7826;
  35393. t[2430] = 7827;
  35394. t[2433] = 7682;
  35395. t[2678] = 8045;
  35396. t[2679] = 8046;
  35397. t[2830] = 1552;
  35398. t[2838] = 686;
  35399. t[2840] = 751;
  35400. t[2842] = 753;
  35401. t[2843] = 754;
  35402. t[2844] = 755;
  35403. t[2846] = 757;
  35404. t[2856] = 767;
  35405. t[2857] = 848;
  35406. t[2858] = 849;
  35407. t[2862] = 853;
  35408. t[2863] = 854;
  35409. t[2864] = 855;
  35410. t[2865] = 861;
  35411. t[2866] = 862;
  35412. t[2906] = 7460;
  35413. t[2908] = 7462;
  35414. t[2909] = 7463;
  35415. t[2910] = 7464;
  35416. t[2912] = 7466;
  35417. t[2913] = 7467;
  35418. t[2914] = 7468;
  35419. t[2916] = 7470;
  35420. t[2917] = 7471;
  35421. t[2918] = 7472;
  35422. t[2920] = 7474;
  35423. t[2921] = 7475;
  35424. t[2922] = 7476;
  35425. t[2924] = 7478;
  35426. t[2925] = 7479;
  35427. t[2926] = 7480;
  35428. t[2928] = 7482;
  35429. t[2929] = 7483;
  35430. t[2930] = 7484;
  35431. t[2932] = 7486;
  35432. t[2933] = 7487;
  35433. t[2934] = 7488;
  35434. t[2936] = 7490;
  35435. t[2937] = 7491;
  35436. t[2938] = 7492;
  35437. t[2940] = 7494;
  35438. t[2941] = 7495;
  35439. t[2942] = 7496;
  35440. t[2944] = 7498;
  35441. t[2946] = 7500;
  35442. t[2948] = 7502;
  35443. t[2950] = 7504;
  35444. t[2951] = 7505;
  35445. t[2952] = 7506;
  35446. t[2954] = 7508;
  35447. t[2955] = 7509;
  35448. t[2956] = 7510;
  35449. t[2958] = 7512;
  35450. t[2959] = 7513;
  35451. t[2960] = 7514;
  35452. t[2962] = 7516;
  35453. t[2963] = 7517;
  35454. t[2964] = 7518;
  35455. t[2966] = 7520;
  35456. t[2967] = 7521;
  35457. t[2968] = 7522;
  35458. t[2970] = 7524;
  35459. t[2971] = 7525;
  35460. t[2972] = 7526;
  35461. t[2974] = 7528;
  35462. t[2975] = 7529;
  35463. t[2976] = 7530;
  35464. t[2978] = 1537;
  35465. t[2979] = 1538;
  35466. t[2980] = 1539;
  35467. t[2982] = 1549;
  35468. t[2983] = 1551;
  35469. t[2984] = 1552;
  35470. t[2986] = 1554;
  35471. t[2987] = 1555;
  35472. t[2988] = 1556;
  35473. t[2990] = 1623;
  35474. t[2991] = 1624;
  35475. t[2995] = 1775;
  35476. t[2999] = 1791;
  35477. t[3002] = 64290;
  35478. t[3003] = 64291;
  35479. t[3004] = 64292;
  35480. t[3006] = 64294;
  35481. t[3007] = 64295;
  35482. t[3008] = 64296;
  35483. t[3011] = 1900;
  35484. t[3014] = 8223;
  35485. t[3015] = 8244;
  35486. t[3017] = 7532;
  35487. t[3018] = 7533;
  35488. t[3019] = 7534;
  35489. t[3075] = 7590;
  35490. t[3076] = 7591;
  35491. t[3079] = 7594;
  35492. t[3080] = 7595;
  35493. t[3083] = 7598;
  35494. t[3084] = 7599;
  35495. t[3087] = 7602;
  35496. t[3088] = 7603;
  35497. t[3091] = 7606;
  35498. t[3092] = 7607;
  35499. t[3095] = 7610;
  35500. t[3096] = 7611;
  35501. t[3099] = 7614;
  35502. t[3100] = 7615;
  35503. t[3103] = 7618;
  35504. t[3104] = 7619;
  35505. t[3107] = 8337;
  35506. t[3108] = 8338;
  35507. t[3116] = 1884;
  35508. t[3119] = 1885;
  35509. t[3120] = 1885;
  35510. t[3123] = 1886;
  35511. t[3124] = 1886;
  35512. t[3127] = 1887;
  35513. t[3128] = 1887;
  35514. t[3131] = 1888;
  35515. t[3132] = 1888;
  35516. t[3135] = 1889;
  35517. t[3136] = 1889;
  35518. t[3139] = 1890;
  35519. t[3140] = 1890;
  35520. t[3143] = 1891;
  35521. t[3144] = 1891;
  35522. t[3147] = 1892;
  35523. t[3148] = 1892;
  35524. t[3153] = 580;
  35525. t[3154] = 581;
  35526. t[3157] = 584;
  35527. t[3158] = 585;
  35528. t[3161] = 588;
  35529. t[3162] = 589;
  35530. t[3165] = 891;
  35531. t[3166] = 892;
  35532. t[3169] = 1274;
  35533. t[3170] = 1275;
  35534. t[3173] = 1278;
  35535. t[3174] = 1279;
  35536. t[3181] = 7622;
  35537. t[3182] = 7623;
  35538. t[3282] = 11799;
  35539. t[3316] = 578;
  35540. t[3379] = 42785;
  35541. t[3393] = 1159;
  35542. t[3416] = 8377;
  35543. });
  35544. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35545. t[227] = 322;
  35546. t[264] = 261;
  35547. t[291] = 346;
  35548. });
  35549. exports.getStdFontMap = getStdFontMap;
  35550. exports.getNonStdFontMap = getNonStdFontMap;
  35551. exports.getSerifFonts = getSerifFonts;
  35552. exports.getSymbolsFonts = getSymbolsFonts;
  35553. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35554. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35555. /***/ }),
  35556. /* 22 */
  35557. /***/ (function(module, exports, __w_pdfjs_require__) {
  35558. "use strict";
  35559. var sharedUtil = __w_pdfjs_require__(0);
  35560. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35561. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35562. t[63721] = 0x00A9;
  35563. t[63193] = 0x00A9;
  35564. t[63720] = 0x00AE;
  35565. t[63194] = 0x00AE;
  35566. t[63722] = 0x2122;
  35567. t[63195] = 0x2122;
  35568. t[63729] = 0x23A7;
  35569. t[63730] = 0x23A8;
  35570. t[63731] = 0x23A9;
  35571. t[63740] = 0x23AB;
  35572. t[63741] = 0x23AC;
  35573. t[63742] = 0x23AD;
  35574. t[63726] = 0x23A1;
  35575. t[63727] = 0x23A2;
  35576. t[63728] = 0x23A3;
  35577. t[63737] = 0x23A4;
  35578. t[63738] = 0x23A5;
  35579. t[63739] = 0x23A6;
  35580. t[63723] = 0x239B;
  35581. t[63724] = 0x239C;
  35582. t[63725] = 0x239D;
  35583. t[63734] = 0x239E;
  35584. t[63735] = 0x239F;
  35585. t[63736] = 0x23A0;
  35586. });
  35587. function mapSpecialUnicodeValues(code) {
  35588. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35589. return 0;
  35590. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35591. return getSpecialPUASymbols()[code] || code;
  35592. }
  35593. return code;
  35594. }
  35595. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35596. var unicode = glyphsUnicodeMap[name];
  35597. if (unicode !== undefined) {
  35598. return unicode;
  35599. }
  35600. if (!name) {
  35601. return -1;
  35602. }
  35603. if (name[0] === 'u') {
  35604. var nameLen = name.length, hexStr;
  35605. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35606. hexStr = name.substr(3);
  35607. } else if (nameLen >= 5 && nameLen <= 7) {
  35608. hexStr = name.substr(1);
  35609. } else {
  35610. return -1;
  35611. }
  35612. if (hexStr === hexStr.toUpperCase()) {
  35613. unicode = parseInt(hexStr, 16);
  35614. if (unicode >= 0) {
  35615. return unicode;
  35616. }
  35617. }
  35618. }
  35619. return -1;
  35620. }
  35621. var UnicodeRanges = [
  35622. {
  35623. 'begin': 0x0000,
  35624. 'end': 0x007F
  35625. },
  35626. {
  35627. 'begin': 0x0080,
  35628. 'end': 0x00FF
  35629. },
  35630. {
  35631. 'begin': 0x0100,
  35632. 'end': 0x017F
  35633. },
  35634. {
  35635. 'begin': 0x0180,
  35636. 'end': 0x024F
  35637. },
  35638. {
  35639. 'begin': 0x0250,
  35640. 'end': 0x02AF
  35641. },
  35642. {
  35643. 'begin': 0x02B0,
  35644. 'end': 0x02FF
  35645. },
  35646. {
  35647. 'begin': 0x0300,
  35648. 'end': 0x036F
  35649. },
  35650. {
  35651. 'begin': 0x0370,
  35652. 'end': 0x03FF
  35653. },
  35654. {
  35655. 'begin': 0x2C80,
  35656. 'end': 0x2CFF
  35657. },
  35658. {
  35659. 'begin': 0x0400,
  35660. 'end': 0x04FF
  35661. },
  35662. {
  35663. 'begin': 0x0530,
  35664. 'end': 0x058F
  35665. },
  35666. {
  35667. 'begin': 0x0590,
  35668. 'end': 0x05FF
  35669. },
  35670. {
  35671. 'begin': 0xA500,
  35672. 'end': 0xA63F
  35673. },
  35674. {
  35675. 'begin': 0x0600,
  35676. 'end': 0x06FF
  35677. },
  35678. {
  35679. 'begin': 0x07C0,
  35680. 'end': 0x07FF
  35681. },
  35682. {
  35683. 'begin': 0x0900,
  35684. 'end': 0x097F
  35685. },
  35686. {
  35687. 'begin': 0x0980,
  35688. 'end': 0x09FF
  35689. },
  35690. {
  35691. 'begin': 0x0A00,
  35692. 'end': 0x0A7F
  35693. },
  35694. {
  35695. 'begin': 0x0A80,
  35696. 'end': 0x0AFF
  35697. },
  35698. {
  35699. 'begin': 0x0B00,
  35700. 'end': 0x0B7F
  35701. },
  35702. {
  35703. 'begin': 0x0B80,
  35704. 'end': 0x0BFF
  35705. },
  35706. {
  35707. 'begin': 0x0C00,
  35708. 'end': 0x0C7F
  35709. },
  35710. {
  35711. 'begin': 0x0C80,
  35712. 'end': 0x0CFF
  35713. },
  35714. {
  35715. 'begin': 0x0D00,
  35716. 'end': 0x0D7F
  35717. },
  35718. {
  35719. 'begin': 0x0E00,
  35720. 'end': 0x0E7F
  35721. },
  35722. {
  35723. 'begin': 0x0E80,
  35724. 'end': 0x0EFF
  35725. },
  35726. {
  35727. 'begin': 0x10A0,
  35728. 'end': 0x10FF
  35729. },
  35730. {
  35731. 'begin': 0x1B00,
  35732. 'end': 0x1B7F
  35733. },
  35734. {
  35735. 'begin': 0x1100,
  35736. 'end': 0x11FF
  35737. },
  35738. {
  35739. 'begin': 0x1E00,
  35740. 'end': 0x1EFF
  35741. },
  35742. {
  35743. 'begin': 0x1F00,
  35744. 'end': 0x1FFF
  35745. },
  35746. {
  35747. 'begin': 0x2000,
  35748. 'end': 0x206F
  35749. },
  35750. {
  35751. 'begin': 0x2070,
  35752. 'end': 0x209F
  35753. },
  35754. {
  35755. 'begin': 0x20A0,
  35756. 'end': 0x20CF
  35757. },
  35758. {
  35759. 'begin': 0x20D0,
  35760. 'end': 0x20FF
  35761. },
  35762. {
  35763. 'begin': 0x2100,
  35764. 'end': 0x214F
  35765. },
  35766. {
  35767. 'begin': 0x2150,
  35768. 'end': 0x218F
  35769. },
  35770. {
  35771. 'begin': 0x2190,
  35772. 'end': 0x21FF
  35773. },
  35774. {
  35775. 'begin': 0x2200,
  35776. 'end': 0x22FF
  35777. },
  35778. {
  35779. 'begin': 0x2300,
  35780. 'end': 0x23FF
  35781. },
  35782. {
  35783. 'begin': 0x2400,
  35784. 'end': 0x243F
  35785. },
  35786. {
  35787. 'begin': 0x2440,
  35788. 'end': 0x245F
  35789. },
  35790. {
  35791. 'begin': 0x2460,
  35792. 'end': 0x24FF
  35793. },
  35794. {
  35795. 'begin': 0x2500,
  35796. 'end': 0x257F
  35797. },
  35798. {
  35799. 'begin': 0x2580,
  35800. 'end': 0x259F
  35801. },
  35802. {
  35803. 'begin': 0x25A0,
  35804. 'end': 0x25FF
  35805. },
  35806. {
  35807. 'begin': 0x2600,
  35808. 'end': 0x26FF
  35809. },
  35810. {
  35811. 'begin': 0x2700,
  35812. 'end': 0x27BF
  35813. },
  35814. {
  35815. 'begin': 0x3000,
  35816. 'end': 0x303F
  35817. },
  35818. {
  35819. 'begin': 0x3040,
  35820. 'end': 0x309F
  35821. },
  35822. {
  35823. 'begin': 0x30A0,
  35824. 'end': 0x30FF
  35825. },
  35826. {
  35827. 'begin': 0x3100,
  35828. 'end': 0x312F
  35829. },
  35830. {
  35831. 'begin': 0x3130,
  35832. 'end': 0x318F
  35833. },
  35834. {
  35835. 'begin': 0xA840,
  35836. 'end': 0xA87F
  35837. },
  35838. {
  35839. 'begin': 0x3200,
  35840. 'end': 0x32FF
  35841. },
  35842. {
  35843. 'begin': 0x3300,
  35844. 'end': 0x33FF
  35845. },
  35846. {
  35847. 'begin': 0xAC00,
  35848. 'end': 0xD7AF
  35849. },
  35850. {
  35851. 'begin': 0xD800,
  35852. 'end': 0xDFFF
  35853. },
  35854. {
  35855. 'begin': 0x10900,
  35856. 'end': 0x1091F
  35857. },
  35858. {
  35859. 'begin': 0x4E00,
  35860. 'end': 0x9FFF
  35861. },
  35862. {
  35863. 'begin': 0xE000,
  35864. 'end': 0xF8FF
  35865. },
  35866. {
  35867. 'begin': 0x31C0,
  35868. 'end': 0x31EF
  35869. },
  35870. {
  35871. 'begin': 0xFB00,
  35872. 'end': 0xFB4F
  35873. },
  35874. {
  35875. 'begin': 0xFB50,
  35876. 'end': 0xFDFF
  35877. },
  35878. {
  35879. 'begin': 0xFE20,
  35880. 'end': 0xFE2F
  35881. },
  35882. {
  35883. 'begin': 0xFE10,
  35884. 'end': 0xFE1F
  35885. },
  35886. {
  35887. 'begin': 0xFE50,
  35888. 'end': 0xFE6F
  35889. },
  35890. {
  35891. 'begin': 0xFE70,
  35892. 'end': 0xFEFF
  35893. },
  35894. {
  35895. 'begin': 0xFF00,
  35896. 'end': 0xFFEF
  35897. },
  35898. {
  35899. 'begin': 0xFFF0,
  35900. 'end': 0xFFFF
  35901. },
  35902. {
  35903. 'begin': 0x0F00,
  35904. 'end': 0x0FFF
  35905. },
  35906. {
  35907. 'begin': 0x0700,
  35908. 'end': 0x074F
  35909. },
  35910. {
  35911. 'begin': 0x0780,
  35912. 'end': 0x07BF
  35913. },
  35914. {
  35915. 'begin': 0x0D80,
  35916. 'end': 0x0DFF
  35917. },
  35918. {
  35919. 'begin': 0x1000,
  35920. 'end': 0x109F
  35921. },
  35922. {
  35923. 'begin': 0x1200,
  35924. 'end': 0x137F
  35925. },
  35926. {
  35927. 'begin': 0x13A0,
  35928. 'end': 0x13FF
  35929. },
  35930. {
  35931. 'begin': 0x1400,
  35932. 'end': 0x167F
  35933. },
  35934. {
  35935. 'begin': 0x1680,
  35936. 'end': 0x169F
  35937. },
  35938. {
  35939. 'begin': 0x16A0,
  35940. 'end': 0x16FF
  35941. },
  35942. {
  35943. 'begin': 0x1780,
  35944. 'end': 0x17FF
  35945. },
  35946. {
  35947. 'begin': 0x1800,
  35948. 'end': 0x18AF
  35949. },
  35950. {
  35951. 'begin': 0x2800,
  35952. 'end': 0x28FF
  35953. },
  35954. {
  35955. 'begin': 0xA000,
  35956. 'end': 0xA48F
  35957. },
  35958. {
  35959. 'begin': 0x1700,
  35960. 'end': 0x171F
  35961. },
  35962. {
  35963. 'begin': 0x10300,
  35964. 'end': 0x1032F
  35965. },
  35966. {
  35967. 'begin': 0x10330,
  35968. 'end': 0x1034F
  35969. },
  35970. {
  35971. 'begin': 0x10400,
  35972. 'end': 0x1044F
  35973. },
  35974. {
  35975. 'begin': 0x1D000,
  35976. 'end': 0x1D0FF
  35977. },
  35978. {
  35979. 'begin': 0x1D400,
  35980. 'end': 0x1D7FF
  35981. },
  35982. {
  35983. 'begin': 0xFF000,
  35984. 'end': 0xFFFFD
  35985. },
  35986. {
  35987. 'begin': 0xFE00,
  35988. 'end': 0xFE0F
  35989. },
  35990. {
  35991. 'begin': 0xE0000,
  35992. 'end': 0xE007F
  35993. },
  35994. {
  35995. 'begin': 0x1900,
  35996. 'end': 0x194F
  35997. },
  35998. {
  35999. 'begin': 0x1950,
  36000. 'end': 0x197F
  36001. },
  36002. {
  36003. 'begin': 0x1980,
  36004. 'end': 0x19DF
  36005. },
  36006. {
  36007. 'begin': 0x1A00,
  36008. 'end': 0x1A1F
  36009. },
  36010. {
  36011. 'begin': 0x2C00,
  36012. 'end': 0x2C5F
  36013. },
  36014. {
  36015. 'begin': 0x2D30,
  36016. 'end': 0x2D7F
  36017. },
  36018. {
  36019. 'begin': 0x4DC0,
  36020. 'end': 0x4DFF
  36021. },
  36022. {
  36023. 'begin': 0xA800,
  36024. 'end': 0xA82F
  36025. },
  36026. {
  36027. 'begin': 0x10000,
  36028. 'end': 0x1007F
  36029. },
  36030. {
  36031. 'begin': 0x10140,
  36032. 'end': 0x1018F
  36033. },
  36034. {
  36035. 'begin': 0x10380,
  36036. 'end': 0x1039F
  36037. },
  36038. {
  36039. 'begin': 0x103A0,
  36040. 'end': 0x103DF
  36041. },
  36042. {
  36043. 'begin': 0x10450,
  36044. 'end': 0x1047F
  36045. },
  36046. {
  36047. 'begin': 0x10480,
  36048. 'end': 0x104AF
  36049. },
  36050. {
  36051. 'begin': 0x10800,
  36052. 'end': 0x1083F
  36053. },
  36054. {
  36055. 'begin': 0x10A00,
  36056. 'end': 0x10A5F
  36057. },
  36058. {
  36059. 'begin': 0x1D300,
  36060. 'end': 0x1D35F
  36061. },
  36062. {
  36063. 'begin': 0x12000,
  36064. 'end': 0x123FF
  36065. },
  36066. {
  36067. 'begin': 0x1D360,
  36068. 'end': 0x1D37F
  36069. },
  36070. {
  36071. 'begin': 0x1B80,
  36072. 'end': 0x1BBF
  36073. },
  36074. {
  36075. 'begin': 0x1C00,
  36076. 'end': 0x1C4F
  36077. },
  36078. {
  36079. 'begin': 0x1C50,
  36080. 'end': 0x1C7F
  36081. },
  36082. {
  36083. 'begin': 0xA880,
  36084. 'end': 0xA8DF
  36085. },
  36086. {
  36087. 'begin': 0xA900,
  36088. 'end': 0xA92F
  36089. },
  36090. {
  36091. 'begin': 0xA930,
  36092. 'end': 0xA95F
  36093. },
  36094. {
  36095. 'begin': 0xAA00,
  36096. 'end': 0xAA5F
  36097. },
  36098. {
  36099. 'begin': 0x10190,
  36100. 'end': 0x101CF
  36101. },
  36102. {
  36103. 'begin': 0x101D0,
  36104. 'end': 0x101FF
  36105. },
  36106. {
  36107. 'begin': 0x102A0,
  36108. 'end': 0x102DF
  36109. },
  36110. {
  36111. 'begin': 0x1F030,
  36112. 'end': 0x1F09F
  36113. }
  36114. ];
  36115. function getUnicodeRangeFor(value) {
  36116. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36117. var range = UnicodeRanges[i];
  36118. if (value >= range.begin && value < range.end) {
  36119. return i;
  36120. }
  36121. }
  36122. return -1;
  36123. }
  36124. function isRTLRangeFor(value) {
  36125. var range = UnicodeRanges[13];
  36126. if (value >= range.begin && value < range.end) {
  36127. return true;
  36128. }
  36129. range = UnicodeRanges[11];
  36130. if (value >= range.begin && value < range.end) {
  36131. return true;
  36132. }
  36133. return false;
  36134. }
  36135. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36136. t['\u00A8'] = '\u0020\u0308';
  36137. t['\u00AF'] = '\u0020\u0304';
  36138. t['\u00B4'] = '\u0020\u0301';
  36139. t['\u00B5'] = '\u03BC';
  36140. t['\u00B8'] = '\u0020\u0327';
  36141. t['\u0132'] = '\u0049\u004A';
  36142. t['\u0133'] = '\u0069\u006A';
  36143. t['\u013F'] = '\u004C\u00B7';
  36144. t['\u0140'] = '\u006C\u00B7';
  36145. t['\u0149'] = '\u02BC\u006E';
  36146. t['\u017F'] = '\u0073';
  36147. t['\u01C4'] = '\u0044\u017D';
  36148. t['\u01C5'] = '\u0044\u017E';
  36149. t['\u01C6'] = '\u0064\u017E';
  36150. t['\u01C7'] = '\u004C\u004A';
  36151. t['\u01C8'] = '\u004C\u006A';
  36152. t['\u01C9'] = '\u006C\u006A';
  36153. t['\u01CA'] = '\u004E\u004A';
  36154. t['\u01CB'] = '\u004E\u006A';
  36155. t['\u01CC'] = '\u006E\u006A';
  36156. t['\u01F1'] = '\u0044\u005A';
  36157. t['\u01F2'] = '\u0044\u007A';
  36158. t['\u01F3'] = '\u0064\u007A';
  36159. t['\u02D8'] = '\u0020\u0306';
  36160. t['\u02D9'] = '\u0020\u0307';
  36161. t['\u02DA'] = '\u0020\u030A';
  36162. t['\u02DB'] = '\u0020\u0328';
  36163. t['\u02DC'] = '\u0020\u0303';
  36164. t['\u02DD'] = '\u0020\u030B';
  36165. t['\u037A'] = '\u0020\u0345';
  36166. t['\u0384'] = '\u0020\u0301';
  36167. t['\u03D0'] = '\u03B2';
  36168. t['\u03D1'] = '\u03B8';
  36169. t['\u03D2'] = '\u03A5';
  36170. t['\u03D5'] = '\u03C6';
  36171. t['\u03D6'] = '\u03C0';
  36172. t['\u03F0'] = '\u03BA';
  36173. t['\u03F1'] = '\u03C1';
  36174. t['\u03F2'] = '\u03C2';
  36175. t['\u03F4'] = '\u0398';
  36176. t['\u03F5'] = '\u03B5';
  36177. t['\u03F9'] = '\u03A3';
  36178. t['\u0587'] = '\u0565\u0582';
  36179. t['\u0675'] = '\u0627\u0674';
  36180. t['\u0676'] = '\u0648\u0674';
  36181. t['\u0677'] = '\u06C7\u0674';
  36182. t['\u0678'] = '\u064A\u0674';
  36183. t['\u0E33'] = '\u0E4D\u0E32';
  36184. t['\u0EB3'] = '\u0ECD\u0EB2';
  36185. t['\u0EDC'] = '\u0EAB\u0E99';
  36186. t['\u0EDD'] = '\u0EAB\u0EA1';
  36187. t['\u0F77'] = '\u0FB2\u0F81';
  36188. t['\u0F79'] = '\u0FB3\u0F81';
  36189. t['\u1E9A'] = '\u0061\u02BE';
  36190. t['\u1FBD'] = '\u0020\u0313';
  36191. t['\u1FBF'] = '\u0020\u0313';
  36192. t['\u1FC0'] = '\u0020\u0342';
  36193. t['\u1FFE'] = '\u0020\u0314';
  36194. t['\u2002'] = '\u0020';
  36195. t['\u2003'] = '\u0020';
  36196. t['\u2004'] = '\u0020';
  36197. t['\u2005'] = '\u0020';
  36198. t['\u2006'] = '\u0020';
  36199. t['\u2008'] = '\u0020';
  36200. t['\u2009'] = '\u0020';
  36201. t['\u200A'] = '\u0020';
  36202. t['\u2017'] = '\u0020\u0333';
  36203. t['\u2024'] = '\u002E';
  36204. t['\u2025'] = '\u002E\u002E';
  36205. t['\u2026'] = '\u002E\u002E\u002E';
  36206. t['\u2033'] = '\u2032\u2032';
  36207. t['\u2034'] = '\u2032\u2032\u2032';
  36208. t['\u2036'] = '\u2035\u2035';
  36209. t['\u2037'] = '\u2035\u2035\u2035';
  36210. t['\u203C'] = '\u0021\u0021';
  36211. t['\u203E'] = '\u0020\u0305';
  36212. t['\u2047'] = '\u003F\u003F';
  36213. t['\u2048'] = '\u003F\u0021';
  36214. t['\u2049'] = '\u0021\u003F';
  36215. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36216. t['\u205F'] = '\u0020';
  36217. t['\u20A8'] = '\u0052\u0073';
  36218. t['\u2100'] = '\u0061\u002F\u0063';
  36219. t['\u2101'] = '\u0061\u002F\u0073';
  36220. t['\u2103'] = '\u00B0\u0043';
  36221. t['\u2105'] = '\u0063\u002F\u006F';
  36222. t['\u2106'] = '\u0063\u002F\u0075';
  36223. t['\u2107'] = '\u0190';
  36224. t['\u2109'] = '\u00B0\u0046';
  36225. t['\u2116'] = '\u004E\u006F';
  36226. t['\u2121'] = '\u0054\u0045\u004C';
  36227. t['\u2135'] = '\u05D0';
  36228. t['\u2136'] = '\u05D1';
  36229. t['\u2137'] = '\u05D2';
  36230. t['\u2138'] = '\u05D3';
  36231. t['\u213B'] = '\u0046\u0041\u0058';
  36232. t['\u2160'] = '\u0049';
  36233. t['\u2161'] = '\u0049\u0049';
  36234. t['\u2162'] = '\u0049\u0049\u0049';
  36235. t['\u2163'] = '\u0049\u0056';
  36236. t['\u2164'] = '\u0056';
  36237. t['\u2165'] = '\u0056\u0049';
  36238. t['\u2166'] = '\u0056\u0049\u0049';
  36239. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36240. t['\u2168'] = '\u0049\u0058';
  36241. t['\u2169'] = '\u0058';
  36242. t['\u216A'] = '\u0058\u0049';
  36243. t['\u216B'] = '\u0058\u0049\u0049';
  36244. t['\u216C'] = '\u004C';
  36245. t['\u216D'] = '\u0043';
  36246. t['\u216E'] = '\u0044';
  36247. t['\u216F'] = '\u004D';
  36248. t['\u2170'] = '\u0069';
  36249. t['\u2171'] = '\u0069\u0069';
  36250. t['\u2172'] = '\u0069\u0069\u0069';
  36251. t['\u2173'] = '\u0069\u0076';
  36252. t['\u2174'] = '\u0076';
  36253. t['\u2175'] = '\u0076\u0069';
  36254. t['\u2176'] = '\u0076\u0069\u0069';
  36255. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36256. t['\u2178'] = '\u0069\u0078';
  36257. t['\u2179'] = '\u0078';
  36258. t['\u217A'] = '\u0078\u0069';
  36259. t['\u217B'] = '\u0078\u0069\u0069';
  36260. t['\u217C'] = '\u006C';
  36261. t['\u217D'] = '\u0063';
  36262. t['\u217E'] = '\u0064';
  36263. t['\u217F'] = '\u006D';
  36264. t['\u222C'] = '\u222B\u222B';
  36265. t['\u222D'] = '\u222B\u222B\u222B';
  36266. t['\u222F'] = '\u222E\u222E';
  36267. t['\u2230'] = '\u222E\u222E\u222E';
  36268. t['\u2474'] = '\u0028\u0031\u0029';
  36269. t['\u2475'] = '\u0028\u0032\u0029';
  36270. t['\u2476'] = '\u0028\u0033\u0029';
  36271. t['\u2477'] = '\u0028\u0034\u0029';
  36272. t['\u2478'] = '\u0028\u0035\u0029';
  36273. t['\u2479'] = '\u0028\u0036\u0029';
  36274. t['\u247A'] = '\u0028\u0037\u0029';
  36275. t['\u247B'] = '\u0028\u0038\u0029';
  36276. t['\u247C'] = '\u0028\u0039\u0029';
  36277. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36278. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36279. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36280. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36281. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36282. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36283. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36284. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36285. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36286. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36287. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36288. t['\u2488'] = '\u0031\u002E';
  36289. t['\u2489'] = '\u0032\u002E';
  36290. t['\u248A'] = '\u0033\u002E';
  36291. t['\u248B'] = '\u0034\u002E';
  36292. t['\u248C'] = '\u0035\u002E';
  36293. t['\u248D'] = '\u0036\u002E';
  36294. t['\u248E'] = '\u0037\u002E';
  36295. t['\u248F'] = '\u0038\u002E';
  36296. t['\u2490'] = '\u0039\u002E';
  36297. t['\u2491'] = '\u0031\u0030\u002E';
  36298. t['\u2492'] = '\u0031\u0031\u002E';
  36299. t['\u2493'] = '\u0031\u0032\u002E';
  36300. t['\u2494'] = '\u0031\u0033\u002E';
  36301. t['\u2495'] = '\u0031\u0034\u002E';
  36302. t['\u2496'] = '\u0031\u0035\u002E';
  36303. t['\u2497'] = '\u0031\u0036\u002E';
  36304. t['\u2498'] = '\u0031\u0037\u002E';
  36305. t['\u2499'] = '\u0031\u0038\u002E';
  36306. t['\u249A'] = '\u0031\u0039\u002E';
  36307. t['\u249B'] = '\u0032\u0030\u002E';
  36308. t['\u249C'] = '\u0028\u0061\u0029';
  36309. t['\u249D'] = '\u0028\u0062\u0029';
  36310. t['\u249E'] = '\u0028\u0063\u0029';
  36311. t['\u249F'] = '\u0028\u0064\u0029';
  36312. t['\u24A0'] = '\u0028\u0065\u0029';
  36313. t['\u24A1'] = '\u0028\u0066\u0029';
  36314. t['\u24A2'] = '\u0028\u0067\u0029';
  36315. t['\u24A3'] = '\u0028\u0068\u0029';
  36316. t['\u24A4'] = '\u0028\u0069\u0029';
  36317. t['\u24A5'] = '\u0028\u006A\u0029';
  36318. t['\u24A6'] = '\u0028\u006B\u0029';
  36319. t['\u24A7'] = '\u0028\u006C\u0029';
  36320. t['\u24A8'] = '\u0028\u006D\u0029';
  36321. t['\u24A9'] = '\u0028\u006E\u0029';
  36322. t['\u24AA'] = '\u0028\u006F\u0029';
  36323. t['\u24AB'] = '\u0028\u0070\u0029';
  36324. t['\u24AC'] = '\u0028\u0071\u0029';
  36325. t['\u24AD'] = '\u0028\u0072\u0029';
  36326. t['\u24AE'] = '\u0028\u0073\u0029';
  36327. t['\u24AF'] = '\u0028\u0074\u0029';
  36328. t['\u24B0'] = '\u0028\u0075\u0029';
  36329. t['\u24B1'] = '\u0028\u0076\u0029';
  36330. t['\u24B2'] = '\u0028\u0077\u0029';
  36331. t['\u24B3'] = '\u0028\u0078\u0029';
  36332. t['\u24B4'] = '\u0028\u0079\u0029';
  36333. t['\u24B5'] = '\u0028\u007A\u0029';
  36334. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36335. t['\u2A74'] = '\u003A\u003A\u003D';
  36336. t['\u2A75'] = '\u003D\u003D';
  36337. t['\u2A76'] = '\u003D\u003D\u003D';
  36338. t['\u2E9F'] = '\u6BCD';
  36339. t['\u2EF3'] = '\u9F9F';
  36340. t['\u2F00'] = '\u4E00';
  36341. t['\u2F01'] = '\u4E28';
  36342. t['\u2F02'] = '\u4E36';
  36343. t['\u2F03'] = '\u4E3F';
  36344. t['\u2F04'] = '\u4E59';
  36345. t['\u2F05'] = '\u4E85';
  36346. t['\u2F06'] = '\u4E8C';
  36347. t['\u2F07'] = '\u4EA0';
  36348. t['\u2F08'] = '\u4EBA';
  36349. t['\u2F09'] = '\u513F';
  36350. t['\u2F0A'] = '\u5165';
  36351. t['\u2F0B'] = '\u516B';
  36352. t['\u2F0C'] = '\u5182';
  36353. t['\u2F0D'] = '\u5196';
  36354. t['\u2F0E'] = '\u51AB';
  36355. t['\u2F0F'] = '\u51E0';
  36356. t['\u2F10'] = '\u51F5';
  36357. t['\u2F11'] = '\u5200';
  36358. t['\u2F12'] = '\u529B';
  36359. t['\u2F13'] = '\u52F9';
  36360. t['\u2F14'] = '\u5315';
  36361. t['\u2F15'] = '\u531A';
  36362. t['\u2F16'] = '\u5338';
  36363. t['\u2F17'] = '\u5341';
  36364. t['\u2F18'] = '\u535C';
  36365. t['\u2F19'] = '\u5369';
  36366. t['\u2F1A'] = '\u5382';
  36367. t['\u2F1B'] = '\u53B6';
  36368. t['\u2F1C'] = '\u53C8';
  36369. t['\u2F1D'] = '\u53E3';
  36370. t['\u2F1E'] = '\u56D7';
  36371. t['\u2F1F'] = '\u571F';
  36372. t['\u2F20'] = '\u58EB';
  36373. t['\u2F21'] = '\u5902';
  36374. t['\u2F22'] = '\u590A';
  36375. t['\u2F23'] = '\u5915';
  36376. t['\u2F24'] = '\u5927';
  36377. t['\u2F25'] = '\u5973';
  36378. t['\u2F26'] = '\u5B50';
  36379. t['\u2F27'] = '\u5B80';
  36380. t['\u2F28'] = '\u5BF8';
  36381. t['\u2F29'] = '\u5C0F';
  36382. t['\u2F2A'] = '\u5C22';
  36383. t['\u2F2B'] = '\u5C38';
  36384. t['\u2F2C'] = '\u5C6E';
  36385. t['\u2F2D'] = '\u5C71';
  36386. t['\u2F2E'] = '\u5DDB';
  36387. t['\u2F2F'] = '\u5DE5';
  36388. t['\u2F30'] = '\u5DF1';
  36389. t['\u2F31'] = '\u5DFE';
  36390. t['\u2F32'] = '\u5E72';
  36391. t['\u2F33'] = '\u5E7A';
  36392. t['\u2F34'] = '\u5E7F';
  36393. t['\u2F35'] = '\u5EF4';
  36394. t['\u2F36'] = '\u5EFE';
  36395. t['\u2F37'] = '\u5F0B';
  36396. t['\u2F38'] = '\u5F13';
  36397. t['\u2F39'] = '\u5F50';
  36398. t['\u2F3A'] = '\u5F61';
  36399. t['\u2F3B'] = '\u5F73';
  36400. t['\u2F3C'] = '\u5FC3';
  36401. t['\u2F3D'] = '\u6208';
  36402. t['\u2F3E'] = '\u6236';
  36403. t['\u2F3F'] = '\u624B';
  36404. t['\u2F40'] = '\u652F';
  36405. t['\u2F41'] = '\u6534';
  36406. t['\u2F42'] = '\u6587';
  36407. t['\u2F43'] = '\u6597';
  36408. t['\u2F44'] = '\u65A4';
  36409. t['\u2F45'] = '\u65B9';
  36410. t['\u2F46'] = '\u65E0';
  36411. t['\u2F47'] = '\u65E5';
  36412. t['\u2F48'] = '\u66F0';
  36413. t['\u2F49'] = '\u6708';
  36414. t['\u2F4A'] = '\u6728';
  36415. t['\u2F4B'] = '\u6B20';
  36416. t['\u2F4C'] = '\u6B62';
  36417. t['\u2F4D'] = '\u6B79';
  36418. t['\u2F4E'] = '\u6BB3';
  36419. t['\u2F4F'] = '\u6BCB';
  36420. t['\u2F50'] = '\u6BD4';
  36421. t['\u2F51'] = '\u6BDB';
  36422. t['\u2F52'] = '\u6C0F';
  36423. t['\u2F53'] = '\u6C14';
  36424. t['\u2F54'] = '\u6C34';
  36425. t['\u2F55'] = '\u706B';
  36426. t['\u2F56'] = '\u722A';
  36427. t['\u2F57'] = '\u7236';
  36428. t['\u2F58'] = '\u723B';
  36429. t['\u2F59'] = '\u723F';
  36430. t['\u2F5A'] = '\u7247';
  36431. t['\u2F5B'] = '\u7259';
  36432. t['\u2F5C'] = '\u725B';
  36433. t['\u2F5D'] = '\u72AC';
  36434. t['\u2F5E'] = '\u7384';
  36435. t['\u2F5F'] = '\u7389';
  36436. t['\u2F60'] = '\u74DC';
  36437. t['\u2F61'] = '\u74E6';
  36438. t['\u2F62'] = '\u7518';
  36439. t['\u2F63'] = '\u751F';
  36440. t['\u2F64'] = '\u7528';
  36441. t['\u2F65'] = '\u7530';
  36442. t['\u2F66'] = '\u758B';
  36443. t['\u2F67'] = '\u7592';
  36444. t['\u2F68'] = '\u7676';
  36445. t['\u2F69'] = '\u767D';
  36446. t['\u2F6A'] = '\u76AE';
  36447. t['\u2F6B'] = '\u76BF';
  36448. t['\u2F6C'] = '\u76EE';
  36449. t['\u2F6D'] = '\u77DB';
  36450. t['\u2F6E'] = '\u77E2';
  36451. t['\u2F6F'] = '\u77F3';
  36452. t['\u2F70'] = '\u793A';
  36453. t['\u2F71'] = '\u79B8';
  36454. t['\u2F72'] = '\u79BE';
  36455. t['\u2F73'] = '\u7A74';
  36456. t['\u2F74'] = '\u7ACB';
  36457. t['\u2F75'] = '\u7AF9';
  36458. t['\u2F76'] = '\u7C73';
  36459. t['\u2F77'] = '\u7CF8';
  36460. t['\u2F78'] = '\u7F36';
  36461. t['\u2F79'] = '\u7F51';
  36462. t['\u2F7A'] = '\u7F8A';
  36463. t['\u2F7B'] = '\u7FBD';
  36464. t['\u2F7C'] = '\u8001';
  36465. t['\u2F7D'] = '\u800C';
  36466. t['\u2F7E'] = '\u8012';
  36467. t['\u2F7F'] = '\u8033';
  36468. t['\u2F80'] = '\u807F';
  36469. t['\u2F81'] = '\u8089';
  36470. t['\u2F82'] = '\u81E3';
  36471. t['\u2F83'] = '\u81EA';
  36472. t['\u2F84'] = '\u81F3';
  36473. t['\u2F85'] = '\u81FC';
  36474. t['\u2F86'] = '\u820C';
  36475. t['\u2F87'] = '\u821B';
  36476. t['\u2F88'] = '\u821F';
  36477. t['\u2F89'] = '\u826E';
  36478. t['\u2F8A'] = '\u8272';
  36479. t['\u2F8B'] = '\u8278';
  36480. t['\u2F8C'] = '\u864D';
  36481. t['\u2F8D'] = '\u866B';
  36482. t['\u2F8E'] = '\u8840';
  36483. t['\u2F8F'] = '\u884C';
  36484. t['\u2F90'] = '\u8863';
  36485. t['\u2F91'] = '\u897E';
  36486. t['\u2F92'] = '\u898B';
  36487. t['\u2F93'] = '\u89D2';
  36488. t['\u2F94'] = '\u8A00';
  36489. t['\u2F95'] = '\u8C37';
  36490. t['\u2F96'] = '\u8C46';
  36491. t['\u2F97'] = '\u8C55';
  36492. t['\u2F98'] = '\u8C78';
  36493. t['\u2F99'] = '\u8C9D';
  36494. t['\u2F9A'] = '\u8D64';
  36495. t['\u2F9B'] = '\u8D70';
  36496. t['\u2F9C'] = '\u8DB3';
  36497. t['\u2F9D'] = '\u8EAB';
  36498. t['\u2F9E'] = '\u8ECA';
  36499. t['\u2F9F'] = '\u8F9B';
  36500. t['\u2FA0'] = '\u8FB0';
  36501. t['\u2FA1'] = '\u8FB5';
  36502. t['\u2FA2'] = '\u9091';
  36503. t['\u2FA3'] = '\u9149';
  36504. t['\u2FA4'] = '\u91C6';
  36505. t['\u2FA5'] = '\u91CC';
  36506. t['\u2FA6'] = '\u91D1';
  36507. t['\u2FA7'] = '\u9577';
  36508. t['\u2FA8'] = '\u9580';
  36509. t['\u2FA9'] = '\u961C';
  36510. t['\u2FAA'] = '\u96B6';
  36511. t['\u2FAB'] = '\u96B9';
  36512. t['\u2FAC'] = '\u96E8';
  36513. t['\u2FAD'] = '\u9751';
  36514. t['\u2FAE'] = '\u975E';
  36515. t['\u2FAF'] = '\u9762';
  36516. t['\u2FB0'] = '\u9769';
  36517. t['\u2FB1'] = '\u97CB';
  36518. t['\u2FB2'] = '\u97ED';
  36519. t['\u2FB3'] = '\u97F3';
  36520. t['\u2FB4'] = '\u9801';
  36521. t['\u2FB5'] = '\u98A8';
  36522. t['\u2FB6'] = '\u98DB';
  36523. t['\u2FB7'] = '\u98DF';
  36524. t['\u2FB8'] = '\u9996';
  36525. t['\u2FB9'] = '\u9999';
  36526. t['\u2FBA'] = '\u99AC';
  36527. t['\u2FBB'] = '\u9AA8';
  36528. t['\u2FBC'] = '\u9AD8';
  36529. t['\u2FBD'] = '\u9ADF';
  36530. t['\u2FBE'] = '\u9B25';
  36531. t['\u2FBF'] = '\u9B2F';
  36532. t['\u2FC0'] = '\u9B32';
  36533. t['\u2FC1'] = '\u9B3C';
  36534. t['\u2FC2'] = '\u9B5A';
  36535. t['\u2FC3'] = '\u9CE5';
  36536. t['\u2FC4'] = '\u9E75';
  36537. t['\u2FC5'] = '\u9E7F';
  36538. t['\u2FC6'] = '\u9EA5';
  36539. t['\u2FC7'] = '\u9EBB';
  36540. t['\u2FC8'] = '\u9EC3';
  36541. t['\u2FC9'] = '\u9ECD';
  36542. t['\u2FCA'] = '\u9ED1';
  36543. t['\u2FCB'] = '\u9EF9';
  36544. t['\u2FCC'] = '\u9EFD';
  36545. t['\u2FCD'] = '\u9F0E';
  36546. t['\u2FCE'] = '\u9F13';
  36547. t['\u2FCF'] = '\u9F20';
  36548. t['\u2FD0'] = '\u9F3B';
  36549. t['\u2FD1'] = '\u9F4A';
  36550. t['\u2FD2'] = '\u9F52';
  36551. t['\u2FD3'] = '\u9F8D';
  36552. t['\u2FD4'] = '\u9F9C';
  36553. t['\u2FD5'] = '\u9FA0';
  36554. t['\u3036'] = '\u3012';
  36555. t['\u3038'] = '\u5341';
  36556. t['\u3039'] = '\u5344';
  36557. t['\u303A'] = '\u5345';
  36558. t['\u309B'] = '\u0020\u3099';
  36559. t['\u309C'] = '\u0020\u309A';
  36560. t['\u3131'] = '\u1100';
  36561. t['\u3132'] = '\u1101';
  36562. t['\u3133'] = '\u11AA';
  36563. t['\u3134'] = '\u1102';
  36564. t['\u3135'] = '\u11AC';
  36565. t['\u3136'] = '\u11AD';
  36566. t['\u3137'] = '\u1103';
  36567. t['\u3138'] = '\u1104';
  36568. t['\u3139'] = '\u1105';
  36569. t['\u313A'] = '\u11B0';
  36570. t['\u313B'] = '\u11B1';
  36571. t['\u313C'] = '\u11B2';
  36572. t['\u313D'] = '\u11B3';
  36573. t['\u313E'] = '\u11B4';
  36574. t['\u313F'] = '\u11B5';
  36575. t['\u3140'] = '\u111A';
  36576. t['\u3141'] = '\u1106';
  36577. t['\u3142'] = '\u1107';
  36578. t['\u3143'] = '\u1108';
  36579. t['\u3144'] = '\u1121';
  36580. t['\u3145'] = '\u1109';
  36581. t['\u3146'] = '\u110A';
  36582. t['\u3147'] = '\u110B';
  36583. t['\u3148'] = '\u110C';
  36584. t['\u3149'] = '\u110D';
  36585. t['\u314A'] = '\u110E';
  36586. t['\u314B'] = '\u110F';
  36587. t['\u314C'] = '\u1110';
  36588. t['\u314D'] = '\u1111';
  36589. t['\u314E'] = '\u1112';
  36590. t['\u314F'] = '\u1161';
  36591. t['\u3150'] = '\u1162';
  36592. t['\u3151'] = '\u1163';
  36593. t['\u3152'] = '\u1164';
  36594. t['\u3153'] = '\u1165';
  36595. t['\u3154'] = '\u1166';
  36596. t['\u3155'] = '\u1167';
  36597. t['\u3156'] = '\u1168';
  36598. t['\u3157'] = '\u1169';
  36599. t['\u3158'] = '\u116A';
  36600. t['\u3159'] = '\u116B';
  36601. t['\u315A'] = '\u116C';
  36602. t['\u315B'] = '\u116D';
  36603. t['\u315C'] = '\u116E';
  36604. t['\u315D'] = '\u116F';
  36605. t['\u315E'] = '\u1170';
  36606. t['\u315F'] = '\u1171';
  36607. t['\u3160'] = '\u1172';
  36608. t['\u3161'] = '\u1173';
  36609. t['\u3162'] = '\u1174';
  36610. t['\u3163'] = '\u1175';
  36611. t['\u3164'] = '\u1160';
  36612. t['\u3165'] = '\u1114';
  36613. t['\u3166'] = '\u1115';
  36614. t['\u3167'] = '\u11C7';
  36615. t['\u3168'] = '\u11C8';
  36616. t['\u3169'] = '\u11CC';
  36617. t['\u316A'] = '\u11CE';
  36618. t['\u316B'] = '\u11D3';
  36619. t['\u316C'] = '\u11D7';
  36620. t['\u316D'] = '\u11D9';
  36621. t['\u316E'] = '\u111C';
  36622. t['\u316F'] = '\u11DD';
  36623. t['\u3170'] = '\u11DF';
  36624. t['\u3171'] = '\u111D';
  36625. t['\u3172'] = '\u111E';
  36626. t['\u3173'] = '\u1120';
  36627. t['\u3174'] = '\u1122';
  36628. t['\u3175'] = '\u1123';
  36629. t['\u3176'] = '\u1127';
  36630. t['\u3177'] = '\u1129';
  36631. t['\u3178'] = '\u112B';
  36632. t['\u3179'] = '\u112C';
  36633. t['\u317A'] = '\u112D';
  36634. t['\u317B'] = '\u112E';
  36635. t['\u317C'] = '\u112F';
  36636. t['\u317D'] = '\u1132';
  36637. t['\u317E'] = '\u1136';
  36638. t['\u317F'] = '\u1140';
  36639. t['\u3180'] = '\u1147';
  36640. t['\u3181'] = '\u114C';
  36641. t['\u3182'] = '\u11F1';
  36642. t['\u3183'] = '\u11F2';
  36643. t['\u3184'] = '\u1157';
  36644. t['\u3185'] = '\u1158';
  36645. t['\u3186'] = '\u1159';
  36646. t['\u3187'] = '\u1184';
  36647. t['\u3188'] = '\u1185';
  36648. t['\u3189'] = '\u1188';
  36649. t['\u318A'] = '\u1191';
  36650. t['\u318B'] = '\u1192';
  36651. t['\u318C'] = '\u1194';
  36652. t['\u318D'] = '\u119E';
  36653. t['\u318E'] = '\u11A1';
  36654. t['\u3200'] = '\u0028\u1100\u0029';
  36655. t['\u3201'] = '\u0028\u1102\u0029';
  36656. t['\u3202'] = '\u0028\u1103\u0029';
  36657. t['\u3203'] = '\u0028\u1105\u0029';
  36658. t['\u3204'] = '\u0028\u1106\u0029';
  36659. t['\u3205'] = '\u0028\u1107\u0029';
  36660. t['\u3206'] = '\u0028\u1109\u0029';
  36661. t['\u3207'] = '\u0028\u110B\u0029';
  36662. t['\u3208'] = '\u0028\u110C\u0029';
  36663. t['\u3209'] = '\u0028\u110E\u0029';
  36664. t['\u320A'] = '\u0028\u110F\u0029';
  36665. t['\u320B'] = '\u0028\u1110\u0029';
  36666. t['\u320C'] = '\u0028\u1111\u0029';
  36667. t['\u320D'] = '\u0028\u1112\u0029';
  36668. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36669. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36670. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36671. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36672. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36673. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36674. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36675. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36676. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36677. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36678. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36679. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36680. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36681. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36682. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36683. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36684. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36685. t['\u3220'] = '\u0028\u4E00\u0029';
  36686. t['\u3221'] = '\u0028\u4E8C\u0029';
  36687. t['\u3222'] = '\u0028\u4E09\u0029';
  36688. t['\u3223'] = '\u0028\u56DB\u0029';
  36689. t['\u3224'] = '\u0028\u4E94\u0029';
  36690. t['\u3225'] = '\u0028\u516D\u0029';
  36691. t['\u3226'] = '\u0028\u4E03\u0029';
  36692. t['\u3227'] = '\u0028\u516B\u0029';
  36693. t['\u3228'] = '\u0028\u4E5D\u0029';
  36694. t['\u3229'] = '\u0028\u5341\u0029';
  36695. t['\u322A'] = '\u0028\u6708\u0029';
  36696. t['\u322B'] = '\u0028\u706B\u0029';
  36697. t['\u322C'] = '\u0028\u6C34\u0029';
  36698. t['\u322D'] = '\u0028\u6728\u0029';
  36699. t['\u322E'] = '\u0028\u91D1\u0029';
  36700. t['\u322F'] = '\u0028\u571F\u0029';
  36701. t['\u3230'] = '\u0028\u65E5\u0029';
  36702. t['\u3231'] = '\u0028\u682A\u0029';
  36703. t['\u3232'] = '\u0028\u6709\u0029';
  36704. t['\u3233'] = '\u0028\u793E\u0029';
  36705. t['\u3234'] = '\u0028\u540D\u0029';
  36706. t['\u3235'] = '\u0028\u7279\u0029';
  36707. t['\u3236'] = '\u0028\u8CA1\u0029';
  36708. t['\u3237'] = '\u0028\u795D\u0029';
  36709. t['\u3238'] = '\u0028\u52B4\u0029';
  36710. t['\u3239'] = '\u0028\u4EE3\u0029';
  36711. t['\u323A'] = '\u0028\u547C\u0029';
  36712. t['\u323B'] = '\u0028\u5B66\u0029';
  36713. t['\u323C'] = '\u0028\u76E3\u0029';
  36714. t['\u323D'] = '\u0028\u4F01\u0029';
  36715. t['\u323E'] = '\u0028\u8CC7\u0029';
  36716. t['\u323F'] = '\u0028\u5354\u0029';
  36717. t['\u3240'] = '\u0028\u796D\u0029';
  36718. t['\u3241'] = '\u0028\u4F11\u0029';
  36719. t['\u3242'] = '\u0028\u81EA\u0029';
  36720. t['\u3243'] = '\u0028\u81F3\u0029';
  36721. t['\u32C0'] = '\u0031\u6708';
  36722. t['\u32C1'] = '\u0032\u6708';
  36723. t['\u32C2'] = '\u0033\u6708';
  36724. t['\u32C3'] = '\u0034\u6708';
  36725. t['\u32C4'] = '\u0035\u6708';
  36726. t['\u32C5'] = '\u0036\u6708';
  36727. t['\u32C6'] = '\u0037\u6708';
  36728. t['\u32C7'] = '\u0038\u6708';
  36729. t['\u32C8'] = '\u0039\u6708';
  36730. t['\u32C9'] = '\u0031\u0030\u6708';
  36731. t['\u32CA'] = '\u0031\u0031\u6708';
  36732. t['\u32CB'] = '\u0031\u0032\u6708';
  36733. t['\u3358'] = '\u0030\u70B9';
  36734. t['\u3359'] = '\u0031\u70B9';
  36735. t['\u335A'] = '\u0032\u70B9';
  36736. t['\u335B'] = '\u0033\u70B9';
  36737. t['\u335C'] = '\u0034\u70B9';
  36738. t['\u335D'] = '\u0035\u70B9';
  36739. t['\u335E'] = '\u0036\u70B9';
  36740. t['\u335F'] = '\u0037\u70B9';
  36741. t['\u3360'] = '\u0038\u70B9';
  36742. t['\u3361'] = '\u0039\u70B9';
  36743. t['\u3362'] = '\u0031\u0030\u70B9';
  36744. t['\u3363'] = '\u0031\u0031\u70B9';
  36745. t['\u3364'] = '\u0031\u0032\u70B9';
  36746. t['\u3365'] = '\u0031\u0033\u70B9';
  36747. t['\u3366'] = '\u0031\u0034\u70B9';
  36748. t['\u3367'] = '\u0031\u0035\u70B9';
  36749. t['\u3368'] = '\u0031\u0036\u70B9';
  36750. t['\u3369'] = '\u0031\u0037\u70B9';
  36751. t['\u336A'] = '\u0031\u0038\u70B9';
  36752. t['\u336B'] = '\u0031\u0039\u70B9';
  36753. t['\u336C'] = '\u0032\u0030\u70B9';
  36754. t['\u336D'] = '\u0032\u0031\u70B9';
  36755. t['\u336E'] = '\u0032\u0032\u70B9';
  36756. t['\u336F'] = '\u0032\u0033\u70B9';
  36757. t['\u3370'] = '\u0032\u0034\u70B9';
  36758. t['\u33E0'] = '\u0031\u65E5';
  36759. t['\u33E1'] = '\u0032\u65E5';
  36760. t['\u33E2'] = '\u0033\u65E5';
  36761. t['\u33E3'] = '\u0034\u65E5';
  36762. t['\u33E4'] = '\u0035\u65E5';
  36763. t['\u33E5'] = '\u0036\u65E5';
  36764. t['\u33E6'] = '\u0037\u65E5';
  36765. t['\u33E7'] = '\u0038\u65E5';
  36766. t['\u33E8'] = '\u0039\u65E5';
  36767. t['\u33E9'] = '\u0031\u0030\u65E5';
  36768. t['\u33EA'] = '\u0031\u0031\u65E5';
  36769. t['\u33EB'] = '\u0031\u0032\u65E5';
  36770. t['\u33EC'] = '\u0031\u0033\u65E5';
  36771. t['\u33ED'] = '\u0031\u0034\u65E5';
  36772. t['\u33EE'] = '\u0031\u0035\u65E5';
  36773. t['\u33EF'] = '\u0031\u0036\u65E5';
  36774. t['\u33F0'] = '\u0031\u0037\u65E5';
  36775. t['\u33F1'] = '\u0031\u0038\u65E5';
  36776. t['\u33F2'] = '\u0031\u0039\u65E5';
  36777. t['\u33F3'] = '\u0032\u0030\u65E5';
  36778. t['\u33F4'] = '\u0032\u0031\u65E5';
  36779. t['\u33F5'] = '\u0032\u0032\u65E5';
  36780. t['\u33F6'] = '\u0032\u0033\u65E5';
  36781. t['\u33F7'] = '\u0032\u0034\u65E5';
  36782. t['\u33F8'] = '\u0032\u0035\u65E5';
  36783. t['\u33F9'] = '\u0032\u0036\u65E5';
  36784. t['\u33FA'] = '\u0032\u0037\u65E5';
  36785. t['\u33FB'] = '\u0032\u0038\u65E5';
  36786. t['\u33FC'] = '\u0032\u0039\u65E5';
  36787. t['\u33FD'] = '\u0033\u0030\u65E5';
  36788. t['\u33FE'] = '\u0033\u0031\u65E5';
  36789. t['\uFB00'] = '\u0066\u0066';
  36790. t['\uFB01'] = '\u0066\u0069';
  36791. t['\uFB02'] = '\u0066\u006C';
  36792. t['\uFB03'] = '\u0066\u0066\u0069';
  36793. t['\uFB04'] = '\u0066\u0066\u006C';
  36794. t['\uFB05'] = '\u017F\u0074';
  36795. t['\uFB06'] = '\u0073\u0074';
  36796. t['\uFB13'] = '\u0574\u0576';
  36797. t['\uFB14'] = '\u0574\u0565';
  36798. t['\uFB15'] = '\u0574\u056B';
  36799. t['\uFB16'] = '\u057E\u0576';
  36800. t['\uFB17'] = '\u0574\u056D';
  36801. t['\uFB4F'] = '\u05D0\u05DC';
  36802. t['\uFB50'] = '\u0671';
  36803. t['\uFB51'] = '\u0671';
  36804. t['\uFB52'] = '\u067B';
  36805. t['\uFB53'] = '\u067B';
  36806. t['\uFB54'] = '\u067B';
  36807. t['\uFB55'] = '\u067B';
  36808. t['\uFB56'] = '\u067E';
  36809. t['\uFB57'] = '\u067E';
  36810. t['\uFB58'] = '\u067E';
  36811. t['\uFB59'] = '\u067E';
  36812. t['\uFB5A'] = '\u0680';
  36813. t['\uFB5B'] = '\u0680';
  36814. t['\uFB5C'] = '\u0680';
  36815. t['\uFB5D'] = '\u0680';
  36816. t['\uFB5E'] = '\u067A';
  36817. t['\uFB5F'] = '\u067A';
  36818. t['\uFB60'] = '\u067A';
  36819. t['\uFB61'] = '\u067A';
  36820. t['\uFB62'] = '\u067F';
  36821. t['\uFB63'] = '\u067F';
  36822. t['\uFB64'] = '\u067F';
  36823. t['\uFB65'] = '\u067F';
  36824. t['\uFB66'] = '\u0679';
  36825. t['\uFB67'] = '\u0679';
  36826. t['\uFB68'] = '\u0679';
  36827. t['\uFB69'] = '\u0679';
  36828. t['\uFB6A'] = '\u06A4';
  36829. t['\uFB6B'] = '\u06A4';
  36830. t['\uFB6C'] = '\u06A4';
  36831. t['\uFB6D'] = '\u06A4';
  36832. t['\uFB6E'] = '\u06A6';
  36833. t['\uFB6F'] = '\u06A6';
  36834. t['\uFB70'] = '\u06A6';
  36835. t['\uFB71'] = '\u06A6';
  36836. t['\uFB72'] = '\u0684';
  36837. t['\uFB73'] = '\u0684';
  36838. t['\uFB74'] = '\u0684';
  36839. t['\uFB75'] = '\u0684';
  36840. t['\uFB76'] = '\u0683';
  36841. t['\uFB77'] = '\u0683';
  36842. t['\uFB78'] = '\u0683';
  36843. t['\uFB79'] = '\u0683';
  36844. t['\uFB7A'] = '\u0686';
  36845. t['\uFB7B'] = '\u0686';
  36846. t['\uFB7C'] = '\u0686';
  36847. t['\uFB7D'] = '\u0686';
  36848. t['\uFB7E'] = '\u0687';
  36849. t['\uFB7F'] = '\u0687';
  36850. t['\uFB80'] = '\u0687';
  36851. t['\uFB81'] = '\u0687';
  36852. t['\uFB82'] = '\u068D';
  36853. t['\uFB83'] = '\u068D';
  36854. t['\uFB84'] = '\u068C';
  36855. t['\uFB85'] = '\u068C';
  36856. t['\uFB86'] = '\u068E';
  36857. t['\uFB87'] = '\u068E';
  36858. t['\uFB88'] = '\u0688';
  36859. t['\uFB89'] = '\u0688';
  36860. t['\uFB8A'] = '\u0698';
  36861. t['\uFB8B'] = '\u0698';
  36862. t['\uFB8C'] = '\u0691';
  36863. t['\uFB8D'] = '\u0691';
  36864. t['\uFB8E'] = '\u06A9';
  36865. t['\uFB8F'] = '\u06A9';
  36866. t['\uFB90'] = '\u06A9';
  36867. t['\uFB91'] = '\u06A9';
  36868. t['\uFB92'] = '\u06AF';
  36869. t['\uFB93'] = '\u06AF';
  36870. t['\uFB94'] = '\u06AF';
  36871. t['\uFB95'] = '\u06AF';
  36872. t['\uFB96'] = '\u06B3';
  36873. t['\uFB97'] = '\u06B3';
  36874. t['\uFB98'] = '\u06B3';
  36875. t['\uFB99'] = '\u06B3';
  36876. t['\uFB9A'] = '\u06B1';
  36877. t['\uFB9B'] = '\u06B1';
  36878. t['\uFB9C'] = '\u06B1';
  36879. t['\uFB9D'] = '\u06B1';
  36880. t['\uFB9E'] = '\u06BA';
  36881. t['\uFB9F'] = '\u06BA';
  36882. t['\uFBA0'] = '\u06BB';
  36883. t['\uFBA1'] = '\u06BB';
  36884. t['\uFBA2'] = '\u06BB';
  36885. t['\uFBA3'] = '\u06BB';
  36886. t['\uFBA4'] = '\u06C0';
  36887. t['\uFBA5'] = '\u06C0';
  36888. t['\uFBA6'] = '\u06C1';
  36889. t['\uFBA7'] = '\u06C1';
  36890. t['\uFBA8'] = '\u06C1';
  36891. t['\uFBA9'] = '\u06C1';
  36892. t['\uFBAA'] = '\u06BE';
  36893. t['\uFBAB'] = '\u06BE';
  36894. t['\uFBAC'] = '\u06BE';
  36895. t['\uFBAD'] = '\u06BE';
  36896. t['\uFBAE'] = '\u06D2';
  36897. t['\uFBAF'] = '\u06D2';
  36898. t['\uFBB0'] = '\u06D3';
  36899. t['\uFBB1'] = '\u06D3';
  36900. t['\uFBD3'] = '\u06AD';
  36901. t['\uFBD4'] = '\u06AD';
  36902. t['\uFBD5'] = '\u06AD';
  36903. t['\uFBD6'] = '\u06AD';
  36904. t['\uFBD7'] = '\u06C7';
  36905. t['\uFBD8'] = '\u06C7';
  36906. t['\uFBD9'] = '\u06C6';
  36907. t['\uFBDA'] = '\u06C6';
  36908. t['\uFBDB'] = '\u06C8';
  36909. t['\uFBDC'] = '\u06C8';
  36910. t['\uFBDD'] = '\u0677';
  36911. t['\uFBDE'] = '\u06CB';
  36912. t['\uFBDF'] = '\u06CB';
  36913. t['\uFBE0'] = '\u06C5';
  36914. t['\uFBE1'] = '\u06C5';
  36915. t['\uFBE2'] = '\u06C9';
  36916. t['\uFBE3'] = '\u06C9';
  36917. t['\uFBE4'] = '\u06D0';
  36918. t['\uFBE5'] = '\u06D0';
  36919. t['\uFBE6'] = '\u06D0';
  36920. t['\uFBE7'] = '\u06D0';
  36921. t['\uFBE8'] = '\u0649';
  36922. t['\uFBE9'] = '\u0649';
  36923. t['\uFBEA'] = '\u0626\u0627';
  36924. t['\uFBEB'] = '\u0626\u0627';
  36925. t['\uFBEC'] = '\u0626\u06D5';
  36926. t['\uFBED'] = '\u0626\u06D5';
  36927. t['\uFBEE'] = '\u0626\u0648';
  36928. t['\uFBEF'] = '\u0626\u0648';
  36929. t['\uFBF0'] = '\u0626\u06C7';
  36930. t['\uFBF1'] = '\u0626\u06C7';
  36931. t['\uFBF2'] = '\u0626\u06C6';
  36932. t['\uFBF3'] = '\u0626\u06C6';
  36933. t['\uFBF4'] = '\u0626\u06C8';
  36934. t['\uFBF5'] = '\u0626\u06C8';
  36935. t['\uFBF6'] = '\u0626\u06D0';
  36936. t['\uFBF7'] = '\u0626\u06D0';
  36937. t['\uFBF8'] = '\u0626\u06D0';
  36938. t['\uFBF9'] = '\u0626\u0649';
  36939. t['\uFBFA'] = '\u0626\u0649';
  36940. t['\uFBFB'] = '\u0626\u0649';
  36941. t['\uFBFC'] = '\u06CC';
  36942. t['\uFBFD'] = '\u06CC';
  36943. t['\uFBFE'] = '\u06CC';
  36944. t['\uFBFF'] = '\u06CC';
  36945. t['\uFC00'] = '\u0626\u062C';
  36946. t['\uFC01'] = '\u0626\u062D';
  36947. t['\uFC02'] = '\u0626\u0645';
  36948. t['\uFC03'] = '\u0626\u0649';
  36949. t['\uFC04'] = '\u0626\u064A';
  36950. t['\uFC05'] = '\u0628\u062C';
  36951. t['\uFC06'] = '\u0628\u062D';
  36952. t['\uFC07'] = '\u0628\u062E';
  36953. t['\uFC08'] = '\u0628\u0645';
  36954. t['\uFC09'] = '\u0628\u0649';
  36955. t['\uFC0A'] = '\u0628\u064A';
  36956. t['\uFC0B'] = '\u062A\u062C';
  36957. t['\uFC0C'] = '\u062A\u062D';
  36958. t['\uFC0D'] = '\u062A\u062E';
  36959. t['\uFC0E'] = '\u062A\u0645';
  36960. t['\uFC0F'] = '\u062A\u0649';
  36961. t['\uFC10'] = '\u062A\u064A';
  36962. t['\uFC11'] = '\u062B\u062C';
  36963. t['\uFC12'] = '\u062B\u0645';
  36964. t['\uFC13'] = '\u062B\u0649';
  36965. t['\uFC14'] = '\u062B\u064A';
  36966. t['\uFC15'] = '\u062C\u062D';
  36967. t['\uFC16'] = '\u062C\u0645';
  36968. t['\uFC17'] = '\u062D\u062C';
  36969. t['\uFC18'] = '\u062D\u0645';
  36970. t['\uFC19'] = '\u062E\u062C';
  36971. t['\uFC1A'] = '\u062E\u062D';
  36972. t['\uFC1B'] = '\u062E\u0645';
  36973. t['\uFC1C'] = '\u0633\u062C';
  36974. t['\uFC1D'] = '\u0633\u062D';
  36975. t['\uFC1E'] = '\u0633\u062E';
  36976. t['\uFC1F'] = '\u0633\u0645';
  36977. t['\uFC20'] = '\u0635\u062D';
  36978. t['\uFC21'] = '\u0635\u0645';
  36979. t['\uFC22'] = '\u0636\u062C';
  36980. t['\uFC23'] = '\u0636\u062D';
  36981. t['\uFC24'] = '\u0636\u062E';
  36982. t['\uFC25'] = '\u0636\u0645';
  36983. t['\uFC26'] = '\u0637\u062D';
  36984. t['\uFC27'] = '\u0637\u0645';
  36985. t['\uFC28'] = '\u0638\u0645';
  36986. t['\uFC29'] = '\u0639\u062C';
  36987. t['\uFC2A'] = '\u0639\u0645';
  36988. t['\uFC2B'] = '\u063A\u062C';
  36989. t['\uFC2C'] = '\u063A\u0645';
  36990. t['\uFC2D'] = '\u0641\u062C';
  36991. t['\uFC2E'] = '\u0641\u062D';
  36992. t['\uFC2F'] = '\u0641\u062E';
  36993. t['\uFC30'] = '\u0641\u0645';
  36994. t['\uFC31'] = '\u0641\u0649';
  36995. t['\uFC32'] = '\u0641\u064A';
  36996. t['\uFC33'] = '\u0642\u062D';
  36997. t['\uFC34'] = '\u0642\u0645';
  36998. t['\uFC35'] = '\u0642\u0649';
  36999. t['\uFC36'] = '\u0642\u064A';
  37000. t['\uFC37'] = '\u0643\u0627';
  37001. t['\uFC38'] = '\u0643\u062C';
  37002. t['\uFC39'] = '\u0643\u062D';
  37003. t['\uFC3A'] = '\u0643\u062E';
  37004. t['\uFC3B'] = '\u0643\u0644';
  37005. t['\uFC3C'] = '\u0643\u0645';
  37006. t['\uFC3D'] = '\u0643\u0649';
  37007. t['\uFC3E'] = '\u0643\u064A';
  37008. t['\uFC3F'] = '\u0644\u062C';
  37009. t['\uFC40'] = '\u0644\u062D';
  37010. t['\uFC41'] = '\u0644\u062E';
  37011. t['\uFC42'] = '\u0644\u0645';
  37012. t['\uFC43'] = '\u0644\u0649';
  37013. t['\uFC44'] = '\u0644\u064A';
  37014. t['\uFC45'] = '\u0645\u062C';
  37015. t['\uFC46'] = '\u0645\u062D';
  37016. t['\uFC47'] = '\u0645\u062E';
  37017. t['\uFC48'] = '\u0645\u0645';
  37018. t['\uFC49'] = '\u0645\u0649';
  37019. t['\uFC4A'] = '\u0645\u064A';
  37020. t['\uFC4B'] = '\u0646\u062C';
  37021. t['\uFC4C'] = '\u0646\u062D';
  37022. t['\uFC4D'] = '\u0646\u062E';
  37023. t['\uFC4E'] = '\u0646\u0645';
  37024. t['\uFC4F'] = '\u0646\u0649';
  37025. t['\uFC50'] = '\u0646\u064A';
  37026. t['\uFC51'] = '\u0647\u062C';
  37027. t['\uFC52'] = '\u0647\u0645';
  37028. t['\uFC53'] = '\u0647\u0649';
  37029. t['\uFC54'] = '\u0647\u064A';
  37030. t['\uFC55'] = '\u064A\u062C';
  37031. t['\uFC56'] = '\u064A\u062D';
  37032. t['\uFC57'] = '\u064A\u062E';
  37033. t['\uFC58'] = '\u064A\u0645';
  37034. t['\uFC59'] = '\u064A\u0649';
  37035. t['\uFC5A'] = '\u064A\u064A';
  37036. t['\uFC5B'] = '\u0630\u0670';
  37037. t['\uFC5C'] = '\u0631\u0670';
  37038. t['\uFC5D'] = '\u0649\u0670';
  37039. t['\uFC5E'] = '\u0020\u064C\u0651';
  37040. t['\uFC5F'] = '\u0020\u064D\u0651';
  37041. t['\uFC60'] = '\u0020\u064E\u0651';
  37042. t['\uFC61'] = '\u0020\u064F\u0651';
  37043. t['\uFC62'] = '\u0020\u0650\u0651';
  37044. t['\uFC63'] = '\u0020\u0651\u0670';
  37045. t['\uFC64'] = '\u0626\u0631';
  37046. t['\uFC65'] = '\u0626\u0632';
  37047. t['\uFC66'] = '\u0626\u0645';
  37048. t['\uFC67'] = '\u0626\u0646';
  37049. t['\uFC68'] = '\u0626\u0649';
  37050. t['\uFC69'] = '\u0626\u064A';
  37051. t['\uFC6A'] = '\u0628\u0631';
  37052. t['\uFC6B'] = '\u0628\u0632';
  37053. t['\uFC6C'] = '\u0628\u0645';
  37054. t['\uFC6D'] = '\u0628\u0646';
  37055. t['\uFC6E'] = '\u0628\u0649';
  37056. t['\uFC6F'] = '\u0628\u064A';
  37057. t['\uFC70'] = '\u062A\u0631';
  37058. t['\uFC71'] = '\u062A\u0632';
  37059. t['\uFC72'] = '\u062A\u0645';
  37060. t['\uFC73'] = '\u062A\u0646';
  37061. t['\uFC74'] = '\u062A\u0649';
  37062. t['\uFC75'] = '\u062A\u064A';
  37063. t['\uFC76'] = '\u062B\u0631';
  37064. t['\uFC77'] = '\u062B\u0632';
  37065. t['\uFC78'] = '\u062B\u0645';
  37066. t['\uFC79'] = '\u062B\u0646';
  37067. t['\uFC7A'] = '\u062B\u0649';
  37068. t['\uFC7B'] = '\u062B\u064A';
  37069. t['\uFC7C'] = '\u0641\u0649';
  37070. t['\uFC7D'] = '\u0641\u064A';
  37071. t['\uFC7E'] = '\u0642\u0649';
  37072. t['\uFC7F'] = '\u0642\u064A';
  37073. t['\uFC80'] = '\u0643\u0627';
  37074. t['\uFC81'] = '\u0643\u0644';
  37075. t['\uFC82'] = '\u0643\u0645';
  37076. t['\uFC83'] = '\u0643\u0649';
  37077. t['\uFC84'] = '\u0643\u064A';
  37078. t['\uFC85'] = '\u0644\u0645';
  37079. t['\uFC86'] = '\u0644\u0649';
  37080. t['\uFC87'] = '\u0644\u064A';
  37081. t['\uFC88'] = '\u0645\u0627';
  37082. t['\uFC89'] = '\u0645\u0645';
  37083. t['\uFC8A'] = '\u0646\u0631';
  37084. t['\uFC8B'] = '\u0646\u0632';
  37085. t['\uFC8C'] = '\u0646\u0645';
  37086. t['\uFC8D'] = '\u0646\u0646';
  37087. t['\uFC8E'] = '\u0646\u0649';
  37088. t['\uFC8F'] = '\u0646\u064A';
  37089. t['\uFC90'] = '\u0649\u0670';
  37090. t['\uFC91'] = '\u064A\u0631';
  37091. t['\uFC92'] = '\u064A\u0632';
  37092. t['\uFC93'] = '\u064A\u0645';
  37093. t['\uFC94'] = '\u064A\u0646';
  37094. t['\uFC95'] = '\u064A\u0649';
  37095. t['\uFC96'] = '\u064A\u064A';
  37096. t['\uFC97'] = '\u0626\u062C';
  37097. t['\uFC98'] = '\u0626\u062D';
  37098. t['\uFC99'] = '\u0626\u062E';
  37099. t['\uFC9A'] = '\u0626\u0645';
  37100. t['\uFC9B'] = '\u0626\u0647';
  37101. t['\uFC9C'] = '\u0628\u062C';
  37102. t['\uFC9D'] = '\u0628\u062D';
  37103. t['\uFC9E'] = '\u0628\u062E';
  37104. t['\uFC9F'] = '\u0628\u0645';
  37105. t['\uFCA0'] = '\u0628\u0647';
  37106. t['\uFCA1'] = '\u062A\u062C';
  37107. t['\uFCA2'] = '\u062A\u062D';
  37108. t['\uFCA3'] = '\u062A\u062E';
  37109. t['\uFCA4'] = '\u062A\u0645';
  37110. t['\uFCA5'] = '\u062A\u0647';
  37111. t['\uFCA6'] = '\u062B\u0645';
  37112. t['\uFCA7'] = '\u062C\u062D';
  37113. t['\uFCA8'] = '\u062C\u0645';
  37114. t['\uFCA9'] = '\u062D\u062C';
  37115. t['\uFCAA'] = '\u062D\u0645';
  37116. t['\uFCAB'] = '\u062E\u062C';
  37117. t['\uFCAC'] = '\u062E\u0645';
  37118. t['\uFCAD'] = '\u0633\u062C';
  37119. t['\uFCAE'] = '\u0633\u062D';
  37120. t['\uFCAF'] = '\u0633\u062E';
  37121. t['\uFCB0'] = '\u0633\u0645';
  37122. t['\uFCB1'] = '\u0635\u062D';
  37123. t['\uFCB2'] = '\u0635\u062E';
  37124. t['\uFCB3'] = '\u0635\u0645';
  37125. t['\uFCB4'] = '\u0636\u062C';
  37126. t['\uFCB5'] = '\u0636\u062D';
  37127. t['\uFCB6'] = '\u0636\u062E';
  37128. t['\uFCB7'] = '\u0636\u0645';
  37129. t['\uFCB8'] = '\u0637\u062D';
  37130. t['\uFCB9'] = '\u0638\u0645';
  37131. t['\uFCBA'] = '\u0639\u062C';
  37132. t['\uFCBB'] = '\u0639\u0645';
  37133. t['\uFCBC'] = '\u063A\u062C';
  37134. t['\uFCBD'] = '\u063A\u0645';
  37135. t['\uFCBE'] = '\u0641\u062C';
  37136. t['\uFCBF'] = '\u0641\u062D';
  37137. t['\uFCC0'] = '\u0641\u062E';
  37138. t['\uFCC1'] = '\u0641\u0645';
  37139. t['\uFCC2'] = '\u0642\u062D';
  37140. t['\uFCC3'] = '\u0642\u0645';
  37141. t['\uFCC4'] = '\u0643\u062C';
  37142. t['\uFCC5'] = '\u0643\u062D';
  37143. t['\uFCC6'] = '\u0643\u062E';
  37144. t['\uFCC7'] = '\u0643\u0644';
  37145. t['\uFCC8'] = '\u0643\u0645';
  37146. t['\uFCC9'] = '\u0644\u062C';
  37147. t['\uFCCA'] = '\u0644\u062D';
  37148. t['\uFCCB'] = '\u0644\u062E';
  37149. t['\uFCCC'] = '\u0644\u0645';
  37150. t['\uFCCD'] = '\u0644\u0647';
  37151. t['\uFCCE'] = '\u0645\u062C';
  37152. t['\uFCCF'] = '\u0645\u062D';
  37153. t['\uFCD0'] = '\u0645\u062E';
  37154. t['\uFCD1'] = '\u0645\u0645';
  37155. t['\uFCD2'] = '\u0646\u062C';
  37156. t['\uFCD3'] = '\u0646\u062D';
  37157. t['\uFCD4'] = '\u0646\u062E';
  37158. t['\uFCD5'] = '\u0646\u0645';
  37159. t['\uFCD6'] = '\u0646\u0647';
  37160. t['\uFCD7'] = '\u0647\u062C';
  37161. t['\uFCD8'] = '\u0647\u0645';
  37162. t['\uFCD9'] = '\u0647\u0670';
  37163. t['\uFCDA'] = '\u064A\u062C';
  37164. t['\uFCDB'] = '\u064A\u062D';
  37165. t['\uFCDC'] = '\u064A\u062E';
  37166. t['\uFCDD'] = '\u064A\u0645';
  37167. t['\uFCDE'] = '\u064A\u0647';
  37168. t['\uFCDF'] = '\u0626\u0645';
  37169. t['\uFCE0'] = '\u0626\u0647';
  37170. t['\uFCE1'] = '\u0628\u0645';
  37171. t['\uFCE2'] = '\u0628\u0647';
  37172. t['\uFCE3'] = '\u062A\u0645';
  37173. t['\uFCE4'] = '\u062A\u0647';
  37174. t['\uFCE5'] = '\u062B\u0645';
  37175. t['\uFCE6'] = '\u062B\u0647';
  37176. t['\uFCE7'] = '\u0633\u0645';
  37177. t['\uFCE8'] = '\u0633\u0647';
  37178. t['\uFCE9'] = '\u0634\u0645';
  37179. t['\uFCEA'] = '\u0634\u0647';
  37180. t['\uFCEB'] = '\u0643\u0644';
  37181. t['\uFCEC'] = '\u0643\u0645';
  37182. t['\uFCED'] = '\u0644\u0645';
  37183. t['\uFCEE'] = '\u0646\u0645';
  37184. t['\uFCEF'] = '\u0646\u0647';
  37185. t['\uFCF0'] = '\u064A\u0645';
  37186. t['\uFCF1'] = '\u064A\u0647';
  37187. t['\uFCF2'] = '\u0640\u064E\u0651';
  37188. t['\uFCF3'] = '\u0640\u064F\u0651';
  37189. t['\uFCF4'] = '\u0640\u0650\u0651';
  37190. t['\uFCF5'] = '\u0637\u0649';
  37191. t['\uFCF6'] = '\u0637\u064A';
  37192. t['\uFCF7'] = '\u0639\u0649';
  37193. t['\uFCF8'] = '\u0639\u064A';
  37194. t['\uFCF9'] = '\u063A\u0649';
  37195. t['\uFCFA'] = '\u063A\u064A';
  37196. t['\uFCFB'] = '\u0633\u0649';
  37197. t['\uFCFC'] = '\u0633\u064A';
  37198. t['\uFCFD'] = '\u0634\u0649';
  37199. t['\uFCFE'] = '\u0634\u064A';
  37200. t['\uFCFF'] = '\u062D\u0649';
  37201. t['\uFD00'] = '\u062D\u064A';
  37202. t['\uFD01'] = '\u062C\u0649';
  37203. t['\uFD02'] = '\u062C\u064A';
  37204. t['\uFD03'] = '\u062E\u0649';
  37205. t['\uFD04'] = '\u062E\u064A';
  37206. t['\uFD05'] = '\u0635\u0649';
  37207. t['\uFD06'] = '\u0635\u064A';
  37208. t['\uFD07'] = '\u0636\u0649';
  37209. t['\uFD08'] = '\u0636\u064A';
  37210. t['\uFD09'] = '\u0634\u062C';
  37211. t['\uFD0A'] = '\u0634\u062D';
  37212. t['\uFD0B'] = '\u0634\u062E';
  37213. t['\uFD0C'] = '\u0634\u0645';
  37214. t['\uFD0D'] = '\u0634\u0631';
  37215. t['\uFD0E'] = '\u0633\u0631';
  37216. t['\uFD0F'] = '\u0635\u0631';
  37217. t['\uFD10'] = '\u0636\u0631';
  37218. t['\uFD11'] = '\u0637\u0649';
  37219. t['\uFD12'] = '\u0637\u064A';
  37220. t['\uFD13'] = '\u0639\u0649';
  37221. t['\uFD14'] = '\u0639\u064A';
  37222. t['\uFD15'] = '\u063A\u0649';
  37223. t['\uFD16'] = '\u063A\u064A';
  37224. t['\uFD17'] = '\u0633\u0649';
  37225. t['\uFD18'] = '\u0633\u064A';
  37226. t['\uFD19'] = '\u0634\u0649';
  37227. t['\uFD1A'] = '\u0634\u064A';
  37228. t['\uFD1B'] = '\u062D\u0649';
  37229. t['\uFD1C'] = '\u062D\u064A';
  37230. t['\uFD1D'] = '\u062C\u0649';
  37231. t['\uFD1E'] = '\u062C\u064A';
  37232. t['\uFD1F'] = '\u062E\u0649';
  37233. t['\uFD20'] = '\u062E\u064A';
  37234. t['\uFD21'] = '\u0635\u0649';
  37235. t['\uFD22'] = '\u0635\u064A';
  37236. t['\uFD23'] = '\u0636\u0649';
  37237. t['\uFD24'] = '\u0636\u064A';
  37238. t['\uFD25'] = '\u0634\u062C';
  37239. t['\uFD26'] = '\u0634\u062D';
  37240. t['\uFD27'] = '\u0634\u062E';
  37241. t['\uFD28'] = '\u0634\u0645';
  37242. t['\uFD29'] = '\u0634\u0631';
  37243. t['\uFD2A'] = '\u0633\u0631';
  37244. t['\uFD2B'] = '\u0635\u0631';
  37245. t['\uFD2C'] = '\u0636\u0631';
  37246. t['\uFD2D'] = '\u0634\u062C';
  37247. t['\uFD2E'] = '\u0634\u062D';
  37248. t['\uFD2F'] = '\u0634\u062E';
  37249. t['\uFD30'] = '\u0634\u0645';
  37250. t['\uFD31'] = '\u0633\u0647';
  37251. t['\uFD32'] = '\u0634\u0647';
  37252. t['\uFD33'] = '\u0637\u0645';
  37253. t['\uFD34'] = '\u0633\u062C';
  37254. t['\uFD35'] = '\u0633\u062D';
  37255. t['\uFD36'] = '\u0633\u062E';
  37256. t['\uFD37'] = '\u0634\u062C';
  37257. t['\uFD38'] = '\u0634\u062D';
  37258. t['\uFD39'] = '\u0634\u062E';
  37259. t['\uFD3A'] = '\u0637\u0645';
  37260. t['\uFD3B'] = '\u0638\u0645';
  37261. t['\uFD3C'] = '\u0627\u064B';
  37262. t['\uFD3D'] = '\u0627\u064B';
  37263. t['\uFD50'] = '\u062A\u062C\u0645';
  37264. t['\uFD51'] = '\u062A\u062D\u062C';
  37265. t['\uFD52'] = '\u062A\u062D\u062C';
  37266. t['\uFD53'] = '\u062A\u062D\u0645';
  37267. t['\uFD54'] = '\u062A\u062E\u0645';
  37268. t['\uFD55'] = '\u062A\u0645\u062C';
  37269. t['\uFD56'] = '\u062A\u0645\u062D';
  37270. t['\uFD57'] = '\u062A\u0645\u062E';
  37271. t['\uFD58'] = '\u062C\u0645\u062D';
  37272. t['\uFD59'] = '\u062C\u0645\u062D';
  37273. t['\uFD5A'] = '\u062D\u0645\u064A';
  37274. t['\uFD5B'] = '\u062D\u0645\u0649';
  37275. t['\uFD5C'] = '\u0633\u062D\u062C';
  37276. t['\uFD5D'] = '\u0633\u062C\u062D';
  37277. t['\uFD5E'] = '\u0633\u062C\u0649';
  37278. t['\uFD5F'] = '\u0633\u0645\u062D';
  37279. t['\uFD60'] = '\u0633\u0645\u062D';
  37280. t['\uFD61'] = '\u0633\u0645\u062C';
  37281. t['\uFD62'] = '\u0633\u0645\u0645';
  37282. t['\uFD63'] = '\u0633\u0645\u0645';
  37283. t['\uFD64'] = '\u0635\u062D\u062D';
  37284. t['\uFD65'] = '\u0635\u062D\u062D';
  37285. t['\uFD66'] = '\u0635\u0645\u0645';
  37286. t['\uFD67'] = '\u0634\u062D\u0645';
  37287. t['\uFD68'] = '\u0634\u062D\u0645';
  37288. t['\uFD69'] = '\u0634\u062C\u064A';
  37289. t['\uFD6A'] = '\u0634\u0645\u062E';
  37290. t['\uFD6B'] = '\u0634\u0645\u062E';
  37291. t['\uFD6C'] = '\u0634\u0645\u0645';
  37292. t['\uFD6D'] = '\u0634\u0645\u0645';
  37293. t['\uFD6E'] = '\u0636\u062D\u0649';
  37294. t['\uFD6F'] = '\u0636\u062E\u0645';
  37295. t['\uFD70'] = '\u0636\u062E\u0645';
  37296. t['\uFD71'] = '\u0637\u0645\u062D';
  37297. t['\uFD72'] = '\u0637\u0645\u062D';
  37298. t['\uFD73'] = '\u0637\u0645\u0645';
  37299. t['\uFD74'] = '\u0637\u0645\u064A';
  37300. t['\uFD75'] = '\u0639\u062C\u0645';
  37301. t['\uFD76'] = '\u0639\u0645\u0645';
  37302. t['\uFD77'] = '\u0639\u0645\u0645';
  37303. t['\uFD78'] = '\u0639\u0645\u0649';
  37304. t['\uFD79'] = '\u063A\u0645\u0645';
  37305. t['\uFD7A'] = '\u063A\u0645\u064A';
  37306. t['\uFD7B'] = '\u063A\u0645\u0649';
  37307. t['\uFD7C'] = '\u0641\u062E\u0645';
  37308. t['\uFD7D'] = '\u0641\u062E\u0645';
  37309. t['\uFD7E'] = '\u0642\u0645\u062D';
  37310. t['\uFD7F'] = '\u0642\u0645\u0645';
  37311. t['\uFD80'] = '\u0644\u062D\u0645';
  37312. t['\uFD81'] = '\u0644\u062D\u064A';
  37313. t['\uFD82'] = '\u0644\u062D\u0649';
  37314. t['\uFD83'] = '\u0644\u062C\u062C';
  37315. t['\uFD84'] = '\u0644\u062C\u062C';
  37316. t['\uFD85'] = '\u0644\u062E\u0645';
  37317. t['\uFD86'] = '\u0644\u062E\u0645';
  37318. t['\uFD87'] = '\u0644\u0645\u062D';
  37319. t['\uFD88'] = '\u0644\u0645\u062D';
  37320. t['\uFD89'] = '\u0645\u062D\u062C';
  37321. t['\uFD8A'] = '\u0645\u062D\u0645';
  37322. t['\uFD8B'] = '\u0645\u062D\u064A';
  37323. t['\uFD8C'] = '\u0645\u062C\u062D';
  37324. t['\uFD8D'] = '\u0645\u062C\u0645';
  37325. t['\uFD8E'] = '\u0645\u062E\u062C';
  37326. t['\uFD8F'] = '\u0645\u062E\u0645';
  37327. t['\uFD92'] = '\u0645\u062C\u062E';
  37328. t['\uFD93'] = '\u0647\u0645\u062C';
  37329. t['\uFD94'] = '\u0647\u0645\u0645';
  37330. t['\uFD95'] = '\u0646\u062D\u0645';
  37331. t['\uFD96'] = '\u0646\u062D\u0649';
  37332. t['\uFD97'] = '\u0646\u062C\u0645';
  37333. t['\uFD98'] = '\u0646\u062C\u0645';
  37334. t['\uFD99'] = '\u0646\u062C\u0649';
  37335. t['\uFD9A'] = '\u0646\u0645\u064A';
  37336. t['\uFD9B'] = '\u0646\u0645\u0649';
  37337. t['\uFD9C'] = '\u064A\u0645\u0645';
  37338. t['\uFD9D'] = '\u064A\u0645\u0645';
  37339. t['\uFD9E'] = '\u0628\u062E\u064A';
  37340. t['\uFD9F'] = '\u062A\u062C\u064A';
  37341. t['\uFDA0'] = '\u062A\u062C\u0649';
  37342. t['\uFDA1'] = '\u062A\u062E\u064A';
  37343. t['\uFDA2'] = '\u062A\u062E\u0649';
  37344. t['\uFDA3'] = '\u062A\u0645\u064A';
  37345. t['\uFDA4'] = '\u062A\u0645\u0649';
  37346. t['\uFDA5'] = '\u062C\u0645\u064A';
  37347. t['\uFDA6'] = '\u062C\u062D\u0649';
  37348. t['\uFDA7'] = '\u062C\u0645\u0649';
  37349. t['\uFDA8'] = '\u0633\u062E\u0649';
  37350. t['\uFDA9'] = '\u0635\u062D\u064A';
  37351. t['\uFDAA'] = '\u0634\u062D\u064A';
  37352. t['\uFDAB'] = '\u0636\u062D\u064A';
  37353. t['\uFDAC'] = '\u0644\u062C\u064A';
  37354. t['\uFDAD'] = '\u0644\u0645\u064A';
  37355. t['\uFDAE'] = '\u064A\u062D\u064A';
  37356. t['\uFDAF'] = '\u064A\u062C\u064A';
  37357. t['\uFDB0'] = '\u064A\u0645\u064A';
  37358. t['\uFDB1'] = '\u0645\u0645\u064A';
  37359. t['\uFDB2'] = '\u0642\u0645\u064A';
  37360. t['\uFDB3'] = '\u0646\u062D\u064A';
  37361. t['\uFDB4'] = '\u0642\u0645\u062D';
  37362. t['\uFDB5'] = '\u0644\u062D\u0645';
  37363. t['\uFDB6'] = '\u0639\u0645\u064A';
  37364. t['\uFDB7'] = '\u0643\u0645\u064A';
  37365. t['\uFDB8'] = '\u0646\u062C\u062D';
  37366. t['\uFDB9'] = '\u0645\u062E\u064A';
  37367. t['\uFDBA'] = '\u0644\u062C\u0645';
  37368. t['\uFDBB'] = '\u0643\u0645\u0645';
  37369. t['\uFDBC'] = '\u0644\u062C\u0645';
  37370. t['\uFDBD'] = '\u0646\u062C\u062D';
  37371. t['\uFDBE'] = '\u062C\u062D\u064A';
  37372. t['\uFDBF'] = '\u062D\u062C\u064A';
  37373. t['\uFDC0'] = '\u0645\u062C\u064A';
  37374. t['\uFDC1'] = '\u0641\u0645\u064A';
  37375. t['\uFDC2'] = '\u0628\u062D\u064A';
  37376. t['\uFDC3'] = '\u0643\u0645\u0645';
  37377. t['\uFDC4'] = '\u0639\u062C\u0645';
  37378. t['\uFDC5'] = '\u0635\u0645\u0645';
  37379. t['\uFDC6'] = '\u0633\u062E\u064A';
  37380. t['\uFDC7'] = '\u0646\u062C\u064A';
  37381. t['\uFE49'] = '\u203E';
  37382. t['\uFE4A'] = '\u203E';
  37383. t['\uFE4B'] = '\u203E';
  37384. t['\uFE4C'] = '\u203E';
  37385. t['\uFE4D'] = '\u005F';
  37386. t['\uFE4E'] = '\u005F';
  37387. t['\uFE4F'] = '\u005F';
  37388. t['\uFE80'] = '\u0621';
  37389. t['\uFE81'] = '\u0622';
  37390. t['\uFE82'] = '\u0622';
  37391. t['\uFE83'] = '\u0623';
  37392. t['\uFE84'] = '\u0623';
  37393. t['\uFE85'] = '\u0624';
  37394. t['\uFE86'] = '\u0624';
  37395. t['\uFE87'] = '\u0625';
  37396. t['\uFE88'] = '\u0625';
  37397. t['\uFE89'] = '\u0626';
  37398. t['\uFE8A'] = '\u0626';
  37399. t['\uFE8B'] = '\u0626';
  37400. t['\uFE8C'] = '\u0626';
  37401. t['\uFE8D'] = '\u0627';
  37402. t['\uFE8E'] = '\u0627';
  37403. t['\uFE8F'] = '\u0628';
  37404. t['\uFE90'] = '\u0628';
  37405. t['\uFE91'] = '\u0628';
  37406. t['\uFE92'] = '\u0628';
  37407. t['\uFE93'] = '\u0629';
  37408. t['\uFE94'] = '\u0629';
  37409. t['\uFE95'] = '\u062A';
  37410. t['\uFE96'] = '\u062A';
  37411. t['\uFE97'] = '\u062A';
  37412. t['\uFE98'] = '\u062A';
  37413. t['\uFE99'] = '\u062B';
  37414. t['\uFE9A'] = '\u062B';
  37415. t['\uFE9B'] = '\u062B';
  37416. t['\uFE9C'] = '\u062B';
  37417. t['\uFE9D'] = '\u062C';
  37418. t['\uFE9E'] = '\u062C';
  37419. t['\uFE9F'] = '\u062C';
  37420. t['\uFEA0'] = '\u062C';
  37421. t['\uFEA1'] = '\u062D';
  37422. t['\uFEA2'] = '\u062D';
  37423. t['\uFEA3'] = '\u062D';
  37424. t['\uFEA4'] = '\u062D';
  37425. t['\uFEA5'] = '\u062E';
  37426. t['\uFEA6'] = '\u062E';
  37427. t['\uFEA7'] = '\u062E';
  37428. t['\uFEA8'] = '\u062E';
  37429. t['\uFEA9'] = '\u062F';
  37430. t['\uFEAA'] = '\u062F';
  37431. t['\uFEAB'] = '\u0630';
  37432. t['\uFEAC'] = '\u0630';
  37433. t['\uFEAD'] = '\u0631';
  37434. t['\uFEAE'] = '\u0631';
  37435. t['\uFEAF'] = '\u0632';
  37436. t['\uFEB0'] = '\u0632';
  37437. t['\uFEB1'] = '\u0633';
  37438. t['\uFEB2'] = '\u0633';
  37439. t['\uFEB3'] = '\u0633';
  37440. t['\uFEB4'] = '\u0633';
  37441. t['\uFEB5'] = '\u0634';
  37442. t['\uFEB6'] = '\u0634';
  37443. t['\uFEB7'] = '\u0634';
  37444. t['\uFEB8'] = '\u0634';
  37445. t['\uFEB9'] = '\u0635';
  37446. t['\uFEBA'] = '\u0635';
  37447. t['\uFEBB'] = '\u0635';
  37448. t['\uFEBC'] = '\u0635';
  37449. t['\uFEBD'] = '\u0636';
  37450. t['\uFEBE'] = '\u0636';
  37451. t['\uFEBF'] = '\u0636';
  37452. t['\uFEC0'] = '\u0636';
  37453. t['\uFEC1'] = '\u0637';
  37454. t['\uFEC2'] = '\u0637';
  37455. t['\uFEC3'] = '\u0637';
  37456. t['\uFEC4'] = '\u0637';
  37457. t['\uFEC5'] = '\u0638';
  37458. t['\uFEC6'] = '\u0638';
  37459. t['\uFEC7'] = '\u0638';
  37460. t['\uFEC8'] = '\u0638';
  37461. t['\uFEC9'] = '\u0639';
  37462. t['\uFECA'] = '\u0639';
  37463. t['\uFECB'] = '\u0639';
  37464. t['\uFECC'] = '\u0639';
  37465. t['\uFECD'] = '\u063A';
  37466. t['\uFECE'] = '\u063A';
  37467. t['\uFECF'] = '\u063A';
  37468. t['\uFED0'] = '\u063A';
  37469. t['\uFED1'] = '\u0641';
  37470. t['\uFED2'] = '\u0641';
  37471. t['\uFED3'] = '\u0641';
  37472. t['\uFED4'] = '\u0641';
  37473. t['\uFED5'] = '\u0642';
  37474. t['\uFED6'] = '\u0642';
  37475. t['\uFED7'] = '\u0642';
  37476. t['\uFED8'] = '\u0642';
  37477. t['\uFED9'] = '\u0643';
  37478. t['\uFEDA'] = '\u0643';
  37479. t['\uFEDB'] = '\u0643';
  37480. t['\uFEDC'] = '\u0643';
  37481. t['\uFEDD'] = '\u0644';
  37482. t['\uFEDE'] = '\u0644';
  37483. t['\uFEDF'] = '\u0644';
  37484. t['\uFEE0'] = '\u0644';
  37485. t['\uFEE1'] = '\u0645';
  37486. t['\uFEE2'] = '\u0645';
  37487. t['\uFEE3'] = '\u0645';
  37488. t['\uFEE4'] = '\u0645';
  37489. t['\uFEE5'] = '\u0646';
  37490. t['\uFEE6'] = '\u0646';
  37491. t['\uFEE7'] = '\u0646';
  37492. t['\uFEE8'] = '\u0646';
  37493. t['\uFEE9'] = '\u0647';
  37494. t['\uFEEA'] = '\u0647';
  37495. t['\uFEEB'] = '\u0647';
  37496. t['\uFEEC'] = '\u0647';
  37497. t['\uFEED'] = '\u0648';
  37498. t['\uFEEE'] = '\u0648';
  37499. t['\uFEEF'] = '\u0649';
  37500. t['\uFEF0'] = '\u0649';
  37501. t['\uFEF1'] = '\u064A';
  37502. t['\uFEF2'] = '\u064A';
  37503. t['\uFEF3'] = '\u064A';
  37504. t['\uFEF4'] = '\u064A';
  37505. t['\uFEF5'] = '\u0644\u0622';
  37506. t['\uFEF6'] = '\u0644\u0622';
  37507. t['\uFEF7'] = '\u0644\u0623';
  37508. t['\uFEF8'] = '\u0644\u0623';
  37509. t['\uFEF9'] = '\u0644\u0625';
  37510. t['\uFEFA'] = '\u0644\u0625';
  37511. t['\uFEFB'] = '\u0644\u0627';
  37512. t['\uFEFC'] = '\u0644\u0627';
  37513. });
  37514. function reverseIfRtl(chars) {
  37515. var charsLength = chars.length;
  37516. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37517. return chars;
  37518. }
  37519. var s = '';
  37520. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37521. s += chars[ii];
  37522. }
  37523. return s;
  37524. }
  37525. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37526. exports.reverseIfRtl = reverseIfRtl;
  37527. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37528. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37529. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37530. /***/ }),
  37531. /* 23 */
  37532. /***/ (function(module, exports, __w_pdfjs_require__) {
  37533. "use strict";
  37534. var sharedUtil = __w_pdfjs_require__(0);
  37535. var corePrimitives = __w_pdfjs_require__(1);
  37536. var corePdfManager = __w_pdfjs_require__(41);
  37537. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37538. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37539. var MessageHandler = sharedUtil.MessageHandler;
  37540. var MissingPDFException = sharedUtil.MissingPDFException;
  37541. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37542. var PasswordException = sharedUtil.PasswordException;
  37543. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37544. var XRefParseException = sharedUtil.XRefParseException;
  37545. var arrayByteLength = sharedUtil.arrayByteLength;
  37546. var arraysToBytes = sharedUtil.arraysToBytes;
  37547. var assert = sharedUtil.assert;
  37548. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37549. var info = sharedUtil.info;
  37550. var warn = sharedUtil.warn;
  37551. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37552. var isNodeJS = sharedUtil.isNodeJS;
  37553. var Ref = corePrimitives.Ref;
  37554. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37555. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37556. var WorkerTask = function WorkerTaskClosure() {
  37557. function WorkerTask(name) {
  37558. this.name = name;
  37559. this.terminated = false;
  37560. this._capability = createPromiseCapability();
  37561. }
  37562. WorkerTask.prototype = {
  37563. get finished() {
  37564. return this._capability.promise;
  37565. },
  37566. finish: function () {
  37567. this._capability.resolve();
  37568. },
  37569. terminate: function () {
  37570. this.terminated = true;
  37571. },
  37572. ensureNotTerminated: function () {
  37573. if (this.terminated) {
  37574. throw new Error('Worker task was terminated');
  37575. }
  37576. }
  37577. };
  37578. return WorkerTask;
  37579. }();
  37580. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37581. function PDFWorkerStream(params, msgHandler) {
  37582. this._queuedChunks = [];
  37583. var initialData = params.initialData;
  37584. if (initialData && initialData.length > 0) {
  37585. this._queuedChunks.push(initialData);
  37586. }
  37587. this._msgHandler = msgHandler;
  37588. this._isRangeSupported = !params.disableRange;
  37589. this._isStreamingSupported = !params.disableStream;
  37590. this._contentLength = params.length;
  37591. this._fullRequestReader = null;
  37592. this._rangeReaders = [];
  37593. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37594. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37595. }
  37596. PDFWorkerStream.prototype = {
  37597. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37598. if (args.begin === undefined) {
  37599. if (this._fullRequestReader) {
  37600. this._fullRequestReader._enqueue(args.chunk);
  37601. } else {
  37602. this._queuedChunks.push(args.chunk);
  37603. }
  37604. } else {
  37605. var found = this._rangeReaders.some(function (rangeReader) {
  37606. if (rangeReader._begin !== args.begin) {
  37607. return false;
  37608. }
  37609. rangeReader._enqueue(args.chunk);
  37610. return true;
  37611. });
  37612. assert(found);
  37613. }
  37614. },
  37615. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37616. if (this._rangeReaders.length > 0) {
  37617. var firstReader = this._rangeReaders[0];
  37618. if (firstReader.onProgress) {
  37619. firstReader.onProgress({ loaded: evt.loaded });
  37620. }
  37621. }
  37622. },
  37623. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37624. var i = this._rangeReaders.indexOf(reader);
  37625. if (i >= 0) {
  37626. this._rangeReaders.splice(i, 1);
  37627. }
  37628. },
  37629. getFullReader: function PDFWorkerStream_getFullReader() {
  37630. assert(!this._fullRequestReader);
  37631. var queuedChunks = this._queuedChunks;
  37632. this._queuedChunks = null;
  37633. return new PDFWorkerStreamReader(this, queuedChunks);
  37634. },
  37635. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37636. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37637. this._msgHandler.send('RequestDataRange', {
  37638. begin: begin,
  37639. end: end
  37640. });
  37641. this._rangeReaders.push(reader);
  37642. return reader;
  37643. },
  37644. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37645. if (this._fullRequestReader) {
  37646. this._fullRequestReader.cancel(reason);
  37647. }
  37648. var readers = this._rangeReaders.slice(0);
  37649. readers.forEach(function (rangeReader) {
  37650. rangeReader.cancel(reason);
  37651. });
  37652. }
  37653. };
  37654. function PDFWorkerStreamReader(stream, queuedChunks) {
  37655. this._stream = stream;
  37656. this._done = false;
  37657. this._queuedChunks = queuedChunks || [];
  37658. this._requests = [];
  37659. this._headersReady = Promise.resolve();
  37660. stream._fullRequestReader = this;
  37661. this.onProgress = null;
  37662. }
  37663. PDFWorkerStreamReader.prototype = {
  37664. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37665. if (this._done) {
  37666. return;
  37667. }
  37668. if (this._requests.length > 0) {
  37669. var requestCapability = this._requests.shift();
  37670. requestCapability.resolve({
  37671. value: chunk,
  37672. done: false
  37673. });
  37674. return;
  37675. }
  37676. this._queuedChunks.push(chunk);
  37677. },
  37678. get headersReady() {
  37679. return this._headersReady;
  37680. },
  37681. get isRangeSupported() {
  37682. return this._stream._isRangeSupported;
  37683. },
  37684. get isStreamingSupported() {
  37685. return this._stream._isStreamingSupported;
  37686. },
  37687. get contentLength() {
  37688. return this._stream._contentLength;
  37689. },
  37690. read: function PDFWorkerStreamReader_read() {
  37691. if (this._queuedChunks.length > 0) {
  37692. var chunk = this._queuedChunks.shift();
  37693. return Promise.resolve({
  37694. value: chunk,
  37695. done: false
  37696. });
  37697. }
  37698. if (this._done) {
  37699. return Promise.resolve({
  37700. value: undefined,
  37701. done: true
  37702. });
  37703. }
  37704. var requestCapability = createPromiseCapability();
  37705. this._requests.push(requestCapability);
  37706. return requestCapability.promise;
  37707. },
  37708. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37709. this._done = true;
  37710. this._requests.forEach(function (requestCapability) {
  37711. requestCapability.resolve({
  37712. value: undefined,
  37713. done: true
  37714. });
  37715. });
  37716. this._requests = [];
  37717. }
  37718. };
  37719. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37720. this._stream = stream;
  37721. this._begin = begin;
  37722. this._end = end;
  37723. this._queuedChunk = null;
  37724. this._requests = [];
  37725. this._done = false;
  37726. this.onProgress = null;
  37727. }
  37728. PDFWorkerStreamRangeReader.prototype = {
  37729. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37730. if (this._done) {
  37731. return;
  37732. }
  37733. if (this._requests.length === 0) {
  37734. this._queuedChunk = chunk;
  37735. } else {
  37736. var requestsCapability = this._requests.shift();
  37737. requestsCapability.resolve({
  37738. value: chunk,
  37739. done: false
  37740. });
  37741. this._requests.forEach(function (requestCapability) {
  37742. requestCapability.resolve({
  37743. value: undefined,
  37744. done: true
  37745. });
  37746. });
  37747. this._requests = [];
  37748. }
  37749. this._done = true;
  37750. this._stream._removeRangeReader(this);
  37751. },
  37752. get isStreamingSupported() {
  37753. return false;
  37754. },
  37755. read: function PDFWorkerStreamRangeReader_read() {
  37756. if (this._queuedChunk) {
  37757. return Promise.resolve({
  37758. value: this._queuedChunk,
  37759. done: false
  37760. });
  37761. }
  37762. if (this._done) {
  37763. return Promise.resolve({
  37764. value: undefined,
  37765. done: true
  37766. });
  37767. }
  37768. var requestCapability = createPromiseCapability();
  37769. this._requests.push(requestCapability);
  37770. return requestCapability.promise;
  37771. },
  37772. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37773. this._done = true;
  37774. this._requests.forEach(function (requestCapability) {
  37775. requestCapability.resolve({
  37776. value: undefined,
  37777. done: true
  37778. });
  37779. });
  37780. this._requests = [];
  37781. this._stream._removeRangeReader(this);
  37782. }
  37783. };
  37784. return PDFWorkerStream;
  37785. }();
  37786. var PDFNetworkStream;
  37787. function setPDFNetworkStreamClass(cls) {
  37788. PDFNetworkStream = cls;
  37789. }
  37790. var WorkerMessageHandler = {
  37791. setup: function wphSetup(handler, port) {
  37792. var testMessageProcessed = false;
  37793. handler.on('test', function wphSetupTest(data) {
  37794. if (testMessageProcessed) {
  37795. return;
  37796. }
  37797. testMessageProcessed = true;
  37798. if (!(data instanceof Uint8Array)) {
  37799. handler.send('test', 'main', false);
  37800. return;
  37801. }
  37802. var supportTransfers = data[0] === 255;
  37803. handler.postMessageTransfers = supportTransfers;
  37804. var xhr = new XMLHttpRequest();
  37805. var responseExists = 'response' in xhr;
  37806. try {
  37807. xhr.responseType;
  37808. } catch (e) {
  37809. responseExists = false;
  37810. }
  37811. if (!responseExists) {
  37812. handler.send('test', false);
  37813. return;
  37814. }
  37815. handler.send('test', {
  37816. supportTypedArray: true,
  37817. supportTransfers: supportTransfers
  37818. });
  37819. });
  37820. handler.on('configure', function wphConfigure(data) {
  37821. setVerbosityLevel(data.verbosity);
  37822. });
  37823. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37824. return WorkerMessageHandler.createDocumentHandler(data, port);
  37825. });
  37826. },
  37827. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37828. var pdfManager;
  37829. var terminated = false;
  37830. var cancelXHRs = null;
  37831. var WorkerTasks = [];
  37832. var docId = docParams.docId;
  37833. var docBaseUrl = docParams.docBaseUrl;
  37834. var workerHandlerName = docParams.docId + '_worker';
  37835. var handler = new MessageHandler(workerHandlerName, docId, port);
  37836. handler.postMessageTransfers = docParams.postMessageTransfers;
  37837. function ensureNotTerminated() {
  37838. if (terminated) {
  37839. throw new Error('Worker was terminated');
  37840. }
  37841. }
  37842. function startWorkerTask(task) {
  37843. WorkerTasks.push(task);
  37844. }
  37845. function finishWorkerTask(task) {
  37846. task.finish();
  37847. var i = WorkerTasks.indexOf(task);
  37848. WorkerTasks.splice(i, 1);
  37849. }
  37850. function loadDocument(recoveryMode) {
  37851. var loadDocumentCapability = createPromiseCapability();
  37852. var parseSuccess = function parseSuccess() {
  37853. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37854. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37855. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37856. Promise.all([
  37857. numPagesPromise,
  37858. fingerprintPromise,
  37859. encryptedPromise
  37860. ]).then(function onDocReady(results) {
  37861. var doc = {
  37862. numPages: results[0],
  37863. fingerprint: results[1],
  37864. encrypted: !!results[2]
  37865. };
  37866. loadDocumentCapability.resolve(doc);
  37867. }, parseFailure);
  37868. };
  37869. var parseFailure = function parseFailure(e) {
  37870. loadDocumentCapability.reject(e);
  37871. };
  37872. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37873. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37874. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37875. }, parseFailure);
  37876. }, parseFailure);
  37877. return loadDocumentCapability.promise;
  37878. }
  37879. function getPdfManager(data, evaluatorOptions) {
  37880. var pdfManagerCapability = createPromiseCapability();
  37881. var pdfManager;
  37882. var source = data.source;
  37883. if (source.data) {
  37884. try {
  37885. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37886. pdfManagerCapability.resolve(pdfManager);
  37887. } catch (ex) {
  37888. pdfManagerCapability.reject(ex);
  37889. }
  37890. return pdfManagerCapability.promise;
  37891. }
  37892. var pdfStream;
  37893. try {
  37894. if (source.chunkedViewerLoading) {
  37895. pdfStream = new PDFWorkerStream(source, handler);
  37896. } else {
  37897. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37898. pdfStream = new PDFNetworkStream(data);
  37899. }
  37900. } catch (ex) {
  37901. pdfManagerCapability.reject(ex);
  37902. return pdfManagerCapability.promise;
  37903. }
  37904. var fullRequest = pdfStream.getFullReader();
  37905. fullRequest.headersReady.then(function () {
  37906. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37907. fullRequest.onProgress = function (evt) {
  37908. handler.send('DocProgress', {
  37909. loaded: evt.loaded,
  37910. total: evt.total
  37911. });
  37912. };
  37913. }
  37914. if (!fullRequest.isRangeSupported) {
  37915. return;
  37916. }
  37917. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37918. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37919. msgHandler: handler,
  37920. url: source.url,
  37921. password: source.password,
  37922. length: fullRequest.contentLength,
  37923. disableAutoFetch: disableAutoFetch,
  37924. rangeChunkSize: source.rangeChunkSize
  37925. }, evaluatorOptions, docBaseUrl);
  37926. pdfManagerCapability.resolve(pdfManager);
  37927. cancelXHRs = null;
  37928. }).catch(function (reason) {
  37929. pdfManagerCapability.reject(reason);
  37930. cancelXHRs = null;
  37931. });
  37932. var cachedChunks = [], loaded = 0;
  37933. var flushChunks = function () {
  37934. var pdfFile = arraysToBytes(cachedChunks);
  37935. if (source.length && pdfFile.length !== source.length) {
  37936. warn('reported HTTP length is different from actual');
  37937. }
  37938. try {
  37939. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37940. pdfManagerCapability.resolve(pdfManager);
  37941. } catch (ex) {
  37942. pdfManagerCapability.reject(ex);
  37943. }
  37944. cachedChunks = [];
  37945. };
  37946. var readPromise = new Promise(function (resolve, reject) {
  37947. var readChunk = function (chunk) {
  37948. try {
  37949. ensureNotTerminated();
  37950. if (chunk.done) {
  37951. if (!pdfManager) {
  37952. flushChunks();
  37953. }
  37954. cancelXHRs = null;
  37955. return;
  37956. }
  37957. var data = chunk.value;
  37958. loaded += arrayByteLength(data);
  37959. if (!fullRequest.isStreamingSupported) {
  37960. handler.send('DocProgress', {
  37961. loaded: loaded,
  37962. total: Math.max(loaded, fullRequest.contentLength || 0)
  37963. });
  37964. }
  37965. if (pdfManager) {
  37966. pdfManager.sendProgressiveData(data);
  37967. } else {
  37968. cachedChunks.push(data);
  37969. }
  37970. fullRequest.read().then(readChunk, reject);
  37971. } catch (e) {
  37972. reject(e);
  37973. }
  37974. };
  37975. fullRequest.read().then(readChunk, reject);
  37976. });
  37977. readPromise.catch(function (e) {
  37978. pdfManagerCapability.reject(e);
  37979. cancelXHRs = null;
  37980. });
  37981. cancelXHRs = function () {
  37982. pdfStream.cancelAllRequests('abort');
  37983. };
  37984. return pdfManagerCapability.promise;
  37985. }
  37986. function setupDoc(data) {
  37987. function onSuccess(doc) {
  37988. ensureNotTerminated();
  37989. handler.send('GetDoc', { pdfInfo: doc });
  37990. }
  37991. function onFailure(e) {
  37992. if (e instanceof PasswordException) {
  37993. var task = new WorkerTask('PasswordException: response ' + e.code);
  37994. startWorkerTask(task);
  37995. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  37996. finishWorkerTask(task);
  37997. pdfManager.updatePassword(data.password);
  37998. pdfManagerReady();
  37999. }).catch(function (ex) {
  38000. finishWorkerTask(task);
  38001. handler.send('PasswordException', ex);
  38002. }.bind(null, e));
  38003. } else if (e instanceof InvalidPDFException) {
  38004. handler.send('InvalidPDF', e);
  38005. } else if (e instanceof MissingPDFException) {
  38006. handler.send('MissingPDF', e);
  38007. } else if (e instanceof UnexpectedResponseException) {
  38008. handler.send('UnexpectedResponse', e);
  38009. } else {
  38010. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38011. }
  38012. }
  38013. function pdfManagerReady() {
  38014. ensureNotTerminated();
  38015. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38016. ensureNotTerminated();
  38017. if (!(ex instanceof XRefParseException)) {
  38018. onFailure(ex);
  38019. return;
  38020. }
  38021. pdfManager.requestLoadedStream();
  38022. pdfManager.onLoadedStream().then(function () {
  38023. ensureNotTerminated();
  38024. loadDocument(true).then(onSuccess, onFailure);
  38025. });
  38026. }, onFailure);
  38027. }
  38028. ensureNotTerminated();
  38029. var evaluatorOptions = {
  38030. forceDataSchema: data.disableCreateObjectURL,
  38031. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38032. disableFontFace: data.disableFontFace,
  38033. disableNativeImageDecoder: data.disableNativeImageDecoder
  38034. };
  38035. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38036. if (terminated) {
  38037. newPdfManager.terminate();
  38038. throw new Error('Worker was terminated');
  38039. }
  38040. pdfManager = newPdfManager;
  38041. handler.send('PDFManagerReady', null);
  38042. pdfManager.onLoadedStream().then(function (stream) {
  38043. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38044. });
  38045. }).then(pdfManagerReady, onFailure);
  38046. }
  38047. handler.on('GetPage', function wphSetupGetPage(data) {
  38048. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38049. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38050. var refPromise = pdfManager.ensure(page, 'ref');
  38051. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38052. var viewPromise = pdfManager.ensure(page, 'view');
  38053. return Promise.all([
  38054. rotatePromise,
  38055. refPromise,
  38056. userUnitPromise,
  38057. viewPromise
  38058. ]).then(function (results) {
  38059. return {
  38060. rotate: results[0],
  38061. ref: results[1],
  38062. userUnit: results[2],
  38063. view: results[3]
  38064. };
  38065. });
  38066. });
  38067. });
  38068. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38069. var ref = new Ref(data.ref.num, data.ref.gen);
  38070. var catalog = pdfManager.pdfDocument.catalog;
  38071. return catalog.getPageIndex(ref);
  38072. });
  38073. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38074. return pdfManager.ensureCatalog('destinations');
  38075. });
  38076. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38077. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38078. });
  38079. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38080. return pdfManager.ensureCatalog('pageLabels');
  38081. });
  38082. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38083. return pdfManager.ensureCatalog('attachments');
  38084. });
  38085. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38086. return pdfManager.ensureCatalog('javaScript');
  38087. });
  38088. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38089. return pdfManager.ensureCatalog('documentOutline');
  38090. });
  38091. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38092. return Promise.all([
  38093. pdfManager.ensureDoc('documentInfo'),
  38094. pdfManager.ensureCatalog('metadata')
  38095. ]);
  38096. });
  38097. handler.on('GetData', function wphSetupGetData(data) {
  38098. pdfManager.requestLoadedStream();
  38099. return pdfManager.onLoadedStream().then(function (stream) {
  38100. return stream.bytes;
  38101. });
  38102. });
  38103. handler.on('GetStats', function wphSetupGetStats(data) {
  38104. return pdfManager.pdfDocument.xref.stats;
  38105. });
  38106. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38107. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38108. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38109. });
  38110. });
  38111. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38112. var pageIndex = data.pageIndex;
  38113. pdfManager.getPage(pageIndex).then(function (page) {
  38114. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38115. startWorkerTask(task);
  38116. var pageNum = pageIndex + 1;
  38117. var start = Date.now();
  38118. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38119. finishWorkerTask(task);
  38120. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38121. }, function (e) {
  38122. finishWorkerTask(task);
  38123. if (task.terminated) {
  38124. return;
  38125. }
  38126. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38127. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38128. var wrappedException;
  38129. if (typeof e === 'string') {
  38130. wrappedException = {
  38131. message: e,
  38132. stack: minimumStackMessage
  38133. };
  38134. } else if (typeof e === 'object') {
  38135. wrappedException = {
  38136. message: e.message || e.toString(),
  38137. stack: e.stack || minimumStackMessage
  38138. };
  38139. } else {
  38140. wrappedException = {
  38141. message: 'Unknown exception type: ' + typeof e,
  38142. stack: minimumStackMessage
  38143. };
  38144. }
  38145. handler.send('PageError', {
  38146. pageNum: pageNum,
  38147. error: wrappedException,
  38148. intent: data.intent
  38149. });
  38150. });
  38151. });
  38152. }, this);
  38153. handler.on('GetTextContent', function wphExtractText(data) {
  38154. var pageIndex = data.pageIndex;
  38155. var normalizeWhitespace = data.normalizeWhitespace;
  38156. var combineTextItems = data.combineTextItems;
  38157. return pdfManager.getPage(pageIndex).then(function (page) {
  38158. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38159. startWorkerTask(task);
  38160. var pageNum = pageIndex + 1;
  38161. var start = Date.now();
  38162. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38163. finishWorkerTask(task);
  38164. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38165. return textContent;
  38166. }, function (reason) {
  38167. finishWorkerTask(task);
  38168. if (task.terminated) {
  38169. return;
  38170. }
  38171. throw reason;
  38172. });
  38173. });
  38174. });
  38175. handler.on('Cleanup', function wphCleanup(data) {
  38176. return pdfManager.cleanup();
  38177. });
  38178. handler.on('Terminate', function wphTerminate(data) {
  38179. terminated = true;
  38180. if (pdfManager) {
  38181. pdfManager.terminate();
  38182. pdfManager = null;
  38183. }
  38184. if (cancelXHRs) {
  38185. cancelXHRs();
  38186. }
  38187. var waitOn = [];
  38188. WorkerTasks.forEach(function (task) {
  38189. waitOn.push(task.finished);
  38190. task.terminate();
  38191. });
  38192. return Promise.all(waitOn).then(function () {
  38193. handler.destroy();
  38194. handler = null;
  38195. });
  38196. });
  38197. handler.on('Ready', function wphReady(data) {
  38198. setupDoc(docParams);
  38199. docParams = null;
  38200. });
  38201. return workerHandlerName;
  38202. }
  38203. };
  38204. function initializeWorker() {
  38205. var handler = new MessageHandler('worker', 'main', self);
  38206. WorkerMessageHandler.setup(handler, self);
  38207. handler.send('ready', null);
  38208. }
  38209. if (typeof window === 'undefined' && !isNodeJS()) {
  38210. initializeWorker();
  38211. }
  38212. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38213. exports.WorkerTask = WorkerTask;
  38214. exports.WorkerMessageHandler = WorkerMessageHandler;
  38215. /***/ }),
  38216. /* 24 */
  38217. /***/ (function(module, exports, __w_pdfjs_require__) {
  38218. "use strict";
  38219. var sharedUtil = __w_pdfjs_require__(0);
  38220. var error = sharedUtil.error;
  38221. function fixMetadata(meta) {
  38222. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38223. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38224. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38225. });
  38226. var chars = '';
  38227. for (var i = 0; i < bytes.length; i += 2) {
  38228. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38229. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38230. }
  38231. return '>' + chars;
  38232. });
  38233. }
  38234. function Metadata(meta) {
  38235. if (typeof meta === 'string') {
  38236. meta = fixMetadata(meta);
  38237. var parser = new DOMParser();
  38238. meta = parser.parseFromString(meta, 'application/xml');
  38239. } else if (!(meta instanceof Document)) {
  38240. error('Metadata: Invalid metadata object');
  38241. }
  38242. this.metaDocument = meta;
  38243. this.metadata = Object.create(null);
  38244. this.parse();
  38245. }
  38246. Metadata.prototype = {
  38247. parse: function Metadata_parse() {
  38248. var doc = this.metaDocument;
  38249. var rdf = doc.documentElement;
  38250. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38251. rdf = rdf.firstChild;
  38252. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38253. rdf = rdf.nextSibling;
  38254. }
  38255. }
  38256. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38257. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38258. return;
  38259. }
  38260. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38261. for (i = 0, length = children.length; i < length; i++) {
  38262. desc = children[i];
  38263. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38264. continue;
  38265. }
  38266. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38267. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38268. entry = desc.childNodes[ii];
  38269. name = entry.nodeName.toLowerCase();
  38270. this.metadata[name] = entry.textContent.trim();
  38271. }
  38272. }
  38273. }
  38274. },
  38275. get: function Metadata_get(name) {
  38276. return this.metadata[name] || null;
  38277. },
  38278. has: function Metadata_has(name) {
  38279. return typeof this.metadata[name] !== 'undefined';
  38280. }
  38281. };
  38282. exports.Metadata = Metadata;
  38283. /***/ }),
  38284. /* 25 */
  38285. /***/ (function(module, exports, __w_pdfjs_require__) {
  38286. "use strict";
  38287. var sharedUtil = __w_pdfjs_require__(0);
  38288. var displayDOMUtils = __w_pdfjs_require__(3);
  38289. var shadow = sharedUtil.shadow;
  38290. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38291. var WebGLUtils = function WebGLUtilsClosure() {
  38292. function loadShader(gl, code, shaderType) {
  38293. var shader = gl.createShader(shaderType);
  38294. gl.shaderSource(shader, code);
  38295. gl.compileShader(shader);
  38296. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38297. if (!compiled) {
  38298. var errorMsg = gl.getShaderInfoLog(shader);
  38299. throw new Error('Error during shader compilation: ' + errorMsg);
  38300. }
  38301. return shader;
  38302. }
  38303. function createVertexShader(gl, code) {
  38304. return loadShader(gl, code, gl.VERTEX_SHADER);
  38305. }
  38306. function createFragmentShader(gl, code) {
  38307. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38308. }
  38309. function createProgram(gl, shaders) {
  38310. var program = gl.createProgram();
  38311. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38312. gl.attachShader(program, shaders[i]);
  38313. }
  38314. gl.linkProgram(program);
  38315. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38316. if (!linked) {
  38317. var errorMsg = gl.getProgramInfoLog(program);
  38318. throw new Error('Error during program linking: ' + errorMsg);
  38319. }
  38320. return program;
  38321. }
  38322. function createTexture(gl, image, textureId) {
  38323. gl.activeTexture(textureId);
  38324. var texture = gl.createTexture();
  38325. gl.bindTexture(gl.TEXTURE_2D, texture);
  38326. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38327. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38328. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38329. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38330. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38331. return texture;
  38332. }
  38333. var currentGL, currentCanvas;
  38334. function generateGL() {
  38335. if (currentGL) {
  38336. return;
  38337. }
  38338. currentCanvas = document.createElement('canvas');
  38339. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38340. }
  38341. var smaskVertexShaderCode = '\
  38342. attribute vec2 a_position; \
  38343. attribute vec2 a_texCoord; \
  38344. \
  38345. uniform vec2 u_resolution; \
  38346. \
  38347. varying vec2 v_texCoord; \
  38348. \
  38349. void main() { \
  38350. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38351. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38352. \
  38353. v_texCoord = a_texCoord; \
  38354. } ';
  38355. var smaskFragmentShaderCode = '\
  38356. precision mediump float; \
  38357. \
  38358. uniform vec4 u_backdrop; \
  38359. uniform int u_subtype; \
  38360. uniform sampler2D u_image; \
  38361. uniform sampler2D u_mask; \
  38362. \
  38363. varying vec2 v_texCoord; \
  38364. \
  38365. void main() { \
  38366. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38367. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38368. if (u_backdrop.a > 0.0) { \
  38369. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38370. u_backdrop.rgb * (1.0 - maskColor.a); \
  38371. } \
  38372. float lum; \
  38373. if (u_subtype == 0) { \
  38374. lum = maskColor.a; \
  38375. } else { \
  38376. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38377. maskColor.b * 0.11; \
  38378. } \
  38379. imageColor.a *= lum; \
  38380. imageColor.rgb *= imageColor.a; \
  38381. gl_FragColor = imageColor; \
  38382. } ';
  38383. var smaskCache = null;
  38384. function initSmaskGL() {
  38385. var canvas, gl;
  38386. generateGL();
  38387. canvas = currentCanvas;
  38388. currentCanvas = null;
  38389. gl = currentGL;
  38390. currentGL = null;
  38391. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38392. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38393. var program = createProgram(gl, [
  38394. vertexShader,
  38395. fragmentShader
  38396. ]);
  38397. gl.useProgram(program);
  38398. var cache = {};
  38399. cache.gl = gl;
  38400. cache.canvas = canvas;
  38401. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38402. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38403. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38404. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38405. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38406. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38407. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38408. var texCoordBuffer = gl.createBuffer();
  38409. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38410. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38411. 0.0,
  38412. 0.0,
  38413. 1.0,
  38414. 0.0,
  38415. 0.0,
  38416. 1.0,
  38417. 0.0,
  38418. 1.0,
  38419. 1.0,
  38420. 0.0,
  38421. 1.0,
  38422. 1.0
  38423. ]), gl.STATIC_DRAW);
  38424. gl.enableVertexAttribArray(texCoordLocation);
  38425. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38426. gl.uniform1i(texLayerLocation, 0);
  38427. gl.uniform1i(texMaskLocation, 1);
  38428. smaskCache = cache;
  38429. }
  38430. function composeSMask(layer, mask, properties) {
  38431. var width = layer.width, height = layer.height;
  38432. if (!smaskCache) {
  38433. initSmaskGL();
  38434. }
  38435. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38436. canvas.width = width;
  38437. canvas.height = height;
  38438. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38439. gl.uniform2f(cache.resolutionLocation, width, height);
  38440. if (properties.backdrop) {
  38441. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38442. } else {
  38443. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38444. }
  38445. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38446. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38447. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38448. var buffer = gl.createBuffer();
  38449. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38450. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38451. 0,
  38452. 0,
  38453. width,
  38454. 0,
  38455. 0,
  38456. height,
  38457. 0,
  38458. height,
  38459. width,
  38460. 0,
  38461. width,
  38462. height
  38463. ]), gl.STATIC_DRAW);
  38464. gl.enableVertexAttribArray(cache.positionLocation);
  38465. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38466. gl.clearColor(0, 0, 0, 0);
  38467. gl.enable(gl.BLEND);
  38468. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38469. gl.clear(gl.COLOR_BUFFER_BIT);
  38470. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38471. gl.flush();
  38472. gl.deleteTexture(texture);
  38473. gl.deleteTexture(maskTexture);
  38474. gl.deleteBuffer(buffer);
  38475. return canvas;
  38476. }
  38477. var figuresVertexShaderCode = '\
  38478. attribute vec2 a_position; \
  38479. attribute vec3 a_color; \
  38480. \
  38481. uniform vec2 u_resolution; \
  38482. uniform vec2 u_scale; \
  38483. uniform vec2 u_offset; \
  38484. \
  38485. varying vec4 v_color; \
  38486. \
  38487. void main() { \
  38488. vec2 position = (a_position + u_offset) * u_scale; \
  38489. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38490. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38491. \
  38492. v_color = vec4(a_color / 255.0, 1.0); \
  38493. } ';
  38494. var figuresFragmentShaderCode = '\
  38495. precision mediump float; \
  38496. \
  38497. varying vec4 v_color; \
  38498. \
  38499. void main() { \
  38500. gl_FragColor = v_color; \
  38501. } ';
  38502. var figuresCache = null;
  38503. function initFiguresGL() {
  38504. var canvas, gl;
  38505. generateGL();
  38506. canvas = currentCanvas;
  38507. currentCanvas = null;
  38508. gl = currentGL;
  38509. currentGL = null;
  38510. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38511. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38512. var program = createProgram(gl, [
  38513. vertexShader,
  38514. fragmentShader
  38515. ]);
  38516. gl.useProgram(program);
  38517. var cache = {};
  38518. cache.gl = gl;
  38519. cache.canvas = canvas;
  38520. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38521. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38522. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38523. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38524. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38525. figuresCache = cache;
  38526. }
  38527. function drawFigures(width, height, backgroundColor, figures, context) {
  38528. if (!figuresCache) {
  38529. initFiguresGL();
  38530. }
  38531. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38532. canvas.width = width;
  38533. canvas.height = height;
  38534. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38535. gl.uniform2f(cache.resolutionLocation, width, height);
  38536. var count = 0;
  38537. var i, ii, rows;
  38538. for (i = 0, ii = figures.length; i < ii; i++) {
  38539. switch (figures[i].type) {
  38540. case 'lattice':
  38541. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38542. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38543. break;
  38544. case 'triangles':
  38545. count += figures[i].coords.length;
  38546. break;
  38547. }
  38548. }
  38549. var coords = new Float32Array(count * 2);
  38550. var colors = new Uint8Array(count * 3);
  38551. var coordsMap = context.coords, colorsMap = context.colors;
  38552. var pIndex = 0, cIndex = 0;
  38553. for (i = 0, ii = figures.length; i < ii; i++) {
  38554. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38555. switch (figure.type) {
  38556. case 'lattice':
  38557. var cols = figure.verticesPerRow;
  38558. rows = ps.length / cols | 0;
  38559. for (var row = 1; row < rows; row++) {
  38560. var offset = row * cols + 1;
  38561. for (var col = 1; col < cols; col++, offset++) {
  38562. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38563. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38564. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38565. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38566. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38567. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38568. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38569. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38570. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38571. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38572. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38573. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38574. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38575. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38576. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38577. coords[pIndex + 6] = coords[pIndex + 2];
  38578. coords[pIndex + 7] = coords[pIndex + 3];
  38579. coords[pIndex + 8] = coords[pIndex + 4];
  38580. coords[pIndex + 9] = coords[pIndex + 5];
  38581. coords[pIndex + 10] = coordsMap[ps[offset]];
  38582. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38583. colors[cIndex + 9] = colors[cIndex + 3];
  38584. colors[cIndex + 10] = colors[cIndex + 4];
  38585. colors[cIndex + 11] = colors[cIndex + 5];
  38586. colors[cIndex + 12] = colors[cIndex + 6];
  38587. colors[cIndex + 13] = colors[cIndex + 7];
  38588. colors[cIndex + 14] = colors[cIndex + 8];
  38589. colors[cIndex + 15] = colorsMap[cs[offset]];
  38590. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38591. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38592. pIndex += 12;
  38593. cIndex += 18;
  38594. }
  38595. }
  38596. break;
  38597. case 'triangles':
  38598. for (var j = 0, jj = ps.length; j < jj; j++) {
  38599. coords[pIndex] = coordsMap[ps[j]];
  38600. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38601. colors[cIndex] = colorsMap[cs[j]];
  38602. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38603. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38604. pIndex += 2;
  38605. cIndex += 3;
  38606. }
  38607. break;
  38608. }
  38609. }
  38610. if (backgroundColor) {
  38611. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38612. } else {
  38613. gl.clearColor(0, 0, 0, 0);
  38614. }
  38615. gl.clear(gl.COLOR_BUFFER_BIT);
  38616. var coordsBuffer = gl.createBuffer();
  38617. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38618. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38619. gl.enableVertexAttribArray(cache.positionLocation);
  38620. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38621. var colorsBuffer = gl.createBuffer();
  38622. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38623. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38624. gl.enableVertexAttribArray(cache.colorLocation);
  38625. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38626. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38627. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38628. gl.drawArrays(gl.TRIANGLES, 0, count);
  38629. gl.flush();
  38630. gl.deleteBuffer(coordsBuffer);
  38631. gl.deleteBuffer(colorsBuffer);
  38632. return canvas;
  38633. }
  38634. function cleanup() {
  38635. if (smaskCache && smaskCache.canvas) {
  38636. smaskCache.canvas.width = 0;
  38637. smaskCache.canvas.height = 0;
  38638. }
  38639. if (figuresCache && figuresCache.canvas) {
  38640. figuresCache.canvas.width = 0;
  38641. figuresCache.canvas.height = 0;
  38642. }
  38643. smaskCache = null;
  38644. figuresCache = null;
  38645. }
  38646. return {
  38647. get isEnabled() {
  38648. if (getDefaultSetting('disableWebGL')) {
  38649. return false;
  38650. }
  38651. var enabled = false;
  38652. try {
  38653. generateGL();
  38654. enabled = !!currentGL;
  38655. } catch (e) {
  38656. }
  38657. return shadow(this, 'isEnabled', enabled);
  38658. },
  38659. composeSMask: composeSMask,
  38660. drawFigures: drawFigures,
  38661. clear: cleanup
  38662. };
  38663. }();
  38664. exports.WebGLUtils = WebGLUtils;
  38665. /***/ }),
  38666. /* 26 */
  38667. /***/ (function(module, exports, __w_pdfjs_require__) {
  38668. "use strict";
  38669. var sharedUtil = __w_pdfjs_require__(0);
  38670. var displayDOMUtils = __w_pdfjs_require__(3);
  38671. var displayAPI = __w_pdfjs_require__(10);
  38672. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38673. var displayTextLayer = __w_pdfjs_require__(12);
  38674. var displayMetadata = __w_pdfjs_require__(24);
  38675. var displaySVG = __w_pdfjs_require__(11);
  38676. var globalScope = sharedUtil.globalScope;
  38677. var deprecated = sharedUtil.deprecated;
  38678. var warn = sharedUtil.warn;
  38679. var LinkTarget = displayDOMUtils.LinkTarget;
  38680. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38681. var isWorker = typeof window === 'undefined';
  38682. if (!globalScope.PDFJS) {
  38683. globalScope.PDFJS = {};
  38684. }
  38685. var PDFJS = globalScope.PDFJS;
  38686. PDFJS.version = '1.7.344';
  38687. PDFJS.build = 'c2905614';
  38688. PDFJS.pdfBug = false;
  38689. if (PDFJS.verbosity !== undefined) {
  38690. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38691. }
  38692. delete PDFJS.verbosity;
  38693. Object.defineProperty(PDFJS, 'verbosity', {
  38694. get: function () {
  38695. return sharedUtil.getVerbosityLevel();
  38696. },
  38697. set: function (level) {
  38698. sharedUtil.setVerbosityLevel(level);
  38699. },
  38700. enumerable: true,
  38701. configurable: true
  38702. });
  38703. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38704. PDFJS.OPS = sharedUtil.OPS;
  38705. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38706. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38707. PDFJS.shadow = sharedUtil.shadow;
  38708. PDFJS.createBlob = sharedUtil.createBlob;
  38709. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38710. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38711. };
  38712. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38713. configurable: true,
  38714. get: function PDFJS_isLittleEndian() {
  38715. var value = sharedUtil.isLittleEndian();
  38716. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38717. }
  38718. });
  38719. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38720. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38721. PDFJS.PasswordException = sharedUtil.PasswordException;
  38722. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38723. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38724. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38725. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38726. PDFJS.Util = sharedUtil.Util;
  38727. PDFJS.PageViewport = sharedUtil.PageViewport;
  38728. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38729. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38730. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38731. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38732. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38733. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38734. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38735. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38736. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  38737. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38738. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38739. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38740. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38741. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38742. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38743. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38744. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38745. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38746. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38747. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38748. delete PDFJS.openExternalLinksInNewWindow;
  38749. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38750. get: function () {
  38751. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38752. },
  38753. set: function (value) {
  38754. if (value) {
  38755. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38756. }
  38757. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38758. warn('PDFJS.externalLinkTarget is already initialized');
  38759. return;
  38760. }
  38761. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38762. },
  38763. enumerable: true,
  38764. configurable: true
  38765. });
  38766. if (savedOpenExternalLinksInNewWindow) {
  38767. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38768. }
  38769. PDFJS.getDocument = displayAPI.getDocument;
  38770. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38771. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38772. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38773. configurable: true,
  38774. get: function PDFJS_hasCanvasTypedArrays() {
  38775. var value = displayDOMUtils.hasCanvasTypedArrays();
  38776. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38777. }
  38778. });
  38779. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38780. PDFJS.LinkTarget = LinkTarget;
  38781. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38782. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38783. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38784. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38785. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38786. PDFJS.Metadata = displayMetadata.Metadata;
  38787. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38788. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38789. exports.globalScope = globalScope;
  38790. exports.isWorker = isWorker;
  38791. exports.PDFJS = globalScope.PDFJS;
  38792. /***/ }),
  38793. /* 27 */
  38794. /***/ (function(module, exports, __w_pdfjs_require__) {
  38795. "use strict";
  38796. var sharedUtil = __w_pdfjs_require__(0);
  38797. var corePrimitives = __w_pdfjs_require__(1);
  38798. var coreStream = __w_pdfjs_require__(2);
  38799. var coreColorSpace = __w_pdfjs_require__(4);
  38800. var coreObj = __w_pdfjs_require__(20);
  38801. var coreEvaluator = __w_pdfjs_require__(18);
  38802. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38803. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38804. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38805. var AnnotationType = sharedUtil.AnnotationType;
  38806. var OPS = sharedUtil.OPS;
  38807. var Util = sharedUtil.Util;
  38808. var isArray = sharedUtil.isArray;
  38809. var isInt = sharedUtil.isInt;
  38810. var stringToBytes = sharedUtil.stringToBytes;
  38811. var stringToPDFString = sharedUtil.stringToPDFString;
  38812. var warn = sharedUtil.warn;
  38813. var Dict = corePrimitives.Dict;
  38814. var isDict = corePrimitives.isDict;
  38815. var isName = corePrimitives.isName;
  38816. var isRef = corePrimitives.isRef;
  38817. var isStream = corePrimitives.isStream;
  38818. var Stream = coreStream.Stream;
  38819. var ColorSpace = coreColorSpace.ColorSpace;
  38820. var Catalog = coreObj.Catalog;
  38821. var ObjectLoader = coreObj.ObjectLoader;
  38822. var FileSpec = coreObj.FileSpec;
  38823. var OperatorList = coreEvaluator.OperatorList;
  38824. function AnnotationFactory() {
  38825. }
  38826. AnnotationFactory.prototype = {
  38827. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38828. var dict = xref.fetchIfRef(ref);
  38829. if (!isDict(dict)) {
  38830. return;
  38831. }
  38832. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38833. var subtype = dict.get('Subtype');
  38834. subtype = isName(subtype) ? subtype.name : null;
  38835. var parameters = {
  38836. xref: xref,
  38837. dict: dict,
  38838. ref: isRef(ref) ? ref : null,
  38839. subtype: subtype,
  38840. id: id,
  38841. pdfManager: pdfManager
  38842. };
  38843. switch (subtype) {
  38844. case 'Link':
  38845. return new LinkAnnotation(parameters);
  38846. case 'Text':
  38847. return new TextAnnotation(parameters);
  38848. case 'Widget':
  38849. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38850. fieldType = isName(fieldType) ? fieldType.name : null;
  38851. switch (fieldType) {
  38852. case 'Tx':
  38853. return new TextWidgetAnnotation(parameters);
  38854. case 'Btn':
  38855. return new ButtonWidgetAnnotation(parameters);
  38856. case 'Ch':
  38857. return new ChoiceWidgetAnnotation(parameters);
  38858. }
  38859. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38860. return new WidgetAnnotation(parameters);
  38861. case 'Popup':
  38862. return new PopupAnnotation(parameters);
  38863. case 'Highlight':
  38864. return new HighlightAnnotation(parameters);
  38865. case 'Underline':
  38866. return new UnderlineAnnotation(parameters);
  38867. case 'Squiggly':
  38868. return new SquigglyAnnotation(parameters);
  38869. case 'StrikeOut':
  38870. return new StrikeOutAnnotation(parameters);
  38871. case 'FileAttachment':
  38872. return new FileAttachmentAnnotation(parameters);
  38873. default:
  38874. if (!subtype) {
  38875. warn('Annotation is missing the required /Subtype.');
  38876. } else {
  38877. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38878. }
  38879. return new Annotation(parameters);
  38880. }
  38881. }
  38882. };
  38883. var Annotation = function AnnotationClosure() {
  38884. function getTransformMatrix(rect, bbox, matrix) {
  38885. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38886. var minX = bounds[0];
  38887. var minY = bounds[1];
  38888. var maxX = bounds[2];
  38889. var maxY = bounds[3];
  38890. if (minX === maxX || minY === maxY) {
  38891. return [
  38892. 1,
  38893. 0,
  38894. 0,
  38895. 1,
  38896. rect[0],
  38897. rect[1]
  38898. ];
  38899. }
  38900. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38901. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38902. return [
  38903. xRatio,
  38904. 0,
  38905. 0,
  38906. yRatio,
  38907. rect[0] - minX * xRatio,
  38908. rect[1] - minY * yRatio
  38909. ];
  38910. }
  38911. function Annotation(params) {
  38912. var dict = params.dict;
  38913. this.setFlags(dict.get('F'));
  38914. this.setRectangle(dict.getArray('Rect'));
  38915. this.setColor(dict.getArray('C'));
  38916. this.setBorderStyle(dict);
  38917. this.setAppearance(dict);
  38918. this.data = {};
  38919. this.data.id = params.id;
  38920. this.data.subtype = params.subtype;
  38921. this.data.annotationFlags = this.flags;
  38922. this.data.rect = this.rectangle;
  38923. this.data.color = this.color;
  38924. this.data.borderStyle = this.borderStyle;
  38925. this.data.hasAppearance = !!this.appearance;
  38926. }
  38927. Annotation.prototype = {
  38928. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38929. return !!(flags & flag);
  38930. },
  38931. _isViewable: function Annotation_isViewable(flags) {
  38932. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38933. },
  38934. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38935. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38936. },
  38937. get viewable() {
  38938. if (this.flags === 0) {
  38939. return true;
  38940. }
  38941. return this._isViewable(this.flags);
  38942. },
  38943. get printable() {
  38944. if (this.flags === 0) {
  38945. return false;
  38946. }
  38947. return this._isPrintable(this.flags);
  38948. },
  38949. setFlags: function Annotation_setFlags(flags) {
  38950. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38951. },
  38952. hasFlag: function Annotation_hasFlag(flag) {
  38953. return this._hasFlag(this.flags, flag);
  38954. },
  38955. setRectangle: function Annotation_setRectangle(rectangle) {
  38956. if (isArray(rectangle) && rectangle.length === 4) {
  38957. this.rectangle = Util.normalizeRect(rectangle);
  38958. } else {
  38959. this.rectangle = [
  38960. 0,
  38961. 0,
  38962. 0,
  38963. 0
  38964. ];
  38965. }
  38966. },
  38967. setColor: function Annotation_setColor(color) {
  38968. var rgbColor = new Uint8Array(3);
  38969. if (!isArray(color)) {
  38970. this.color = rgbColor;
  38971. return;
  38972. }
  38973. switch (color.length) {
  38974. case 0:
  38975. this.color = null;
  38976. break;
  38977. case 1:
  38978. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38979. this.color = rgbColor;
  38980. break;
  38981. case 3:
  38982. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38983. this.color = rgbColor;
  38984. break;
  38985. case 4:
  38986. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  38987. this.color = rgbColor;
  38988. break;
  38989. default:
  38990. this.color = rgbColor;
  38991. break;
  38992. }
  38993. },
  38994. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  38995. this.borderStyle = new AnnotationBorderStyle();
  38996. if (!isDict(borderStyle)) {
  38997. return;
  38998. }
  38999. if (borderStyle.has('BS')) {
  39000. var dict = borderStyle.get('BS');
  39001. var dictType = dict.get('Type');
  39002. if (!dictType || isName(dictType, 'Border')) {
  39003. this.borderStyle.setWidth(dict.get('W'));
  39004. this.borderStyle.setStyle(dict.get('S'));
  39005. this.borderStyle.setDashArray(dict.getArray('D'));
  39006. }
  39007. } else if (borderStyle.has('Border')) {
  39008. var array = borderStyle.getArray('Border');
  39009. if (isArray(array) && array.length >= 3) {
  39010. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39011. this.borderStyle.setVerticalCornerRadius(array[1]);
  39012. this.borderStyle.setWidth(array[2]);
  39013. if (array.length === 4) {
  39014. this.borderStyle.setDashArray(array[3]);
  39015. }
  39016. }
  39017. } else {
  39018. this.borderStyle.setWidth(0);
  39019. }
  39020. },
  39021. setAppearance: function Annotation_setAppearance(dict) {
  39022. this.appearance = null;
  39023. var appearanceStates = dict.get('AP');
  39024. if (!isDict(appearanceStates)) {
  39025. return;
  39026. }
  39027. var normalAppearanceState = appearanceStates.get('N');
  39028. if (isStream(normalAppearanceState)) {
  39029. this.appearance = normalAppearanceState;
  39030. return;
  39031. }
  39032. if (!isDict(normalAppearanceState)) {
  39033. return;
  39034. }
  39035. var as = dict.get('AS');
  39036. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39037. return;
  39038. }
  39039. this.appearance = normalAppearanceState.get(as.name);
  39040. },
  39041. _preparePopup: function Annotation_preparePopup(dict) {
  39042. if (!dict.has('C')) {
  39043. this.data.color = null;
  39044. }
  39045. this.data.hasPopup = dict.has('Popup');
  39046. this.data.title = stringToPDFString(dict.get('T') || '');
  39047. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39048. },
  39049. loadResources: function Annotation_loadResources(keys) {
  39050. return new Promise(function (resolve, reject) {
  39051. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39052. if (!resources) {
  39053. resolve();
  39054. return;
  39055. }
  39056. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39057. objectLoader.load().then(function () {
  39058. resolve(resources);
  39059. }, reject);
  39060. }, reject);
  39061. }.bind(this));
  39062. },
  39063. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39064. if (!this.appearance) {
  39065. return Promise.resolve(new OperatorList());
  39066. }
  39067. var data = this.data;
  39068. var appearanceDict = this.appearance.dict;
  39069. var resourcesPromise = this.loadResources([
  39070. 'ExtGState',
  39071. 'ColorSpace',
  39072. 'Pattern',
  39073. 'Shading',
  39074. 'XObject',
  39075. 'Font'
  39076. ]);
  39077. var bbox = appearanceDict.getArray('BBox') || [
  39078. 0,
  39079. 0,
  39080. 1,
  39081. 1
  39082. ];
  39083. var matrix = appearanceDict.getArray('Matrix') || [
  39084. 1,
  39085. 0,
  39086. 0,
  39087. 1,
  39088. 0,
  39089. 0
  39090. ];
  39091. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39092. var self = this;
  39093. return resourcesPromise.then(function (resources) {
  39094. var opList = new OperatorList();
  39095. opList.addOp(OPS.beginAnnotation, [
  39096. data.rect,
  39097. transform,
  39098. matrix
  39099. ]);
  39100. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39101. opList.addOp(OPS.endAnnotation, []);
  39102. self.appearance.reset();
  39103. return opList;
  39104. });
  39105. });
  39106. }
  39107. };
  39108. return Annotation;
  39109. }();
  39110. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39111. function AnnotationBorderStyle() {
  39112. this.width = 1;
  39113. this.style = AnnotationBorderStyleType.SOLID;
  39114. this.dashArray = [3];
  39115. this.horizontalCornerRadius = 0;
  39116. this.verticalCornerRadius = 0;
  39117. }
  39118. AnnotationBorderStyle.prototype = {
  39119. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39120. if (width === (width | 0)) {
  39121. this.width = width;
  39122. }
  39123. },
  39124. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39125. if (!style) {
  39126. return;
  39127. }
  39128. switch (style.name) {
  39129. case 'S':
  39130. this.style = AnnotationBorderStyleType.SOLID;
  39131. break;
  39132. case 'D':
  39133. this.style = AnnotationBorderStyleType.DASHED;
  39134. break;
  39135. case 'B':
  39136. this.style = AnnotationBorderStyleType.BEVELED;
  39137. break;
  39138. case 'I':
  39139. this.style = AnnotationBorderStyleType.INSET;
  39140. break;
  39141. case 'U':
  39142. this.style = AnnotationBorderStyleType.UNDERLINE;
  39143. break;
  39144. default:
  39145. break;
  39146. }
  39147. },
  39148. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39149. if (isArray(dashArray) && dashArray.length > 0) {
  39150. var isValid = true;
  39151. var allZeros = true;
  39152. for (var i = 0, len = dashArray.length; i < len; i++) {
  39153. var element = dashArray[i];
  39154. var validNumber = +element >= 0;
  39155. if (!validNumber) {
  39156. isValid = false;
  39157. break;
  39158. } else if (element > 0) {
  39159. allZeros = false;
  39160. }
  39161. }
  39162. if (isValid && !allZeros) {
  39163. this.dashArray = dashArray;
  39164. } else {
  39165. this.width = 0;
  39166. }
  39167. } else if (dashArray) {
  39168. this.width = 0;
  39169. }
  39170. },
  39171. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39172. if (radius === (radius | 0)) {
  39173. this.horizontalCornerRadius = radius;
  39174. }
  39175. },
  39176. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39177. if (radius === (radius | 0)) {
  39178. this.verticalCornerRadius = radius;
  39179. }
  39180. }
  39181. };
  39182. return AnnotationBorderStyle;
  39183. }();
  39184. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39185. function WidgetAnnotation(params) {
  39186. Annotation.call(this, params);
  39187. var dict = params.dict;
  39188. var data = this.data;
  39189. data.annotationType = AnnotationType.WIDGET;
  39190. data.fieldName = this._constructFieldName(dict);
  39191. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39192. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39193. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39194. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39195. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39196. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39197. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39198. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39199. data.fieldFlags = 0;
  39200. }
  39201. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39202. if (data.fieldType === 'Sig') {
  39203. this.setFlags(AnnotationFlag.HIDDEN);
  39204. }
  39205. }
  39206. Util.inherit(WidgetAnnotation, Annotation, {
  39207. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39208. if (!dict.has('T') && !dict.has('Parent')) {
  39209. warn('Unknown field name, falling back to empty field name.');
  39210. return '';
  39211. }
  39212. if (!dict.has('Parent')) {
  39213. return stringToPDFString(dict.get('T'));
  39214. }
  39215. var fieldName = [];
  39216. if (dict.has('T')) {
  39217. fieldName.unshift(stringToPDFString(dict.get('T')));
  39218. }
  39219. var loopDict = dict;
  39220. while (loopDict.has('Parent')) {
  39221. loopDict = loopDict.get('Parent');
  39222. if (loopDict.has('T')) {
  39223. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39224. }
  39225. }
  39226. return fieldName.join('.');
  39227. },
  39228. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39229. return !!(this.data.fieldFlags & flag);
  39230. }
  39231. });
  39232. return WidgetAnnotation;
  39233. }();
  39234. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39235. function TextWidgetAnnotation(params) {
  39236. WidgetAnnotation.call(this, params);
  39237. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39238. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39239. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39240. alignment = null;
  39241. }
  39242. this.data.textAlignment = alignment;
  39243. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39244. if (!isInt(maximumLength) || maximumLength < 0) {
  39245. maximumLength = null;
  39246. }
  39247. this.data.maxLen = maximumLength;
  39248. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39249. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39250. }
  39251. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39252. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39253. var operatorList = new OperatorList();
  39254. if (renderForms) {
  39255. return Promise.resolve(operatorList);
  39256. }
  39257. if (this.appearance) {
  39258. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39259. }
  39260. if (!this.data.defaultAppearance) {
  39261. return Promise.resolve(operatorList);
  39262. }
  39263. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39264. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39265. return operatorList;
  39266. });
  39267. }
  39268. });
  39269. return TextWidgetAnnotation;
  39270. }();
  39271. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39272. function ButtonWidgetAnnotation(params) {
  39273. WidgetAnnotation.call(this, params);
  39274. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39275. if (this.data.checkBox) {
  39276. if (!isName(this.data.fieldValue)) {
  39277. return;
  39278. }
  39279. this.data.fieldValue = this.data.fieldValue.name;
  39280. }
  39281. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39282. if (this.data.radioButton) {
  39283. this.data.fieldValue = this.data.buttonValue = null;
  39284. var fieldParent = params.dict.get('Parent');
  39285. if (isDict(fieldParent) && fieldParent.has('V')) {
  39286. var fieldParentValue = fieldParent.get('V');
  39287. if (isName(fieldParentValue)) {
  39288. this.data.fieldValue = fieldParentValue.name;
  39289. }
  39290. }
  39291. var appearanceStates = params.dict.get('AP');
  39292. if (!isDict(appearanceStates)) {
  39293. return;
  39294. }
  39295. var normalAppearanceState = appearanceStates.get('N');
  39296. if (!isDict(normalAppearanceState)) {
  39297. return;
  39298. }
  39299. var keys = normalAppearanceState.getKeys();
  39300. for (var i = 0, ii = keys.length; i < ii; i++) {
  39301. if (keys[i] !== 'Off') {
  39302. this.data.buttonValue = keys[i];
  39303. break;
  39304. }
  39305. }
  39306. }
  39307. }
  39308. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39309. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39310. var operatorList = new OperatorList();
  39311. if (renderForms) {
  39312. return Promise.resolve(operatorList);
  39313. }
  39314. if (this.appearance) {
  39315. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39316. }
  39317. return Promise.resolve(operatorList);
  39318. }
  39319. });
  39320. return ButtonWidgetAnnotation;
  39321. }();
  39322. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39323. function ChoiceWidgetAnnotation(params) {
  39324. WidgetAnnotation.call(this, params);
  39325. this.data.options = [];
  39326. var options = Util.getInheritableProperty(params.dict, 'Opt');
  39327. if (isArray(options)) {
  39328. var xref = params.xref;
  39329. for (var i = 0, ii = options.length; i < ii; i++) {
  39330. var option = xref.fetchIfRef(options[i]);
  39331. var isOptionArray = isArray(option);
  39332. this.data.options[i] = {
  39333. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39334. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39335. };
  39336. }
  39337. }
  39338. if (!isArray(this.data.fieldValue)) {
  39339. this.data.fieldValue = [this.data.fieldValue];
  39340. }
  39341. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39342. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39343. }
  39344. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39345. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39346. var operatorList = new OperatorList();
  39347. if (renderForms) {
  39348. return Promise.resolve(operatorList);
  39349. }
  39350. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39351. }
  39352. });
  39353. return ChoiceWidgetAnnotation;
  39354. }();
  39355. var TextAnnotation = function TextAnnotationClosure() {
  39356. var DEFAULT_ICON_SIZE = 22;
  39357. function TextAnnotation(parameters) {
  39358. Annotation.call(this, parameters);
  39359. this.data.annotationType = AnnotationType.TEXT;
  39360. if (this.data.hasAppearance) {
  39361. this.data.name = 'NoIcon';
  39362. } else {
  39363. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39364. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39365. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39366. }
  39367. this._preparePopup(parameters.dict);
  39368. }
  39369. Util.inherit(TextAnnotation, Annotation, {});
  39370. return TextAnnotation;
  39371. }();
  39372. var LinkAnnotation = function LinkAnnotationClosure() {
  39373. function LinkAnnotation(params) {
  39374. Annotation.call(this, params);
  39375. var data = this.data;
  39376. data.annotationType = AnnotationType.LINK;
  39377. Catalog.parseDestDictionary({
  39378. destDict: params.dict,
  39379. resultObj: data,
  39380. docBaseUrl: params.pdfManager.docBaseUrl
  39381. });
  39382. }
  39383. Util.inherit(LinkAnnotation, Annotation, {});
  39384. return LinkAnnotation;
  39385. }();
  39386. var PopupAnnotation = function PopupAnnotationClosure() {
  39387. function PopupAnnotation(parameters) {
  39388. Annotation.call(this, parameters);
  39389. this.data.annotationType = AnnotationType.POPUP;
  39390. var dict = parameters.dict;
  39391. var parentItem = dict.get('Parent');
  39392. if (!parentItem) {
  39393. warn('Popup annotation has a missing or invalid parent annotation.');
  39394. return;
  39395. }
  39396. this.data.parentId = dict.getRaw('Parent').toString();
  39397. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39398. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39399. if (!parentItem.has('C')) {
  39400. this.data.color = null;
  39401. } else {
  39402. this.setColor(parentItem.getArray('C'));
  39403. this.data.color = this.color;
  39404. }
  39405. if (!this.viewable) {
  39406. var parentFlags = parentItem.get('F');
  39407. if (this._isViewable(parentFlags)) {
  39408. this.setFlags(parentFlags);
  39409. }
  39410. }
  39411. }
  39412. Util.inherit(PopupAnnotation, Annotation, {});
  39413. return PopupAnnotation;
  39414. }();
  39415. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39416. function HighlightAnnotation(parameters) {
  39417. Annotation.call(this, parameters);
  39418. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39419. this._preparePopup(parameters.dict);
  39420. this.data.borderStyle.setWidth(0);
  39421. }
  39422. Util.inherit(HighlightAnnotation, Annotation, {});
  39423. return HighlightAnnotation;
  39424. }();
  39425. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39426. function UnderlineAnnotation(parameters) {
  39427. Annotation.call(this, parameters);
  39428. this.data.annotationType = AnnotationType.UNDERLINE;
  39429. this._preparePopup(parameters.dict);
  39430. this.data.borderStyle.setWidth(0);
  39431. }
  39432. Util.inherit(UnderlineAnnotation, Annotation, {});
  39433. return UnderlineAnnotation;
  39434. }();
  39435. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39436. function SquigglyAnnotation(parameters) {
  39437. Annotation.call(this, parameters);
  39438. this.data.annotationType = AnnotationType.SQUIGGLY;
  39439. this._preparePopup(parameters.dict);
  39440. this.data.borderStyle.setWidth(0);
  39441. }
  39442. Util.inherit(SquigglyAnnotation, Annotation, {});
  39443. return SquigglyAnnotation;
  39444. }();
  39445. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39446. function StrikeOutAnnotation(parameters) {
  39447. Annotation.call(this, parameters);
  39448. this.data.annotationType = AnnotationType.STRIKEOUT;
  39449. this._preparePopup(parameters.dict);
  39450. this.data.borderStyle.setWidth(0);
  39451. }
  39452. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39453. return StrikeOutAnnotation;
  39454. }();
  39455. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39456. function FileAttachmentAnnotation(parameters) {
  39457. Annotation.call(this, parameters);
  39458. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39459. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39460. this.data.file = file.serializable;
  39461. this._preparePopup(parameters.dict);
  39462. }
  39463. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39464. return FileAttachmentAnnotation;
  39465. }();
  39466. exports.Annotation = Annotation;
  39467. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39468. exports.AnnotationFactory = AnnotationFactory;
  39469. /***/ }),
  39470. /* 28 */
  39471. /***/ (function(module, exports, __w_pdfjs_require__) {
  39472. "use strict";
  39473. var sharedUtil = __w_pdfjs_require__(0);
  39474. var warn = sharedUtil.warn;
  39475. var baseTypes = [
  39476. 'BN',
  39477. 'BN',
  39478. 'BN',
  39479. 'BN',
  39480. 'BN',
  39481. 'BN',
  39482. 'BN',
  39483. 'BN',
  39484. 'BN',
  39485. 'S',
  39486. 'B',
  39487. 'S',
  39488. 'WS',
  39489. 'B',
  39490. 'BN',
  39491. 'BN',
  39492. 'BN',
  39493. 'BN',
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'BN',
  39499. 'BN',
  39500. 'BN',
  39501. 'BN',
  39502. 'BN',
  39503. 'BN',
  39504. 'B',
  39505. 'B',
  39506. 'B',
  39507. 'S',
  39508. 'WS',
  39509. 'ON',
  39510. 'ON',
  39511. 'ET',
  39512. 'ET',
  39513. 'ET',
  39514. 'ON',
  39515. 'ON',
  39516. 'ON',
  39517. 'ON',
  39518. 'ON',
  39519. 'ES',
  39520. 'CS',
  39521. 'ES',
  39522. 'CS',
  39523. 'CS',
  39524. 'EN',
  39525. 'EN',
  39526. 'EN',
  39527. 'EN',
  39528. 'EN',
  39529. 'EN',
  39530. 'EN',
  39531. 'EN',
  39532. 'EN',
  39533. 'EN',
  39534. 'CS',
  39535. 'ON',
  39536. 'ON',
  39537. 'ON',
  39538. 'ON',
  39539. 'ON',
  39540. 'ON',
  39541. 'L',
  39542. 'L',
  39543. 'L',
  39544. 'L',
  39545. 'L',
  39546. 'L',
  39547. 'L',
  39548. 'L',
  39549. 'L',
  39550. 'L',
  39551. 'L',
  39552. 'L',
  39553. 'L',
  39554. 'L',
  39555. 'L',
  39556. 'L',
  39557. 'L',
  39558. 'L',
  39559. 'L',
  39560. 'L',
  39561. 'L',
  39562. 'L',
  39563. 'L',
  39564. 'L',
  39565. 'L',
  39566. 'L',
  39567. 'ON',
  39568. 'ON',
  39569. 'ON',
  39570. 'ON',
  39571. 'ON',
  39572. 'ON',
  39573. 'L',
  39574. 'L',
  39575. 'L',
  39576. 'L',
  39577. 'L',
  39578. 'L',
  39579. 'L',
  39580. 'L',
  39581. 'L',
  39582. 'L',
  39583. 'L',
  39584. 'L',
  39585. 'L',
  39586. 'L',
  39587. 'L',
  39588. 'L',
  39589. 'L',
  39590. 'L',
  39591. 'L',
  39592. 'L',
  39593. 'L',
  39594. 'L',
  39595. 'L',
  39596. 'L',
  39597. 'L',
  39598. 'L',
  39599. 'ON',
  39600. 'ON',
  39601. 'ON',
  39602. 'ON',
  39603. 'BN',
  39604. 'BN',
  39605. 'BN',
  39606. 'BN',
  39607. 'BN',
  39608. 'BN',
  39609. 'B',
  39610. 'BN',
  39611. 'BN',
  39612. 'BN',
  39613. 'BN',
  39614. 'BN',
  39615. 'BN',
  39616. 'BN',
  39617. 'BN',
  39618. 'BN',
  39619. 'BN',
  39620. 'BN',
  39621. 'BN',
  39622. 'BN',
  39623. 'BN',
  39624. 'BN',
  39625. 'BN',
  39626. 'BN',
  39627. 'BN',
  39628. 'BN',
  39629. 'BN',
  39630. 'BN',
  39631. 'BN',
  39632. 'BN',
  39633. 'BN',
  39634. 'BN',
  39635. 'BN',
  39636. 'CS',
  39637. 'ON',
  39638. 'ET',
  39639. 'ET',
  39640. 'ET',
  39641. 'ET',
  39642. 'ON',
  39643. 'ON',
  39644. 'ON',
  39645. 'ON',
  39646. 'L',
  39647. 'ON',
  39648. 'ON',
  39649. 'BN',
  39650. 'ON',
  39651. 'ON',
  39652. 'ET',
  39653. 'ET',
  39654. 'EN',
  39655. 'EN',
  39656. 'ON',
  39657. 'L',
  39658. 'ON',
  39659. 'ON',
  39660. 'ON',
  39661. 'EN',
  39662. 'L',
  39663. 'ON',
  39664. 'ON',
  39665. 'ON',
  39666. 'ON',
  39667. 'ON',
  39668. 'L',
  39669. 'L',
  39670. 'L',
  39671. 'L',
  39672. 'L',
  39673. 'L',
  39674. 'L',
  39675. 'L',
  39676. 'L',
  39677. 'L',
  39678. 'L',
  39679. 'L',
  39680. 'L',
  39681. 'L',
  39682. 'L',
  39683. 'L',
  39684. 'L',
  39685. 'L',
  39686. 'L',
  39687. 'L',
  39688. 'L',
  39689. 'L',
  39690. 'L',
  39691. 'ON',
  39692. 'L',
  39693. 'L',
  39694. 'L',
  39695. 'L',
  39696. 'L',
  39697. 'L',
  39698. 'L',
  39699. 'L',
  39700. 'L',
  39701. 'L',
  39702. 'L',
  39703. 'L',
  39704. 'L',
  39705. 'L',
  39706. 'L',
  39707. 'L',
  39708. 'L',
  39709. 'L',
  39710. 'L',
  39711. 'L',
  39712. 'L',
  39713. 'L',
  39714. 'L',
  39715. 'L',
  39716. 'L',
  39717. 'L',
  39718. 'L',
  39719. 'L',
  39720. 'L',
  39721. 'L',
  39722. 'L',
  39723. 'ON',
  39724. 'L',
  39725. 'L',
  39726. 'L',
  39727. 'L',
  39728. 'L',
  39729. 'L',
  39730. 'L',
  39731. 'L'
  39732. ];
  39733. var arabicTypes = [
  39734. 'AN',
  39735. 'AN',
  39736. 'AN',
  39737. 'AN',
  39738. 'AN',
  39739. 'AN',
  39740. 'ON',
  39741. 'ON',
  39742. 'AL',
  39743. 'ET',
  39744. 'ET',
  39745. 'AL',
  39746. 'CS',
  39747. 'AL',
  39748. 'ON',
  39749. 'ON',
  39750. 'NSM',
  39751. 'NSM',
  39752. 'NSM',
  39753. 'NSM',
  39754. 'NSM',
  39755. 'NSM',
  39756. 'NSM',
  39757. 'NSM',
  39758. 'NSM',
  39759. 'NSM',
  39760. 'NSM',
  39761. 'AL',
  39762. 'AL',
  39763. '',
  39764. 'AL',
  39765. 'AL',
  39766. 'AL',
  39767. 'AL',
  39768. 'AL',
  39769. 'AL',
  39770. 'AL',
  39771. 'AL',
  39772. 'AL',
  39773. 'AL',
  39774. 'AL',
  39775. 'AL',
  39776. 'AL',
  39777. 'AL',
  39778. 'AL',
  39779. 'AL',
  39780. 'AL',
  39781. 'AL',
  39782. 'AL',
  39783. 'AL',
  39784. 'AL',
  39785. 'AL',
  39786. 'AL',
  39787. 'AL',
  39788. 'AL',
  39789. 'AL',
  39790. 'AL',
  39791. 'AL',
  39792. 'AL',
  39793. 'AL',
  39794. 'AL',
  39795. 'AL',
  39796. 'AL',
  39797. 'AL',
  39798. 'AL',
  39799. 'AL',
  39800. 'AL',
  39801. 'AL',
  39802. 'AL',
  39803. 'AL',
  39804. 'AL',
  39805. 'AL',
  39806. 'AL',
  39807. 'AL',
  39808. 'AL',
  39809. 'NSM',
  39810. 'NSM',
  39811. 'NSM',
  39812. 'NSM',
  39813. 'NSM',
  39814. 'NSM',
  39815. 'NSM',
  39816. 'NSM',
  39817. 'NSM',
  39818. 'NSM',
  39819. 'NSM',
  39820. 'NSM',
  39821. 'NSM',
  39822. 'NSM',
  39823. 'NSM',
  39824. 'NSM',
  39825. 'NSM',
  39826. 'NSM',
  39827. 'NSM',
  39828. 'NSM',
  39829. 'NSM',
  39830. 'AN',
  39831. 'AN',
  39832. 'AN',
  39833. 'AN',
  39834. 'AN',
  39835. 'AN',
  39836. 'AN',
  39837. 'AN',
  39838. 'AN',
  39839. 'AN',
  39840. 'ET',
  39841. 'AN',
  39842. 'AN',
  39843. 'AL',
  39844. 'AL',
  39845. 'AL',
  39846. 'NSM',
  39847. 'AL',
  39848. 'AL',
  39849. 'AL',
  39850. 'AL',
  39851. 'AL',
  39852. 'AL',
  39853. 'AL',
  39854. 'AL',
  39855. 'AL',
  39856. 'AL',
  39857. 'AL',
  39858. 'AL',
  39859. 'AL',
  39860. 'AL',
  39861. 'AL',
  39862. 'AL',
  39863. 'AL',
  39864. 'AL',
  39865. 'AL',
  39866. 'AL',
  39867. 'AL',
  39868. 'AL',
  39869. 'AL',
  39870. 'AL',
  39871. 'AL',
  39872. 'AL',
  39873. 'AL',
  39874. 'AL',
  39875. 'AL',
  39876. 'AL',
  39877. 'AL',
  39878. 'AL',
  39879. 'AL',
  39880. 'AL',
  39881. 'AL',
  39882. 'AL',
  39883. 'AL',
  39884. 'AL',
  39885. 'AL',
  39886. 'AL',
  39887. 'AL',
  39888. 'AL',
  39889. 'AL',
  39890. 'AL',
  39891. 'AL',
  39892. 'AL',
  39893. 'AL',
  39894. 'AL',
  39895. 'AL',
  39896. 'AL',
  39897. 'AL',
  39898. 'AL',
  39899. 'AL',
  39900. 'AL',
  39901. 'AL',
  39902. 'AL',
  39903. 'AL',
  39904. 'AL',
  39905. 'AL',
  39906. 'AL',
  39907. 'AL',
  39908. 'AL',
  39909. 'AL',
  39910. 'AL',
  39911. 'AL',
  39912. 'AL',
  39913. 'AL',
  39914. 'AL',
  39915. 'AL',
  39916. 'AL',
  39917. 'AL',
  39918. 'AL',
  39919. 'AL',
  39920. 'AL',
  39921. 'AL',
  39922. 'AL',
  39923. 'AL',
  39924. 'AL',
  39925. 'AL',
  39926. 'AL',
  39927. 'AL',
  39928. 'AL',
  39929. 'AL',
  39930. 'AL',
  39931. 'AL',
  39932. 'AL',
  39933. 'AL',
  39934. 'AL',
  39935. 'AL',
  39936. 'AL',
  39937. 'AL',
  39938. 'AL',
  39939. 'AL',
  39940. 'AL',
  39941. 'AL',
  39942. 'AL',
  39943. 'AL',
  39944. 'AL',
  39945. 'AL',
  39946. 'AL',
  39947. 'AL',
  39948. 'NSM',
  39949. 'NSM',
  39950. 'NSM',
  39951. 'NSM',
  39952. 'NSM',
  39953. 'NSM',
  39954. 'NSM',
  39955. 'AN',
  39956. 'ON',
  39957. 'NSM',
  39958. 'NSM',
  39959. 'NSM',
  39960. 'NSM',
  39961. 'NSM',
  39962. 'NSM',
  39963. 'AL',
  39964. 'AL',
  39965. 'NSM',
  39966. 'NSM',
  39967. 'ON',
  39968. 'NSM',
  39969. 'NSM',
  39970. 'NSM',
  39971. 'NSM',
  39972. 'AL',
  39973. 'AL',
  39974. 'EN',
  39975. 'EN',
  39976. 'EN',
  39977. 'EN',
  39978. 'EN',
  39979. 'EN',
  39980. 'EN',
  39981. 'EN',
  39982. 'EN',
  39983. 'EN',
  39984. 'AL',
  39985. 'AL',
  39986. 'AL',
  39987. 'AL',
  39988. 'AL',
  39989. 'AL'
  39990. ];
  39991. function isOdd(i) {
  39992. return (i & 1) !== 0;
  39993. }
  39994. function isEven(i) {
  39995. return (i & 1) === 0;
  39996. }
  39997. function findUnequal(arr, start, value) {
  39998. for (var j = start, jj = arr.length; j < jj; ++j) {
  39999. if (arr[j] !== value) {
  40000. return j;
  40001. }
  40002. }
  40003. return j;
  40004. }
  40005. function setValues(arr, start, end, value) {
  40006. for (var j = start; j < end; ++j) {
  40007. arr[j] = value;
  40008. }
  40009. }
  40010. function reverseValues(arr, start, end) {
  40011. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40012. var temp = arr[i];
  40013. arr[i] = arr[j];
  40014. arr[j] = temp;
  40015. }
  40016. }
  40017. function createBidiText(str, isLTR, vertical) {
  40018. return {
  40019. str: str,
  40020. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40021. };
  40022. }
  40023. var chars = [];
  40024. var types = [];
  40025. function bidi(str, startLevel, vertical) {
  40026. var isLTR = true;
  40027. var strLength = str.length;
  40028. if (strLength === 0 || vertical) {
  40029. return createBidiText(str, isLTR, vertical);
  40030. }
  40031. chars.length = strLength;
  40032. types.length = strLength;
  40033. var numBidi = 0;
  40034. var i, ii;
  40035. for (i = 0; i < strLength; ++i) {
  40036. chars[i] = str.charAt(i);
  40037. var charCode = str.charCodeAt(i);
  40038. var charType = 'L';
  40039. if (charCode <= 0x00ff) {
  40040. charType = baseTypes[charCode];
  40041. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40042. charType = 'R';
  40043. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40044. charType = arabicTypes[charCode & 0xff];
  40045. if (!charType) {
  40046. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40047. }
  40048. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40049. charType = 'AL';
  40050. }
  40051. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40052. numBidi++;
  40053. }
  40054. types[i] = charType;
  40055. }
  40056. if (numBidi === 0) {
  40057. isLTR = true;
  40058. return createBidiText(str, isLTR);
  40059. }
  40060. if (startLevel === -1) {
  40061. if (numBidi / strLength < 0.3) {
  40062. isLTR = true;
  40063. startLevel = 0;
  40064. } else {
  40065. isLTR = false;
  40066. startLevel = 1;
  40067. }
  40068. }
  40069. var levels = [];
  40070. for (i = 0; i < strLength; ++i) {
  40071. levels[i] = startLevel;
  40072. }
  40073. var e = isOdd(startLevel) ? 'R' : 'L';
  40074. var sor = e;
  40075. var eor = sor;
  40076. var lastType = sor;
  40077. for (i = 0; i < strLength; ++i) {
  40078. if (types[i] === 'NSM') {
  40079. types[i] = lastType;
  40080. } else {
  40081. lastType = types[i];
  40082. }
  40083. }
  40084. lastType = sor;
  40085. var t;
  40086. for (i = 0; i < strLength; ++i) {
  40087. t = types[i];
  40088. if (t === 'EN') {
  40089. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40090. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40091. lastType = t;
  40092. }
  40093. }
  40094. for (i = 0; i < strLength; ++i) {
  40095. t = types[i];
  40096. if (t === 'AL') {
  40097. types[i] = 'R';
  40098. }
  40099. }
  40100. for (i = 1; i < strLength - 1; ++i) {
  40101. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40102. types[i] = 'EN';
  40103. }
  40104. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40105. types[i] = types[i - 1];
  40106. }
  40107. }
  40108. for (i = 0; i < strLength; ++i) {
  40109. if (types[i] === 'EN') {
  40110. var j;
  40111. for (j = i - 1; j >= 0; --j) {
  40112. if (types[j] !== 'ET') {
  40113. break;
  40114. }
  40115. types[j] = 'EN';
  40116. }
  40117. for (j = i + 1; j < strLength; ++j) {
  40118. if (types[j] !== 'ET') {
  40119. break;
  40120. }
  40121. types[j] = 'EN';
  40122. }
  40123. }
  40124. }
  40125. for (i = 0; i < strLength; ++i) {
  40126. t = types[i];
  40127. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40128. types[i] = 'ON';
  40129. }
  40130. }
  40131. lastType = sor;
  40132. for (i = 0; i < strLength; ++i) {
  40133. t = types[i];
  40134. if (t === 'EN') {
  40135. types[i] = lastType === 'L' ? 'L' : 'EN';
  40136. } else if (t === 'R' || t === 'L') {
  40137. lastType = t;
  40138. }
  40139. }
  40140. for (i = 0; i < strLength; ++i) {
  40141. if (types[i] === 'ON') {
  40142. var end = findUnequal(types, i + 1, 'ON');
  40143. var before = sor;
  40144. if (i > 0) {
  40145. before = types[i - 1];
  40146. }
  40147. var after = eor;
  40148. if (end + 1 < strLength) {
  40149. after = types[end + 1];
  40150. }
  40151. if (before !== 'L') {
  40152. before = 'R';
  40153. }
  40154. if (after !== 'L') {
  40155. after = 'R';
  40156. }
  40157. if (before === after) {
  40158. setValues(types, i, end, before);
  40159. }
  40160. i = end - 1;
  40161. }
  40162. }
  40163. for (i = 0; i < strLength; ++i) {
  40164. if (types[i] === 'ON') {
  40165. types[i] = e;
  40166. }
  40167. }
  40168. for (i = 0; i < strLength; ++i) {
  40169. t = types[i];
  40170. if (isEven(levels[i])) {
  40171. if (t === 'R') {
  40172. levels[i] += 1;
  40173. } else if (t === 'AN' || t === 'EN') {
  40174. levels[i] += 2;
  40175. }
  40176. } else {
  40177. if (t === 'L' || t === 'AN' || t === 'EN') {
  40178. levels[i] += 1;
  40179. }
  40180. }
  40181. }
  40182. var highestLevel = -1;
  40183. var lowestOddLevel = 99;
  40184. var level;
  40185. for (i = 0, ii = levels.length; i < ii; ++i) {
  40186. level = levels[i];
  40187. if (highestLevel < level) {
  40188. highestLevel = level;
  40189. }
  40190. if (lowestOddLevel > level && isOdd(level)) {
  40191. lowestOddLevel = level;
  40192. }
  40193. }
  40194. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40195. var start = -1;
  40196. for (i = 0, ii = levels.length; i < ii; ++i) {
  40197. if (levels[i] < level) {
  40198. if (start >= 0) {
  40199. reverseValues(chars, start, i);
  40200. start = -1;
  40201. }
  40202. } else if (start < 0) {
  40203. start = i;
  40204. }
  40205. }
  40206. if (start >= 0) {
  40207. reverseValues(chars, start, levels.length);
  40208. }
  40209. }
  40210. for (i = 0, ii = chars.length; i < ii; ++i) {
  40211. var ch = chars[i];
  40212. if (ch === '<' || ch === '>') {
  40213. chars[i] = '';
  40214. }
  40215. }
  40216. return createBidiText(chars.join(''), isLTR);
  40217. }
  40218. exports.bidi = bidi;
  40219. /***/ }),
  40220. /* 29 */
  40221. /***/ (function(module, exports, __w_pdfjs_require__) {
  40222. "use strict";
  40223. var ISOAdobeCharset = [
  40224. '.notdef',
  40225. 'space',
  40226. 'exclam',
  40227. 'quotedbl',
  40228. 'numbersign',
  40229. 'dollar',
  40230. 'percent',
  40231. 'ampersand',
  40232. 'quoteright',
  40233. 'parenleft',
  40234. 'parenright',
  40235. 'asterisk',
  40236. 'plus',
  40237. 'comma',
  40238. 'hyphen',
  40239. 'period',
  40240. 'slash',
  40241. 'zero',
  40242. 'one',
  40243. 'two',
  40244. 'three',
  40245. 'four',
  40246. 'five',
  40247. 'six',
  40248. 'seven',
  40249. 'eight',
  40250. 'nine',
  40251. 'colon',
  40252. 'semicolon',
  40253. 'less',
  40254. 'equal',
  40255. 'greater',
  40256. 'question',
  40257. 'at',
  40258. 'A',
  40259. 'B',
  40260. 'C',
  40261. 'D',
  40262. 'E',
  40263. 'F',
  40264. 'G',
  40265. 'H',
  40266. 'I',
  40267. 'J',
  40268. 'K',
  40269. 'L',
  40270. 'M',
  40271. 'N',
  40272. 'O',
  40273. 'P',
  40274. 'Q',
  40275. 'R',
  40276. 'S',
  40277. 'T',
  40278. 'U',
  40279. 'V',
  40280. 'W',
  40281. 'X',
  40282. 'Y',
  40283. 'Z',
  40284. 'bracketleft',
  40285. 'backslash',
  40286. 'bracketright',
  40287. 'asciicircum',
  40288. 'underscore',
  40289. 'quoteleft',
  40290. 'a',
  40291. 'b',
  40292. 'c',
  40293. 'd',
  40294. 'e',
  40295. 'f',
  40296. 'g',
  40297. 'h',
  40298. 'i',
  40299. 'j',
  40300. 'k',
  40301. 'l',
  40302. 'm',
  40303. 'n',
  40304. 'o',
  40305. 'p',
  40306. 'q',
  40307. 'r',
  40308. 's',
  40309. 't',
  40310. 'u',
  40311. 'v',
  40312. 'w',
  40313. 'x',
  40314. 'y',
  40315. 'z',
  40316. 'braceleft',
  40317. 'bar',
  40318. 'braceright',
  40319. 'asciitilde',
  40320. 'exclamdown',
  40321. 'cent',
  40322. 'sterling',
  40323. 'fraction',
  40324. 'yen',
  40325. 'florin',
  40326. 'section',
  40327. 'currency',
  40328. 'quotesingle',
  40329. 'quotedblleft',
  40330. 'guillemotleft',
  40331. 'guilsinglleft',
  40332. 'guilsinglright',
  40333. 'fi',
  40334. 'fl',
  40335. 'endash',
  40336. 'dagger',
  40337. 'daggerdbl',
  40338. 'periodcentered',
  40339. 'paragraph',
  40340. 'bullet',
  40341. 'quotesinglbase',
  40342. 'quotedblbase',
  40343. 'quotedblright',
  40344. 'guillemotright',
  40345. 'ellipsis',
  40346. 'perthousand',
  40347. 'questiondown',
  40348. 'grave',
  40349. 'acute',
  40350. 'circumflex',
  40351. 'tilde',
  40352. 'macron',
  40353. 'breve',
  40354. 'dotaccent',
  40355. 'dieresis',
  40356. 'ring',
  40357. 'cedilla',
  40358. 'hungarumlaut',
  40359. 'ogonek',
  40360. 'caron',
  40361. 'emdash',
  40362. 'AE',
  40363. 'ordfeminine',
  40364. 'Lslash',
  40365. 'Oslash',
  40366. 'OE',
  40367. 'ordmasculine',
  40368. 'ae',
  40369. 'dotlessi',
  40370. 'lslash',
  40371. 'oslash',
  40372. 'oe',
  40373. 'germandbls',
  40374. 'onesuperior',
  40375. 'logicalnot',
  40376. 'mu',
  40377. 'trademark',
  40378. 'Eth',
  40379. 'onehalf',
  40380. 'plusminus',
  40381. 'Thorn',
  40382. 'onequarter',
  40383. 'divide',
  40384. 'brokenbar',
  40385. 'degree',
  40386. 'thorn',
  40387. 'threequarters',
  40388. 'twosuperior',
  40389. 'registered',
  40390. 'minus',
  40391. 'eth',
  40392. 'multiply',
  40393. 'threesuperior',
  40394. 'copyright',
  40395. 'Aacute',
  40396. 'Acircumflex',
  40397. 'Adieresis',
  40398. 'Agrave',
  40399. 'Aring',
  40400. 'Atilde',
  40401. 'Ccedilla',
  40402. 'Eacute',
  40403. 'Ecircumflex',
  40404. 'Edieresis',
  40405. 'Egrave',
  40406. 'Iacute',
  40407. 'Icircumflex',
  40408. 'Idieresis',
  40409. 'Igrave',
  40410. 'Ntilde',
  40411. 'Oacute',
  40412. 'Ocircumflex',
  40413. 'Odieresis',
  40414. 'Ograve',
  40415. 'Otilde',
  40416. 'Scaron',
  40417. 'Uacute',
  40418. 'Ucircumflex',
  40419. 'Udieresis',
  40420. 'Ugrave',
  40421. 'Yacute',
  40422. 'Ydieresis',
  40423. 'Zcaron',
  40424. 'aacute',
  40425. 'acircumflex',
  40426. 'adieresis',
  40427. 'agrave',
  40428. 'aring',
  40429. 'atilde',
  40430. 'ccedilla',
  40431. 'eacute',
  40432. 'ecircumflex',
  40433. 'edieresis',
  40434. 'egrave',
  40435. 'iacute',
  40436. 'icircumflex',
  40437. 'idieresis',
  40438. 'igrave',
  40439. 'ntilde',
  40440. 'oacute',
  40441. 'ocircumflex',
  40442. 'odieresis',
  40443. 'ograve',
  40444. 'otilde',
  40445. 'scaron',
  40446. 'uacute',
  40447. 'ucircumflex',
  40448. 'udieresis',
  40449. 'ugrave',
  40450. 'yacute',
  40451. 'ydieresis',
  40452. 'zcaron'
  40453. ];
  40454. var ExpertCharset = [
  40455. '.notdef',
  40456. 'space',
  40457. 'exclamsmall',
  40458. 'Hungarumlautsmall',
  40459. 'dollaroldstyle',
  40460. 'dollarsuperior',
  40461. 'ampersandsmall',
  40462. 'Acutesmall',
  40463. 'parenleftsuperior',
  40464. 'parenrightsuperior',
  40465. 'twodotenleader',
  40466. 'onedotenleader',
  40467. 'comma',
  40468. 'hyphen',
  40469. 'period',
  40470. 'fraction',
  40471. 'zerooldstyle',
  40472. 'oneoldstyle',
  40473. 'twooldstyle',
  40474. 'threeoldstyle',
  40475. 'fouroldstyle',
  40476. 'fiveoldstyle',
  40477. 'sixoldstyle',
  40478. 'sevenoldstyle',
  40479. 'eightoldstyle',
  40480. 'nineoldstyle',
  40481. 'colon',
  40482. 'semicolon',
  40483. 'commasuperior',
  40484. 'threequartersemdash',
  40485. 'periodsuperior',
  40486. 'questionsmall',
  40487. 'asuperior',
  40488. 'bsuperior',
  40489. 'centsuperior',
  40490. 'dsuperior',
  40491. 'esuperior',
  40492. 'isuperior',
  40493. 'lsuperior',
  40494. 'msuperior',
  40495. 'nsuperior',
  40496. 'osuperior',
  40497. 'rsuperior',
  40498. 'ssuperior',
  40499. 'tsuperior',
  40500. 'ff',
  40501. 'fi',
  40502. 'fl',
  40503. 'ffi',
  40504. 'ffl',
  40505. 'parenleftinferior',
  40506. 'parenrightinferior',
  40507. 'Circumflexsmall',
  40508. 'hyphensuperior',
  40509. 'Gravesmall',
  40510. 'Asmall',
  40511. 'Bsmall',
  40512. 'Csmall',
  40513. 'Dsmall',
  40514. 'Esmall',
  40515. 'Fsmall',
  40516. 'Gsmall',
  40517. 'Hsmall',
  40518. 'Ismall',
  40519. 'Jsmall',
  40520. 'Ksmall',
  40521. 'Lsmall',
  40522. 'Msmall',
  40523. 'Nsmall',
  40524. 'Osmall',
  40525. 'Psmall',
  40526. 'Qsmall',
  40527. 'Rsmall',
  40528. 'Ssmall',
  40529. 'Tsmall',
  40530. 'Usmall',
  40531. 'Vsmall',
  40532. 'Wsmall',
  40533. 'Xsmall',
  40534. 'Ysmall',
  40535. 'Zsmall',
  40536. 'colonmonetary',
  40537. 'onefitted',
  40538. 'rupiah',
  40539. 'Tildesmall',
  40540. 'exclamdownsmall',
  40541. 'centoldstyle',
  40542. 'Lslashsmall',
  40543. 'Scaronsmall',
  40544. 'Zcaronsmall',
  40545. 'Dieresissmall',
  40546. 'Brevesmall',
  40547. 'Caronsmall',
  40548. 'Dotaccentsmall',
  40549. 'Macronsmall',
  40550. 'figuredash',
  40551. 'hypheninferior',
  40552. 'Ogoneksmall',
  40553. 'Ringsmall',
  40554. 'Cedillasmall',
  40555. 'onequarter',
  40556. 'onehalf',
  40557. 'threequarters',
  40558. 'questiondownsmall',
  40559. 'oneeighth',
  40560. 'threeeighths',
  40561. 'fiveeighths',
  40562. 'seveneighths',
  40563. 'onethird',
  40564. 'twothirds',
  40565. 'zerosuperior',
  40566. 'onesuperior',
  40567. 'twosuperior',
  40568. 'threesuperior',
  40569. 'foursuperior',
  40570. 'fivesuperior',
  40571. 'sixsuperior',
  40572. 'sevensuperior',
  40573. 'eightsuperior',
  40574. 'ninesuperior',
  40575. 'zeroinferior',
  40576. 'oneinferior',
  40577. 'twoinferior',
  40578. 'threeinferior',
  40579. 'fourinferior',
  40580. 'fiveinferior',
  40581. 'sixinferior',
  40582. 'seveninferior',
  40583. 'eightinferior',
  40584. 'nineinferior',
  40585. 'centinferior',
  40586. 'dollarinferior',
  40587. 'periodinferior',
  40588. 'commainferior',
  40589. 'Agravesmall',
  40590. 'Aacutesmall',
  40591. 'Acircumflexsmall',
  40592. 'Atildesmall',
  40593. 'Adieresissmall',
  40594. 'Aringsmall',
  40595. 'AEsmall',
  40596. 'Ccedillasmall',
  40597. 'Egravesmall',
  40598. 'Eacutesmall',
  40599. 'Ecircumflexsmall',
  40600. 'Edieresissmall',
  40601. 'Igravesmall',
  40602. 'Iacutesmall',
  40603. 'Icircumflexsmall',
  40604. 'Idieresissmall',
  40605. 'Ethsmall',
  40606. 'Ntildesmall',
  40607. 'Ogravesmall',
  40608. 'Oacutesmall',
  40609. 'Ocircumflexsmall',
  40610. 'Otildesmall',
  40611. 'Odieresissmall',
  40612. 'OEsmall',
  40613. 'Oslashsmall',
  40614. 'Ugravesmall',
  40615. 'Uacutesmall',
  40616. 'Ucircumflexsmall',
  40617. 'Udieresissmall',
  40618. 'Yacutesmall',
  40619. 'Thornsmall',
  40620. 'Ydieresissmall'
  40621. ];
  40622. var ExpertSubsetCharset = [
  40623. '.notdef',
  40624. 'space',
  40625. 'dollaroldstyle',
  40626. 'dollarsuperior',
  40627. 'parenleftsuperior',
  40628. 'parenrightsuperior',
  40629. 'twodotenleader',
  40630. 'onedotenleader',
  40631. 'comma',
  40632. 'hyphen',
  40633. 'period',
  40634. 'fraction',
  40635. 'zerooldstyle',
  40636. 'oneoldstyle',
  40637. 'twooldstyle',
  40638. 'threeoldstyle',
  40639. 'fouroldstyle',
  40640. 'fiveoldstyle',
  40641. 'sixoldstyle',
  40642. 'sevenoldstyle',
  40643. 'eightoldstyle',
  40644. 'nineoldstyle',
  40645. 'colon',
  40646. 'semicolon',
  40647. 'commasuperior',
  40648. 'threequartersemdash',
  40649. 'periodsuperior',
  40650. 'asuperior',
  40651. 'bsuperior',
  40652. 'centsuperior',
  40653. 'dsuperior',
  40654. 'esuperior',
  40655. 'isuperior',
  40656. 'lsuperior',
  40657. 'msuperior',
  40658. 'nsuperior',
  40659. 'osuperior',
  40660. 'rsuperior',
  40661. 'ssuperior',
  40662. 'tsuperior',
  40663. 'ff',
  40664. 'fi',
  40665. 'fl',
  40666. 'ffi',
  40667. 'ffl',
  40668. 'parenleftinferior',
  40669. 'parenrightinferior',
  40670. 'hyphensuperior',
  40671. 'colonmonetary',
  40672. 'onefitted',
  40673. 'rupiah',
  40674. 'centoldstyle',
  40675. 'figuredash',
  40676. 'hypheninferior',
  40677. 'onequarter',
  40678. 'onehalf',
  40679. 'threequarters',
  40680. 'oneeighth',
  40681. 'threeeighths',
  40682. 'fiveeighths',
  40683. 'seveneighths',
  40684. 'onethird',
  40685. 'twothirds',
  40686. 'zerosuperior',
  40687. 'onesuperior',
  40688. 'twosuperior',
  40689. 'threesuperior',
  40690. 'foursuperior',
  40691. 'fivesuperior',
  40692. 'sixsuperior',
  40693. 'sevensuperior',
  40694. 'eightsuperior',
  40695. 'ninesuperior',
  40696. 'zeroinferior',
  40697. 'oneinferior',
  40698. 'twoinferior',
  40699. 'threeinferior',
  40700. 'fourinferior',
  40701. 'fiveinferior',
  40702. 'sixinferior',
  40703. 'seveninferior',
  40704. 'eightinferior',
  40705. 'nineinferior',
  40706. 'centinferior',
  40707. 'dollarinferior',
  40708. 'periodinferior',
  40709. 'commainferior'
  40710. ];
  40711. exports.ISOAdobeCharset = ISOAdobeCharset;
  40712. exports.ExpertCharset = ExpertCharset;
  40713. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40714. /***/ }),
  40715. /* 30 */
  40716. /***/ (function(module, exports, __w_pdfjs_require__) {
  40717. "use strict";
  40718. var sharedUtil = __w_pdfjs_require__(0);
  40719. var corePrimitives = __w_pdfjs_require__(1);
  40720. var coreStream = __w_pdfjs_require__(2);
  40721. var coreParser = __w_pdfjs_require__(6);
  40722. var Util = sharedUtil.Util;
  40723. var assert = sharedUtil.assert;
  40724. var warn = sharedUtil.warn;
  40725. var error = sharedUtil.error;
  40726. var isInt = sharedUtil.isInt;
  40727. var isString = sharedUtil.isString;
  40728. var MissingDataException = sharedUtil.MissingDataException;
  40729. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40730. var isEOF = corePrimitives.isEOF;
  40731. var isName = corePrimitives.isName;
  40732. var isCmd = corePrimitives.isCmd;
  40733. var isStream = corePrimitives.isStream;
  40734. var Stream = coreStream.Stream;
  40735. var Lexer = coreParser.Lexer;
  40736. var BUILT_IN_CMAPS = [
  40737. 'Adobe-GB1-UCS2',
  40738. 'Adobe-CNS1-UCS2',
  40739. 'Adobe-Japan1-UCS2',
  40740. 'Adobe-Korea1-UCS2',
  40741. '78-EUC-H',
  40742. '78-EUC-V',
  40743. '78-H',
  40744. '78-RKSJ-H',
  40745. '78-RKSJ-V',
  40746. '78-V',
  40747. '78ms-RKSJ-H',
  40748. '78ms-RKSJ-V',
  40749. '83pv-RKSJ-H',
  40750. '90ms-RKSJ-H',
  40751. '90ms-RKSJ-V',
  40752. '90msp-RKSJ-H',
  40753. '90msp-RKSJ-V',
  40754. '90pv-RKSJ-H',
  40755. '90pv-RKSJ-V',
  40756. 'Add-H',
  40757. 'Add-RKSJ-H',
  40758. 'Add-RKSJ-V',
  40759. 'Add-V',
  40760. 'Adobe-CNS1-0',
  40761. 'Adobe-CNS1-1',
  40762. 'Adobe-CNS1-2',
  40763. 'Adobe-CNS1-3',
  40764. 'Adobe-CNS1-4',
  40765. 'Adobe-CNS1-5',
  40766. 'Adobe-CNS1-6',
  40767. 'Adobe-GB1-0',
  40768. 'Adobe-GB1-1',
  40769. 'Adobe-GB1-2',
  40770. 'Adobe-GB1-3',
  40771. 'Adobe-GB1-4',
  40772. 'Adobe-GB1-5',
  40773. 'Adobe-Japan1-0',
  40774. 'Adobe-Japan1-1',
  40775. 'Adobe-Japan1-2',
  40776. 'Adobe-Japan1-3',
  40777. 'Adobe-Japan1-4',
  40778. 'Adobe-Japan1-5',
  40779. 'Adobe-Japan1-6',
  40780. 'Adobe-Korea1-0',
  40781. 'Adobe-Korea1-1',
  40782. 'Adobe-Korea1-2',
  40783. 'B5-H',
  40784. 'B5-V',
  40785. 'B5pc-H',
  40786. 'B5pc-V',
  40787. 'CNS-EUC-H',
  40788. 'CNS-EUC-V',
  40789. 'CNS1-H',
  40790. 'CNS1-V',
  40791. 'CNS2-H',
  40792. 'CNS2-V',
  40793. 'ETHK-B5-H',
  40794. 'ETHK-B5-V',
  40795. 'ETen-B5-H',
  40796. 'ETen-B5-V',
  40797. 'ETenms-B5-H',
  40798. 'ETenms-B5-V',
  40799. 'EUC-H',
  40800. 'EUC-V',
  40801. 'Ext-H',
  40802. 'Ext-RKSJ-H',
  40803. 'Ext-RKSJ-V',
  40804. 'Ext-V',
  40805. 'GB-EUC-H',
  40806. 'GB-EUC-V',
  40807. 'GB-H',
  40808. 'GB-V',
  40809. 'GBK-EUC-H',
  40810. 'GBK-EUC-V',
  40811. 'GBK2K-H',
  40812. 'GBK2K-V',
  40813. 'GBKp-EUC-H',
  40814. 'GBKp-EUC-V',
  40815. 'GBT-EUC-H',
  40816. 'GBT-EUC-V',
  40817. 'GBT-H',
  40818. 'GBT-V',
  40819. 'GBTpc-EUC-H',
  40820. 'GBTpc-EUC-V',
  40821. 'GBpc-EUC-H',
  40822. 'GBpc-EUC-V',
  40823. 'H',
  40824. 'HKdla-B5-H',
  40825. 'HKdla-B5-V',
  40826. 'HKdlb-B5-H',
  40827. 'HKdlb-B5-V',
  40828. 'HKgccs-B5-H',
  40829. 'HKgccs-B5-V',
  40830. 'HKm314-B5-H',
  40831. 'HKm314-B5-V',
  40832. 'HKm471-B5-H',
  40833. 'HKm471-B5-V',
  40834. 'HKscs-B5-H',
  40835. 'HKscs-B5-V',
  40836. 'Hankaku',
  40837. 'Hiragana',
  40838. 'KSC-EUC-H',
  40839. 'KSC-EUC-V',
  40840. 'KSC-H',
  40841. 'KSC-Johab-H',
  40842. 'KSC-Johab-V',
  40843. 'KSC-V',
  40844. 'KSCms-UHC-H',
  40845. 'KSCms-UHC-HW-H',
  40846. 'KSCms-UHC-HW-V',
  40847. 'KSCms-UHC-V',
  40848. 'KSCpc-EUC-H',
  40849. 'KSCpc-EUC-V',
  40850. 'Katakana',
  40851. 'NWP-H',
  40852. 'NWP-V',
  40853. 'RKSJ-H',
  40854. 'RKSJ-V',
  40855. 'Roman',
  40856. 'UniCNS-UCS2-H',
  40857. 'UniCNS-UCS2-V',
  40858. 'UniCNS-UTF16-H',
  40859. 'UniCNS-UTF16-V',
  40860. 'UniCNS-UTF32-H',
  40861. 'UniCNS-UTF32-V',
  40862. 'UniCNS-UTF8-H',
  40863. 'UniCNS-UTF8-V',
  40864. 'UniGB-UCS2-H',
  40865. 'UniGB-UCS2-V',
  40866. 'UniGB-UTF16-H',
  40867. 'UniGB-UTF16-V',
  40868. 'UniGB-UTF32-H',
  40869. 'UniGB-UTF32-V',
  40870. 'UniGB-UTF8-H',
  40871. 'UniGB-UTF8-V',
  40872. 'UniJIS-UCS2-H',
  40873. 'UniJIS-UCS2-HW-H',
  40874. 'UniJIS-UCS2-HW-V',
  40875. 'UniJIS-UCS2-V',
  40876. 'UniJIS-UTF16-H',
  40877. 'UniJIS-UTF16-V',
  40878. 'UniJIS-UTF32-H',
  40879. 'UniJIS-UTF32-V',
  40880. 'UniJIS-UTF8-H',
  40881. 'UniJIS-UTF8-V',
  40882. 'UniJIS2004-UTF16-H',
  40883. 'UniJIS2004-UTF16-V',
  40884. 'UniJIS2004-UTF32-H',
  40885. 'UniJIS2004-UTF32-V',
  40886. 'UniJIS2004-UTF8-H',
  40887. 'UniJIS2004-UTF8-V',
  40888. 'UniJISPro-UCS2-HW-V',
  40889. 'UniJISPro-UCS2-V',
  40890. 'UniJISPro-UTF8-V',
  40891. 'UniJISX0213-UTF32-H',
  40892. 'UniJISX0213-UTF32-V',
  40893. 'UniJISX02132004-UTF32-H',
  40894. 'UniJISX02132004-UTF32-V',
  40895. 'UniKS-UCS2-H',
  40896. 'UniKS-UCS2-V',
  40897. 'UniKS-UTF16-H',
  40898. 'UniKS-UTF16-V',
  40899. 'UniKS-UTF32-H',
  40900. 'UniKS-UTF32-V',
  40901. 'UniKS-UTF8-H',
  40902. 'UniKS-UTF8-V',
  40903. 'V',
  40904. 'WP-Symbol'
  40905. ];
  40906. var CMap = function CMapClosure() {
  40907. function CMap(builtInCMap) {
  40908. this.codespaceRanges = [
  40909. [],
  40910. [],
  40911. [],
  40912. []
  40913. ];
  40914. this.numCodespaceRanges = 0;
  40915. this._map = [];
  40916. this.name = '';
  40917. this.vertical = false;
  40918. this.useCMap = null;
  40919. this.builtInCMap = builtInCMap;
  40920. }
  40921. CMap.prototype = {
  40922. addCodespaceRange: function (n, low, high) {
  40923. this.codespaceRanges[n - 1].push(low, high);
  40924. this.numCodespaceRanges++;
  40925. },
  40926. mapCidRange: function (low, high, dstLow) {
  40927. while (low <= high) {
  40928. this._map[low++] = dstLow++;
  40929. }
  40930. },
  40931. mapBfRange: function (low, high, dstLow) {
  40932. var lastByte = dstLow.length - 1;
  40933. while (low <= high) {
  40934. this._map[low++] = dstLow;
  40935. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40936. }
  40937. },
  40938. mapBfRangeToArray: function (low, high, array) {
  40939. var i = 0, ii = array.length;
  40940. while (low <= high && i < ii) {
  40941. this._map[low] = array[i++];
  40942. ++low;
  40943. }
  40944. },
  40945. mapOne: function (src, dst) {
  40946. this._map[src] = dst;
  40947. },
  40948. lookup: function (code) {
  40949. return this._map[code];
  40950. },
  40951. contains: function (code) {
  40952. return this._map[code] !== undefined;
  40953. },
  40954. forEach: function (callback) {
  40955. var map = this._map;
  40956. var length = map.length;
  40957. var i;
  40958. if (length <= 0x10000) {
  40959. for (i = 0; i < length; i++) {
  40960. if (map[i] !== undefined) {
  40961. callback(i, map[i]);
  40962. }
  40963. }
  40964. } else {
  40965. for (i in this._map) {
  40966. callback(i, map[i]);
  40967. }
  40968. }
  40969. },
  40970. charCodeOf: function (value) {
  40971. return this._map.indexOf(value);
  40972. },
  40973. getMap: function () {
  40974. return this._map;
  40975. },
  40976. readCharCode: function (str, offset, out) {
  40977. var c = 0;
  40978. var codespaceRanges = this.codespaceRanges;
  40979. var codespaceRangesLen = this.codespaceRanges.length;
  40980. for (var n = 0; n < codespaceRangesLen; n++) {
  40981. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  40982. var codespaceRange = codespaceRanges[n];
  40983. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  40984. var low = codespaceRange[k++];
  40985. var high = codespaceRange[k++];
  40986. if (c >= low && c <= high) {
  40987. out.charcode = c;
  40988. out.length = n + 1;
  40989. return;
  40990. }
  40991. }
  40992. }
  40993. out.charcode = 0;
  40994. out.length = 1;
  40995. },
  40996. get length() {
  40997. return this._map.length;
  40998. },
  40999. get isIdentityCMap() {
  41000. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41001. return false;
  41002. }
  41003. if (this._map.length !== 0x10000) {
  41004. return false;
  41005. }
  41006. for (var i = 0; i < 0x10000; i++) {
  41007. if (this._map[i] !== i) {
  41008. return false;
  41009. }
  41010. }
  41011. return true;
  41012. }
  41013. };
  41014. return CMap;
  41015. }();
  41016. var IdentityCMap = function IdentityCMapClosure() {
  41017. function IdentityCMap(vertical, n) {
  41018. CMap.call(this);
  41019. this.vertical = vertical;
  41020. this.addCodespaceRange(n, 0, 0xffff);
  41021. }
  41022. Util.inherit(IdentityCMap, CMap, {});
  41023. IdentityCMap.prototype = {
  41024. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41025. mapCidRange: function (low, high, dstLow) {
  41026. error('should not call mapCidRange');
  41027. },
  41028. mapBfRange: function (low, high, dstLow) {
  41029. error('should not call mapBfRange');
  41030. },
  41031. mapBfRangeToArray: function (low, high, array) {
  41032. error('should not call mapBfRangeToArray');
  41033. },
  41034. mapOne: function (src, dst) {
  41035. error('should not call mapCidOne');
  41036. },
  41037. lookup: function (code) {
  41038. return isInt(code) && code <= 0xffff ? code : undefined;
  41039. },
  41040. contains: function (code) {
  41041. return isInt(code) && code <= 0xffff;
  41042. },
  41043. forEach: function (callback) {
  41044. for (var i = 0; i <= 0xffff; i++) {
  41045. callback(i, i);
  41046. }
  41047. },
  41048. charCodeOf: function (value) {
  41049. return isInt(value) && value <= 0xffff ? value : -1;
  41050. },
  41051. getMap: function () {
  41052. var map = new Array(0x10000);
  41053. for (var i = 0; i <= 0xffff; i++) {
  41054. map[i] = i;
  41055. }
  41056. return map;
  41057. },
  41058. readCharCode: CMap.prototype.readCharCode,
  41059. get length() {
  41060. return 0x10000;
  41061. },
  41062. get isIdentityCMap() {
  41063. error('should not access .isIdentityCMap');
  41064. }
  41065. };
  41066. return IdentityCMap;
  41067. }();
  41068. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41069. function hexToInt(a, size) {
  41070. var n = 0;
  41071. for (var i = 0; i <= size; i++) {
  41072. n = n << 8 | a[i];
  41073. }
  41074. return n >>> 0;
  41075. }
  41076. function hexToStr(a, size) {
  41077. if (size === 1) {
  41078. return String.fromCharCode(a[0], a[1]);
  41079. }
  41080. if (size === 3) {
  41081. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41082. }
  41083. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41084. }
  41085. function addHex(a, b, size) {
  41086. var c = 0;
  41087. for (var i = size; i >= 0; i--) {
  41088. c += a[i] + b[i];
  41089. a[i] = c & 255;
  41090. c >>= 8;
  41091. }
  41092. }
  41093. function incHex(a, size) {
  41094. var c = 1;
  41095. for (var i = size; i >= 0 && c > 0; i--) {
  41096. c += a[i];
  41097. a[i] = c & 255;
  41098. c >>= 8;
  41099. }
  41100. }
  41101. var MAX_NUM_SIZE = 16;
  41102. var MAX_ENCODED_NUM_SIZE = 19;
  41103. function BinaryCMapStream(data) {
  41104. this.buffer = data;
  41105. this.pos = 0;
  41106. this.end = data.length;
  41107. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41108. }
  41109. BinaryCMapStream.prototype = {
  41110. readByte: function () {
  41111. if (this.pos >= this.end) {
  41112. return -1;
  41113. }
  41114. return this.buffer[this.pos++];
  41115. },
  41116. readNumber: function () {
  41117. var n = 0;
  41118. var last;
  41119. do {
  41120. var b = this.readByte();
  41121. if (b < 0) {
  41122. error('unexpected EOF in bcmap');
  41123. }
  41124. last = !(b & 0x80);
  41125. n = n << 7 | b & 0x7F;
  41126. } while (!last);
  41127. return n;
  41128. },
  41129. readSigned: function () {
  41130. var n = this.readNumber();
  41131. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41132. },
  41133. readHex: function (num, size) {
  41134. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41135. this.pos += size + 1;
  41136. },
  41137. readHexNumber: function (num, size) {
  41138. var last;
  41139. var stack = this.tmpBuf, sp = 0;
  41140. do {
  41141. var b = this.readByte();
  41142. if (b < 0) {
  41143. error('unexpected EOF in bcmap');
  41144. }
  41145. last = !(b & 0x80);
  41146. stack[sp++] = b & 0x7F;
  41147. } while (!last);
  41148. var i = size, buffer = 0, bufferSize = 0;
  41149. while (i >= 0) {
  41150. while (bufferSize < 8 && stack.length > 0) {
  41151. buffer = stack[--sp] << bufferSize | buffer;
  41152. bufferSize += 7;
  41153. }
  41154. num[i] = buffer & 255;
  41155. i--;
  41156. buffer >>= 8;
  41157. bufferSize -= 8;
  41158. }
  41159. },
  41160. readHexSigned: function (num, size) {
  41161. this.readHexNumber(num, size);
  41162. var sign = num[size] & 1 ? 255 : 0;
  41163. var c = 0;
  41164. for (var i = 0; i <= size; i++) {
  41165. c = (c & 1) << 8 | num[i];
  41166. num[i] = c >> 1 ^ sign;
  41167. }
  41168. },
  41169. readString: function () {
  41170. var len = this.readNumber();
  41171. var s = '';
  41172. for (var i = 0; i < len; i++) {
  41173. s += String.fromCharCode(this.readNumber());
  41174. }
  41175. return s;
  41176. }
  41177. };
  41178. function processBinaryCMap(data, cMap, extend) {
  41179. return new Promise(function (resolve, reject) {
  41180. var stream = new BinaryCMapStream(data);
  41181. var header = stream.readByte();
  41182. cMap.vertical = !!(header & 1);
  41183. var useCMap = null;
  41184. var start = new Uint8Array(MAX_NUM_SIZE);
  41185. var end = new Uint8Array(MAX_NUM_SIZE);
  41186. var char = new Uint8Array(MAX_NUM_SIZE);
  41187. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41188. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41189. var code;
  41190. var b;
  41191. while ((b = stream.readByte()) >= 0) {
  41192. var type = b >> 5;
  41193. if (type === 7) {
  41194. switch (b & 0x1F) {
  41195. case 0:
  41196. stream.readString();
  41197. break;
  41198. case 1:
  41199. useCMap = stream.readString();
  41200. break;
  41201. }
  41202. continue;
  41203. }
  41204. var sequence = !!(b & 0x10);
  41205. var dataSize = b & 15;
  41206. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41207. var ucs2DataSize = 1;
  41208. var subitemsCount = stream.readNumber();
  41209. var i;
  41210. switch (type) {
  41211. case 0:
  41212. stream.readHex(start, dataSize);
  41213. stream.readHexNumber(end, dataSize);
  41214. addHex(end, start, dataSize);
  41215. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41216. for (i = 1; i < subitemsCount; i++) {
  41217. incHex(end, dataSize);
  41218. stream.readHexNumber(start, dataSize);
  41219. addHex(start, end, dataSize);
  41220. stream.readHexNumber(end, dataSize);
  41221. addHex(end, start, dataSize);
  41222. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41223. }
  41224. break;
  41225. case 1:
  41226. stream.readHex(start, dataSize);
  41227. stream.readHexNumber(end, dataSize);
  41228. addHex(end, start, dataSize);
  41229. code = stream.readNumber();
  41230. for (i = 1; i < subitemsCount; i++) {
  41231. incHex(end, dataSize);
  41232. stream.readHexNumber(start, dataSize);
  41233. addHex(start, end, dataSize);
  41234. stream.readHexNumber(end, dataSize);
  41235. addHex(end, start, dataSize);
  41236. code = stream.readNumber();
  41237. }
  41238. break;
  41239. case 2:
  41240. stream.readHex(char, dataSize);
  41241. code = stream.readNumber();
  41242. cMap.mapOne(hexToInt(char, dataSize), code);
  41243. for (i = 1; i < subitemsCount; i++) {
  41244. incHex(char, dataSize);
  41245. if (!sequence) {
  41246. stream.readHexNumber(tmp, dataSize);
  41247. addHex(char, tmp, dataSize);
  41248. }
  41249. code = stream.readSigned() + (code + 1);
  41250. cMap.mapOne(hexToInt(char, dataSize), code);
  41251. }
  41252. break;
  41253. case 3:
  41254. stream.readHex(start, dataSize);
  41255. stream.readHexNumber(end, dataSize);
  41256. addHex(end, start, dataSize);
  41257. code = stream.readNumber();
  41258. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41259. for (i = 1; i < subitemsCount; i++) {
  41260. incHex(end, dataSize);
  41261. if (!sequence) {
  41262. stream.readHexNumber(start, dataSize);
  41263. addHex(start, end, dataSize);
  41264. } else {
  41265. start.set(end);
  41266. }
  41267. stream.readHexNumber(end, dataSize);
  41268. addHex(end, start, dataSize);
  41269. code = stream.readNumber();
  41270. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41271. }
  41272. break;
  41273. case 4:
  41274. stream.readHex(char, ucs2DataSize);
  41275. stream.readHex(charCode, dataSize);
  41276. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41277. for (i = 1; i < subitemsCount; i++) {
  41278. incHex(char, ucs2DataSize);
  41279. if (!sequence) {
  41280. stream.readHexNumber(tmp, ucs2DataSize);
  41281. addHex(char, tmp, ucs2DataSize);
  41282. }
  41283. incHex(charCode, dataSize);
  41284. stream.readHexSigned(tmp, dataSize);
  41285. addHex(charCode, tmp, dataSize);
  41286. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41287. }
  41288. break;
  41289. case 5:
  41290. stream.readHex(start, ucs2DataSize);
  41291. stream.readHexNumber(end, ucs2DataSize);
  41292. addHex(end, start, ucs2DataSize);
  41293. stream.readHex(charCode, dataSize);
  41294. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41295. for (i = 1; i < subitemsCount; i++) {
  41296. incHex(end, ucs2DataSize);
  41297. if (!sequence) {
  41298. stream.readHexNumber(start, ucs2DataSize);
  41299. addHex(start, end, ucs2DataSize);
  41300. } else {
  41301. start.set(end);
  41302. }
  41303. stream.readHexNumber(end, ucs2DataSize);
  41304. addHex(end, start, ucs2DataSize);
  41305. stream.readHex(charCode, dataSize);
  41306. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41307. }
  41308. break;
  41309. default:
  41310. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41311. return;
  41312. }
  41313. }
  41314. if (useCMap) {
  41315. resolve(extend(useCMap));
  41316. return;
  41317. }
  41318. resolve(cMap);
  41319. });
  41320. }
  41321. function BinaryCMapReader() {
  41322. }
  41323. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41324. return BinaryCMapReader;
  41325. }();
  41326. var CMapFactory = function CMapFactoryClosure() {
  41327. function strToInt(str) {
  41328. var a = 0;
  41329. for (var i = 0; i < str.length; i++) {
  41330. a = a << 8 | str.charCodeAt(i);
  41331. }
  41332. return a >>> 0;
  41333. }
  41334. function expectString(obj) {
  41335. if (!isString(obj)) {
  41336. error('Malformed CMap: expected string.');
  41337. }
  41338. }
  41339. function expectInt(obj) {
  41340. if (!isInt(obj)) {
  41341. error('Malformed CMap: expected int.');
  41342. }
  41343. }
  41344. function parseBfChar(cMap, lexer) {
  41345. while (true) {
  41346. var obj = lexer.getObj();
  41347. if (isEOF(obj)) {
  41348. break;
  41349. }
  41350. if (isCmd(obj, 'endbfchar')) {
  41351. return;
  41352. }
  41353. expectString(obj);
  41354. var src = strToInt(obj);
  41355. obj = lexer.getObj();
  41356. expectString(obj);
  41357. var dst = obj;
  41358. cMap.mapOne(src, dst);
  41359. }
  41360. }
  41361. function parseBfRange(cMap, lexer) {
  41362. while (true) {
  41363. var obj = lexer.getObj();
  41364. if (isEOF(obj)) {
  41365. break;
  41366. }
  41367. if (isCmd(obj, 'endbfrange')) {
  41368. return;
  41369. }
  41370. expectString(obj);
  41371. var low = strToInt(obj);
  41372. obj = lexer.getObj();
  41373. expectString(obj);
  41374. var high = strToInt(obj);
  41375. obj = lexer.getObj();
  41376. if (isInt(obj) || isString(obj)) {
  41377. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41378. cMap.mapBfRange(low, high, dstLow);
  41379. } else if (isCmd(obj, '[')) {
  41380. obj = lexer.getObj();
  41381. var array = [];
  41382. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41383. array.push(obj);
  41384. obj = lexer.getObj();
  41385. }
  41386. cMap.mapBfRangeToArray(low, high, array);
  41387. } else {
  41388. break;
  41389. }
  41390. }
  41391. error('Invalid bf range.');
  41392. }
  41393. function parseCidChar(cMap, lexer) {
  41394. while (true) {
  41395. var obj = lexer.getObj();
  41396. if (isEOF(obj)) {
  41397. break;
  41398. }
  41399. if (isCmd(obj, 'endcidchar')) {
  41400. return;
  41401. }
  41402. expectString(obj);
  41403. var src = strToInt(obj);
  41404. obj = lexer.getObj();
  41405. expectInt(obj);
  41406. var dst = obj;
  41407. cMap.mapOne(src, dst);
  41408. }
  41409. }
  41410. function parseCidRange(cMap, lexer) {
  41411. while (true) {
  41412. var obj = lexer.getObj();
  41413. if (isEOF(obj)) {
  41414. break;
  41415. }
  41416. if (isCmd(obj, 'endcidrange')) {
  41417. return;
  41418. }
  41419. expectString(obj);
  41420. var low = strToInt(obj);
  41421. obj = lexer.getObj();
  41422. expectString(obj);
  41423. var high = strToInt(obj);
  41424. obj = lexer.getObj();
  41425. expectInt(obj);
  41426. var dstLow = obj;
  41427. cMap.mapCidRange(low, high, dstLow);
  41428. }
  41429. }
  41430. function parseCodespaceRange(cMap, lexer) {
  41431. while (true) {
  41432. var obj = lexer.getObj();
  41433. if (isEOF(obj)) {
  41434. break;
  41435. }
  41436. if (isCmd(obj, 'endcodespacerange')) {
  41437. return;
  41438. }
  41439. if (!isString(obj)) {
  41440. break;
  41441. }
  41442. var low = strToInt(obj);
  41443. obj = lexer.getObj();
  41444. if (!isString(obj)) {
  41445. break;
  41446. }
  41447. var high = strToInt(obj);
  41448. cMap.addCodespaceRange(obj.length, low, high);
  41449. }
  41450. error('Invalid codespace range.');
  41451. }
  41452. function parseWMode(cMap, lexer) {
  41453. var obj = lexer.getObj();
  41454. if (isInt(obj)) {
  41455. cMap.vertical = !!obj;
  41456. }
  41457. }
  41458. function parseCMapName(cMap, lexer) {
  41459. var obj = lexer.getObj();
  41460. if (isName(obj) && isString(obj.name)) {
  41461. cMap.name = obj.name;
  41462. }
  41463. }
  41464. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41465. var previous;
  41466. var embededUseCMap;
  41467. objLoop:
  41468. while (true) {
  41469. try {
  41470. var obj = lexer.getObj();
  41471. if (isEOF(obj)) {
  41472. break;
  41473. } else if (isName(obj)) {
  41474. if (obj.name === 'WMode') {
  41475. parseWMode(cMap, lexer);
  41476. } else if (obj.name === 'CMapName') {
  41477. parseCMapName(cMap, lexer);
  41478. }
  41479. previous = obj;
  41480. } else if (isCmd(obj)) {
  41481. switch (obj.cmd) {
  41482. case 'endcmap':
  41483. break objLoop;
  41484. case 'usecmap':
  41485. if (isName(previous)) {
  41486. embededUseCMap = previous.name;
  41487. }
  41488. break;
  41489. case 'begincodespacerange':
  41490. parseCodespaceRange(cMap, lexer);
  41491. break;
  41492. case 'beginbfchar':
  41493. parseBfChar(cMap, lexer);
  41494. break;
  41495. case 'begincidchar':
  41496. parseCidChar(cMap, lexer);
  41497. break;
  41498. case 'beginbfrange':
  41499. parseBfRange(cMap, lexer);
  41500. break;
  41501. case 'begincidrange':
  41502. parseCidRange(cMap, lexer);
  41503. break;
  41504. }
  41505. }
  41506. } catch (ex) {
  41507. if (ex instanceof MissingDataException) {
  41508. throw ex;
  41509. }
  41510. warn('Invalid cMap data: ' + ex);
  41511. continue;
  41512. }
  41513. }
  41514. if (!useCMap && embededUseCMap) {
  41515. useCMap = embededUseCMap;
  41516. }
  41517. if (useCMap) {
  41518. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41519. }
  41520. return Promise.resolve(cMap);
  41521. }
  41522. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41523. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41524. cMap.useCMap = newCMap;
  41525. if (cMap.numCodespaceRanges === 0) {
  41526. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41527. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41528. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41529. }
  41530. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41531. }
  41532. cMap.useCMap.forEach(function (key, value) {
  41533. if (!cMap.contains(key)) {
  41534. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41535. }
  41536. });
  41537. return cMap;
  41538. });
  41539. }
  41540. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41541. if (name === 'Identity-H') {
  41542. return Promise.resolve(new IdentityCMap(false, 2));
  41543. } else if (name === 'Identity-V') {
  41544. return Promise.resolve(new IdentityCMap(true, 2));
  41545. }
  41546. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41547. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41548. }
  41549. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41550. return fetchBuiltInCMap(name).then(function (data) {
  41551. var cMapData = data.cMapData, compressionType = data.compressionType;
  41552. var cMap = new CMap(true);
  41553. if (compressionType === CMapCompressionType.BINARY) {
  41554. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41555. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41556. });
  41557. }
  41558. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41559. var lexer = new Lexer(new Stream(cMapData));
  41560. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41561. });
  41562. }
  41563. return {
  41564. create: function (params) {
  41565. var encoding = params.encoding;
  41566. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41567. var useCMap = params.useCMap;
  41568. if (isName(encoding)) {
  41569. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41570. } else if (isStream(encoding)) {
  41571. var cMap = new CMap();
  41572. var lexer = new Lexer(encoding);
  41573. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41574. if (parsedCMap.isIdentityCMap) {
  41575. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41576. }
  41577. return parsedCMap;
  41578. });
  41579. }
  41580. return Promise.reject(new Error('Encoding required.'));
  41581. }
  41582. };
  41583. }();
  41584. exports.CMap = CMap;
  41585. exports.CMapFactory = CMapFactory;
  41586. exports.IdentityCMap = IdentityCMap;
  41587. /***/ }),
  41588. /* 31 */
  41589. /***/ (function(module, exports, __w_pdfjs_require__) {
  41590. "use strict";
  41591. var sharedUtil = __w_pdfjs_require__(0);
  41592. var corePrimitives = __w_pdfjs_require__(1);
  41593. var coreStream = __w_pdfjs_require__(2);
  41594. var coreObj = __w_pdfjs_require__(20);
  41595. var coreParser = __w_pdfjs_require__(6);
  41596. var coreCrypto = __w_pdfjs_require__(17);
  41597. var coreEvaluator = __w_pdfjs_require__(18);
  41598. var coreAnnotation = __w_pdfjs_require__(27);
  41599. var OPS = sharedUtil.OPS;
  41600. var MissingDataException = sharedUtil.MissingDataException;
  41601. var Util = sharedUtil.Util;
  41602. var assert = sharedUtil.assert;
  41603. var error = sharedUtil.error;
  41604. var info = sharedUtil.info;
  41605. var isArray = sharedUtil.isArray;
  41606. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41607. var isNum = sharedUtil.isNum;
  41608. var isString = sharedUtil.isString;
  41609. var shadow = sharedUtil.shadow;
  41610. var stringToBytes = sharedUtil.stringToBytes;
  41611. var stringToPDFString = sharedUtil.stringToPDFString;
  41612. var warn = sharedUtil.warn;
  41613. var isSpace = sharedUtil.isSpace;
  41614. var Dict = corePrimitives.Dict;
  41615. var isDict = corePrimitives.isDict;
  41616. var isName = corePrimitives.isName;
  41617. var isStream = corePrimitives.isStream;
  41618. var NullStream = coreStream.NullStream;
  41619. var Stream = coreStream.Stream;
  41620. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41621. var Catalog = coreObj.Catalog;
  41622. var ObjectLoader = coreObj.ObjectLoader;
  41623. var XRef = coreObj.XRef;
  41624. var Linearization = coreParser.Linearization;
  41625. var calculateMD5 = coreCrypto.calculateMD5;
  41626. var OperatorList = coreEvaluator.OperatorList;
  41627. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41628. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41629. var Page = function PageClosure() {
  41630. var DEFAULT_USER_UNIT = 1.0;
  41631. var LETTER_SIZE_MEDIABOX = [
  41632. 0,
  41633. 0,
  41634. 612,
  41635. 792
  41636. ];
  41637. function isAnnotationRenderable(annotation, intent) {
  41638. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  41639. }
  41640. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41641. this.pdfManager = pdfManager;
  41642. this.pageIndex = pageIndex;
  41643. this.pageDict = pageDict;
  41644. this.xref = xref;
  41645. this.ref = ref;
  41646. this.fontCache = fontCache;
  41647. this.builtInCMapCache = builtInCMapCache;
  41648. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41649. this.resourcesPromise = null;
  41650. var uniquePrefix = 'p' + this.pageIndex + '_';
  41651. var idCounters = { obj: 0 };
  41652. this.idFactory = {
  41653. createObjId: function () {
  41654. return uniquePrefix + ++idCounters.obj;
  41655. }
  41656. };
  41657. }
  41658. Page.prototype = {
  41659. getPageProp: function Page_getPageProp(key) {
  41660. return this.pageDict.get(key);
  41661. },
  41662. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41663. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41664. var MAX_LOOP_COUNT = 100;
  41665. getArray = getArray || false;
  41666. while (dict) {
  41667. var value = getArray ? dict.getArray(key) : dict.get(key);
  41668. if (value !== undefined) {
  41669. if (!valueArray) {
  41670. valueArray = [];
  41671. }
  41672. valueArray.push(value);
  41673. }
  41674. if (++loopCount > MAX_LOOP_COUNT) {
  41675. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  41676. break;
  41677. }
  41678. dict = dict.get('Parent');
  41679. }
  41680. if (!valueArray) {
  41681. return Dict.empty;
  41682. }
  41683. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  41684. return valueArray[0];
  41685. }
  41686. return Dict.merge(this.xref, valueArray);
  41687. },
  41688. get content() {
  41689. return this.getPageProp('Contents');
  41690. },
  41691. get resources() {
  41692. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  41693. },
  41694. get mediaBox() {
  41695. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41696. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41697. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41698. }
  41699. return shadow(this, 'mediaBox', mediaBox);
  41700. },
  41701. get cropBox() {
  41702. var cropBox = this.getInheritedPageProp('CropBox', true);
  41703. if (!isArray(cropBox) || cropBox.length !== 4) {
  41704. return shadow(this, 'cropBox', this.mediaBox);
  41705. }
  41706. return shadow(this, 'cropBox', cropBox);
  41707. },
  41708. get userUnit() {
  41709. var obj = this.getPageProp('UserUnit');
  41710. if (!isNum(obj) || obj <= 0) {
  41711. obj = DEFAULT_USER_UNIT;
  41712. }
  41713. return shadow(this, 'userUnit', obj);
  41714. },
  41715. get view() {
  41716. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41717. if (mediaBox === cropBox) {
  41718. return shadow(this, 'view', mediaBox);
  41719. }
  41720. var intersection = Util.intersect(cropBox, mediaBox);
  41721. return shadow(this, 'view', intersection || mediaBox);
  41722. },
  41723. get rotate() {
  41724. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41725. if (rotate % 90 !== 0) {
  41726. rotate = 0;
  41727. } else if (rotate >= 360) {
  41728. rotate = rotate % 360;
  41729. } else if (rotate < 0) {
  41730. rotate = (rotate % 360 + 360) % 360;
  41731. }
  41732. return shadow(this, 'rotate', rotate);
  41733. },
  41734. getContentStream: function Page_getContentStream() {
  41735. var content = this.content;
  41736. var stream;
  41737. if (isArray(content)) {
  41738. var xref = this.xref;
  41739. var i, n = content.length;
  41740. var streams = [];
  41741. for (i = 0; i < n; ++i) {
  41742. streams.push(xref.fetchIfRef(content[i]));
  41743. }
  41744. stream = new StreamsSequenceStream(streams);
  41745. } else if (isStream(content)) {
  41746. stream = content;
  41747. } else {
  41748. stream = new NullStream();
  41749. }
  41750. return stream;
  41751. },
  41752. loadResources: function Page_loadResources(keys) {
  41753. if (!this.resourcesPromise) {
  41754. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41755. }
  41756. return this.resourcesPromise.then(function resourceSuccess() {
  41757. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41758. return objectLoader.load();
  41759. }.bind(this));
  41760. },
  41761. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41762. var self = this;
  41763. var pdfManager = this.pdfManager;
  41764. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41765. var resourcesPromise = this.loadResources([
  41766. 'ExtGState',
  41767. 'ColorSpace',
  41768. 'Pattern',
  41769. 'Shading',
  41770. 'XObject',
  41771. 'Font'
  41772. ]);
  41773. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41774. var dataPromises = Promise.all([
  41775. contentStreamPromise,
  41776. resourcesPromise
  41777. ]);
  41778. var pageListPromise = dataPromises.then(function (data) {
  41779. var contentStream = data[0];
  41780. var opList = new OperatorList(intent, handler, self.pageIndex);
  41781. handler.send('StartRenderPage', {
  41782. transparency: partialEvaluator.hasBlendModes(self.resources),
  41783. pageIndex: self.pageIndex,
  41784. intent: intent
  41785. });
  41786. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41787. return opList;
  41788. });
  41789. });
  41790. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41791. return Promise.all([
  41792. pageListPromise,
  41793. annotationsPromise
  41794. ]).then(function (datas) {
  41795. var pageOpList = datas[0];
  41796. var annotations = datas[1];
  41797. if (annotations.length === 0) {
  41798. pageOpList.flush(true);
  41799. return pageOpList;
  41800. }
  41801. var i, ii, opListPromises = [];
  41802. for (i = 0, ii = annotations.length; i < ii; i++) {
  41803. if (isAnnotationRenderable(annotations[i], intent)) {
  41804. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  41805. }
  41806. }
  41807. return Promise.all(opListPromises).then(function (opLists) {
  41808. pageOpList.addOp(OPS.beginAnnotations, []);
  41809. for (i = 0, ii = opLists.length; i < ii; i++) {
  41810. pageOpList.addOpList(opLists[i]);
  41811. }
  41812. pageOpList.addOp(OPS.endAnnotations, []);
  41813. pageOpList.flush(true);
  41814. return pageOpList;
  41815. });
  41816. });
  41817. },
  41818. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  41819. var handler = {
  41820. on: function nullHandlerOn() {
  41821. },
  41822. send: function nullHandlerSend() {
  41823. }
  41824. };
  41825. var self = this;
  41826. var pdfManager = this.pdfManager;
  41827. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41828. var resourcesPromise = this.loadResources([
  41829. 'ExtGState',
  41830. 'XObject',
  41831. 'Font'
  41832. ]);
  41833. var dataPromises = Promise.all([
  41834. contentStreamPromise,
  41835. resourcesPromise
  41836. ]);
  41837. return dataPromises.then(function (data) {
  41838. var contentStream = data[0];
  41839. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41840. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41841. });
  41842. },
  41843. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41844. var annotations = this.annotations;
  41845. var annotationsData = [];
  41846. for (var i = 0, n = annotations.length; i < n; ++i) {
  41847. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  41848. annotationsData.push(annotations[i].data);
  41849. }
  41850. }
  41851. return annotationsData;
  41852. },
  41853. get annotations() {
  41854. var annotations = [];
  41855. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41856. var annotationFactory = new AnnotationFactory();
  41857. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41858. var annotationRef = annotationRefs[i];
  41859. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41860. if (annotation) {
  41861. annotations.push(annotation);
  41862. }
  41863. }
  41864. return shadow(this, 'annotations', annotations);
  41865. }
  41866. };
  41867. return Page;
  41868. }();
  41869. var PDFDocument = function PDFDocumentClosure() {
  41870. var FINGERPRINT_FIRST_BYTES = 1024;
  41871. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41872. function PDFDocument(pdfManager, arg) {
  41873. var stream;
  41874. if (isStream(arg)) {
  41875. stream = arg;
  41876. } else if (isArrayBuffer(arg)) {
  41877. stream = new Stream(arg);
  41878. } else {
  41879. error('PDFDocument: Unknown argument type');
  41880. }
  41881. assert(stream.length > 0, 'stream must have data');
  41882. this.pdfManager = pdfManager;
  41883. this.stream = stream;
  41884. this.xref = new XRef(stream, pdfManager);
  41885. }
  41886. function find(stream, needle, limit, backwards) {
  41887. var pos = stream.pos;
  41888. var end = stream.end;
  41889. var strBuf = [];
  41890. if (pos + limit > end) {
  41891. limit = end - pos;
  41892. }
  41893. for (var n = 0; n < limit; ++n) {
  41894. strBuf.push(String.fromCharCode(stream.getByte()));
  41895. }
  41896. var str = strBuf.join('');
  41897. stream.pos = pos;
  41898. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41899. if (index === -1) {
  41900. return false;
  41901. }
  41902. stream.pos += index;
  41903. return true;
  41904. }
  41905. var DocumentInfoValidators = {
  41906. get entries() {
  41907. return shadow(this, 'entries', {
  41908. Title: isString,
  41909. Author: isString,
  41910. Subject: isString,
  41911. Keywords: isString,
  41912. Creator: isString,
  41913. Producer: isString,
  41914. CreationDate: isString,
  41915. ModDate: isString,
  41916. Trapped: isName
  41917. });
  41918. }
  41919. };
  41920. PDFDocument.prototype = {
  41921. parse: function PDFDocument_parse(recoveryMode) {
  41922. this.setup(recoveryMode);
  41923. var version = this.catalog.catDict.get('Version');
  41924. if (isName(version)) {
  41925. this.pdfFormatVersion = version.name;
  41926. }
  41927. try {
  41928. this.acroForm = this.catalog.catDict.get('AcroForm');
  41929. if (this.acroForm) {
  41930. this.xfa = this.acroForm.get('XFA');
  41931. var fields = this.acroForm.get('Fields');
  41932. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41933. this.acroForm = null;
  41934. }
  41935. }
  41936. } catch (ex) {
  41937. info('Something wrong with AcroForm entry');
  41938. this.acroForm = null;
  41939. }
  41940. },
  41941. get linearization() {
  41942. var linearization = null;
  41943. if (this.stream.length) {
  41944. try {
  41945. linearization = Linearization.create(this.stream);
  41946. } catch (err) {
  41947. if (err instanceof MissingDataException) {
  41948. throw err;
  41949. }
  41950. info(err);
  41951. }
  41952. }
  41953. return shadow(this, 'linearization', linearization);
  41954. },
  41955. get startXRef() {
  41956. var stream = this.stream;
  41957. var startXRef = 0;
  41958. var linearization = this.linearization;
  41959. if (linearization) {
  41960. stream.reset();
  41961. if (find(stream, 'endobj', 1024)) {
  41962. startXRef = stream.pos + 6;
  41963. }
  41964. } else {
  41965. var step = 1024;
  41966. var found = false, pos = stream.end;
  41967. while (!found && pos > 0) {
  41968. pos -= step - 'startxref'.length;
  41969. if (pos < 0) {
  41970. pos = 0;
  41971. }
  41972. stream.pos = pos;
  41973. found = find(stream, 'startxref', step, true);
  41974. }
  41975. if (found) {
  41976. stream.skip(9);
  41977. var ch;
  41978. do {
  41979. ch = stream.getByte();
  41980. } while (isSpace(ch));
  41981. var str = '';
  41982. while (ch >= 0x20 && ch <= 0x39) {
  41983. str += String.fromCharCode(ch);
  41984. ch = stream.getByte();
  41985. }
  41986. startXRef = parseInt(str, 10);
  41987. if (isNaN(startXRef)) {
  41988. startXRef = 0;
  41989. }
  41990. }
  41991. }
  41992. return shadow(this, 'startXRef', startXRef);
  41993. },
  41994. get mainXRefEntriesOffset() {
  41995. var mainXRefEntriesOffset = 0;
  41996. var linearization = this.linearization;
  41997. if (linearization) {
  41998. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  41999. }
  42000. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42001. },
  42002. checkHeader: function PDFDocument_checkHeader() {
  42003. var stream = this.stream;
  42004. stream.reset();
  42005. if (find(stream, '%PDF-', 1024)) {
  42006. stream.moveStart();
  42007. var MAX_VERSION_LENGTH = 12;
  42008. var version = '', ch;
  42009. while ((ch = stream.getByte()) > 0x20) {
  42010. if (version.length >= MAX_VERSION_LENGTH) {
  42011. break;
  42012. }
  42013. version += String.fromCharCode(ch);
  42014. }
  42015. if (!this.pdfFormatVersion) {
  42016. this.pdfFormatVersion = version.substring(5);
  42017. }
  42018. return;
  42019. }
  42020. },
  42021. parseStartXRef: function PDFDocument_parseStartXRef() {
  42022. var startXRef = this.startXRef;
  42023. this.xref.setStartXRef(startXRef);
  42024. },
  42025. setup: function PDFDocument_setup(recoveryMode) {
  42026. this.xref.parse(recoveryMode);
  42027. var self = this;
  42028. var pageFactory = {
  42029. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42030. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42031. }
  42032. };
  42033. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42034. },
  42035. get numPages() {
  42036. var linearization = this.linearization;
  42037. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42038. return shadow(this, 'numPages', num);
  42039. },
  42040. get documentInfo() {
  42041. var docInfo = {
  42042. PDFFormatVersion: this.pdfFormatVersion,
  42043. IsAcroFormPresent: !!this.acroForm,
  42044. IsXFAPresent: !!this.xfa
  42045. };
  42046. var infoDict;
  42047. try {
  42048. infoDict = this.xref.trailer.get('Info');
  42049. } catch (err) {
  42050. info('The document information dictionary is invalid.');
  42051. }
  42052. if (infoDict) {
  42053. var validEntries = DocumentInfoValidators.entries;
  42054. for (var key in validEntries) {
  42055. if (infoDict.has(key)) {
  42056. var value = infoDict.get(key);
  42057. if (validEntries[key](value)) {
  42058. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42059. } else {
  42060. info('Bad value in document info for "' + key + '"');
  42061. }
  42062. }
  42063. }
  42064. }
  42065. return shadow(this, 'documentInfo', docInfo);
  42066. },
  42067. get fingerprint() {
  42068. var xref = this.xref, hash, fileID = '';
  42069. var idArray = xref.trailer.get('ID');
  42070. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42071. hash = stringToBytes(idArray[0]);
  42072. } else {
  42073. if (this.stream.ensureRange) {
  42074. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42075. }
  42076. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42077. }
  42078. for (var i = 0, n = hash.length; i < n; i++) {
  42079. var hex = hash[i].toString(16);
  42080. fileID += hex.length === 1 ? '0' + hex : hex;
  42081. }
  42082. return shadow(this, 'fingerprint', fileID);
  42083. },
  42084. getPage: function PDFDocument_getPage(pageIndex) {
  42085. return this.catalog.getPage(pageIndex);
  42086. },
  42087. cleanup: function PDFDocument_cleanup() {
  42088. return this.catalog.cleanup();
  42089. }
  42090. };
  42091. return PDFDocument;
  42092. }();
  42093. exports.Page = Page;
  42094. exports.PDFDocument = PDFDocument;
  42095. /***/ }),
  42096. /* 32 */
  42097. /***/ (function(module, exports, __w_pdfjs_require__) {
  42098. "use strict";
  42099. var sharedUtil = __w_pdfjs_require__(0);
  42100. var coreStream = __w_pdfjs_require__(2);
  42101. var coreGlyphList = __w_pdfjs_require__(8);
  42102. var coreEncodings = __w_pdfjs_require__(5);
  42103. var coreCFFParser = __w_pdfjs_require__(15);
  42104. var Util = sharedUtil.Util;
  42105. var bytesToString = sharedUtil.bytesToString;
  42106. var error = sharedUtil.error;
  42107. var Stream = coreStream.Stream;
  42108. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42109. var StandardEncoding = coreEncodings.StandardEncoding;
  42110. var CFFParser = coreCFFParser.CFFParser;
  42111. var FontRendererFactory = function FontRendererFactoryClosure() {
  42112. function getLong(data, offset) {
  42113. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42114. }
  42115. function getUshort(data, offset) {
  42116. return data[offset] << 8 | data[offset + 1];
  42117. }
  42118. function parseCmap(data, start, end) {
  42119. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42120. var format = getUshort(data, start + offset);
  42121. var ranges, p, i;
  42122. if (format === 4) {
  42123. getUshort(data, start + offset + 2);
  42124. var segCount = getUshort(data, start + offset + 6) >> 1;
  42125. p = start + offset + 14;
  42126. ranges = [];
  42127. for (i = 0; i < segCount; i++, p += 2) {
  42128. ranges[i] = { end: getUshort(data, p) };
  42129. }
  42130. p += 2;
  42131. for (i = 0; i < segCount; i++, p += 2) {
  42132. ranges[i].start = getUshort(data, p);
  42133. }
  42134. for (i = 0; i < segCount; i++, p += 2) {
  42135. ranges[i].idDelta = getUshort(data, p);
  42136. }
  42137. for (i = 0; i < segCount; i++, p += 2) {
  42138. var idOffset = getUshort(data, p);
  42139. if (idOffset === 0) {
  42140. continue;
  42141. }
  42142. ranges[i].ids = [];
  42143. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42144. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42145. idOffset += 2;
  42146. }
  42147. }
  42148. return ranges;
  42149. } else if (format === 12) {
  42150. getLong(data, start + offset + 4);
  42151. var groups = getLong(data, start + offset + 12);
  42152. p = start + offset + 16;
  42153. ranges = [];
  42154. for (i = 0; i < groups; i++) {
  42155. ranges.push({
  42156. start: getLong(data, p),
  42157. end: getLong(data, p + 4),
  42158. idDelta: getLong(data, p + 8) - getLong(data, p)
  42159. });
  42160. p += 12;
  42161. }
  42162. return ranges;
  42163. }
  42164. error('not supported cmap: ' + format);
  42165. }
  42166. function parseCff(data, start, end, seacAnalysisEnabled) {
  42167. var properties = {};
  42168. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42169. var cff = parser.parse();
  42170. return {
  42171. glyphs: cff.charStrings.objects,
  42172. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42173. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42174. };
  42175. }
  42176. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42177. var itemSize, itemDecode;
  42178. if (isGlyphLocationsLong) {
  42179. itemSize = 4;
  42180. itemDecode = function fontItemDecodeLong(data, offset) {
  42181. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42182. };
  42183. } else {
  42184. itemSize = 2;
  42185. itemDecode = function fontItemDecode(data, offset) {
  42186. return data[offset] << 9 | data[offset + 1] << 1;
  42187. };
  42188. }
  42189. var glyphs = [];
  42190. var startOffset = itemDecode(loca, 0);
  42191. for (var j = itemSize; j < loca.length; j += itemSize) {
  42192. var endOffset = itemDecode(loca, j);
  42193. glyphs.push(glyf.subarray(startOffset, endOffset));
  42194. startOffset = endOffset;
  42195. }
  42196. return glyphs;
  42197. }
  42198. function lookupCmap(ranges, unicode) {
  42199. var code = unicode.charCodeAt(0), gid = 0;
  42200. var l = 0, r = ranges.length - 1;
  42201. while (l < r) {
  42202. var c = l + r + 1 >> 1;
  42203. if (code < ranges[c].start) {
  42204. r = c - 1;
  42205. } else {
  42206. l = c;
  42207. }
  42208. }
  42209. if (ranges[l].start <= code && code <= ranges[l].end) {
  42210. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42211. }
  42212. return {
  42213. charCode: code,
  42214. glyphId: gid
  42215. };
  42216. }
  42217. function compileGlyf(code, cmds, font) {
  42218. function moveTo(x, y) {
  42219. cmds.push({
  42220. cmd: 'moveTo',
  42221. args: [
  42222. x,
  42223. y
  42224. ]
  42225. });
  42226. }
  42227. function lineTo(x, y) {
  42228. cmds.push({
  42229. cmd: 'lineTo',
  42230. args: [
  42231. x,
  42232. y
  42233. ]
  42234. });
  42235. }
  42236. function quadraticCurveTo(xa, ya, x, y) {
  42237. cmds.push({
  42238. cmd: 'quadraticCurveTo',
  42239. args: [
  42240. xa,
  42241. ya,
  42242. x,
  42243. y
  42244. ]
  42245. });
  42246. }
  42247. var i = 0;
  42248. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42249. var flags;
  42250. var x = 0, y = 0;
  42251. i += 10;
  42252. if (numberOfContours < 0) {
  42253. do {
  42254. flags = code[i] << 8 | code[i + 1];
  42255. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42256. i += 4;
  42257. var arg1, arg2;
  42258. if (flags & 0x01) {
  42259. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42260. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42261. i += 4;
  42262. } else {
  42263. arg1 = code[i++];
  42264. arg2 = code[i++];
  42265. }
  42266. if (flags & 0x02) {
  42267. x = arg1;
  42268. y = arg2;
  42269. } else {
  42270. x = 0;
  42271. y = 0;
  42272. }
  42273. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42274. if (flags & 0x08) {
  42275. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42276. i += 2;
  42277. } else if (flags & 0x40) {
  42278. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42279. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42280. i += 4;
  42281. } else if (flags & 0x80) {
  42282. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42283. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42284. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42285. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42286. i += 8;
  42287. }
  42288. var subglyph = font.glyphs[glyphIndex];
  42289. if (subglyph) {
  42290. cmds.push({ cmd: 'save' });
  42291. cmds.push({
  42292. cmd: 'transform',
  42293. args: [
  42294. scaleX,
  42295. scale01,
  42296. scale10,
  42297. scaleY,
  42298. x,
  42299. y
  42300. ]
  42301. });
  42302. compileGlyf(subglyph, cmds, font);
  42303. cmds.push({ cmd: 'restore' });
  42304. }
  42305. } while (flags & 0x20);
  42306. } else {
  42307. var endPtsOfContours = [];
  42308. var j, jj;
  42309. for (j = 0; j < numberOfContours; j++) {
  42310. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42311. i += 2;
  42312. }
  42313. var instructionLength = code[i] << 8 | code[i + 1];
  42314. i += 2 + instructionLength;
  42315. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42316. var points = [];
  42317. while (points.length < numberOfPoints) {
  42318. flags = code[i++];
  42319. var repeat = 1;
  42320. if (flags & 0x08) {
  42321. repeat += code[i++];
  42322. }
  42323. while (repeat-- > 0) {
  42324. points.push({ flags: flags });
  42325. }
  42326. }
  42327. for (j = 0; j < numberOfPoints; j++) {
  42328. switch (points[j].flags & 0x12) {
  42329. case 0x00:
  42330. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42331. i += 2;
  42332. break;
  42333. case 0x02:
  42334. x -= code[i++];
  42335. break;
  42336. case 0x12:
  42337. x += code[i++];
  42338. break;
  42339. }
  42340. points[j].x = x;
  42341. }
  42342. for (j = 0; j < numberOfPoints; j++) {
  42343. switch (points[j].flags & 0x24) {
  42344. case 0x00:
  42345. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42346. i += 2;
  42347. break;
  42348. case 0x04:
  42349. y -= code[i++];
  42350. break;
  42351. case 0x24:
  42352. y += code[i++];
  42353. break;
  42354. }
  42355. points[j].y = y;
  42356. }
  42357. var startPoint = 0;
  42358. for (i = 0; i < numberOfContours; i++) {
  42359. var endPoint = endPtsOfContours[i];
  42360. var contour = points.slice(startPoint, endPoint + 1);
  42361. if (contour[0].flags & 1) {
  42362. contour.push(contour[0]);
  42363. } else if (contour[contour.length - 1].flags & 1) {
  42364. contour.unshift(contour[contour.length - 1]);
  42365. } else {
  42366. var p = {
  42367. flags: 1,
  42368. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42369. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42370. };
  42371. contour.unshift(p);
  42372. contour.push(p);
  42373. }
  42374. moveTo(contour[0].x, contour[0].y);
  42375. for (j = 1, jj = contour.length; j < jj; j++) {
  42376. if (contour[j].flags & 1) {
  42377. lineTo(contour[j].x, contour[j].y);
  42378. } else if (contour[j + 1].flags & 1) {
  42379. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42380. j++;
  42381. } else {
  42382. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42383. }
  42384. }
  42385. startPoint = endPoint + 1;
  42386. }
  42387. }
  42388. }
  42389. function compileCharString(code, cmds, font) {
  42390. var stack = [];
  42391. var x = 0, y = 0;
  42392. var stems = 0;
  42393. function moveTo(x, y) {
  42394. cmds.push({
  42395. cmd: 'moveTo',
  42396. args: [
  42397. x,
  42398. y
  42399. ]
  42400. });
  42401. }
  42402. function lineTo(x, y) {
  42403. cmds.push({
  42404. cmd: 'lineTo',
  42405. args: [
  42406. x,
  42407. y
  42408. ]
  42409. });
  42410. }
  42411. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42412. cmds.push({
  42413. cmd: 'bezierCurveTo',
  42414. args: [
  42415. x1,
  42416. y1,
  42417. x2,
  42418. y2,
  42419. x,
  42420. y
  42421. ]
  42422. });
  42423. }
  42424. function parse(code) {
  42425. var i = 0;
  42426. while (i < code.length) {
  42427. var stackClean = false;
  42428. var v = code[i++];
  42429. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42430. switch (v) {
  42431. case 1:
  42432. stems += stack.length >> 1;
  42433. stackClean = true;
  42434. break;
  42435. case 3:
  42436. stems += stack.length >> 1;
  42437. stackClean = true;
  42438. break;
  42439. case 4:
  42440. y += stack.pop();
  42441. moveTo(x, y);
  42442. stackClean = true;
  42443. break;
  42444. case 5:
  42445. while (stack.length > 0) {
  42446. x += stack.shift();
  42447. y += stack.shift();
  42448. lineTo(x, y);
  42449. }
  42450. break;
  42451. case 6:
  42452. while (stack.length > 0) {
  42453. x += stack.shift();
  42454. lineTo(x, y);
  42455. if (stack.length === 0) {
  42456. break;
  42457. }
  42458. y += stack.shift();
  42459. lineTo(x, y);
  42460. }
  42461. break;
  42462. case 7:
  42463. while (stack.length > 0) {
  42464. y += stack.shift();
  42465. lineTo(x, y);
  42466. if (stack.length === 0) {
  42467. break;
  42468. }
  42469. x += stack.shift();
  42470. lineTo(x, y);
  42471. }
  42472. break;
  42473. case 8:
  42474. while (stack.length > 0) {
  42475. xa = x + stack.shift();
  42476. ya = y + stack.shift();
  42477. xb = xa + stack.shift();
  42478. yb = ya + stack.shift();
  42479. x = xb + stack.shift();
  42480. y = yb + stack.shift();
  42481. bezierCurveTo(xa, ya, xb, yb, x, y);
  42482. }
  42483. break;
  42484. case 10:
  42485. n = stack.pop() + font.subrsBias;
  42486. subrCode = font.subrs[n];
  42487. if (subrCode) {
  42488. parse(subrCode);
  42489. }
  42490. break;
  42491. case 11:
  42492. return;
  42493. case 12:
  42494. v = code[i++];
  42495. switch (v) {
  42496. case 34:
  42497. xa = x + stack.shift();
  42498. xb = xa + stack.shift();
  42499. y1 = y + stack.shift();
  42500. x = xb + stack.shift();
  42501. bezierCurveTo(xa, y, xb, y1, x, y1);
  42502. xa = x + stack.shift();
  42503. xb = xa + stack.shift();
  42504. x = xb + stack.shift();
  42505. bezierCurveTo(xa, y1, xb, y, x, y);
  42506. break;
  42507. case 35:
  42508. xa = x + stack.shift();
  42509. ya = y + stack.shift();
  42510. xb = xa + stack.shift();
  42511. yb = ya + stack.shift();
  42512. x = xb + stack.shift();
  42513. y = yb + stack.shift();
  42514. bezierCurveTo(xa, ya, xb, yb, x, y);
  42515. xa = x + stack.shift();
  42516. ya = y + stack.shift();
  42517. xb = xa + stack.shift();
  42518. yb = ya + stack.shift();
  42519. x = xb + stack.shift();
  42520. y = yb + stack.shift();
  42521. bezierCurveTo(xa, ya, xb, yb, x, y);
  42522. stack.pop();
  42523. break;
  42524. case 36:
  42525. xa = x + stack.shift();
  42526. y1 = y + stack.shift();
  42527. xb = xa + stack.shift();
  42528. y2 = y1 + stack.shift();
  42529. x = xb + stack.shift();
  42530. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42531. xa = x + stack.shift();
  42532. xb = xa + stack.shift();
  42533. y3 = y2 + stack.shift();
  42534. x = xb + stack.shift();
  42535. bezierCurveTo(xa, y2, xb, y3, x, y);
  42536. break;
  42537. case 37:
  42538. var x0 = x, y0 = y;
  42539. xa = x + stack.shift();
  42540. ya = y + stack.shift();
  42541. xb = xa + stack.shift();
  42542. yb = ya + stack.shift();
  42543. x = xb + stack.shift();
  42544. y = yb + stack.shift();
  42545. bezierCurveTo(xa, ya, xb, yb, x, y);
  42546. xa = x + stack.shift();
  42547. ya = y + stack.shift();
  42548. xb = xa + stack.shift();
  42549. yb = ya + stack.shift();
  42550. x = xb;
  42551. y = yb;
  42552. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42553. x += stack.shift();
  42554. } else {
  42555. y += stack.shift();
  42556. }
  42557. bezierCurveTo(xa, ya, xb, yb, x, y);
  42558. break;
  42559. default:
  42560. error('unknown operator: 12 ' + v);
  42561. }
  42562. break;
  42563. case 14:
  42564. if (stack.length >= 4) {
  42565. var achar = stack.pop();
  42566. var bchar = stack.pop();
  42567. y = stack.pop();
  42568. x = stack.pop();
  42569. cmds.push({ cmd: 'save' });
  42570. cmds.push({
  42571. cmd: 'translate',
  42572. args: [
  42573. x,
  42574. y
  42575. ]
  42576. });
  42577. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42578. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42579. cmds.push({ cmd: 'restore' });
  42580. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42581. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42582. }
  42583. return;
  42584. case 18:
  42585. stems += stack.length >> 1;
  42586. stackClean = true;
  42587. break;
  42588. case 19:
  42589. stems += stack.length >> 1;
  42590. i += stems + 7 >> 3;
  42591. stackClean = true;
  42592. break;
  42593. case 20:
  42594. stems += stack.length >> 1;
  42595. i += stems + 7 >> 3;
  42596. stackClean = true;
  42597. break;
  42598. case 21:
  42599. y += stack.pop();
  42600. x += stack.pop();
  42601. moveTo(x, y);
  42602. stackClean = true;
  42603. break;
  42604. case 22:
  42605. x += stack.pop();
  42606. moveTo(x, y);
  42607. stackClean = true;
  42608. break;
  42609. case 23:
  42610. stems += stack.length >> 1;
  42611. stackClean = true;
  42612. break;
  42613. case 24:
  42614. while (stack.length > 2) {
  42615. xa = x + stack.shift();
  42616. ya = y + stack.shift();
  42617. xb = xa + stack.shift();
  42618. yb = ya + stack.shift();
  42619. x = xb + stack.shift();
  42620. y = yb + stack.shift();
  42621. bezierCurveTo(xa, ya, xb, yb, x, y);
  42622. }
  42623. x += stack.shift();
  42624. y += stack.shift();
  42625. lineTo(x, y);
  42626. break;
  42627. case 25:
  42628. while (stack.length > 6) {
  42629. x += stack.shift();
  42630. y += stack.shift();
  42631. lineTo(x, y);
  42632. }
  42633. xa = x + stack.shift();
  42634. ya = y + stack.shift();
  42635. xb = xa + stack.shift();
  42636. yb = ya + stack.shift();
  42637. x = xb + stack.shift();
  42638. y = yb + stack.shift();
  42639. bezierCurveTo(xa, ya, xb, yb, x, y);
  42640. break;
  42641. case 26:
  42642. if (stack.length % 2) {
  42643. x += stack.shift();
  42644. }
  42645. while (stack.length > 0) {
  42646. xa = x;
  42647. ya = y + stack.shift();
  42648. xb = xa + stack.shift();
  42649. yb = ya + stack.shift();
  42650. x = xb;
  42651. y = yb + stack.shift();
  42652. bezierCurveTo(xa, ya, xb, yb, x, y);
  42653. }
  42654. break;
  42655. case 27:
  42656. if (stack.length % 2) {
  42657. y += stack.shift();
  42658. }
  42659. while (stack.length > 0) {
  42660. xa = x + stack.shift();
  42661. ya = y;
  42662. xb = xa + stack.shift();
  42663. yb = ya + stack.shift();
  42664. x = xb + stack.shift();
  42665. y = yb;
  42666. bezierCurveTo(xa, ya, xb, yb, x, y);
  42667. }
  42668. break;
  42669. case 28:
  42670. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42671. i += 2;
  42672. break;
  42673. case 29:
  42674. n = stack.pop() + font.gsubrsBias;
  42675. subrCode = font.gsubrs[n];
  42676. if (subrCode) {
  42677. parse(subrCode);
  42678. }
  42679. break;
  42680. case 30:
  42681. while (stack.length > 0) {
  42682. xa = x;
  42683. ya = y + stack.shift();
  42684. xb = xa + stack.shift();
  42685. yb = ya + stack.shift();
  42686. x = xb + stack.shift();
  42687. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42688. bezierCurveTo(xa, ya, xb, yb, x, y);
  42689. if (stack.length === 0) {
  42690. break;
  42691. }
  42692. xa = x + stack.shift();
  42693. ya = y;
  42694. xb = xa + stack.shift();
  42695. yb = ya + stack.shift();
  42696. y = yb + stack.shift();
  42697. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42698. bezierCurveTo(xa, ya, xb, yb, x, y);
  42699. }
  42700. break;
  42701. case 31:
  42702. while (stack.length > 0) {
  42703. xa = x + stack.shift();
  42704. ya = y;
  42705. xb = xa + stack.shift();
  42706. yb = ya + stack.shift();
  42707. y = yb + stack.shift();
  42708. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42709. bezierCurveTo(xa, ya, xb, yb, x, y);
  42710. if (stack.length === 0) {
  42711. break;
  42712. }
  42713. xa = x;
  42714. ya = y + stack.shift();
  42715. xb = xa + stack.shift();
  42716. yb = ya + stack.shift();
  42717. x = xb + stack.shift();
  42718. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42719. bezierCurveTo(xa, ya, xb, yb, x, y);
  42720. }
  42721. break;
  42722. default:
  42723. if (v < 32) {
  42724. error('unknown operator: ' + v);
  42725. }
  42726. if (v < 247) {
  42727. stack.push(v - 139);
  42728. } else if (v < 251) {
  42729. stack.push((v - 247) * 256 + code[i++] + 108);
  42730. } else if (v < 255) {
  42731. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42732. } else {
  42733. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42734. i += 4;
  42735. }
  42736. break;
  42737. }
  42738. if (stackClean) {
  42739. stack.length = 0;
  42740. }
  42741. }
  42742. }
  42743. parse(code);
  42744. }
  42745. var noop = '';
  42746. function CompiledFont(fontMatrix) {
  42747. this.compiledGlyphs = Object.create(null);
  42748. this.compiledCharCodeToGlyphId = Object.create(null);
  42749. this.fontMatrix = fontMatrix;
  42750. }
  42751. CompiledFont.prototype = {
  42752. getPathJs: function (unicode) {
  42753. var cmap = lookupCmap(this.cmap, unicode);
  42754. var fn = this.compiledGlyphs[cmap.glyphId];
  42755. if (!fn) {
  42756. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42757. this.compiledGlyphs[cmap.glyphId] = fn;
  42758. }
  42759. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42760. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42761. }
  42762. return fn;
  42763. },
  42764. compileGlyph: function (code) {
  42765. if (!code || code.length === 0 || code[0] === 14) {
  42766. return noop;
  42767. }
  42768. var cmds = [];
  42769. cmds.push({ cmd: 'save' });
  42770. cmds.push({
  42771. cmd: 'transform',
  42772. args: this.fontMatrix.slice()
  42773. });
  42774. cmds.push({
  42775. cmd: 'scale',
  42776. args: [
  42777. 'size',
  42778. '-size'
  42779. ]
  42780. });
  42781. this.compileGlyphImpl(code, cmds);
  42782. cmds.push({ cmd: 'restore' });
  42783. return cmds;
  42784. },
  42785. compileGlyphImpl: function () {
  42786. error('Children classes should implement this.');
  42787. },
  42788. hasBuiltPath: function (unicode) {
  42789. var cmap = lookupCmap(this.cmap, unicode);
  42790. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42791. }
  42792. };
  42793. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42794. fontMatrix = fontMatrix || [
  42795. 0.000488,
  42796. 0,
  42797. 0,
  42798. 0.000488,
  42799. 0,
  42800. 0
  42801. ];
  42802. CompiledFont.call(this, fontMatrix);
  42803. this.glyphs = glyphs;
  42804. this.cmap = cmap;
  42805. }
  42806. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42807. compileGlyphImpl: function (code, cmds) {
  42808. compileGlyf(code, cmds, this);
  42809. }
  42810. });
  42811. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42812. fontMatrix = fontMatrix || [
  42813. 0.001,
  42814. 0,
  42815. 0,
  42816. 0.001,
  42817. 0,
  42818. 0
  42819. ];
  42820. CompiledFont.call(this, fontMatrix);
  42821. this.glyphs = cffInfo.glyphs;
  42822. this.gsubrs = cffInfo.gsubrs || [];
  42823. this.subrs = cffInfo.subrs || [];
  42824. this.cmap = cmap;
  42825. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42826. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42827. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42828. }
  42829. Util.inherit(Type2Compiled, CompiledFont, {
  42830. compileGlyphImpl: function (code, cmds) {
  42831. compileCharString(code, cmds, this);
  42832. }
  42833. });
  42834. return {
  42835. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42836. var data = new Uint8Array(font.data);
  42837. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42838. var numTables = getUshort(data, 4);
  42839. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42840. var tag = bytesToString(data.subarray(p, p + 4));
  42841. var offset = getLong(data, p + 8);
  42842. var length = getLong(data, p + 12);
  42843. switch (tag) {
  42844. case 'cmap':
  42845. cmap = parseCmap(data, offset, offset + length);
  42846. break;
  42847. case 'glyf':
  42848. glyf = data.subarray(offset, offset + length);
  42849. break;
  42850. case 'loca':
  42851. loca = data.subarray(offset, offset + length);
  42852. break;
  42853. case 'head':
  42854. unitsPerEm = getUshort(data, offset + 18);
  42855. indexToLocFormat = getUshort(data, offset + 50);
  42856. break;
  42857. case 'CFF ':
  42858. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42859. break;
  42860. }
  42861. }
  42862. if (glyf) {
  42863. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42864. 1 / unitsPerEm,
  42865. 0,
  42866. 0,
  42867. 1 / unitsPerEm,
  42868. 0,
  42869. 0
  42870. ];
  42871. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42872. }
  42873. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42874. }
  42875. };
  42876. }();
  42877. exports.FontRendererFactory = FontRendererFactory;
  42878. /***/ }),
  42879. /* 33 */
  42880. /***/ (function(module, exports, __w_pdfjs_require__) {
  42881. "use strict";
  42882. var sharedUtil = __w_pdfjs_require__(0);
  42883. var corePrimitives = __w_pdfjs_require__(1);
  42884. var coreStream = __w_pdfjs_require__(2);
  42885. var coreGlyphList = __w_pdfjs_require__(8);
  42886. var coreFontRenderer = __w_pdfjs_require__(32);
  42887. var coreEncodings = __w_pdfjs_require__(5);
  42888. var coreStandardFonts = __w_pdfjs_require__(21);
  42889. var coreUnicode = __w_pdfjs_require__(22);
  42890. var coreType1Parser = __w_pdfjs_require__(43);
  42891. var coreCFFParser = __w_pdfjs_require__(15);
  42892. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42893. var FontType = sharedUtil.FontType;
  42894. var assert = sharedUtil.assert;
  42895. var bytesToString = sharedUtil.bytesToString;
  42896. var error = sharedUtil.error;
  42897. var info = sharedUtil.info;
  42898. var isArray = sharedUtil.isArray;
  42899. var isInt = sharedUtil.isInt;
  42900. var isNum = sharedUtil.isNum;
  42901. var readUint32 = sharedUtil.readUint32;
  42902. var shadow = sharedUtil.shadow;
  42903. var string32 = sharedUtil.string32;
  42904. var warn = sharedUtil.warn;
  42905. var MissingDataException = sharedUtil.MissingDataException;
  42906. var isSpace = sharedUtil.isSpace;
  42907. var Stream = coreStream.Stream;
  42908. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42909. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42910. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42911. var StandardEncoding = coreEncodings.StandardEncoding;
  42912. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42913. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42914. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42915. var getEncoding = coreEncodings.getEncoding;
  42916. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42917. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42918. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42919. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42920. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42921. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42922. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42923. var Type1Parser = coreType1Parser.Type1Parser;
  42924. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42925. var CFFParser = coreCFFParser.CFFParser;
  42926. var CFFCompiler = coreCFFParser.CFFCompiler;
  42927. var CFF = coreCFFParser.CFF;
  42928. var CFFHeader = coreCFFParser.CFFHeader;
  42929. var CFFTopDict = coreCFFParser.CFFTopDict;
  42930. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42931. var CFFStrings = coreCFFParser.CFFStrings;
  42932. var CFFIndex = coreCFFParser.CFFIndex;
  42933. var CFFCharset = coreCFFParser.CFFCharset;
  42934. var PRIVATE_USE_OFFSET_START = 0xE000;
  42935. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42936. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42937. var PDF_GLYPH_SPACE_UNITS = 1000;
  42938. var SEAC_ANALYSIS_ENABLED = false;
  42939. var FontFlags = {
  42940. FixedPitch: 1,
  42941. Serif: 2,
  42942. Symbolic: 4,
  42943. Script: 8,
  42944. Nonsymbolic: 32,
  42945. Italic: 64,
  42946. AllCap: 65536,
  42947. SmallCap: 131072,
  42948. ForceBold: 262144
  42949. };
  42950. var MacStandardGlyphOrdering = [
  42951. '.notdef',
  42952. '.null',
  42953. 'nonmarkingreturn',
  42954. 'space',
  42955. 'exclam',
  42956. 'quotedbl',
  42957. 'numbersign',
  42958. 'dollar',
  42959. 'percent',
  42960. 'ampersand',
  42961. 'quotesingle',
  42962. 'parenleft',
  42963. 'parenright',
  42964. 'asterisk',
  42965. 'plus',
  42966. 'comma',
  42967. 'hyphen',
  42968. 'period',
  42969. 'slash',
  42970. 'zero',
  42971. 'one',
  42972. 'two',
  42973. 'three',
  42974. 'four',
  42975. 'five',
  42976. 'six',
  42977. 'seven',
  42978. 'eight',
  42979. 'nine',
  42980. 'colon',
  42981. 'semicolon',
  42982. 'less',
  42983. 'equal',
  42984. 'greater',
  42985. 'question',
  42986. 'at',
  42987. 'A',
  42988. 'B',
  42989. 'C',
  42990. 'D',
  42991. 'E',
  42992. 'F',
  42993. 'G',
  42994. 'H',
  42995. 'I',
  42996. 'J',
  42997. 'K',
  42998. 'L',
  42999. 'M',
  43000. 'N',
  43001. 'O',
  43002. 'P',
  43003. 'Q',
  43004. 'R',
  43005. 'S',
  43006. 'T',
  43007. 'U',
  43008. 'V',
  43009. 'W',
  43010. 'X',
  43011. 'Y',
  43012. 'Z',
  43013. 'bracketleft',
  43014. 'backslash',
  43015. 'bracketright',
  43016. 'asciicircum',
  43017. 'underscore',
  43018. 'grave',
  43019. 'a',
  43020. 'b',
  43021. 'c',
  43022. 'd',
  43023. 'e',
  43024. 'f',
  43025. 'g',
  43026. 'h',
  43027. 'i',
  43028. 'j',
  43029. 'k',
  43030. 'l',
  43031. 'm',
  43032. 'n',
  43033. 'o',
  43034. 'p',
  43035. 'q',
  43036. 'r',
  43037. 's',
  43038. 't',
  43039. 'u',
  43040. 'v',
  43041. 'w',
  43042. 'x',
  43043. 'y',
  43044. 'z',
  43045. 'braceleft',
  43046. 'bar',
  43047. 'braceright',
  43048. 'asciitilde',
  43049. 'Adieresis',
  43050. 'Aring',
  43051. 'Ccedilla',
  43052. 'Eacute',
  43053. 'Ntilde',
  43054. 'Odieresis',
  43055. 'Udieresis',
  43056. 'aacute',
  43057. 'agrave',
  43058. 'acircumflex',
  43059. 'adieresis',
  43060. 'atilde',
  43061. 'aring',
  43062. 'ccedilla',
  43063. 'eacute',
  43064. 'egrave',
  43065. 'ecircumflex',
  43066. 'edieresis',
  43067. 'iacute',
  43068. 'igrave',
  43069. 'icircumflex',
  43070. 'idieresis',
  43071. 'ntilde',
  43072. 'oacute',
  43073. 'ograve',
  43074. 'ocircumflex',
  43075. 'odieresis',
  43076. 'otilde',
  43077. 'uacute',
  43078. 'ugrave',
  43079. 'ucircumflex',
  43080. 'udieresis',
  43081. 'dagger',
  43082. 'degree',
  43083. 'cent',
  43084. 'sterling',
  43085. 'section',
  43086. 'bullet',
  43087. 'paragraph',
  43088. 'germandbls',
  43089. 'registered',
  43090. 'copyright',
  43091. 'trademark',
  43092. 'acute',
  43093. 'dieresis',
  43094. 'notequal',
  43095. 'AE',
  43096. 'Oslash',
  43097. 'infinity',
  43098. 'plusminus',
  43099. 'lessequal',
  43100. 'greaterequal',
  43101. 'yen',
  43102. 'mu',
  43103. 'partialdiff',
  43104. 'summation',
  43105. 'product',
  43106. 'pi',
  43107. 'integral',
  43108. 'ordfeminine',
  43109. 'ordmasculine',
  43110. 'Omega',
  43111. 'ae',
  43112. 'oslash',
  43113. 'questiondown',
  43114. 'exclamdown',
  43115. 'logicalnot',
  43116. 'radical',
  43117. 'florin',
  43118. 'approxequal',
  43119. 'Delta',
  43120. 'guillemotleft',
  43121. 'guillemotright',
  43122. 'ellipsis',
  43123. 'nonbreakingspace',
  43124. 'Agrave',
  43125. 'Atilde',
  43126. 'Otilde',
  43127. 'OE',
  43128. 'oe',
  43129. 'endash',
  43130. 'emdash',
  43131. 'quotedblleft',
  43132. 'quotedblright',
  43133. 'quoteleft',
  43134. 'quoteright',
  43135. 'divide',
  43136. 'lozenge',
  43137. 'ydieresis',
  43138. 'Ydieresis',
  43139. 'fraction',
  43140. 'currency',
  43141. 'guilsinglleft',
  43142. 'guilsinglright',
  43143. 'fi',
  43144. 'fl',
  43145. 'daggerdbl',
  43146. 'periodcentered',
  43147. 'quotesinglbase',
  43148. 'quotedblbase',
  43149. 'perthousand',
  43150. 'Acircumflex',
  43151. 'Ecircumflex',
  43152. 'Aacute',
  43153. 'Edieresis',
  43154. 'Egrave',
  43155. 'Iacute',
  43156. 'Icircumflex',
  43157. 'Idieresis',
  43158. 'Igrave',
  43159. 'Oacute',
  43160. 'Ocircumflex',
  43161. 'apple',
  43162. 'Ograve',
  43163. 'Uacute',
  43164. 'Ucircumflex',
  43165. 'Ugrave',
  43166. 'dotlessi',
  43167. 'circumflex',
  43168. 'tilde',
  43169. 'macron',
  43170. 'breve',
  43171. 'dotaccent',
  43172. 'ring',
  43173. 'cedilla',
  43174. 'hungarumlaut',
  43175. 'ogonek',
  43176. 'caron',
  43177. 'Lslash',
  43178. 'lslash',
  43179. 'Scaron',
  43180. 'scaron',
  43181. 'Zcaron',
  43182. 'zcaron',
  43183. 'brokenbar',
  43184. 'Eth',
  43185. 'eth',
  43186. 'Yacute',
  43187. 'yacute',
  43188. 'Thorn',
  43189. 'thorn',
  43190. 'minus',
  43191. 'multiply',
  43192. 'onesuperior',
  43193. 'twosuperior',
  43194. 'threesuperior',
  43195. 'onehalf',
  43196. 'onequarter',
  43197. 'threequarters',
  43198. 'franc',
  43199. 'Gbreve',
  43200. 'gbreve',
  43201. 'Idotaccent',
  43202. 'Scedilla',
  43203. 'scedilla',
  43204. 'Cacute',
  43205. 'cacute',
  43206. 'Ccaron',
  43207. 'ccaron',
  43208. 'dcroat'
  43209. ];
  43210. function adjustWidths(properties) {
  43211. if (!properties.fontMatrix) {
  43212. return;
  43213. }
  43214. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43215. return;
  43216. }
  43217. var scale = 0.001 / properties.fontMatrix[0];
  43218. var glyphsWidths = properties.widths;
  43219. for (var glyph in glyphsWidths) {
  43220. glyphsWidths[glyph] *= scale;
  43221. }
  43222. properties.defaultWidth *= scale;
  43223. }
  43224. function adjustToUnicode(properties, builtInEncoding) {
  43225. if (properties.hasIncludedToUnicodeMap) {
  43226. return;
  43227. }
  43228. if (properties.hasEncoding) {
  43229. return;
  43230. }
  43231. if (builtInEncoding === properties.defaultEncoding) {
  43232. return;
  43233. }
  43234. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43235. return;
  43236. }
  43237. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43238. for (var charCode in builtInEncoding) {
  43239. var glyphName = builtInEncoding[charCode];
  43240. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43241. if (unicode !== -1) {
  43242. toUnicode[charCode] = String.fromCharCode(unicode);
  43243. }
  43244. }
  43245. properties.toUnicode.amend(toUnicode);
  43246. }
  43247. function getFontType(type, subtype) {
  43248. switch (type) {
  43249. case 'Type1':
  43250. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43251. case 'CIDFontType0':
  43252. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43253. case 'OpenType':
  43254. return FontType.OPENTYPE;
  43255. case 'TrueType':
  43256. return FontType.TRUETYPE;
  43257. case 'CIDFontType2':
  43258. return FontType.CIDFONTTYPE2;
  43259. case 'MMType1':
  43260. return FontType.MMTYPE1;
  43261. case 'Type0':
  43262. return FontType.TYPE0;
  43263. default:
  43264. return FontType.UNKNOWN;
  43265. }
  43266. }
  43267. function recoverGlyphName(name, glyphsUnicodeMap) {
  43268. if (glyphsUnicodeMap[name] !== undefined) {
  43269. return name;
  43270. }
  43271. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43272. if (unicode !== -1) {
  43273. for (var key in glyphsUnicodeMap) {
  43274. if (glyphsUnicodeMap[key] === unicode) {
  43275. return key;
  43276. }
  43277. }
  43278. }
  43279. info('Unable to recover a standard glyph name for: ' + name);
  43280. return name;
  43281. }
  43282. var Glyph = function GlyphClosure() {
  43283. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43284. this.fontChar = fontChar;
  43285. this.unicode = unicode;
  43286. this.accent = accent;
  43287. this.width = width;
  43288. this.vmetric = vmetric;
  43289. this.operatorListId = operatorListId;
  43290. this.isSpace = isSpace;
  43291. this.isInFont = isInFont;
  43292. }
  43293. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43294. 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;
  43295. };
  43296. return Glyph;
  43297. }();
  43298. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43299. function ToUnicodeMap(cmap) {
  43300. this._map = cmap;
  43301. }
  43302. ToUnicodeMap.prototype = {
  43303. get length() {
  43304. return this._map.length;
  43305. },
  43306. forEach: function (callback) {
  43307. for (var charCode in this._map) {
  43308. callback(charCode, this._map[charCode].charCodeAt(0));
  43309. }
  43310. },
  43311. has: function (i) {
  43312. return this._map[i] !== undefined;
  43313. },
  43314. get: function (i) {
  43315. return this._map[i];
  43316. },
  43317. charCodeOf: function (v) {
  43318. return this._map.indexOf(v);
  43319. },
  43320. amend: function (map) {
  43321. for (var charCode in map) {
  43322. this._map[charCode] = map[charCode];
  43323. }
  43324. }
  43325. };
  43326. return ToUnicodeMap;
  43327. }();
  43328. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43329. function IdentityToUnicodeMap(firstChar, lastChar) {
  43330. this.firstChar = firstChar;
  43331. this.lastChar = lastChar;
  43332. }
  43333. IdentityToUnicodeMap.prototype = {
  43334. get length() {
  43335. return this.lastChar + 1 - this.firstChar;
  43336. },
  43337. forEach: function (callback) {
  43338. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43339. callback(i, i);
  43340. }
  43341. },
  43342. has: function (i) {
  43343. return this.firstChar <= i && i <= this.lastChar;
  43344. },
  43345. get: function (i) {
  43346. if (this.firstChar <= i && i <= this.lastChar) {
  43347. return String.fromCharCode(i);
  43348. }
  43349. return undefined;
  43350. },
  43351. charCodeOf: function (v) {
  43352. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43353. },
  43354. amend: function (map) {
  43355. error('Should not call amend()');
  43356. }
  43357. };
  43358. return IdentityToUnicodeMap;
  43359. }();
  43360. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43361. function writeInt16(dest, offset, num) {
  43362. dest[offset] = num >> 8 & 0xFF;
  43363. dest[offset + 1] = num & 0xFF;
  43364. }
  43365. function writeInt32(dest, offset, num) {
  43366. dest[offset] = num >> 24 & 0xFF;
  43367. dest[offset + 1] = num >> 16 & 0xFF;
  43368. dest[offset + 2] = num >> 8 & 0xFF;
  43369. dest[offset + 3] = num & 0xFF;
  43370. }
  43371. function writeData(dest, offset, data) {
  43372. var i, ii;
  43373. if (data instanceof Uint8Array) {
  43374. dest.set(data, offset);
  43375. } else if (typeof data === 'string') {
  43376. for (i = 0, ii = data.length; i < ii; i++) {
  43377. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43378. }
  43379. } else {
  43380. for (i = 0, ii = data.length; i < ii; i++) {
  43381. dest[offset++] = data[i] & 0xFF;
  43382. }
  43383. }
  43384. }
  43385. function OpenTypeFileBuilder(sfnt) {
  43386. this.sfnt = sfnt;
  43387. this.tables = Object.create(null);
  43388. }
  43389. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43390. var maxPower2 = 1, log2 = 0;
  43391. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43392. maxPower2 <<= 1;
  43393. log2++;
  43394. }
  43395. var searchRange = maxPower2 * entrySize;
  43396. return {
  43397. range: searchRange,
  43398. entry: log2,
  43399. rangeShift: entrySize * entriesCount - searchRange
  43400. };
  43401. };
  43402. var OTF_HEADER_SIZE = 12;
  43403. var OTF_TABLE_ENTRY_SIZE = 16;
  43404. OpenTypeFileBuilder.prototype = {
  43405. toArray: function OpenTypeFileBuilder_toArray() {
  43406. var sfnt = this.sfnt;
  43407. var tables = this.tables;
  43408. var tablesNames = Object.keys(tables);
  43409. tablesNames.sort();
  43410. var numTables = tablesNames.length;
  43411. var i, j, jj, table, tableName;
  43412. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43413. var tableOffsets = [offset];
  43414. for (i = 0; i < numTables; i++) {
  43415. table = tables[tablesNames[i]];
  43416. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43417. offset += paddedLength;
  43418. tableOffsets.push(offset);
  43419. }
  43420. var file = new Uint8Array(offset);
  43421. for (i = 0; i < numTables; i++) {
  43422. table = tables[tablesNames[i]];
  43423. writeData(file, tableOffsets[i], table);
  43424. }
  43425. if (sfnt === 'true') {
  43426. sfnt = string32(0x00010000);
  43427. }
  43428. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43429. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43430. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43431. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43432. writeInt16(file, 4, numTables);
  43433. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43434. writeInt16(file, 6, searchParams.range);
  43435. writeInt16(file, 8, searchParams.entry);
  43436. writeInt16(file, 10, searchParams.rangeShift);
  43437. offset = OTF_HEADER_SIZE;
  43438. for (i = 0; i < numTables; i++) {
  43439. tableName = tablesNames[i];
  43440. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43441. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43442. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43443. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43444. var checksum = 0;
  43445. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43446. var quad = readUint32(file, j);
  43447. checksum = checksum + quad >>> 0;
  43448. }
  43449. writeInt32(file, offset + 4, checksum);
  43450. writeInt32(file, offset + 8, tableOffsets[i]);
  43451. writeInt32(file, offset + 12, tables[tableName].length);
  43452. offset += OTF_TABLE_ENTRY_SIZE;
  43453. }
  43454. return file;
  43455. },
  43456. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43457. if (tag in this.tables) {
  43458. throw new Error('Table ' + tag + ' already exists');
  43459. }
  43460. this.tables[tag] = data;
  43461. }
  43462. };
  43463. return OpenTypeFileBuilder;
  43464. }();
  43465. var ProblematicCharRanges = new Int32Array([
  43466. 0x0000,
  43467. 0x0020,
  43468. 0x007F,
  43469. 0x00A1,
  43470. 0x00AD,
  43471. 0x00AE,
  43472. 0x0600,
  43473. 0x0780,
  43474. 0x08A0,
  43475. 0x10A0,
  43476. 0x1780,
  43477. 0x1800,
  43478. 0x1C00,
  43479. 0x1C50,
  43480. 0x2000,
  43481. 0x2010,
  43482. 0x2011,
  43483. 0x2012,
  43484. 0x2028,
  43485. 0x2030,
  43486. 0x205F,
  43487. 0x2070,
  43488. 0x25CC,
  43489. 0x25CD,
  43490. 0x3000,
  43491. 0x3001,
  43492. 0xAA60,
  43493. 0xAA80,
  43494. 0xFFF0,
  43495. 0x10000
  43496. ]);
  43497. var Font = function FontClosure() {
  43498. function Font(name, file, properties) {
  43499. var charCode, glyphName, unicode;
  43500. this.name = name;
  43501. this.loadedName = properties.loadedName;
  43502. this.isType3Font = properties.isType3Font;
  43503. this.sizes = [];
  43504. this.missingFile = false;
  43505. this.glyphCache = Object.create(null);
  43506. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43507. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43508. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43509. var type = properties.type;
  43510. var subtype = properties.subtype;
  43511. this.type = type;
  43512. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43513. this.differences = properties.differences;
  43514. this.widths = properties.widths;
  43515. this.defaultWidth = properties.defaultWidth;
  43516. this.composite = properties.composite;
  43517. this.wideChars = properties.wideChars;
  43518. this.cMap = properties.cMap;
  43519. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43520. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43521. this.fontMatrix = properties.fontMatrix;
  43522. this.bbox = properties.bbox;
  43523. this.toUnicode = properties.toUnicode;
  43524. this.toFontChar = [];
  43525. if (properties.type === 'Type3') {
  43526. for (charCode = 0; charCode < 256; charCode++) {
  43527. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43528. }
  43529. this.fontType = FontType.TYPE3;
  43530. return;
  43531. }
  43532. this.cidEncoding = properties.cidEncoding;
  43533. this.vertical = properties.vertical;
  43534. if (this.vertical) {
  43535. this.vmetrics = properties.vmetrics;
  43536. this.defaultVMetrics = properties.defaultVMetrics;
  43537. }
  43538. var glyphsUnicodeMap;
  43539. if (!file || file.isEmpty) {
  43540. if (file) {
  43541. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43542. }
  43543. this.missingFile = true;
  43544. var fontName = name.replace(/[,_]/g, '-');
  43545. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43546. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43547. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43548. this.bold = fontName.search(/bold/gi) !== -1;
  43549. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43550. this.black = name.search(/Black/g) !== -1;
  43551. this.remeasure = Object.keys(this.widths).length > 0;
  43552. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43553. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43554. var map = [];
  43555. for (charCode in GlyphMapForStandardFonts) {
  43556. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43557. }
  43558. if (/Arial-?Black/i.test(name)) {
  43559. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43560. for (charCode in SupplementalGlyphMapForArialBlack) {
  43561. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43562. }
  43563. }
  43564. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43565. if (!isIdentityUnicode) {
  43566. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43567. map[+charCode] = unicodeCharCode;
  43568. });
  43569. }
  43570. this.toFontChar = map;
  43571. this.toUnicode = new ToUnicodeMap(map);
  43572. } else if (/Symbol/i.test(fontName)) {
  43573. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43574. } else if (/Dingbats/i.test(fontName)) {
  43575. if (/Wingdings/i.test(name)) {
  43576. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43577. }
  43578. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43579. } else if (isStandardFont) {
  43580. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43581. } else {
  43582. glyphsUnicodeMap = getGlyphsUnicode();
  43583. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43584. if (!this.composite) {
  43585. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43586. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43587. if (unicode !== -1) {
  43588. unicodeCharCode = unicode;
  43589. }
  43590. }
  43591. this.toFontChar[charCode] = unicodeCharCode;
  43592. }.bind(this));
  43593. }
  43594. this.loadedName = fontName.split('-')[0];
  43595. this.loading = false;
  43596. this.fontType = getFontType(type, subtype);
  43597. return;
  43598. }
  43599. if (subtype === 'Type1C') {
  43600. if (type !== 'Type1' && type !== 'MMType1') {
  43601. if (isTrueTypeFile(file)) {
  43602. subtype = 'TrueType';
  43603. } else {
  43604. type = 'Type1';
  43605. }
  43606. } else if (isOpenTypeFile(file)) {
  43607. type = subtype = 'OpenType';
  43608. }
  43609. }
  43610. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43611. type = 'CIDFontType0';
  43612. }
  43613. if (subtype === 'OpenType') {
  43614. type = 'OpenType';
  43615. }
  43616. if (type === 'CIDFontType0') {
  43617. if (isType1File(file)) {
  43618. subtype = 'CIDFontType0';
  43619. } else if (isOpenTypeFile(file)) {
  43620. type = subtype = 'OpenType';
  43621. } else {
  43622. subtype = 'CIDFontType0C';
  43623. }
  43624. }
  43625. var data;
  43626. switch (type) {
  43627. case 'MMType1':
  43628. info('MMType1 font (' + name + '), falling back to Type1.');
  43629. case 'Type1':
  43630. case 'CIDFontType0':
  43631. this.mimetype = 'font/opentype';
  43632. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43633. adjustWidths(properties);
  43634. data = this.convert(name, cff, properties);
  43635. break;
  43636. case 'OpenType':
  43637. case 'TrueType':
  43638. case 'CIDFontType2':
  43639. this.mimetype = 'font/opentype';
  43640. data = this.checkAndRepair(name, file, properties);
  43641. if (this.isOpenType) {
  43642. adjustWidths(properties);
  43643. type = 'OpenType';
  43644. }
  43645. break;
  43646. default:
  43647. error('Font ' + type + ' is not supported');
  43648. break;
  43649. }
  43650. this.data = data;
  43651. this.fontType = getFontType(type, subtype);
  43652. this.fontMatrix = properties.fontMatrix;
  43653. this.widths = properties.widths;
  43654. this.defaultWidth = properties.defaultWidth;
  43655. this.toUnicode = properties.toUnicode;
  43656. this.encoding = properties.baseEncoding;
  43657. this.seacMap = properties.seacMap;
  43658. this.loading = true;
  43659. }
  43660. Font.getFontID = function () {
  43661. var ID = 1;
  43662. return function Font_getFontID() {
  43663. return String(ID++);
  43664. };
  43665. }();
  43666. function int16(b0, b1) {
  43667. return (b0 << 8) + b1;
  43668. }
  43669. function signedInt16(b0, b1) {
  43670. var value = (b0 << 8) + b1;
  43671. return value & 1 << 15 ? value - 0x10000 : value;
  43672. }
  43673. function int32(b0, b1, b2, b3) {
  43674. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43675. }
  43676. function string16(value) {
  43677. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43678. }
  43679. function safeString16(value) {
  43680. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43681. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43682. }
  43683. function isTrueTypeFile(file) {
  43684. var header = file.peekBytes(4);
  43685. return readUint32(header, 0) === 0x00010000;
  43686. }
  43687. function isOpenTypeFile(file) {
  43688. var header = file.peekBytes(4);
  43689. return bytesToString(header) === 'OTTO';
  43690. }
  43691. function isType1File(file) {
  43692. var header = file.peekBytes(2);
  43693. if (header[0] === 0x25 && header[1] === 0x21) {
  43694. return true;
  43695. }
  43696. if (header[0] === 0x80 && header[1] === 0x01) {
  43697. return true;
  43698. }
  43699. return false;
  43700. }
  43701. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43702. var toFontChar = [], unicode;
  43703. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43704. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43705. if (unicode !== -1) {
  43706. toFontChar[i] = unicode;
  43707. }
  43708. }
  43709. for (var charCode in differences) {
  43710. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43711. if (unicode !== -1) {
  43712. toFontChar[+charCode] = unicode;
  43713. }
  43714. }
  43715. return toFontChar;
  43716. }
  43717. function isProblematicUnicodeLocation(code) {
  43718. var i = 0, j = ProblematicCharRanges.length - 1;
  43719. while (i < j) {
  43720. var c = i + j + 1 >> 1;
  43721. if (code < ProblematicCharRanges[c]) {
  43722. j = c - 1;
  43723. } else {
  43724. i = c;
  43725. }
  43726. }
  43727. return !(i & 1);
  43728. }
  43729. function adjustMapping(charCodeToGlyphId, properties) {
  43730. var toUnicode = properties.toUnicode;
  43731. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43732. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43733. var newMap = Object.create(null);
  43734. var toFontChar = [];
  43735. var usedFontCharCodes = [];
  43736. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43737. for (var originalCharCode in charCodeToGlyphId) {
  43738. originalCharCode |= 0;
  43739. var glyphId = charCodeToGlyphId[originalCharCode];
  43740. var fontCharCode = originalCharCode;
  43741. var hasUnicodeValue = false;
  43742. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43743. hasUnicodeValue = true;
  43744. var unicode = toUnicode.get(fontCharCode);
  43745. if (unicode.length === 1) {
  43746. fontCharCode = unicode.charCodeAt(0);
  43747. }
  43748. }
  43749. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43750. do {
  43751. fontCharCode = nextAvailableFontCharCode++;
  43752. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43753. fontCharCode = 0xF020;
  43754. nextAvailableFontCharCode = fontCharCode + 1;
  43755. }
  43756. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43757. }
  43758. newMap[fontCharCode] = glyphId;
  43759. toFontChar[originalCharCode] = fontCharCode;
  43760. usedFontCharCodes[fontCharCode] = true;
  43761. }
  43762. return {
  43763. toFontChar: toFontChar,
  43764. charCodeToGlyphId: newMap,
  43765. nextAvailableFontCharCode: nextAvailableFontCharCode
  43766. };
  43767. }
  43768. function getRanges(glyphs, numGlyphs) {
  43769. var codes = [];
  43770. for (var charCode in glyphs) {
  43771. if (glyphs[charCode] >= numGlyphs) {
  43772. continue;
  43773. }
  43774. codes.push({
  43775. fontCharCode: charCode | 0,
  43776. glyphId: glyphs[charCode]
  43777. });
  43778. }
  43779. codes.sort(function fontGetRangesSort(a, b) {
  43780. return a.fontCharCode - b.fontCharCode;
  43781. });
  43782. var ranges = [];
  43783. var length = codes.length;
  43784. for (var n = 0; n < length;) {
  43785. var start = codes[n].fontCharCode;
  43786. var codeIndices = [codes[n].glyphId];
  43787. ++n;
  43788. var end = start;
  43789. while (n < length && end + 1 === codes[n].fontCharCode) {
  43790. codeIndices.push(codes[n].glyphId);
  43791. ++end;
  43792. ++n;
  43793. if (end === 0xFFFF) {
  43794. break;
  43795. }
  43796. }
  43797. ranges.push([
  43798. start,
  43799. end,
  43800. codeIndices
  43801. ]);
  43802. }
  43803. return ranges;
  43804. }
  43805. function createCmapTable(glyphs, numGlyphs) {
  43806. var ranges = getRanges(glyphs, numGlyphs);
  43807. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43808. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43809. var i, ii, j, jj;
  43810. for (i = ranges.length - 1; i >= 0; --i) {
  43811. if (ranges[i][0] <= 0xFFFF) {
  43812. break;
  43813. }
  43814. }
  43815. var bmpLength = i + 1;
  43816. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43817. ranges[i][1] = 0xFFFE;
  43818. }
  43819. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43820. var segCount = bmpLength + trailingRangesCount;
  43821. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43822. var startCount = '';
  43823. var endCount = '';
  43824. var idDeltas = '';
  43825. var idRangeOffsets = '';
  43826. var glyphsIds = '';
  43827. var bias = 0;
  43828. var range, start, end, codes;
  43829. for (i = 0, ii = bmpLength; i < ii; i++) {
  43830. range = ranges[i];
  43831. start = range[0];
  43832. end = range[1];
  43833. startCount += string16(start);
  43834. endCount += string16(end);
  43835. codes = range[2];
  43836. var contiguous = true;
  43837. for (j = 1, jj = codes.length; j < jj; ++j) {
  43838. if (codes[j] !== codes[j - 1] + 1) {
  43839. contiguous = false;
  43840. break;
  43841. }
  43842. }
  43843. if (!contiguous) {
  43844. var offset = (segCount - i) * 2 + bias * 2;
  43845. bias += end - start + 1;
  43846. idDeltas += string16(0);
  43847. idRangeOffsets += string16(offset);
  43848. for (j = 0, jj = codes.length; j < jj; ++j) {
  43849. glyphsIds += string16(codes[j]);
  43850. }
  43851. } else {
  43852. var startCode = codes[0];
  43853. idDeltas += string16(startCode - start & 0xFFFF);
  43854. idRangeOffsets += string16(0);
  43855. }
  43856. }
  43857. if (trailingRangesCount > 0) {
  43858. endCount += '\xFF\xFF';
  43859. startCount += '\xFF\xFF';
  43860. idDeltas += '\x00\x01';
  43861. idRangeOffsets += '\x00\x00';
  43862. }
  43863. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43864. var format31012 = '';
  43865. var header31012 = '';
  43866. if (numTables > 1) {
  43867. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43868. format31012 = '';
  43869. for (i = 0, ii = ranges.length; i < ii; i++) {
  43870. range = ranges[i];
  43871. start = range[0];
  43872. codes = range[2];
  43873. var code = codes[0];
  43874. for (j = 1, jj = codes.length; j < jj; ++j) {
  43875. if (codes[j] !== codes[j - 1] + 1) {
  43876. end = range[0] + j - 1;
  43877. format31012 += string32(start) + string32(end) + string32(code);
  43878. start = end + 1;
  43879. code = codes[j];
  43880. }
  43881. }
  43882. format31012 += string32(start) + string32(range[1]) + string32(code);
  43883. }
  43884. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43885. }
  43886. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43887. }
  43888. function validateOS2Table(os2) {
  43889. var stream = new Stream(os2.data);
  43890. var version = stream.getUint16();
  43891. stream.getBytes(60);
  43892. var selection = stream.getUint16();
  43893. if (version < 4 && selection & 0x0300) {
  43894. return false;
  43895. }
  43896. var firstChar = stream.getUint16();
  43897. var lastChar = stream.getUint16();
  43898. if (firstChar > lastChar) {
  43899. return false;
  43900. }
  43901. stream.getBytes(6);
  43902. var usWinAscent = stream.getUint16();
  43903. if (usWinAscent === 0) {
  43904. return false;
  43905. }
  43906. os2.data[8] = os2.data[9] = 0;
  43907. return true;
  43908. }
  43909. function createOS2Table(properties, charstrings, override) {
  43910. override = override || {
  43911. unitsPerEm: 0,
  43912. yMax: 0,
  43913. yMin: 0,
  43914. ascent: 0,
  43915. descent: 0
  43916. };
  43917. var ulUnicodeRange1 = 0;
  43918. var ulUnicodeRange2 = 0;
  43919. var ulUnicodeRange3 = 0;
  43920. var ulUnicodeRange4 = 0;
  43921. var firstCharIndex = null;
  43922. var lastCharIndex = 0;
  43923. if (charstrings) {
  43924. for (var code in charstrings) {
  43925. code |= 0;
  43926. if (firstCharIndex > code || !firstCharIndex) {
  43927. firstCharIndex = code;
  43928. }
  43929. if (lastCharIndex < code) {
  43930. lastCharIndex = code;
  43931. }
  43932. var position = getUnicodeRangeFor(code);
  43933. if (position < 32) {
  43934. ulUnicodeRange1 |= 1 << position;
  43935. } else if (position < 64) {
  43936. ulUnicodeRange2 |= 1 << position - 32;
  43937. } else if (position < 96) {
  43938. ulUnicodeRange3 |= 1 << position - 64;
  43939. } else if (position < 123) {
  43940. ulUnicodeRange4 |= 1 << position - 96;
  43941. } else {
  43942. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43943. }
  43944. }
  43945. } else {
  43946. firstCharIndex = 0;
  43947. lastCharIndex = 255;
  43948. }
  43949. var bbox = properties.bbox || [
  43950. 0,
  43951. 0,
  43952. 0,
  43953. 0
  43954. ];
  43955. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43956. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43957. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43958. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43959. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43960. typoDescent = -typoDescent;
  43961. }
  43962. var winAscent = override.yMax || typoAscent;
  43963. var winDescent = -override.yMin || -typoDescent;
  43964. 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';
  43965. }
  43966. function createPostTable(properties) {
  43967. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43968. 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';
  43969. }
  43970. function createNameTable(name, proto) {
  43971. if (!proto) {
  43972. proto = [
  43973. [],
  43974. []
  43975. ];
  43976. }
  43977. var strings = [
  43978. proto[0][0] || 'Original licence',
  43979. proto[0][1] || name,
  43980. proto[0][2] || 'Unknown',
  43981. proto[0][3] || 'uniqueID',
  43982. proto[0][4] || name,
  43983. proto[0][5] || 'Version 0.11',
  43984. proto[0][6] || '',
  43985. proto[0][7] || 'Unknown',
  43986. proto[0][8] || 'Unknown',
  43987. proto[0][9] || 'Unknown'
  43988. ];
  43989. var stringsUnicode = [];
  43990. var i, ii, j, jj, str;
  43991. for (i = 0, ii = strings.length; i < ii; i++) {
  43992. str = proto[1][i] || strings[i];
  43993. var strBufUnicode = [];
  43994. for (j = 0, jj = str.length; j < jj; j++) {
  43995. strBufUnicode.push(string16(str.charCodeAt(j)));
  43996. }
  43997. stringsUnicode.push(strBufUnicode.join(''));
  43998. }
  43999. var names = [
  44000. strings,
  44001. stringsUnicode
  44002. ];
  44003. var platforms = [
  44004. '\x00\x01',
  44005. '\x00\x03'
  44006. ];
  44007. var encodings = [
  44008. '\x00\x00',
  44009. '\x00\x01'
  44010. ];
  44011. var languages = [
  44012. '\x00\x00',
  44013. '\x04\x09'
  44014. ];
  44015. var namesRecordCount = strings.length * platforms.length;
  44016. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44017. var strOffset = 0;
  44018. for (i = 0, ii = platforms.length; i < ii; i++) {
  44019. var strs = names[i];
  44020. for (j = 0, jj = strs.length; j < jj; j++) {
  44021. str = strs[j];
  44022. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44023. nameTable += nameRecord;
  44024. strOffset += str.length;
  44025. }
  44026. }
  44027. nameTable += strings.join('') + stringsUnicode.join('');
  44028. return nameTable;
  44029. }
  44030. Font.prototype = {
  44031. name: null,
  44032. font: null,
  44033. mimetype: null,
  44034. encoding: null,
  44035. get renderer() {
  44036. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44037. return shadow(this, 'renderer', renderer);
  44038. },
  44039. exportData: function Font_exportData() {
  44040. var data = {};
  44041. for (var i in this) {
  44042. if (this.hasOwnProperty(i)) {
  44043. data[i] = this[i];
  44044. }
  44045. }
  44046. return data;
  44047. },
  44048. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44049. function readTableEntry(file) {
  44050. var tag = bytesToString(file.getBytes(4));
  44051. var checksum = file.getInt32() >>> 0;
  44052. var offset = file.getInt32() >>> 0;
  44053. var length = file.getInt32() >>> 0;
  44054. var previousPosition = file.pos;
  44055. file.pos = file.start ? file.start : 0;
  44056. file.skip(offset);
  44057. var data = file.getBytes(length);
  44058. file.pos = previousPosition;
  44059. if (tag === 'head') {
  44060. data[8] = data[9] = data[10] = data[11] = 0;
  44061. data[17] |= 0x20;
  44062. }
  44063. return {
  44064. tag: tag,
  44065. checksum: checksum,
  44066. length: length,
  44067. offset: offset,
  44068. data: data
  44069. };
  44070. }
  44071. function readOpenTypeHeader(ttf) {
  44072. return {
  44073. version: bytesToString(ttf.getBytes(4)),
  44074. numTables: ttf.getUint16(),
  44075. searchRange: ttf.getUint16(),
  44076. entrySelector: ttf.getUint16(),
  44077. rangeShift: ttf.getUint16()
  44078. };
  44079. }
  44080. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44081. if (!cmap) {
  44082. warn('No cmap table available.');
  44083. return {
  44084. platformId: -1,
  44085. encodingId: -1,
  44086. mappings: [],
  44087. hasShortCmap: false
  44088. };
  44089. }
  44090. var segment;
  44091. var start = (font.start ? font.start : 0) + cmap.offset;
  44092. font.pos = start;
  44093. font.getUint16();
  44094. var numTables = font.getUint16();
  44095. var potentialTable;
  44096. var canBreak = false;
  44097. for (var i = 0; i < numTables; i++) {
  44098. var platformId = font.getUint16();
  44099. var encodingId = font.getUint16();
  44100. var offset = font.getInt32() >>> 0;
  44101. var useTable = false;
  44102. if (platformId === 0 && encodingId === 0) {
  44103. useTable = true;
  44104. } else if (platformId === 1 && encodingId === 0) {
  44105. useTable = true;
  44106. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44107. useTable = true;
  44108. if (!isSymbolicFont) {
  44109. canBreak = true;
  44110. }
  44111. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44112. useTable = true;
  44113. canBreak = true;
  44114. }
  44115. if (useTable) {
  44116. potentialTable = {
  44117. platformId: platformId,
  44118. encodingId: encodingId,
  44119. offset: offset
  44120. };
  44121. }
  44122. if (canBreak) {
  44123. break;
  44124. }
  44125. }
  44126. if (potentialTable) {
  44127. font.pos = start + potentialTable.offset;
  44128. }
  44129. if (!potentialTable || font.peekByte() === -1) {
  44130. warn('Could not find a preferred cmap table.');
  44131. return {
  44132. platformId: -1,
  44133. encodingId: -1,
  44134. mappings: [],
  44135. hasShortCmap: false
  44136. };
  44137. }
  44138. var format = font.getUint16();
  44139. font.getUint16();
  44140. font.getUint16();
  44141. var hasShortCmap = false;
  44142. var mappings = [];
  44143. var j, glyphId;
  44144. if (format === 0) {
  44145. for (j = 0; j < 256; j++) {
  44146. var index = font.getByte();
  44147. if (!index) {
  44148. continue;
  44149. }
  44150. mappings.push({
  44151. charCode: j,
  44152. glyphId: index
  44153. });
  44154. }
  44155. hasShortCmap = true;
  44156. } else if (format === 4) {
  44157. var segCount = font.getUint16() >> 1;
  44158. font.getBytes(6);
  44159. var segIndex, segments = [];
  44160. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44161. segments.push({ end: font.getUint16() });
  44162. }
  44163. font.getUint16();
  44164. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44165. segments[segIndex].start = font.getUint16();
  44166. }
  44167. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44168. segments[segIndex].delta = font.getUint16();
  44169. }
  44170. var offsetsCount = 0;
  44171. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44172. segment = segments[segIndex];
  44173. var rangeOffset = font.getUint16();
  44174. if (!rangeOffset) {
  44175. segment.offsetIndex = -1;
  44176. continue;
  44177. }
  44178. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44179. segment.offsetIndex = offsetIndex;
  44180. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44181. }
  44182. var offsets = [];
  44183. for (j = 0; j < offsetsCount; j++) {
  44184. offsets.push(font.getUint16());
  44185. }
  44186. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44187. segment = segments[segIndex];
  44188. start = segment.start;
  44189. var end = segment.end;
  44190. var delta = segment.delta;
  44191. offsetIndex = segment.offsetIndex;
  44192. for (j = start; j <= end; j++) {
  44193. if (j === 0xFFFF) {
  44194. continue;
  44195. }
  44196. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44197. glyphId = glyphId + delta & 0xFFFF;
  44198. if (glyphId === 0) {
  44199. continue;
  44200. }
  44201. mappings.push({
  44202. charCode: j,
  44203. glyphId: glyphId
  44204. });
  44205. }
  44206. }
  44207. } else if (format === 6) {
  44208. var firstCode = font.getUint16();
  44209. var entryCount = font.getUint16();
  44210. for (j = 0; j < entryCount; j++) {
  44211. glyphId = font.getUint16();
  44212. var charCode = firstCode + j;
  44213. mappings.push({
  44214. charCode: charCode,
  44215. glyphId: glyphId
  44216. });
  44217. }
  44218. } else {
  44219. warn('cmap table has unsupported format: ' + format);
  44220. return {
  44221. platformId: -1,
  44222. encodingId: -1,
  44223. mappings: [],
  44224. hasShortCmap: false
  44225. };
  44226. }
  44227. mappings.sort(function (a, b) {
  44228. return a.charCode - b.charCode;
  44229. });
  44230. for (i = 1; i < mappings.length; i++) {
  44231. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44232. mappings.splice(i, 1);
  44233. i--;
  44234. }
  44235. }
  44236. return {
  44237. platformId: potentialTable.platformId,
  44238. encodingId: potentialTable.encodingId,
  44239. mappings: mappings,
  44240. hasShortCmap: hasShortCmap
  44241. };
  44242. }
  44243. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44244. if (!header) {
  44245. if (metrics) {
  44246. metrics.data = null;
  44247. }
  44248. return;
  44249. }
  44250. font.pos = (font.start ? font.start : 0) + header.offset;
  44251. font.pos += header.length - 2;
  44252. var numOfMetrics = font.getUint16();
  44253. if (numOfMetrics > numGlyphs) {
  44254. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44255. numOfMetrics = numGlyphs;
  44256. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44257. header.data[35] = numOfMetrics & 0x00ff;
  44258. }
  44259. var numOfSidebearings = numGlyphs - numOfMetrics;
  44260. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44261. if (numMissing > 0) {
  44262. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44263. entries.set(metrics.data);
  44264. metrics.data = entries;
  44265. }
  44266. }
  44267. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44268. if (sourceEnd - sourceStart <= 12) {
  44269. return 0;
  44270. }
  44271. var glyf = source.subarray(sourceStart, sourceEnd);
  44272. var contoursCount = glyf[0] << 8 | glyf[1];
  44273. if (contoursCount & 0x8000) {
  44274. dest.set(glyf, destStart);
  44275. return glyf.length;
  44276. }
  44277. var i, j = 10, flagsCount = 0;
  44278. for (i = 0; i < contoursCount; i++) {
  44279. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44280. flagsCount = endPoint + 1;
  44281. j += 2;
  44282. }
  44283. var instructionsStart = j;
  44284. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44285. j += 2 + instructionsLength;
  44286. var instructionsEnd = j;
  44287. var coordinatesLength = 0;
  44288. for (i = 0; i < flagsCount; i++) {
  44289. var flag = glyf[j++];
  44290. if (flag & 0xC0) {
  44291. glyf[j - 1] = flag & 0x3F;
  44292. }
  44293. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44294. coordinatesLength += xyLength;
  44295. if (flag & 8) {
  44296. var repeat = glyf[j++];
  44297. i += repeat;
  44298. coordinatesLength += repeat * xyLength;
  44299. }
  44300. }
  44301. if (coordinatesLength === 0) {
  44302. return 0;
  44303. }
  44304. var glyphDataLength = j + coordinatesLength;
  44305. if (glyphDataLength > glyf.length) {
  44306. return 0;
  44307. }
  44308. if (!hintsValid && instructionsLength > 0) {
  44309. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44310. dest.set([
  44311. 0,
  44312. 0
  44313. ], destStart + instructionsStart);
  44314. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44315. glyphDataLength -= instructionsLength;
  44316. if (glyf.length - glyphDataLength > 3) {
  44317. glyphDataLength = glyphDataLength + 3 & ~3;
  44318. }
  44319. return glyphDataLength;
  44320. }
  44321. if (glyf.length - glyphDataLength > 3) {
  44322. glyphDataLength = glyphDataLength + 3 & ~3;
  44323. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44324. return glyphDataLength;
  44325. }
  44326. dest.set(glyf, destStart);
  44327. return glyf.length;
  44328. }
  44329. function sanitizeHead(head, numGlyphs, locaLength) {
  44330. var data = head.data;
  44331. var version = int32(data[0], data[1], data[2], data[3]);
  44332. if (version >> 16 !== 1) {
  44333. info('Attempting to fix invalid version in head table: ' + version);
  44334. data[0] = 0;
  44335. data[1] = 1;
  44336. data[2] = 0;
  44337. data[3] = 0;
  44338. }
  44339. var indexToLocFormat = int16(data[50], data[51]);
  44340. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44341. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44342. var numGlyphsPlusOne = numGlyphs + 1;
  44343. if (locaLength === numGlyphsPlusOne << 1) {
  44344. data[50] = 0;
  44345. data[51] = 0;
  44346. } else if (locaLength === numGlyphsPlusOne << 2) {
  44347. data[50] = 0;
  44348. data[51] = 1;
  44349. } else {
  44350. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44351. }
  44352. }
  44353. }
  44354. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44355. var itemSize, itemDecode, itemEncode;
  44356. if (isGlyphLocationsLong) {
  44357. itemSize = 4;
  44358. itemDecode = function fontItemDecodeLong(data, offset) {
  44359. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44360. };
  44361. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44362. data[offset] = value >>> 24 & 0xFF;
  44363. data[offset + 1] = value >> 16 & 0xFF;
  44364. data[offset + 2] = value >> 8 & 0xFF;
  44365. data[offset + 3] = value & 0xFF;
  44366. };
  44367. } else {
  44368. itemSize = 2;
  44369. itemDecode = function fontItemDecode(data, offset) {
  44370. return data[offset] << 9 | data[offset + 1] << 1;
  44371. };
  44372. itemEncode = function fontItemEncode(data, offset, value) {
  44373. data[offset] = value >> 9 & 0xFF;
  44374. data[offset + 1] = value >> 1 & 0xFF;
  44375. };
  44376. }
  44377. var locaData = loca.data;
  44378. var locaDataSize = itemSize * (1 + numGlyphs);
  44379. if (locaData.length !== locaDataSize) {
  44380. locaData = new Uint8Array(locaDataSize);
  44381. locaData.set(loca.data.subarray(0, locaDataSize));
  44382. loca.data = locaData;
  44383. }
  44384. var oldGlyfData = glyf.data;
  44385. var oldGlyfDataLength = oldGlyfData.length;
  44386. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44387. var startOffset = itemDecode(locaData, 0);
  44388. var writeOffset = 0;
  44389. var missingGlyphData = Object.create(null);
  44390. itemEncode(locaData, 0, writeOffset);
  44391. var i, j;
  44392. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44393. var endOffset = itemDecode(locaData, j);
  44394. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44395. endOffset = oldGlyfDataLength;
  44396. }
  44397. if (endOffset > oldGlyfDataLength) {
  44398. itemEncode(locaData, j, writeOffset);
  44399. startOffset = endOffset;
  44400. continue;
  44401. }
  44402. if (startOffset === endOffset) {
  44403. missingGlyphData[i] = true;
  44404. }
  44405. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44406. writeOffset += newLength;
  44407. itemEncode(locaData, j, writeOffset);
  44408. startOffset = endOffset;
  44409. }
  44410. if (writeOffset === 0) {
  44411. var simpleGlyph = new Uint8Array([
  44412. 0,
  44413. 1,
  44414. 0,
  44415. 0,
  44416. 0,
  44417. 0,
  44418. 0,
  44419. 0,
  44420. 0,
  44421. 0,
  44422. 0,
  44423. 0,
  44424. 0,
  44425. 0,
  44426. 49,
  44427. 0
  44428. ]);
  44429. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44430. itemEncode(locaData, j, simpleGlyph.length);
  44431. }
  44432. glyf.data = simpleGlyph;
  44433. return missingGlyphData;
  44434. }
  44435. if (dupFirstEntry) {
  44436. var firstEntryLength = itemDecode(locaData, itemSize);
  44437. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44438. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44439. } else {
  44440. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44441. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44442. }
  44443. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44444. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44445. } else {
  44446. glyf.data = newGlyfData.subarray(0, writeOffset);
  44447. }
  44448. return missingGlyphData;
  44449. }
  44450. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44451. var start = (font.start ? font.start : 0) + post.offset;
  44452. font.pos = start;
  44453. var length = post.length, end = start + length;
  44454. var version = font.getInt32();
  44455. font.getBytes(28);
  44456. var glyphNames;
  44457. var valid = true;
  44458. var i;
  44459. switch (version) {
  44460. case 0x00010000:
  44461. glyphNames = MacStandardGlyphOrdering;
  44462. break;
  44463. case 0x00020000:
  44464. var numGlyphs = font.getUint16();
  44465. if (numGlyphs !== maxpNumGlyphs) {
  44466. valid = false;
  44467. break;
  44468. }
  44469. var glyphNameIndexes = [];
  44470. for (i = 0; i < numGlyphs; ++i) {
  44471. var index = font.getUint16();
  44472. if (index >= 32768) {
  44473. valid = false;
  44474. break;
  44475. }
  44476. glyphNameIndexes.push(index);
  44477. }
  44478. if (!valid) {
  44479. break;
  44480. }
  44481. var customNames = [];
  44482. var strBuf = [];
  44483. while (font.pos < end) {
  44484. var stringLength = font.getByte();
  44485. strBuf.length = stringLength;
  44486. for (i = 0; i < stringLength; ++i) {
  44487. strBuf[i] = String.fromCharCode(font.getByte());
  44488. }
  44489. customNames.push(strBuf.join(''));
  44490. }
  44491. glyphNames = [];
  44492. for (i = 0; i < numGlyphs; ++i) {
  44493. var j = glyphNameIndexes[i];
  44494. if (j < 258) {
  44495. glyphNames.push(MacStandardGlyphOrdering[j]);
  44496. continue;
  44497. }
  44498. glyphNames.push(customNames[j - 258]);
  44499. }
  44500. break;
  44501. case 0x00030000:
  44502. break;
  44503. default:
  44504. warn('Unknown/unsupported post table version ' + version);
  44505. valid = false;
  44506. if (properties.defaultEncoding) {
  44507. glyphNames = properties.defaultEncoding;
  44508. }
  44509. break;
  44510. }
  44511. properties.glyphNames = glyphNames;
  44512. return valid;
  44513. }
  44514. function readNameTable(nameTable) {
  44515. var start = (font.start ? font.start : 0) + nameTable.offset;
  44516. font.pos = start;
  44517. var names = [
  44518. [],
  44519. []
  44520. ];
  44521. var length = nameTable.length, end = start + length;
  44522. var format = font.getUint16();
  44523. var FORMAT_0_HEADER_LENGTH = 6;
  44524. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44525. return names;
  44526. }
  44527. var numRecords = font.getUint16();
  44528. var stringsStart = font.getUint16();
  44529. var records = [];
  44530. var NAME_RECORD_LENGTH = 12;
  44531. var i, ii;
  44532. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44533. var r = {
  44534. platform: font.getUint16(),
  44535. encoding: font.getUint16(),
  44536. language: font.getUint16(),
  44537. name: font.getUint16(),
  44538. length: font.getUint16(),
  44539. offset: font.getUint16()
  44540. };
  44541. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44542. records.push(r);
  44543. }
  44544. }
  44545. for (i = 0, ii = records.length; i < ii; i++) {
  44546. var record = records[i];
  44547. if (record.length <= 0) {
  44548. continue;
  44549. }
  44550. var pos = start + stringsStart + record.offset;
  44551. if (pos + record.length > end) {
  44552. continue;
  44553. }
  44554. font.pos = pos;
  44555. var nameIndex = record.name;
  44556. if (record.encoding) {
  44557. var str = '';
  44558. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44559. str += String.fromCharCode(font.getUint16());
  44560. }
  44561. names[1][nameIndex] = str;
  44562. } else {
  44563. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44564. }
  44565. }
  44566. return names;
  44567. }
  44568. var TTOpsStackDeltas = [
  44569. 0,
  44570. 0,
  44571. 0,
  44572. 0,
  44573. 0,
  44574. 0,
  44575. 0,
  44576. 0,
  44577. -2,
  44578. -2,
  44579. -2,
  44580. -2,
  44581. 0,
  44582. 0,
  44583. -2,
  44584. -5,
  44585. -1,
  44586. -1,
  44587. -1,
  44588. -1,
  44589. -1,
  44590. -1,
  44591. -1,
  44592. -1,
  44593. 0,
  44594. 0,
  44595. -1,
  44596. 0,
  44597. -1,
  44598. -1,
  44599. -1,
  44600. -1,
  44601. 1,
  44602. -1,
  44603. -999,
  44604. 0,
  44605. 1,
  44606. 0,
  44607. -1,
  44608. -2,
  44609. 0,
  44610. -1,
  44611. -2,
  44612. -1,
  44613. -1,
  44614. 0,
  44615. -1,
  44616. -1,
  44617. 0,
  44618. 0,
  44619. -999,
  44620. -999,
  44621. -1,
  44622. -1,
  44623. -1,
  44624. -1,
  44625. -2,
  44626. -999,
  44627. -2,
  44628. -2,
  44629. -999,
  44630. 0,
  44631. -2,
  44632. -2,
  44633. 0,
  44634. 0,
  44635. -2,
  44636. 0,
  44637. -2,
  44638. 0,
  44639. 0,
  44640. 0,
  44641. -2,
  44642. -1,
  44643. -1,
  44644. 1,
  44645. 1,
  44646. 0,
  44647. 0,
  44648. -1,
  44649. -1,
  44650. -1,
  44651. -1,
  44652. -1,
  44653. -1,
  44654. -1,
  44655. 0,
  44656. 0,
  44657. -1,
  44658. 0,
  44659. -1,
  44660. -1,
  44661. 0,
  44662. -999,
  44663. -1,
  44664. -1,
  44665. -1,
  44666. -1,
  44667. -1,
  44668. -1,
  44669. 0,
  44670. 0,
  44671. 0,
  44672. 0,
  44673. 0,
  44674. 0,
  44675. 0,
  44676. 0,
  44677. 0,
  44678. 0,
  44679. 0,
  44680. 0,
  44681. -2,
  44682. -999,
  44683. -999,
  44684. -999,
  44685. -999,
  44686. -999,
  44687. -1,
  44688. -1,
  44689. -2,
  44690. -2,
  44691. 0,
  44692. 0,
  44693. 0,
  44694. 0,
  44695. -1,
  44696. -1,
  44697. -999,
  44698. -2,
  44699. -2,
  44700. 0,
  44701. 0,
  44702. -1,
  44703. -2,
  44704. -2,
  44705. 0,
  44706. 0,
  44707. 0,
  44708. -1,
  44709. -1,
  44710. -1,
  44711. -2
  44712. ];
  44713. function sanitizeTTProgram(table, ttContext) {
  44714. var data = table.data;
  44715. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44716. var stack = [];
  44717. var callstack = [];
  44718. var functionsCalled = [];
  44719. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44720. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44721. for (var ii = data.length; i < ii;) {
  44722. var op = data[i++];
  44723. if (op === 0x40) {
  44724. n = data[i++];
  44725. if (inFDEF || inELSE) {
  44726. i += n;
  44727. } else {
  44728. for (j = 0; j < n; j++) {
  44729. stack.push(data[i++]);
  44730. }
  44731. }
  44732. } else if (op === 0x41) {
  44733. n = data[i++];
  44734. if (inFDEF || inELSE) {
  44735. i += n * 2;
  44736. } else {
  44737. for (j = 0; j < n; j++) {
  44738. b = data[i++];
  44739. stack.push(b << 8 | data[i++]);
  44740. }
  44741. }
  44742. } else if ((op & 0xF8) === 0xB0) {
  44743. n = op - 0xB0 + 1;
  44744. if (inFDEF || inELSE) {
  44745. i += n;
  44746. } else {
  44747. for (j = 0; j < n; j++) {
  44748. stack.push(data[i++]);
  44749. }
  44750. }
  44751. } else if ((op & 0xF8) === 0xB8) {
  44752. n = op - 0xB8 + 1;
  44753. if (inFDEF || inELSE) {
  44754. i += n * 2;
  44755. } else {
  44756. for (j = 0; j < n; j++) {
  44757. b = data[i++];
  44758. stack.push(b << 8 | data[i++]);
  44759. }
  44760. }
  44761. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44762. if (!inFDEF && !inELSE) {
  44763. funcId = stack[stack.length - 1];
  44764. ttContext.functionsUsed[funcId] = true;
  44765. if (funcId in ttContext.functionsStackDeltas) {
  44766. stack.length += ttContext.functionsStackDeltas[funcId];
  44767. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44768. callstack.push({
  44769. data: data,
  44770. i: i,
  44771. stackTop: stack.length - 1
  44772. });
  44773. functionsCalled.push(funcId);
  44774. pc = ttContext.functionsDefined[funcId];
  44775. if (!pc) {
  44776. warn('TT: CALL non-existent function');
  44777. ttContext.hintsValid = false;
  44778. return;
  44779. }
  44780. data = pc.data;
  44781. i = pc.i;
  44782. }
  44783. }
  44784. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44785. if (inFDEF || inELSE) {
  44786. warn('TT: nested FDEFs not allowed');
  44787. tooComplexToFollowFunctions = true;
  44788. }
  44789. inFDEF = true;
  44790. lastDeff = i;
  44791. funcId = stack.pop();
  44792. ttContext.functionsDefined[funcId] = {
  44793. data: data,
  44794. i: i
  44795. };
  44796. } else if (op === 0x2D) {
  44797. if (inFDEF) {
  44798. inFDEF = false;
  44799. lastEndf = i;
  44800. } else {
  44801. pc = callstack.pop();
  44802. if (!pc) {
  44803. warn('TT: ENDF bad stack');
  44804. ttContext.hintsValid = false;
  44805. return;
  44806. }
  44807. funcId = functionsCalled.pop();
  44808. data = pc.data;
  44809. i = pc.i;
  44810. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44811. }
  44812. } else if (op === 0x89) {
  44813. if (inFDEF || inELSE) {
  44814. warn('TT: nested IDEFs not allowed');
  44815. tooComplexToFollowFunctions = true;
  44816. }
  44817. inFDEF = true;
  44818. lastDeff = i;
  44819. } else if (op === 0x58) {
  44820. ++ifLevel;
  44821. } else if (op === 0x1B) {
  44822. inELSE = ifLevel;
  44823. } else if (op === 0x59) {
  44824. if (inELSE === ifLevel) {
  44825. inELSE = 0;
  44826. }
  44827. --ifLevel;
  44828. } else if (op === 0x1C) {
  44829. if (!inFDEF && !inELSE) {
  44830. var offset = stack[stack.length - 1];
  44831. if (offset > 0) {
  44832. i += offset - 1;
  44833. }
  44834. }
  44835. }
  44836. if (!inFDEF && !inELSE) {
  44837. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44838. if (op >= 0x71 && op <= 0x75) {
  44839. n = stack.pop();
  44840. if (!isNaN(n)) {
  44841. stackDelta = -n * 2;
  44842. }
  44843. }
  44844. while (stackDelta < 0 && stack.length > 0) {
  44845. stack.pop();
  44846. stackDelta++;
  44847. }
  44848. while (stackDelta > 0) {
  44849. stack.push(NaN);
  44850. stackDelta--;
  44851. }
  44852. }
  44853. }
  44854. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44855. var content = [data];
  44856. if (i > data.length) {
  44857. content.push(new Uint8Array(i - data.length));
  44858. }
  44859. if (lastDeff > lastEndf) {
  44860. warn('TT: complementing a missing function tail');
  44861. content.push(new Uint8Array([
  44862. 0x22,
  44863. 0x2D
  44864. ]));
  44865. }
  44866. foldTTTable(table, content);
  44867. }
  44868. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44869. if (ttContext.tooComplexToFollowFunctions) {
  44870. return;
  44871. }
  44872. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44873. warn('TT: more functions defined than expected');
  44874. ttContext.hintsValid = false;
  44875. return;
  44876. }
  44877. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44878. if (j > maxFunctionDefs) {
  44879. warn('TT: invalid function id: ' + j);
  44880. ttContext.hintsValid = false;
  44881. return;
  44882. }
  44883. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44884. warn('TT: undefined function: ' + j);
  44885. ttContext.hintsValid = false;
  44886. return;
  44887. }
  44888. }
  44889. }
  44890. function foldTTTable(table, content) {
  44891. if (content.length > 1) {
  44892. var newLength = 0;
  44893. var j, jj;
  44894. for (j = 0, jj = content.length; j < jj; j++) {
  44895. newLength += content[j].length;
  44896. }
  44897. newLength = newLength + 3 & ~3;
  44898. var result = new Uint8Array(newLength);
  44899. var pos = 0;
  44900. for (j = 0, jj = content.length; j < jj; j++) {
  44901. result.set(content[j], pos);
  44902. pos += content[j].length;
  44903. }
  44904. table.data = result;
  44905. table.length = newLength;
  44906. }
  44907. }
  44908. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44909. var ttContext = {
  44910. functionsDefined: [],
  44911. functionsUsed: [],
  44912. functionsStackDeltas: [],
  44913. tooComplexToFollowFunctions: false,
  44914. hintsValid: true
  44915. };
  44916. if (fpgm) {
  44917. sanitizeTTProgram(fpgm, ttContext);
  44918. }
  44919. if (prep) {
  44920. sanitizeTTProgram(prep, ttContext);
  44921. }
  44922. if (fpgm) {
  44923. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44924. }
  44925. if (cvt && cvt.length & 1) {
  44926. var cvtData = new Uint8Array(cvt.length + 1);
  44927. cvtData.set(cvt.data);
  44928. cvt.data = cvtData;
  44929. }
  44930. return ttContext.hintsValid;
  44931. }
  44932. font = new Stream(new Uint8Array(font.getBytes()));
  44933. var VALID_TABLES = [
  44934. 'OS/2',
  44935. 'cmap',
  44936. 'head',
  44937. 'hhea',
  44938. 'hmtx',
  44939. 'maxp',
  44940. 'name',
  44941. 'post',
  44942. 'loca',
  44943. 'glyf',
  44944. 'fpgm',
  44945. 'prep',
  44946. 'cvt ',
  44947. 'CFF '
  44948. ];
  44949. var header = readOpenTypeHeader(font);
  44950. var numTables = header.numTables;
  44951. var cff, cffFile;
  44952. var tables = Object.create(null);
  44953. tables['OS/2'] = null;
  44954. tables['cmap'] = null;
  44955. tables['head'] = null;
  44956. tables['hhea'] = null;
  44957. tables['hmtx'] = null;
  44958. tables['maxp'] = null;
  44959. tables['name'] = null;
  44960. tables['post'] = null;
  44961. var table;
  44962. for (var i = 0; i < numTables; i++) {
  44963. table = readTableEntry(font);
  44964. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44965. continue;
  44966. }
  44967. if (table.length === 0) {
  44968. continue;
  44969. }
  44970. tables[table.tag] = table;
  44971. }
  44972. var isTrueType = !tables['CFF '];
  44973. if (!isTrueType) {
  44974. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44975. cffFile = new Stream(tables['CFF '].data);
  44976. cff = new CFFFont(cffFile, properties);
  44977. adjustWidths(properties);
  44978. return this.convert(name, cff, properties);
  44979. }
  44980. delete tables['glyf'];
  44981. delete tables['loca'];
  44982. delete tables['fpgm'];
  44983. delete tables['prep'];
  44984. delete tables['cvt '];
  44985. this.isOpenType = true;
  44986. } else {
  44987. if (!tables['loca']) {
  44988. error('Required "loca" table is not found');
  44989. }
  44990. if (!tables['glyf']) {
  44991. warn('Required "glyf" table is not found -- trying to recover.');
  44992. tables['glyf'] = {
  44993. tag: 'glyf',
  44994. data: new Uint8Array(0)
  44995. };
  44996. }
  44997. this.isOpenType = false;
  44998. }
  44999. if (!tables['maxp']) {
  45000. error('Required "maxp" table is not found');
  45001. }
  45002. font.pos = (font.start || 0) + tables['maxp'].offset;
  45003. var version = font.getInt32();
  45004. var numGlyphs = font.getUint16();
  45005. var maxFunctionDefs = 0;
  45006. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45007. font.pos += 8;
  45008. var maxZones = font.getUint16();
  45009. if (maxZones > 2) {
  45010. tables['maxp'].data[14] = 0;
  45011. tables['maxp'].data[15] = 2;
  45012. }
  45013. font.pos += 4;
  45014. maxFunctionDefs = font.getUint16();
  45015. }
  45016. var dupFirstEntry = false;
  45017. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45018. dupFirstEntry = true;
  45019. numGlyphs++;
  45020. tables['maxp'].data[4] = numGlyphs >> 8;
  45021. tables['maxp'].data[5] = numGlyphs & 255;
  45022. }
  45023. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45024. if (!hintsValid) {
  45025. delete tables['fpgm'];
  45026. delete tables['prep'];
  45027. delete tables['cvt '];
  45028. }
  45029. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45030. if (!tables['head']) {
  45031. error('Required "head" table is not found');
  45032. }
  45033. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45034. var missingGlyphs = Object.create(null);
  45035. if (isTrueType) {
  45036. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45037. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45038. }
  45039. if (!tables['hhea']) {
  45040. error('Required "hhea" table is not found');
  45041. }
  45042. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45043. tables['hhea'].data[10] = 0xFF;
  45044. tables['hhea'].data[11] = 0xFF;
  45045. }
  45046. var metricsOverride = {
  45047. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45048. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45049. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45050. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45051. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45052. };
  45053. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45054. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45055. if (tables['post']) {
  45056. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45057. if (!valid) {
  45058. tables['post'] = null;
  45059. }
  45060. }
  45061. var charCodeToGlyphId = [], charCode;
  45062. var toUnicode = properties.toUnicode, widths = properties.widths;
  45063. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45064. function hasGlyph(glyphId, charCode, widthCode) {
  45065. if (!missingGlyphs[glyphId]) {
  45066. return true;
  45067. }
  45068. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45069. return true;
  45070. }
  45071. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45072. return true;
  45073. }
  45074. return false;
  45075. }
  45076. if (properties.composite) {
  45077. var cidToGidMap = properties.cidToGidMap || [];
  45078. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45079. properties.cMap.forEach(function (charCode, cid) {
  45080. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45081. var glyphId = -1;
  45082. if (isCidToGidMapEmpty) {
  45083. glyphId = cid;
  45084. } else if (cidToGidMap[cid] !== undefined) {
  45085. glyphId = cidToGidMap[cid];
  45086. }
  45087. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45088. charCodeToGlyphId[charCode] = glyphId;
  45089. }
  45090. });
  45091. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45092. charCodeToGlyphId[0] = numGlyphs - 1;
  45093. }
  45094. } else {
  45095. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45096. var cmapPlatformId = cmapTable.platformId;
  45097. var cmapEncodingId = cmapTable.encodingId;
  45098. var cmapMappings = cmapTable.mappings;
  45099. var cmapMappingsLength = cmapMappings.length;
  45100. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45101. var baseEncoding = [];
  45102. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45103. baseEncoding = getEncoding(properties.baseEncodingName);
  45104. }
  45105. var glyphsUnicodeMap = getGlyphsUnicode();
  45106. for (charCode = 0; charCode < 256; charCode++) {
  45107. var glyphName, standardGlyphName;
  45108. if (this.differences && charCode in this.differences) {
  45109. glyphName = this.differences[charCode];
  45110. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45111. glyphName = baseEncoding[charCode];
  45112. } else {
  45113. glyphName = StandardEncoding[charCode];
  45114. }
  45115. if (!glyphName) {
  45116. continue;
  45117. }
  45118. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45119. var unicodeOrCharCode, isUnicode = false;
  45120. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45121. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45122. isUnicode = true;
  45123. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45124. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45125. }
  45126. var found = false;
  45127. for (i = 0; i < cmapMappingsLength; ++i) {
  45128. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45129. continue;
  45130. }
  45131. var code = isUnicode ? charCode : unicodeOrCharCode;
  45132. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45133. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45134. found = true;
  45135. break;
  45136. }
  45137. }
  45138. if (!found && properties.glyphNames) {
  45139. var glyphId = properties.glyphNames.indexOf(glyphName);
  45140. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45141. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45142. }
  45143. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45144. charCodeToGlyphId[charCode] = glyphId;
  45145. found = true;
  45146. }
  45147. }
  45148. if (!found) {
  45149. charCodeToGlyphId[charCode] = 0;
  45150. }
  45151. }
  45152. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45153. for (i = 0; i < cmapMappingsLength; ++i) {
  45154. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45155. }
  45156. } else {
  45157. for (i = 0; i < cmapMappingsLength; ++i) {
  45158. charCode = cmapMappings[i].charCode & 0xFF;
  45159. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45160. }
  45161. }
  45162. }
  45163. if (charCodeToGlyphId.length === 0) {
  45164. charCodeToGlyphId[0] = 0;
  45165. }
  45166. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45167. this.toFontChar = newMapping.toFontChar;
  45168. tables['cmap'] = {
  45169. tag: 'cmap',
  45170. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45171. };
  45172. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45173. tables['OS/2'] = {
  45174. tag: 'OS/2',
  45175. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45176. };
  45177. }
  45178. if (!tables['post']) {
  45179. tables['post'] = {
  45180. tag: 'post',
  45181. data: createPostTable(properties)
  45182. };
  45183. }
  45184. if (!isTrueType) {
  45185. try {
  45186. cffFile = new Stream(tables['CFF '].data);
  45187. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45188. cff = parser.parse();
  45189. var compiler = new CFFCompiler(cff);
  45190. tables['CFF '].data = compiler.compile();
  45191. } catch (e) {
  45192. warn('Failed to compile font ' + properties.loadedName);
  45193. }
  45194. }
  45195. if (!tables['name']) {
  45196. tables['name'] = {
  45197. tag: 'name',
  45198. data: createNameTable(this.name)
  45199. };
  45200. } else {
  45201. var namePrototype = readNameTable(tables['name']);
  45202. tables['name'].data = createNameTable(name, namePrototype);
  45203. }
  45204. var builder = new OpenTypeFileBuilder(header.version);
  45205. for (var tableTag in tables) {
  45206. builder.addTable(tableTag, tables[tableTag].data);
  45207. }
  45208. return builder.toArray();
  45209. },
  45210. convert: function Font_convert(fontName, font, properties) {
  45211. properties.fixedPitch = false;
  45212. if (properties.builtInEncoding) {
  45213. adjustToUnicode(properties, properties.builtInEncoding);
  45214. }
  45215. var mapping = font.getGlyphMapping(properties);
  45216. var newMapping = adjustMapping(mapping, properties);
  45217. this.toFontChar = newMapping.toFontChar;
  45218. var numGlyphs = font.numGlyphs;
  45219. function getCharCodes(charCodeToGlyphId, glyphId) {
  45220. var charCodes = null;
  45221. for (var charCode in charCodeToGlyphId) {
  45222. if (glyphId === charCodeToGlyphId[charCode]) {
  45223. if (!charCodes) {
  45224. charCodes = [];
  45225. }
  45226. charCodes.push(charCode | 0);
  45227. }
  45228. }
  45229. return charCodes;
  45230. }
  45231. function createCharCode(charCodeToGlyphId, glyphId) {
  45232. for (var charCode in charCodeToGlyphId) {
  45233. if (glyphId === charCodeToGlyphId[charCode]) {
  45234. return charCode | 0;
  45235. }
  45236. }
  45237. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45238. return newMapping.nextAvailableFontCharCode++;
  45239. }
  45240. var seacs = font.seacs;
  45241. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45242. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45243. var charset = font.getCharset();
  45244. var seacMap = Object.create(null);
  45245. for (var glyphId in seacs) {
  45246. glyphId |= 0;
  45247. var seac = seacs[glyphId];
  45248. var baseGlyphName = StandardEncoding[seac[2]];
  45249. var accentGlyphName = StandardEncoding[seac[3]];
  45250. var baseGlyphId = charset.indexOf(baseGlyphName);
  45251. var accentGlyphId = charset.indexOf(accentGlyphName);
  45252. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45253. continue;
  45254. }
  45255. var accentOffset = {
  45256. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45257. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45258. };
  45259. var charCodes = getCharCodes(mapping, glyphId);
  45260. if (!charCodes) {
  45261. continue;
  45262. }
  45263. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45264. var charCode = charCodes[i];
  45265. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45266. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45267. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45268. seacMap[charCode] = {
  45269. baseFontCharCode: baseFontCharCode,
  45270. accentFontCharCode: accentFontCharCode,
  45271. accentOffset: accentOffset
  45272. };
  45273. }
  45274. }
  45275. properties.seacMap = seacMap;
  45276. }
  45277. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45278. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45279. builder.addTable('CFF ', font.data);
  45280. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45281. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45282. 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');
  45283. 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));
  45284. builder.addTable('hmtx', function fontFieldsHmtx() {
  45285. var charstrings = font.charstrings;
  45286. var cffWidths = font.cff ? font.cff.widths : null;
  45287. var hmtx = '\x00\x00\x00\x00';
  45288. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45289. var width = 0;
  45290. if (charstrings) {
  45291. var charstring = charstrings[i - 1];
  45292. width = 'width' in charstring ? charstring.width : 0;
  45293. } else if (cffWidths) {
  45294. width = Math.ceil(cffWidths[i] || 0);
  45295. }
  45296. hmtx += string16(width) + string16(0);
  45297. }
  45298. return hmtx;
  45299. }());
  45300. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45301. builder.addTable('name', createNameTable(fontName));
  45302. builder.addTable('post', createPostTable(properties));
  45303. return builder.toArray();
  45304. },
  45305. get spaceWidth() {
  45306. if ('_shadowWidth' in this) {
  45307. return this._shadowWidth;
  45308. }
  45309. var possibleSpaceReplacements = [
  45310. 'space',
  45311. 'minus',
  45312. 'one',
  45313. 'i',
  45314. 'I'
  45315. ];
  45316. var width;
  45317. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45318. var glyphName = possibleSpaceReplacements[i];
  45319. if (glyphName in this.widths) {
  45320. width = this.widths[glyphName];
  45321. break;
  45322. }
  45323. var glyphsUnicodeMap = getGlyphsUnicode();
  45324. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45325. var charcode = 0;
  45326. if (this.composite) {
  45327. if (this.cMap.contains(glyphUnicode)) {
  45328. charcode = this.cMap.lookup(glyphUnicode);
  45329. }
  45330. }
  45331. if (!charcode && this.toUnicode) {
  45332. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45333. }
  45334. if (charcode <= 0) {
  45335. charcode = glyphUnicode;
  45336. }
  45337. width = this.widths[charcode];
  45338. if (width) {
  45339. break;
  45340. }
  45341. }
  45342. width = width || this.defaultWidth;
  45343. this._shadowWidth = width;
  45344. return width;
  45345. },
  45346. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45347. var fontCharCode, width, operatorListId;
  45348. var widthCode = charcode;
  45349. if (this.cMap && this.cMap.contains(charcode)) {
  45350. widthCode = this.cMap.lookup(charcode);
  45351. }
  45352. width = this.widths[widthCode];
  45353. width = isNum(width) ? width : this.defaultWidth;
  45354. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45355. var unicode = this.toUnicode.get(charcode) || charcode;
  45356. if (typeof unicode === 'number') {
  45357. unicode = String.fromCharCode(unicode);
  45358. }
  45359. var isInFont = charcode in this.toFontChar;
  45360. fontCharCode = this.toFontChar[charcode] || charcode;
  45361. if (this.missingFile) {
  45362. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45363. }
  45364. if (this.isType3Font) {
  45365. operatorListId = fontCharCode;
  45366. }
  45367. var accent = null;
  45368. if (this.seacMap && this.seacMap[charcode]) {
  45369. isInFont = true;
  45370. var seac = this.seacMap[charcode];
  45371. fontCharCode = seac.baseFontCharCode;
  45372. accent = {
  45373. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45374. offset: seac.accentOffset
  45375. };
  45376. }
  45377. var fontChar = String.fromCharCode(fontCharCode);
  45378. var glyph = this.glyphCache[charcode];
  45379. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45380. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45381. this.glyphCache[charcode] = glyph;
  45382. }
  45383. return glyph;
  45384. },
  45385. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45386. var charsCache = this.charsCache;
  45387. var glyphs, glyph, charcode;
  45388. if (charsCache) {
  45389. glyphs = charsCache[chars];
  45390. if (glyphs) {
  45391. return glyphs;
  45392. }
  45393. }
  45394. if (!charsCache) {
  45395. charsCache = this.charsCache = Object.create(null);
  45396. }
  45397. glyphs = [];
  45398. var charsCacheKey = chars;
  45399. var i = 0, ii;
  45400. if (this.cMap) {
  45401. var c = Object.create(null);
  45402. while (i < chars.length) {
  45403. this.cMap.readCharCode(chars, i, c);
  45404. charcode = c.charcode;
  45405. var length = c.length;
  45406. i += length;
  45407. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45408. glyph = this.charToGlyph(charcode, isSpace);
  45409. glyphs.push(glyph);
  45410. }
  45411. } else {
  45412. for (i = 0, ii = chars.length; i < ii; ++i) {
  45413. charcode = chars.charCodeAt(i);
  45414. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45415. glyphs.push(glyph);
  45416. }
  45417. }
  45418. return charsCache[charsCacheKey] = glyphs;
  45419. }
  45420. };
  45421. return Font;
  45422. }();
  45423. var ErrorFont = function ErrorFontClosure() {
  45424. function ErrorFont(error) {
  45425. this.error = error;
  45426. this.loadedName = 'g_font_error';
  45427. this.loading = false;
  45428. }
  45429. ErrorFont.prototype = {
  45430. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45431. return [];
  45432. },
  45433. exportData: function ErrorFont_exportData() {
  45434. return { error: this.error };
  45435. }
  45436. };
  45437. return ErrorFont;
  45438. }();
  45439. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45440. var charCodeToGlyphId = Object.create(null);
  45441. var glyphId, charCode, baseEncoding;
  45442. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45443. if (properties.baseEncodingName) {
  45444. baseEncoding = getEncoding(properties.baseEncodingName);
  45445. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45446. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45447. if (glyphId >= 0) {
  45448. charCodeToGlyphId[charCode] = glyphId;
  45449. } else {
  45450. charCodeToGlyphId[charCode] = 0;
  45451. }
  45452. }
  45453. } else if (isSymbolicFont) {
  45454. for (charCode in builtInEncoding) {
  45455. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45456. }
  45457. } else {
  45458. baseEncoding = StandardEncoding;
  45459. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45460. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45461. if (glyphId >= 0) {
  45462. charCodeToGlyphId[charCode] = glyphId;
  45463. } else {
  45464. charCodeToGlyphId[charCode] = 0;
  45465. }
  45466. }
  45467. }
  45468. var differences = properties.differences, glyphsUnicodeMap;
  45469. if (differences) {
  45470. for (charCode in differences) {
  45471. var glyphName = differences[charCode];
  45472. glyphId = glyphNames.indexOf(glyphName);
  45473. if (glyphId === -1) {
  45474. if (!glyphsUnicodeMap) {
  45475. glyphsUnicodeMap = getGlyphsUnicode();
  45476. }
  45477. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45478. if (standardGlyphName !== glyphName) {
  45479. glyphId = glyphNames.indexOf(standardGlyphName);
  45480. }
  45481. }
  45482. if (glyphId >= 0) {
  45483. charCodeToGlyphId[charCode] = glyphId;
  45484. } else {
  45485. charCodeToGlyphId[charCode] = 0;
  45486. }
  45487. }
  45488. }
  45489. return charCodeToGlyphId;
  45490. }
  45491. var Type1Font = function Type1FontClosure() {
  45492. function findBlock(streamBytes, signature, startIndex) {
  45493. var streamBytesLength = streamBytes.length;
  45494. var signatureLength = signature.length;
  45495. var scanLength = streamBytesLength - signatureLength;
  45496. var i = startIndex, j, found = false;
  45497. while (i < scanLength) {
  45498. j = 0;
  45499. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45500. j++;
  45501. }
  45502. if (j >= signatureLength) {
  45503. i += j;
  45504. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45505. i++;
  45506. }
  45507. found = true;
  45508. break;
  45509. }
  45510. i++;
  45511. }
  45512. return {
  45513. found: found,
  45514. length: i
  45515. };
  45516. }
  45517. function getHeaderBlock(stream, suggestedLength) {
  45518. var EEXEC_SIGNATURE = [
  45519. 0x65,
  45520. 0x65,
  45521. 0x78,
  45522. 0x65,
  45523. 0x63
  45524. ];
  45525. var streamStartPos = stream.pos;
  45526. var headerBytes, headerBytesLength, block;
  45527. try {
  45528. headerBytes = stream.getBytes(suggestedLength);
  45529. headerBytesLength = headerBytes.length;
  45530. } catch (ex) {
  45531. if (ex instanceof MissingDataException) {
  45532. throw ex;
  45533. }
  45534. }
  45535. if (headerBytesLength === suggestedLength) {
  45536. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45537. if (block.found && block.length === suggestedLength) {
  45538. return {
  45539. stream: new Stream(headerBytes),
  45540. length: suggestedLength
  45541. };
  45542. }
  45543. }
  45544. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45545. stream.pos = streamStartPos;
  45546. var SCAN_BLOCK_LENGTH = 2048;
  45547. var actualLength;
  45548. while (true) {
  45549. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45550. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45551. if (block.length === 0) {
  45552. break;
  45553. }
  45554. stream.pos += block.length;
  45555. if (block.found) {
  45556. actualLength = stream.pos - streamStartPos;
  45557. break;
  45558. }
  45559. }
  45560. stream.pos = streamStartPos;
  45561. if (actualLength) {
  45562. return {
  45563. stream: new Stream(stream.getBytes(actualLength)),
  45564. length: actualLength
  45565. };
  45566. }
  45567. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45568. return {
  45569. stream: new Stream(stream.getBytes(suggestedLength)),
  45570. length: suggestedLength
  45571. };
  45572. }
  45573. function getEexecBlock(stream, suggestedLength) {
  45574. var eexecBytes = stream.getBytes();
  45575. return {
  45576. stream: new Stream(eexecBytes),
  45577. length: eexecBytes.length
  45578. };
  45579. }
  45580. function Type1Font(name, file, properties) {
  45581. var PFB_HEADER_SIZE = 6;
  45582. var headerBlockLength = properties.length1;
  45583. var eexecBlockLength = properties.length2;
  45584. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45585. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45586. if (pfbHeaderPresent) {
  45587. file.skip(PFB_HEADER_SIZE);
  45588. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45589. }
  45590. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45591. headerBlockLength = headerBlock.length;
  45592. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45593. headerBlockParser.extractFontHeader(properties);
  45594. if (pfbHeaderPresent) {
  45595. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45596. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45597. }
  45598. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45599. eexecBlockLength = eexecBlock.length;
  45600. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45601. var data = eexecBlockParser.extractFontProgram();
  45602. for (var info in data.properties) {
  45603. properties[info] = data.properties[info];
  45604. }
  45605. var charstrings = data.charstrings;
  45606. var type2Charstrings = this.getType2Charstrings(charstrings);
  45607. var subrs = this.getType2Subrs(data.subrs);
  45608. this.charstrings = charstrings;
  45609. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45610. this.seacs = this.getSeacs(data.charstrings);
  45611. }
  45612. Type1Font.prototype = {
  45613. get numGlyphs() {
  45614. return this.charstrings.length + 1;
  45615. },
  45616. getCharset: function Type1Font_getCharset() {
  45617. var charset = ['.notdef'];
  45618. var charstrings = this.charstrings;
  45619. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45620. charset.push(charstrings[glyphId].glyphName);
  45621. }
  45622. return charset;
  45623. },
  45624. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45625. var charstrings = this.charstrings;
  45626. var glyphNames = ['.notdef'], glyphId;
  45627. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45628. glyphNames.push(charstrings[glyphId].glyphName);
  45629. }
  45630. var encoding = properties.builtInEncoding;
  45631. if (encoding) {
  45632. var builtInEncoding = Object.create(null);
  45633. for (var charCode in encoding) {
  45634. glyphId = glyphNames.indexOf(encoding[charCode]);
  45635. if (glyphId >= 0) {
  45636. builtInEncoding[charCode] = glyphId;
  45637. }
  45638. }
  45639. }
  45640. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45641. },
  45642. getSeacs: function Type1Font_getSeacs(charstrings) {
  45643. var i, ii;
  45644. var seacMap = [];
  45645. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45646. var charstring = charstrings[i];
  45647. if (charstring.seac) {
  45648. seacMap[i + 1] = charstring.seac;
  45649. }
  45650. }
  45651. return seacMap;
  45652. },
  45653. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45654. var type2Charstrings = [];
  45655. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45656. type2Charstrings.push(type1Charstrings[i].charstring);
  45657. }
  45658. return type2Charstrings;
  45659. },
  45660. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45661. var bias = 0;
  45662. var count = type1Subrs.length;
  45663. if (count < 1133) {
  45664. bias = 107;
  45665. } else if (count < 33769) {
  45666. bias = 1131;
  45667. } else {
  45668. bias = 32768;
  45669. }
  45670. var type2Subrs = [];
  45671. var i;
  45672. for (i = 0; i < bias; i++) {
  45673. type2Subrs.push([0x0B]);
  45674. }
  45675. for (i = 0; i < count; i++) {
  45676. type2Subrs.push(type1Subrs[i]);
  45677. }
  45678. return type2Subrs;
  45679. },
  45680. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45681. var cff = new CFF();
  45682. cff.header = new CFFHeader(1, 0, 4, 4);
  45683. cff.names = [name];
  45684. var topDict = new CFFTopDict();
  45685. topDict.setByName('version', 391);
  45686. topDict.setByName('Notice', 392);
  45687. topDict.setByName('FullName', 393);
  45688. topDict.setByName('FamilyName', 394);
  45689. topDict.setByName('Weight', 395);
  45690. topDict.setByName('Encoding', null);
  45691. topDict.setByName('FontMatrix', properties.fontMatrix);
  45692. topDict.setByName('FontBBox', properties.bbox);
  45693. topDict.setByName('charset', null);
  45694. topDict.setByName('CharStrings', null);
  45695. topDict.setByName('Private', null);
  45696. cff.topDict = topDict;
  45697. var strings = new CFFStrings();
  45698. strings.add('Version 0.11');
  45699. strings.add('See original notice');
  45700. strings.add(name);
  45701. strings.add(name);
  45702. strings.add('Medium');
  45703. cff.strings = strings;
  45704. cff.globalSubrIndex = new CFFIndex();
  45705. var count = glyphs.length;
  45706. var charsetArray = [0];
  45707. var i, ii;
  45708. for (i = 0; i < count; i++) {
  45709. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45710. if (index === -1) {
  45711. index = 0;
  45712. }
  45713. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45714. }
  45715. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45716. var charStringsIndex = new CFFIndex();
  45717. charStringsIndex.add([
  45718. 0x8B,
  45719. 0x0E
  45720. ]);
  45721. for (i = 0; i < count; i++) {
  45722. var glyph = glyphs[i];
  45723. if (glyph.length === 0) {
  45724. charStringsIndex.add([
  45725. 0x8B,
  45726. 0x0E
  45727. ]);
  45728. continue;
  45729. }
  45730. charStringsIndex.add(glyph);
  45731. }
  45732. cff.charStrings = charStringsIndex;
  45733. var privateDict = new CFFPrivateDict();
  45734. privateDict.setByName('Subrs', null);
  45735. var fields = [
  45736. 'BlueValues',
  45737. 'OtherBlues',
  45738. 'FamilyBlues',
  45739. 'FamilyOtherBlues',
  45740. 'StemSnapH',
  45741. 'StemSnapV',
  45742. 'BlueShift',
  45743. 'BlueFuzz',
  45744. 'BlueScale',
  45745. 'LanguageGroup',
  45746. 'ExpansionFactor',
  45747. 'ForceBold',
  45748. 'StdHW',
  45749. 'StdVW'
  45750. ];
  45751. for (i = 0, ii = fields.length; i < ii; i++) {
  45752. var field = fields[i];
  45753. if (!(field in properties.privateData)) {
  45754. continue;
  45755. }
  45756. var value = properties.privateData[field];
  45757. if (isArray(value)) {
  45758. for (var j = value.length - 1; j > 0; j--) {
  45759. value[j] -= value[j - 1];
  45760. }
  45761. }
  45762. privateDict.setByName(field, value);
  45763. }
  45764. cff.topDict.privateDict = privateDict;
  45765. var subrIndex = new CFFIndex();
  45766. for (i = 0, ii = subrs.length; i < ii; i++) {
  45767. subrIndex.add(subrs[i]);
  45768. }
  45769. privateDict.subrsIndex = subrIndex;
  45770. var compiler = new CFFCompiler(cff);
  45771. return compiler.compile();
  45772. }
  45773. };
  45774. return Type1Font;
  45775. }();
  45776. var CFFFont = function CFFFontClosure() {
  45777. function CFFFont(file, properties) {
  45778. this.properties = properties;
  45779. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45780. this.cff = parser.parse();
  45781. var compiler = new CFFCompiler(this.cff);
  45782. this.seacs = this.cff.seacs;
  45783. try {
  45784. this.data = compiler.compile();
  45785. } catch (e) {
  45786. warn('Failed to compile font ' + properties.loadedName);
  45787. this.data = file;
  45788. }
  45789. }
  45790. CFFFont.prototype = {
  45791. get numGlyphs() {
  45792. return this.cff.charStrings.count;
  45793. },
  45794. getCharset: function CFFFont_getCharset() {
  45795. return this.cff.charset.charset;
  45796. },
  45797. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45798. var cff = this.cff;
  45799. var properties = this.properties;
  45800. var charsets = cff.charset.charset;
  45801. var charCodeToGlyphId;
  45802. var glyphId;
  45803. if (properties.composite) {
  45804. charCodeToGlyphId = Object.create(null);
  45805. if (cff.isCIDFont) {
  45806. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45807. var cid = charsets[glyphId];
  45808. var charCode = properties.cMap.charCodeOf(cid);
  45809. charCodeToGlyphId[charCode] = glyphId;
  45810. }
  45811. } else {
  45812. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45813. charCodeToGlyphId[glyphId] = glyphId;
  45814. }
  45815. }
  45816. return charCodeToGlyphId;
  45817. }
  45818. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45819. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45820. return charCodeToGlyphId;
  45821. }
  45822. };
  45823. return CFFFont;
  45824. }();
  45825. (function checkSeacSupport() {
  45826. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45827. SEAC_ANALYSIS_ENABLED = true;
  45828. }
  45829. }());
  45830. (function checkChromeWindows() {
  45831. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45832. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45833. }
  45834. }());
  45835. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  45836. exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
  45837. exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
  45838. exports.ErrorFont = ErrorFont;
  45839. exports.Font = Font;
  45840. exports.FontFlags = FontFlags;
  45841. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45842. exports.ProblematicCharRanges = ProblematicCharRanges;
  45843. exports.ToUnicodeMap = ToUnicodeMap;
  45844. exports.getFontType = getFontType;
  45845. /***/ }),
  45846. /* 34 */
  45847. /***/ (function(module, exports, __w_pdfjs_require__) {
  45848. "use strict";
  45849. var sharedUtil = __w_pdfjs_require__(0);
  45850. var corePrimitives = __w_pdfjs_require__(1);
  45851. var coreColorSpace = __w_pdfjs_require__(4);
  45852. var coreStream = __w_pdfjs_require__(2);
  45853. var coreJpx = __w_pdfjs_require__(19);
  45854. var ImageKind = sharedUtil.ImageKind;
  45855. var assert = sharedUtil.assert;
  45856. var error = sharedUtil.error;
  45857. var info = sharedUtil.info;
  45858. var isArray = sharedUtil.isArray;
  45859. var warn = sharedUtil.warn;
  45860. var Name = corePrimitives.Name;
  45861. var isStream = corePrimitives.isStream;
  45862. var ColorSpace = coreColorSpace.ColorSpace;
  45863. var DecodeStream = coreStream.DecodeStream;
  45864. var JpegStream = coreStream.JpegStream;
  45865. var JpxImage = coreJpx.JpxImage;
  45866. var PDFImage = function PDFImageClosure() {
  45867. function handleImageData(image, nativeDecoder) {
  45868. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45869. return nativeDecoder.decode(image);
  45870. }
  45871. return Promise.resolve(image);
  45872. }
  45873. function decodeAndClamp(value, addend, coefficient, max) {
  45874. value = addend + value * coefficient;
  45875. return value < 0 ? 0 : value > max ? max : value;
  45876. }
  45877. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45878. var length = w2 * h2;
  45879. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45880. var xRatio = w1 / w2;
  45881. var yRatio = h1 / h2;
  45882. var i, j, py, newIndex = 0, oldIndex;
  45883. var xScaled = new Uint16Array(w2);
  45884. var w1Scanline = w1;
  45885. for (i = 0; i < w2; i++) {
  45886. xScaled[i] = Math.floor(i * xRatio);
  45887. }
  45888. for (i = 0; i < h2; i++) {
  45889. py = Math.floor(i * yRatio) * w1Scanline;
  45890. for (j = 0; j < w2; j++) {
  45891. oldIndex = py + xScaled[j];
  45892. dest[newIndex++] = src[oldIndex];
  45893. }
  45894. }
  45895. return dest;
  45896. }
  45897. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45898. this.image = image;
  45899. var dict = image.dict;
  45900. if (dict.has('Filter')) {
  45901. var filter = dict.get('Filter').name;
  45902. if (filter === 'JPXDecode') {
  45903. var jpxImage = new JpxImage();
  45904. jpxImage.parseImageProperties(image.stream);
  45905. image.stream.reset();
  45906. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45907. image.numComps = jpxImage.componentsCount;
  45908. } else if (filter === 'JBIG2Decode') {
  45909. image.bitsPerComponent = 1;
  45910. image.numComps = 1;
  45911. }
  45912. }
  45913. this.width = dict.get('Width', 'W');
  45914. this.height = dict.get('Height', 'H');
  45915. if (this.width < 1 || this.height < 1) {
  45916. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45917. }
  45918. this.interpolate = dict.get('Interpolate', 'I') || false;
  45919. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45920. this.matte = dict.get('Matte') || false;
  45921. var bitsPerComponent = image.bitsPerComponent;
  45922. if (!bitsPerComponent) {
  45923. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45924. if (!bitsPerComponent) {
  45925. if (this.imageMask) {
  45926. bitsPerComponent = 1;
  45927. } else {
  45928. error('Bits per component missing in image: ' + this.imageMask);
  45929. }
  45930. }
  45931. }
  45932. this.bpc = bitsPerComponent;
  45933. if (!this.imageMask) {
  45934. var colorSpace = dict.get('ColorSpace', 'CS');
  45935. if (!colorSpace) {
  45936. info('JPX images (which do not require color spaces)');
  45937. switch (image.numComps) {
  45938. case 1:
  45939. colorSpace = Name.get('DeviceGray');
  45940. break;
  45941. case 3:
  45942. colorSpace = Name.get('DeviceRGB');
  45943. break;
  45944. case 4:
  45945. colorSpace = Name.get('DeviceCMYK');
  45946. break;
  45947. default:
  45948. error('JPX images with ' + this.numComps + ' color components not supported.');
  45949. }
  45950. }
  45951. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45952. this.numComps = this.colorSpace.numComps;
  45953. }
  45954. this.decode = dict.getArray('Decode', 'D');
  45955. this.needsDecode = false;
  45956. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45957. this.needsDecode = true;
  45958. var max = (1 << bitsPerComponent) - 1;
  45959. this.decodeCoefficients = [];
  45960. this.decodeAddends = [];
  45961. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45962. var dmin = this.decode[i];
  45963. var dmax = this.decode[i + 1];
  45964. this.decodeCoefficients[j] = dmax - dmin;
  45965. this.decodeAddends[j] = max * dmin;
  45966. }
  45967. }
  45968. if (smask) {
  45969. this.smask = new PDFImage(xref, res, smask, false);
  45970. } else if (mask) {
  45971. if (isStream(mask)) {
  45972. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45973. if (!imageMask) {
  45974. warn('Ignoring /Mask in image without /ImageMask.');
  45975. } else {
  45976. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45977. }
  45978. } else {
  45979. this.mask = mask;
  45980. }
  45981. }
  45982. }
  45983. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  45984. var imagePromise = handleImageData(image, nativeDecoder);
  45985. var smaskPromise;
  45986. var maskPromise;
  45987. var smask = image.dict.get('SMask');
  45988. var mask = image.dict.get('Mask');
  45989. if (smask) {
  45990. smaskPromise = handleImageData(smask, nativeDecoder);
  45991. maskPromise = Promise.resolve(null);
  45992. } else {
  45993. smaskPromise = Promise.resolve(null);
  45994. if (mask) {
  45995. if (isStream(mask)) {
  45996. maskPromise = handleImageData(mask, nativeDecoder);
  45997. } else if (isArray(mask)) {
  45998. maskPromise = Promise.resolve(mask);
  45999. } else {
  46000. warn('Unsupported mask format.');
  46001. maskPromise = Promise.resolve(null);
  46002. }
  46003. } else {
  46004. maskPromise = Promise.resolve(null);
  46005. }
  46006. }
  46007. return Promise.all([
  46008. imagePromise,
  46009. smaskPromise,
  46010. maskPromise
  46011. ]).then(function (results) {
  46012. var imageData = results[0];
  46013. var smaskData = results[1];
  46014. var maskData = results[2];
  46015. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46016. });
  46017. };
  46018. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46019. var computedLength = (width + 7 >> 3) * height;
  46020. var actualLength = imgArray.byteLength;
  46021. var haveFullData = computedLength === actualLength;
  46022. var data, i;
  46023. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46024. data = imgArray;
  46025. } else if (!inverseDecode) {
  46026. data = new Uint8Array(actualLength);
  46027. data.set(imgArray);
  46028. } else {
  46029. data = new Uint8Array(computedLength);
  46030. data.set(imgArray);
  46031. for (i = actualLength; i < computedLength; i++) {
  46032. data[i] = 0xff;
  46033. }
  46034. }
  46035. if (inverseDecode) {
  46036. for (i = 0; i < actualLength; i++) {
  46037. data[i] = ~data[i];
  46038. }
  46039. }
  46040. return {
  46041. data: data,
  46042. width: width,
  46043. height: height
  46044. };
  46045. };
  46046. PDFImage.prototype = {
  46047. get drawWidth() {
  46048. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46049. },
  46050. get drawHeight() {
  46051. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46052. },
  46053. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46054. var bpc = this.bpc;
  46055. var numComps = this.numComps;
  46056. var decodeAddends = this.decodeAddends;
  46057. var decodeCoefficients = this.decodeCoefficients;
  46058. var max = (1 << bpc) - 1;
  46059. var i, ii;
  46060. if (bpc === 1) {
  46061. for (i = 0, ii = buffer.length; i < ii; i++) {
  46062. buffer[i] = +!buffer[i];
  46063. }
  46064. return;
  46065. }
  46066. var index = 0;
  46067. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46068. for (var j = 0; j < numComps; j++) {
  46069. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46070. index++;
  46071. }
  46072. }
  46073. },
  46074. getComponents: function PDFImage_getComponents(buffer) {
  46075. var bpc = this.bpc;
  46076. if (bpc === 8) {
  46077. return buffer;
  46078. }
  46079. var width = this.width;
  46080. var height = this.height;
  46081. var numComps = this.numComps;
  46082. var length = width * height * numComps;
  46083. var bufferPos = 0;
  46084. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46085. var rowComps = width * numComps;
  46086. var max = (1 << bpc) - 1;
  46087. var i = 0, ii, buf;
  46088. if (bpc === 1) {
  46089. var mask, loop1End, loop2End;
  46090. for (var j = 0; j < height; j++) {
  46091. loop1End = i + (rowComps & ~7);
  46092. loop2End = i + rowComps;
  46093. while (i < loop1End) {
  46094. buf = buffer[bufferPos++];
  46095. output[i] = buf >> 7 & 1;
  46096. output[i + 1] = buf >> 6 & 1;
  46097. output[i + 2] = buf >> 5 & 1;
  46098. output[i + 3] = buf >> 4 & 1;
  46099. output[i + 4] = buf >> 3 & 1;
  46100. output[i + 5] = buf >> 2 & 1;
  46101. output[i + 6] = buf >> 1 & 1;
  46102. output[i + 7] = buf & 1;
  46103. i += 8;
  46104. }
  46105. if (i < loop2End) {
  46106. buf = buffer[bufferPos++];
  46107. mask = 128;
  46108. while (i < loop2End) {
  46109. output[i++] = +!!(buf & mask);
  46110. mask >>= 1;
  46111. }
  46112. }
  46113. }
  46114. } else {
  46115. var bits = 0;
  46116. buf = 0;
  46117. for (i = 0, ii = length; i < ii; ++i) {
  46118. if (i % rowComps === 0) {
  46119. buf = 0;
  46120. bits = 0;
  46121. }
  46122. while (bits < bpc) {
  46123. buf = buf << 8 | buffer[bufferPos++];
  46124. bits += 8;
  46125. }
  46126. var remainingBits = bits - bpc;
  46127. var value = buf >> remainingBits;
  46128. output[i] = value < 0 ? 0 : value > max ? max : value;
  46129. buf = buf & (1 << remainingBits) - 1;
  46130. bits = remainingBits;
  46131. }
  46132. }
  46133. return output;
  46134. },
  46135. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46136. var smask = this.smask;
  46137. var mask = this.mask;
  46138. var alphaBuf, sw, sh, i, ii, j;
  46139. if (smask) {
  46140. sw = smask.width;
  46141. sh = smask.height;
  46142. alphaBuf = new Uint8Array(sw * sh);
  46143. smask.fillGrayBuffer(alphaBuf);
  46144. if (sw !== width || sh !== height) {
  46145. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46146. }
  46147. } else if (mask) {
  46148. if (mask instanceof PDFImage) {
  46149. sw = mask.width;
  46150. sh = mask.height;
  46151. alphaBuf = new Uint8Array(sw * sh);
  46152. mask.numComps = 1;
  46153. mask.fillGrayBuffer(alphaBuf);
  46154. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46155. alphaBuf[i] = 255 - alphaBuf[i];
  46156. }
  46157. if (sw !== width || sh !== height) {
  46158. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46159. }
  46160. } else if (isArray(mask)) {
  46161. alphaBuf = new Uint8Array(width * height);
  46162. var numComps = this.numComps;
  46163. for (i = 0, ii = width * height; i < ii; ++i) {
  46164. var opacity = 0;
  46165. var imageOffset = i * numComps;
  46166. for (j = 0; j < numComps; ++j) {
  46167. var color = image[imageOffset + j];
  46168. var maskOffset = j * 2;
  46169. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46170. opacity = 255;
  46171. break;
  46172. }
  46173. }
  46174. alphaBuf[i] = opacity;
  46175. }
  46176. } else {
  46177. error('Unknown mask format.');
  46178. }
  46179. }
  46180. if (alphaBuf) {
  46181. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46182. rgbaBuf[j] = alphaBuf[i];
  46183. }
  46184. } else {
  46185. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46186. rgbaBuf[j] = 255;
  46187. }
  46188. }
  46189. },
  46190. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46191. var matte = this.smask && this.smask.matte;
  46192. if (!matte) {
  46193. return;
  46194. }
  46195. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46196. var matteR = matteRgb[0];
  46197. var matteG = matteRgb[1];
  46198. var matteB = matteRgb[2];
  46199. var length = width * height * 4;
  46200. var r, g, b;
  46201. for (var i = 0; i < length; i += 4) {
  46202. var alpha = buffer[i + 3];
  46203. if (alpha === 0) {
  46204. buffer[i] = 255;
  46205. buffer[i + 1] = 255;
  46206. buffer[i + 2] = 255;
  46207. continue;
  46208. }
  46209. var k = 255 / alpha;
  46210. r = (buffer[i] - matteR) * k + matteR;
  46211. g = (buffer[i + 1] - matteG) * k + matteG;
  46212. b = (buffer[i + 2] - matteB) * k + matteB;
  46213. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46214. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46215. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46216. }
  46217. },
  46218. createImageData: function PDFImage_createImageData(forceRGBA) {
  46219. var drawWidth = this.drawWidth;
  46220. var drawHeight = this.drawHeight;
  46221. var imgData = {
  46222. width: drawWidth,
  46223. height: drawHeight
  46224. };
  46225. var numComps = this.numComps;
  46226. var originalWidth = this.width;
  46227. var originalHeight = this.height;
  46228. var bpc = this.bpc;
  46229. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46230. var imgArray;
  46231. if (!forceRGBA) {
  46232. var kind;
  46233. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46234. kind = ImageKind.GRAYSCALE_1BPP;
  46235. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46236. kind = ImageKind.RGB_24BPP;
  46237. }
  46238. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46239. imgData.kind = kind;
  46240. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46241. if (this.image instanceof DecodeStream) {
  46242. imgData.data = imgArray;
  46243. } else {
  46244. var newArray = new Uint8Array(imgArray.length);
  46245. newArray.set(imgArray);
  46246. imgData.data = newArray;
  46247. }
  46248. if (this.needsDecode) {
  46249. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46250. var buffer = imgData.data;
  46251. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46252. buffer[i] ^= 0xff;
  46253. }
  46254. }
  46255. return imgData;
  46256. }
  46257. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46258. imgData.kind = ImageKind.RGB_24BPP;
  46259. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46260. return imgData;
  46261. }
  46262. }
  46263. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46264. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46265. var comps = this.getComponents(imgArray);
  46266. var alpha01, maybeUndoPreblend;
  46267. if (!forceRGBA && !this.smask && !this.mask) {
  46268. imgData.kind = ImageKind.RGB_24BPP;
  46269. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46270. alpha01 = 0;
  46271. maybeUndoPreblend = false;
  46272. } else {
  46273. imgData.kind = ImageKind.RGBA_32BPP;
  46274. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46275. alpha01 = 1;
  46276. maybeUndoPreblend = true;
  46277. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46278. }
  46279. if (this.needsDecode) {
  46280. this.decodeBuffer(comps);
  46281. }
  46282. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46283. if (maybeUndoPreblend) {
  46284. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46285. }
  46286. return imgData;
  46287. },
  46288. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46289. var numComps = this.numComps;
  46290. if (numComps !== 1) {
  46291. error('Reading gray scale from a color image: ' + numComps);
  46292. }
  46293. var width = this.width;
  46294. var height = this.height;
  46295. var bpc = this.bpc;
  46296. var rowBytes = width * numComps * bpc + 7 >> 3;
  46297. var imgArray = this.getImageBytes(height * rowBytes);
  46298. var comps = this.getComponents(imgArray);
  46299. var i, length;
  46300. if (bpc === 1) {
  46301. length = width * height;
  46302. if (this.needsDecode) {
  46303. for (i = 0; i < length; ++i) {
  46304. buffer[i] = comps[i] - 1 & 255;
  46305. }
  46306. } else {
  46307. for (i = 0; i < length; ++i) {
  46308. buffer[i] = -comps[i] & 255;
  46309. }
  46310. }
  46311. return;
  46312. }
  46313. if (this.needsDecode) {
  46314. this.decodeBuffer(comps);
  46315. }
  46316. length = width * height;
  46317. var scale = 255 / ((1 << bpc) - 1);
  46318. for (i = 0; i < length; ++i) {
  46319. buffer[i] = scale * comps[i] | 0;
  46320. }
  46321. },
  46322. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46323. this.image.reset();
  46324. this.image.drawWidth = drawWidth || this.width;
  46325. this.image.drawHeight = drawHeight || this.height;
  46326. this.image.forceRGB = !!forceRGB;
  46327. return this.image.getBytes(length);
  46328. }
  46329. };
  46330. return PDFImage;
  46331. }();
  46332. exports.PDFImage = PDFImage;
  46333. /***/ }),
  46334. /* 35 */
  46335. /***/ (function(module, exports, __w_pdfjs_require__) {
  46336. "use strict";
  46337. var sharedUtil = __w_pdfjs_require__(0);
  46338. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46339. var error = sharedUtil.error;
  46340. var log2 = sharedUtil.log2;
  46341. var readInt8 = sharedUtil.readInt8;
  46342. var readUint16 = sharedUtil.readUint16;
  46343. var readUint32 = sharedUtil.readUint32;
  46344. var shadow = sharedUtil.shadow;
  46345. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46346. var Jbig2Image = function Jbig2ImageClosure() {
  46347. function ContextCache() {
  46348. }
  46349. ContextCache.prototype = {
  46350. getContexts: function (id) {
  46351. if (id in this) {
  46352. return this[id];
  46353. }
  46354. return this[id] = new Int8Array(1 << 16);
  46355. }
  46356. };
  46357. function DecodingContext(data, start, end) {
  46358. this.data = data;
  46359. this.start = start;
  46360. this.end = end;
  46361. }
  46362. DecodingContext.prototype = {
  46363. get decoder() {
  46364. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46365. return shadow(this, 'decoder', decoder);
  46366. },
  46367. get contextCache() {
  46368. var cache = new ContextCache();
  46369. return shadow(this, 'contextCache', cache);
  46370. }
  46371. };
  46372. function decodeInteger(contextCache, procedure, decoder) {
  46373. var contexts = contextCache.getContexts(procedure);
  46374. var prev = 1;
  46375. function readBits(length) {
  46376. var v = 0;
  46377. for (var i = 0; i < length; i++) {
  46378. var bit = decoder.readBit(contexts, prev);
  46379. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46380. v = v << 1 | bit;
  46381. }
  46382. return v >>> 0;
  46383. }
  46384. var sign = readBits(1);
  46385. 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);
  46386. return sign === 0 ? value : value > 0 ? -value : null;
  46387. }
  46388. function decodeIAID(contextCache, decoder, codeLength) {
  46389. var contexts = contextCache.getContexts('IAID');
  46390. var prev = 1;
  46391. for (var i = 0; i < codeLength; i++) {
  46392. var bit = decoder.readBit(contexts, prev);
  46393. prev = prev << 1 | bit;
  46394. }
  46395. if (codeLength < 31) {
  46396. return prev & (1 << codeLength) - 1;
  46397. }
  46398. return prev & 0x7FFFFFFF;
  46399. }
  46400. var SegmentTypes = [
  46401. 'SymbolDictionary',
  46402. null,
  46403. null,
  46404. null,
  46405. 'IntermediateTextRegion',
  46406. null,
  46407. 'ImmediateTextRegion',
  46408. 'ImmediateLosslessTextRegion',
  46409. null,
  46410. null,
  46411. null,
  46412. null,
  46413. null,
  46414. null,
  46415. null,
  46416. null,
  46417. 'patternDictionary',
  46418. null,
  46419. null,
  46420. null,
  46421. 'IntermediateHalftoneRegion',
  46422. null,
  46423. 'ImmediateHalftoneRegion',
  46424. 'ImmediateLosslessHalftoneRegion',
  46425. null,
  46426. null,
  46427. null,
  46428. null,
  46429. null,
  46430. null,
  46431. null,
  46432. null,
  46433. null,
  46434. null,
  46435. null,
  46436. null,
  46437. 'IntermediateGenericRegion',
  46438. null,
  46439. 'ImmediateGenericRegion',
  46440. 'ImmediateLosslessGenericRegion',
  46441. 'IntermediateGenericRefinementRegion',
  46442. null,
  46443. 'ImmediateGenericRefinementRegion',
  46444. 'ImmediateLosslessGenericRefinementRegion',
  46445. null,
  46446. null,
  46447. null,
  46448. null,
  46449. 'PageInformation',
  46450. 'EndOfPage',
  46451. 'EndOfStripe',
  46452. 'EndOfFile',
  46453. 'Profiles',
  46454. 'Tables',
  46455. null,
  46456. null,
  46457. null,
  46458. null,
  46459. null,
  46460. null,
  46461. null,
  46462. null,
  46463. 'Extension'
  46464. ];
  46465. var CodingTemplates = [
  46466. [
  46467. {
  46468. x: -1,
  46469. y: -2
  46470. },
  46471. {
  46472. x: 0,
  46473. y: -2
  46474. },
  46475. {
  46476. x: 1,
  46477. y: -2
  46478. },
  46479. {
  46480. x: -2,
  46481. y: -1
  46482. },
  46483. {
  46484. x: -1,
  46485. y: -1
  46486. },
  46487. {
  46488. x: 0,
  46489. y: -1
  46490. },
  46491. {
  46492. x: 1,
  46493. y: -1
  46494. },
  46495. {
  46496. x: 2,
  46497. y: -1
  46498. },
  46499. {
  46500. x: -4,
  46501. y: 0
  46502. },
  46503. {
  46504. x: -3,
  46505. y: 0
  46506. },
  46507. {
  46508. x: -2,
  46509. y: 0
  46510. },
  46511. {
  46512. x: -1,
  46513. y: 0
  46514. }
  46515. ],
  46516. [
  46517. {
  46518. x: -1,
  46519. y: -2
  46520. },
  46521. {
  46522. x: 0,
  46523. y: -2
  46524. },
  46525. {
  46526. x: 1,
  46527. y: -2
  46528. },
  46529. {
  46530. x: 2,
  46531. y: -2
  46532. },
  46533. {
  46534. x: -2,
  46535. y: -1
  46536. },
  46537. {
  46538. x: -1,
  46539. y: -1
  46540. },
  46541. {
  46542. x: 0,
  46543. y: -1
  46544. },
  46545. {
  46546. x: 1,
  46547. y: -1
  46548. },
  46549. {
  46550. x: 2,
  46551. y: -1
  46552. },
  46553. {
  46554. x: -3,
  46555. y: 0
  46556. },
  46557. {
  46558. x: -2,
  46559. y: 0
  46560. },
  46561. {
  46562. x: -1,
  46563. y: 0
  46564. }
  46565. ],
  46566. [
  46567. {
  46568. x: -1,
  46569. y: -2
  46570. },
  46571. {
  46572. x: 0,
  46573. y: -2
  46574. },
  46575. {
  46576. x: 1,
  46577. y: -2
  46578. },
  46579. {
  46580. x: -2,
  46581. y: -1
  46582. },
  46583. {
  46584. x: -1,
  46585. y: -1
  46586. },
  46587. {
  46588. x: 0,
  46589. y: -1
  46590. },
  46591. {
  46592. x: 1,
  46593. y: -1
  46594. },
  46595. {
  46596. x: -2,
  46597. y: 0
  46598. },
  46599. {
  46600. x: -1,
  46601. y: 0
  46602. }
  46603. ],
  46604. [
  46605. {
  46606. x: -3,
  46607. y: -1
  46608. },
  46609. {
  46610. x: -2,
  46611. y: -1
  46612. },
  46613. {
  46614. x: -1,
  46615. y: -1
  46616. },
  46617. {
  46618. x: 0,
  46619. y: -1
  46620. },
  46621. {
  46622. x: 1,
  46623. y: -1
  46624. },
  46625. {
  46626. x: -4,
  46627. y: 0
  46628. },
  46629. {
  46630. x: -3,
  46631. y: 0
  46632. },
  46633. {
  46634. x: -2,
  46635. y: 0
  46636. },
  46637. {
  46638. x: -1,
  46639. y: 0
  46640. }
  46641. ]
  46642. ];
  46643. var RefinementTemplates = [
  46644. {
  46645. coding: [
  46646. {
  46647. x: 0,
  46648. y: -1
  46649. },
  46650. {
  46651. x: 1,
  46652. y: -1
  46653. },
  46654. {
  46655. x: -1,
  46656. y: 0
  46657. }
  46658. ],
  46659. reference: [
  46660. {
  46661. x: 0,
  46662. y: -1
  46663. },
  46664. {
  46665. x: 1,
  46666. y: -1
  46667. },
  46668. {
  46669. x: -1,
  46670. y: 0
  46671. },
  46672. {
  46673. x: 0,
  46674. y: 0
  46675. },
  46676. {
  46677. x: 1,
  46678. y: 0
  46679. },
  46680. {
  46681. x: -1,
  46682. y: 1
  46683. },
  46684. {
  46685. x: 0,
  46686. y: 1
  46687. },
  46688. {
  46689. x: 1,
  46690. y: 1
  46691. }
  46692. ]
  46693. },
  46694. {
  46695. coding: [
  46696. {
  46697. x: -1,
  46698. y: -1
  46699. },
  46700. {
  46701. x: 0,
  46702. y: -1
  46703. },
  46704. {
  46705. x: 1,
  46706. y: -1
  46707. },
  46708. {
  46709. x: -1,
  46710. y: 0
  46711. }
  46712. ],
  46713. reference: [
  46714. {
  46715. x: 0,
  46716. y: -1
  46717. },
  46718. {
  46719. x: -1,
  46720. y: 0
  46721. },
  46722. {
  46723. x: 0,
  46724. y: 0
  46725. },
  46726. {
  46727. x: 1,
  46728. y: 0
  46729. },
  46730. {
  46731. x: 0,
  46732. y: 1
  46733. },
  46734. {
  46735. x: 1,
  46736. y: 1
  46737. }
  46738. ]
  46739. }
  46740. ];
  46741. var ReusedContexts = [
  46742. 0x9B25,
  46743. 0x0795,
  46744. 0x00E5,
  46745. 0x0195
  46746. ];
  46747. var RefinementReusedContexts = [
  46748. 0x0020,
  46749. 0x0008
  46750. ];
  46751. function decodeBitmapTemplate0(width, height, decodingContext) {
  46752. var decoder = decodingContext.decoder;
  46753. var contexts = decodingContext.contextCache.getContexts('GB');
  46754. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46755. var OLD_PIXEL_MASK = 0x7BF7;
  46756. for (i = 0; i < height; i++) {
  46757. row = bitmap[i] = new Uint8Array(width);
  46758. row1 = i < 1 ? row : bitmap[i - 1];
  46759. row2 = i < 2 ? row : bitmap[i - 2];
  46760. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46761. for (j = 0; j < width; j++) {
  46762. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46763. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46764. }
  46765. }
  46766. return bitmap;
  46767. }
  46768. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46769. if (mmr) {
  46770. error('JBIG2 error: MMR encoding is not supported');
  46771. }
  46772. 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) {
  46773. return decodeBitmapTemplate0(width, height, decodingContext);
  46774. }
  46775. var useskip = !!skip;
  46776. var template = CodingTemplates[templateIndex].concat(at);
  46777. template.sort(function (a, b) {
  46778. return a.y - b.y || a.x - b.x;
  46779. });
  46780. var templateLength = template.length;
  46781. var templateX = new Int8Array(templateLength);
  46782. var templateY = new Int8Array(templateLength);
  46783. var changingTemplateEntries = [];
  46784. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46785. var c, k;
  46786. for (k = 0; k < templateLength; k++) {
  46787. templateX[k] = template[k].x;
  46788. templateY[k] = template[k].y;
  46789. minX = Math.min(minX, template[k].x);
  46790. maxX = Math.max(maxX, template[k].x);
  46791. minY = Math.min(minY, template[k].y);
  46792. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46793. reuseMask |= 1 << templateLength - 1 - k;
  46794. } else {
  46795. changingTemplateEntries.push(k);
  46796. }
  46797. }
  46798. var changingEntriesLength = changingTemplateEntries.length;
  46799. var changingTemplateX = new Int8Array(changingEntriesLength);
  46800. var changingTemplateY = new Int8Array(changingEntriesLength);
  46801. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46802. for (c = 0; c < changingEntriesLength; c++) {
  46803. k = changingTemplateEntries[c];
  46804. changingTemplateX[c] = template[k].x;
  46805. changingTemplateY[c] = template[k].y;
  46806. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46807. }
  46808. var sbb_left = -minX;
  46809. var sbb_top = -minY;
  46810. var sbb_right = width - maxX;
  46811. var pseudoPixelContext = ReusedContexts[templateIndex];
  46812. var row = new Uint8Array(width);
  46813. var bitmap = [];
  46814. var decoder = decodingContext.decoder;
  46815. var contexts = decodingContext.contextCache.getContexts('GB');
  46816. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46817. for (var i = 0; i < height; i++) {
  46818. if (prediction) {
  46819. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46820. ltp ^= sltp;
  46821. if (ltp) {
  46822. bitmap.push(row);
  46823. continue;
  46824. }
  46825. }
  46826. row = new Uint8Array(row);
  46827. bitmap.push(row);
  46828. for (j = 0; j < width; j++) {
  46829. if (useskip && skip[i][j]) {
  46830. row[j] = 0;
  46831. continue;
  46832. }
  46833. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46834. contextLabel = contextLabel << 1 & reuseMask;
  46835. for (k = 0; k < changingEntriesLength; k++) {
  46836. i0 = i + changingTemplateY[k];
  46837. j0 = j + changingTemplateX[k];
  46838. bit = bitmap[i0][j0];
  46839. if (bit) {
  46840. bit = changingTemplateBit[k];
  46841. contextLabel |= bit;
  46842. }
  46843. }
  46844. } else {
  46845. contextLabel = 0;
  46846. shift = templateLength - 1;
  46847. for (k = 0; k < templateLength; k++, shift--) {
  46848. j0 = j + templateX[k];
  46849. if (j0 >= 0 && j0 < width) {
  46850. i0 = i + templateY[k];
  46851. if (i0 >= 0) {
  46852. bit = bitmap[i0][j0];
  46853. if (bit) {
  46854. contextLabel |= bit << shift;
  46855. }
  46856. }
  46857. }
  46858. }
  46859. }
  46860. var pixel = decoder.readBit(contexts, contextLabel);
  46861. row[j] = pixel;
  46862. }
  46863. }
  46864. return bitmap;
  46865. }
  46866. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46867. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46868. if (templateIndex === 0) {
  46869. codingTemplate = codingTemplate.concat([at[0]]);
  46870. }
  46871. var codingTemplateLength = codingTemplate.length;
  46872. var codingTemplateX = new Int32Array(codingTemplateLength);
  46873. var codingTemplateY = new Int32Array(codingTemplateLength);
  46874. var k;
  46875. for (k = 0; k < codingTemplateLength; k++) {
  46876. codingTemplateX[k] = codingTemplate[k].x;
  46877. codingTemplateY[k] = codingTemplate[k].y;
  46878. }
  46879. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46880. if (templateIndex === 0) {
  46881. referenceTemplate = referenceTemplate.concat([at[1]]);
  46882. }
  46883. var referenceTemplateLength = referenceTemplate.length;
  46884. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46885. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46886. for (k = 0; k < referenceTemplateLength; k++) {
  46887. referenceTemplateX[k] = referenceTemplate[k].x;
  46888. referenceTemplateY[k] = referenceTemplate[k].y;
  46889. }
  46890. var referenceWidth = referenceBitmap[0].length;
  46891. var referenceHeight = referenceBitmap.length;
  46892. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46893. var bitmap = [];
  46894. var decoder = decodingContext.decoder;
  46895. var contexts = decodingContext.contextCache.getContexts('GR');
  46896. var ltp = 0;
  46897. for (var i = 0; i < height; i++) {
  46898. if (prediction) {
  46899. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46900. ltp ^= sltp;
  46901. if (ltp) {
  46902. error('JBIG2 error: prediction is not supported');
  46903. }
  46904. }
  46905. var row = new Uint8Array(width);
  46906. bitmap.push(row);
  46907. for (var j = 0; j < width; j++) {
  46908. var i0, j0;
  46909. var contextLabel = 0;
  46910. for (k = 0; k < codingTemplateLength; k++) {
  46911. i0 = i + codingTemplateY[k];
  46912. j0 = j + codingTemplateX[k];
  46913. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46914. contextLabel <<= 1;
  46915. } else {
  46916. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46917. }
  46918. }
  46919. for (k = 0; k < referenceTemplateLength; k++) {
  46920. i0 = i + referenceTemplateY[k] + offsetY;
  46921. j0 = j + referenceTemplateX[k] + offsetX;
  46922. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46923. contextLabel <<= 1;
  46924. } else {
  46925. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46926. }
  46927. }
  46928. var pixel = decoder.readBit(contexts, contextLabel);
  46929. row[j] = pixel;
  46930. }
  46931. }
  46932. return bitmap;
  46933. }
  46934. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46935. if (huffman) {
  46936. error('JBIG2 error: huffman is not supported');
  46937. }
  46938. var newSymbols = [];
  46939. var currentHeight = 0;
  46940. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46941. var decoder = decodingContext.decoder;
  46942. var contextCache = decodingContext.contextCache;
  46943. while (newSymbols.length < numberOfNewSymbols) {
  46944. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46945. currentHeight += deltaHeight;
  46946. var currentWidth = 0;
  46947. while (true) {
  46948. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46949. if (deltaWidth === null) {
  46950. break;
  46951. }
  46952. currentWidth += deltaWidth;
  46953. var bitmap;
  46954. if (refinement) {
  46955. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46956. if (numberOfInstances > 1) {
  46957. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46958. } else {
  46959. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46960. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46961. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46962. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46963. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46964. }
  46965. } else {
  46966. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46967. }
  46968. newSymbols.push(bitmap);
  46969. }
  46970. }
  46971. var exportedSymbols = [];
  46972. var flags = [], currentFlag = false;
  46973. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46974. while (flags.length < totalSymbolsLength) {
  46975. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46976. while (runLength--) {
  46977. flags.push(currentFlag);
  46978. }
  46979. currentFlag = !currentFlag;
  46980. }
  46981. for (var i = 0, ii = symbols.length; i < ii; i++) {
  46982. if (flags[i]) {
  46983. exportedSymbols.push(symbols[i]);
  46984. }
  46985. }
  46986. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  46987. if (flags[i]) {
  46988. exportedSymbols.push(newSymbols[j]);
  46989. }
  46990. }
  46991. return exportedSymbols;
  46992. }
  46993. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  46994. if (huffman) {
  46995. error('JBIG2 error: huffman is not supported');
  46996. }
  46997. var bitmap = [];
  46998. var i, row;
  46999. for (i = 0; i < height; i++) {
  47000. row = new Uint8Array(width);
  47001. if (defaultPixelValue) {
  47002. for (var j = 0; j < width; j++) {
  47003. row[j] = defaultPixelValue;
  47004. }
  47005. }
  47006. bitmap.push(row);
  47007. }
  47008. var decoder = decodingContext.decoder;
  47009. var contextCache = decodingContext.contextCache;
  47010. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47011. var firstS = 0;
  47012. i = 0;
  47013. while (i < numberOfSymbolInstances) {
  47014. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47015. stripT += deltaT;
  47016. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47017. firstS += deltaFirstS;
  47018. var currentS = firstS;
  47019. do {
  47020. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47021. var t = stripSize * stripT + currentT;
  47022. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47023. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47024. var symbolBitmap = inputSymbols[symbolId];
  47025. var symbolWidth = symbolBitmap[0].length;
  47026. var symbolHeight = symbolBitmap.length;
  47027. if (applyRefinement) {
  47028. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47029. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47030. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47031. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47032. symbolWidth += rdw;
  47033. symbolHeight += rdh;
  47034. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47035. }
  47036. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47037. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47038. var s2, t2, symbolRow;
  47039. if (transposed) {
  47040. for (s2 = 0; s2 < symbolHeight; s2++) {
  47041. row = bitmap[offsetS + s2];
  47042. if (!row) {
  47043. continue;
  47044. }
  47045. symbolRow = symbolBitmap[s2];
  47046. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47047. switch (combinationOperator) {
  47048. case 0:
  47049. for (t2 = 0; t2 < maxWidth; t2++) {
  47050. row[offsetT + t2] |= symbolRow[t2];
  47051. }
  47052. break;
  47053. case 2:
  47054. for (t2 = 0; t2 < maxWidth; t2++) {
  47055. row[offsetT + t2] ^= symbolRow[t2];
  47056. }
  47057. break;
  47058. default:
  47059. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47060. }
  47061. }
  47062. currentS += symbolHeight - 1;
  47063. } else {
  47064. for (t2 = 0; t2 < symbolHeight; t2++) {
  47065. row = bitmap[offsetT + t2];
  47066. if (!row) {
  47067. continue;
  47068. }
  47069. symbolRow = symbolBitmap[t2];
  47070. switch (combinationOperator) {
  47071. case 0:
  47072. for (s2 = 0; s2 < symbolWidth; s2++) {
  47073. row[offsetS + s2] |= symbolRow[s2];
  47074. }
  47075. break;
  47076. case 2:
  47077. for (s2 = 0; s2 < symbolWidth; s2++) {
  47078. row[offsetS + s2] ^= symbolRow[s2];
  47079. }
  47080. break;
  47081. default:
  47082. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47083. }
  47084. }
  47085. currentS += symbolWidth - 1;
  47086. }
  47087. i++;
  47088. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47089. if (deltaS === null) {
  47090. break;
  47091. }
  47092. currentS += deltaS + dsOffset;
  47093. } while (true);
  47094. }
  47095. return bitmap;
  47096. }
  47097. function readSegmentHeader(data, start) {
  47098. var segmentHeader = {};
  47099. segmentHeader.number = readUint32(data, start);
  47100. var flags = data[start + 4];
  47101. var segmentType = flags & 0x3F;
  47102. if (!SegmentTypes[segmentType]) {
  47103. error('JBIG2 error: invalid segment type: ' + segmentType);
  47104. }
  47105. segmentHeader.type = segmentType;
  47106. segmentHeader.typeName = SegmentTypes[segmentType];
  47107. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47108. var pageAssociationFieldSize = !!(flags & 0x40);
  47109. var referredFlags = data[start + 5];
  47110. var referredToCount = referredFlags >> 5 & 7;
  47111. var retainBits = [referredFlags & 31];
  47112. var position = start + 6;
  47113. if (referredFlags === 7) {
  47114. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47115. position += 3;
  47116. var bytes = referredToCount + 7 >> 3;
  47117. retainBits[0] = data[position++];
  47118. while (--bytes > 0) {
  47119. retainBits.push(data[position++]);
  47120. }
  47121. } else if (referredFlags === 5 || referredFlags === 6) {
  47122. error('JBIG2 error: invalid referred-to flags');
  47123. }
  47124. segmentHeader.retainBits = retainBits;
  47125. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47126. var referredTo = [];
  47127. var i, ii;
  47128. for (i = 0; i < referredToCount; i++) {
  47129. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47130. referredTo.push(number);
  47131. position += referredToSegmentNumberSize;
  47132. }
  47133. segmentHeader.referredTo = referredTo;
  47134. if (!pageAssociationFieldSize) {
  47135. segmentHeader.pageAssociation = data[position++];
  47136. } else {
  47137. segmentHeader.pageAssociation = readUint32(data, position);
  47138. position += 4;
  47139. }
  47140. segmentHeader.length = readUint32(data, position);
  47141. position += 4;
  47142. if (segmentHeader.length === 0xFFFFFFFF) {
  47143. if (segmentType === 38) {
  47144. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47145. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47146. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47147. var searchPatternLength = 6;
  47148. var searchPattern = new Uint8Array(searchPatternLength);
  47149. if (!genericRegionMmr) {
  47150. searchPattern[0] = 0xFF;
  47151. searchPattern[1] = 0xAC;
  47152. }
  47153. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47154. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47155. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47156. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47157. for (i = position, ii = data.length; i < ii; i++) {
  47158. var j = 0;
  47159. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47160. j++;
  47161. }
  47162. if (j === searchPatternLength) {
  47163. segmentHeader.length = i + searchPatternLength;
  47164. break;
  47165. }
  47166. }
  47167. if (segmentHeader.length === 0xFFFFFFFF) {
  47168. error('JBIG2 error: segment end was not found');
  47169. }
  47170. } else {
  47171. error('JBIG2 error: invalid unknown segment length');
  47172. }
  47173. }
  47174. segmentHeader.headerEnd = position;
  47175. return segmentHeader;
  47176. }
  47177. function readSegments(header, data, start, end) {
  47178. var segments = [];
  47179. var position = start;
  47180. while (position < end) {
  47181. var segmentHeader = readSegmentHeader(data, position);
  47182. position = segmentHeader.headerEnd;
  47183. var segment = {
  47184. header: segmentHeader,
  47185. data: data
  47186. };
  47187. if (!header.randomAccess) {
  47188. segment.start = position;
  47189. position += segmentHeader.length;
  47190. segment.end = position;
  47191. }
  47192. segments.push(segment);
  47193. if (segmentHeader.type === 51) {
  47194. break;
  47195. }
  47196. }
  47197. if (header.randomAccess) {
  47198. for (var i = 0, ii = segments.length; i < ii; i++) {
  47199. segments[i].start = position;
  47200. position += segments[i].header.length;
  47201. segments[i].end = position;
  47202. }
  47203. }
  47204. return segments;
  47205. }
  47206. function readRegionSegmentInformation(data, start) {
  47207. return {
  47208. width: readUint32(data, start),
  47209. height: readUint32(data, start + 4),
  47210. x: readUint32(data, start + 8),
  47211. y: readUint32(data, start + 12),
  47212. combinationOperator: data[start + 16] & 7
  47213. };
  47214. }
  47215. var RegionSegmentInformationFieldLength = 17;
  47216. function processSegment(segment, visitor) {
  47217. var header = segment.header;
  47218. var data = segment.data, position = segment.start, end = segment.end;
  47219. var args, at, i, atLength;
  47220. switch (header.type) {
  47221. case 0:
  47222. var dictionary = {};
  47223. var dictionaryFlags = readUint16(data, position);
  47224. dictionary.huffman = !!(dictionaryFlags & 1);
  47225. dictionary.refinement = !!(dictionaryFlags & 2);
  47226. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47227. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47228. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47229. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47230. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47231. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47232. dictionary.template = dictionaryFlags >> 10 & 3;
  47233. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47234. position += 2;
  47235. if (!dictionary.huffman) {
  47236. atLength = dictionary.template === 0 ? 4 : 1;
  47237. at = [];
  47238. for (i = 0; i < atLength; i++) {
  47239. at.push({
  47240. x: readInt8(data, position),
  47241. y: readInt8(data, position + 1)
  47242. });
  47243. position += 2;
  47244. }
  47245. dictionary.at = at;
  47246. }
  47247. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47248. at = [];
  47249. for (i = 0; i < 2; i++) {
  47250. at.push({
  47251. x: readInt8(data, position),
  47252. y: readInt8(data, position + 1)
  47253. });
  47254. position += 2;
  47255. }
  47256. dictionary.refinementAt = at;
  47257. }
  47258. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47259. position += 4;
  47260. dictionary.numberOfNewSymbols = readUint32(data, position);
  47261. position += 4;
  47262. args = [
  47263. dictionary,
  47264. header.number,
  47265. header.referredTo,
  47266. data,
  47267. position,
  47268. end
  47269. ];
  47270. break;
  47271. case 6:
  47272. case 7:
  47273. var textRegion = {};
  47274. textRegion.info = readRegionSegmentInformation(data, position);
  47275. position += RegionSegmentInformationFieldLength;
  47276. var textRegionSegmentFlags = readUint16(data, position);
  47277. position += 2;
  47278. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47279. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47280. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47281. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47282. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47283. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47284. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47285. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47286. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47287. if (textRegion.huffman) {
  47288. var textRegionHuffmanFlags = readUint16(data, position);
  47289. position += 2;
  47290. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47291. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47292. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47293. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47294. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47295. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47296. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47297. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47298. }
  47299. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47300. at = [];
  47301. for (i = 0; i < 2; i++) {
  47302. at.push({
  47303. x: readInt8(data, position),
  47304. y: readInt8(data, position + 1)
  47305. });
  47306. position += 2;
  47307. }
  47308. textRegion.refinementAt = at;
  47309. }
  47310. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47311. position += 4;
  47312. if (textRegion.huffman) {
  47313. error('JBIG2 error: huffman is not supported');
  47314. }
  47315. args = [
  47316. textRegion,
  47317. header.referredTo,
  47318. data,
  47319. position,
  47320. end
  47321. ];
  47322. break;
  47323. case 38:
  47324. case 39:
  47325. var genericRegion = {};
  47326. genericRegion.info = readRegionSegmentInformation(data, position);
  47327. position += RegionSegmentInformationFieldLength;
  47328. var genericRegionSegmentFlags = data[position++];
  47329. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47330. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47331. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47332. if (!genericRegion.mmr) {
  47333. atLength = genericRegion.template === 0 ? 4 : 1;
  47334. at = [];
  47335. for (i = 0; i < atLength; i++) {
  47336. at.push({
  47337. x: readInt8(data, position),
  47338. y: readInt8(data, position + 1)
  47339. });
  47340. position += 2;
  47341. }
  47342. genericRegion.at = at;
  47343. }
  47344. args = [
  47345. genericRegion,
  47346. data,
  47347. position,
  47348. end
  47349. ];
  47350. break;
  47351. case 48:
  47352. var pageInfo = {
  47353. width: readUint32(data, position),
  47354. height: readUint32(data, position + 4),
  47355. resolutionX: readUint32(data, position + 8),
  47356. resolutionY: readUint32(data, position + 12)
  47357. };
  47358. if (pageInfo.height === 0xFFFFFFFF) {
  47359. delete pageInfo.height;
  47360. }
  47361. var pageSegmentFlags = data[position + 16];
  47362. readUint16(data, position + 17);
  47363. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47364. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47365. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47366. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47367. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47368. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47369. args = [pageInfo];
  47370. break;
  47371. case 49:
  47372. break;
  47373. case 50:
  47374. break;
  47375. case 51:
  47376. break;
  47377. case 62:
  47378. break;
  47379. default:
  47380. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47381. }
  47382. var callbackName = 'on' + header.typeName;
  47383. if (callbackName in visitor) {
  47384. visitor[callbackName].apply(visitor, args);
  47385. }
  47386. }
  47387. function processSegments(segments, visitor) {
  47388. for (var i = 0, ii = segments.length; i < ii; i++) {
  47389. processSegment(segments[i], visitor);
  47390. }
  47391. }
  47392. function parseJbig2(data, start, end) {
  47393. var position = start;
  47394. 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) {
  47395. error('JBIG2 error: invalid header');
  47396. }
  47397. var header = {};
  47398. position += 8;
  47399. var flags = data[position++];
  47400. header.randomAccess = !(flags & 1);
  47401. if (!(flags & 2)) {
  47402. header.numberOfPages = readUint32(data, position);
  47403. position += 4;
  47404. }
  47405. readSegments(header, data, position, end);
  47406. error('Not implemented');
  47407. }
  47408. function parseJbig2Chunks(chunks) {
  47409. var visitor = new SimpleSegmentVisitor();
  47410. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47411. var chunk = chunks[i];
  47412. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47413. processSegments(segments, visitor);
  47414. }
  47415. return visitor.buffer;
  47416. }
  47417. function SimpleSegmentVisitor() {
  47418. }
  47419. SimpleSegmentVisitor.prototype = {
  47420. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47421. this.currentPageInfo = info;
  47422. var rowSize = info.width + 7 >> 3;
  47423. var buffer = new Uint8Array(rowSize * info.height);
  47424. if (info.defaultPixelValue) {
  47425. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47426. buffer[i] = 0xFF;
  47427. }
  47428. }
  47429. this.buffer = buffer;
  47430. },
  47431. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47432. var pageInfo = this.currentPageInfo;
  47433. var width = regionInfo.width, height = regionInfo.height;
  47434. var rowSize = pageInfo.width + 7 >> 3;
  47435. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47436. var buffer = this.buffer;
  47437. var mask0 = 128 >> (regionInfo.x & 7);
  47438. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47439. var i, j, mask, offset;
  47440. switch (combinationOperator) {
  47441. case 0:
  47442. for (i = 0; i < height; i++) {
  47443. mask = mask0;
  47444. offset = offset0;
  47445. for (j = 0; j < width; j++) {
  47446. if (bitmap[i][j]) {
  47447. buffer[offset] |= mask;
  47448. }
  47449. mask >>= 1;
  47450. if (!mask) {
  47451. mask = 128;
  47452. offset++;
  47453. }
  47454. }
  47455. offset0 += rowSize;
  47456. }
  47457. break;
  47458. case 2:
  47459. for (i = 0; i < height; i++) {
  47460. mask = mask0;
  47461. offset = offset0;
  47462. for (j = 0; j < width; j++) {
  47463. if (bitmap[i][j]) {
  47464. buffer[offset] ^= mask;
  47465. }
  47466. mask >>= 1;
  47467. if (!mask) {
  47468. mask = 128;
  47469. offset++;
  47470. }
  47471. }
  47472. offset0 += rowSize;
  47473. }
  47474. break;
  47475. default:
  47476. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47477. }
  47478. },
  47479. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47480. var regionInfo = region.info;
  47481. var decodingContext = new DecodingContext(data, start, end);
  47482. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47483. this.drawBitmap(regionInfo, bitmap);
  47484. },
  47485. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47486. this.onImmediateGenericRegion.apply(this, arguments);
  47487. },
  47488. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47489. var huffmanTables;
  47490. if (dictionary.huffman) {
  47491. error('JBIG2 error: huffman is not supported');
  47492. }
  47493. var symbols = this.symbols;
  47494. if (!symbols) {
  47495. this.symbols = symbols = {};
  47496. }
  47497. var inputSymbols = [];
  47498. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47499. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47500. }
  47501. var decodingContext = new DecodingContext(data, start, end);
  47502. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47503. },
  47504. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47505. var regionInfo = region.info;
  47506. var huffmanTables;
  47507. var symbols = this.symbols;
  47508. var inputSymbols = [];
  47509. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47510. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47511. }
  47512. var symbolCodeLength = log2(inputSymbols.length);
  47513. var decodingContext = new DecodingContext(data, start, end);
  47514. 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);
  47515. this.drawBitmap(regionInfo, bitmap);
  47516. },
  47517. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47518. this.onImmediateTextRegion.apply(this, arguments);
  47519. }
  47520. };
  47521. function Jbig2Image() {
  47522. }
  47523. Jbig2Image.prototype = {
  47524. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47525. return parseJbig2Chunks(chunks);
  47526. }
  47527. };
  47528. return Jbig2Image;
  47529. }();
  47530. exports.Jbig2Image = Jbig2Image;
  47531. /***/ }),
  47532. /* 36 */
  47533. /***/ (function(module, exports, __w_pdfjs_require__) {
  47534. "use strict";
  47535. var sharedUtil = __w_pdfjs_require__(0);
  47536. var error = sharedUtil.error;
  47537. var JpegImage = function JpegImageClosure() {
  47538. var dctZigZag = new Uint8Array([
  47539. 0,
  47540. 1,
  47541. 8,
  47542. 16,
  47543. 9,
  47544. 2,
  47545. 3,
  47546. 10,
  47547. 17,
  47548. 24,
  47549. 32,
  47550. 25,
  47551. 18,
  47552. 11,
  47553. 4,
  47554. 5,
  47555. 12,
  47556. 19,
  47557. 26,
  47558. 33,
  47559. 40,
  47560. 48,
  47561. 41,
  47562. 34,
  47563. 27,
  47564. 20,
  47565. 13,
  47566. 6,
  47567. 7,
  47568. 14,
  47569. 21,
  47570. 28,
  47571. 35,
  47572. 42,
  47573. 49,
  47574. 56,
  47575. 57,
  47576. 50,
  47577. 43,
  47578. 36,
  47579. 29,
  47580. 22,
  47581. 15,
  47582. 23,
  47583. 30,
  47584. 37,
  47585. 44,
  47586. 51,
  47587. 58,
  47588. 59,
  47589. 52,
  47590. 45,
  47591. 38,
  47592. 31,
  47593. 39,
  47594. 46,
  47595. 53,
  47596. 60,
  47597. 61,
  47598. 54,
  47599. 47,
  47600. 55,
  47601. 62,
  47602. 63
  47603. ]);
  47604. var dctCos1 = 4017;
  47605. var dctSin1 = 799;
  47606. var dctCos3 = 3406;
  47607. var dctSin3 = 2276;
  47608. var dctCos6 = 1567;
  47609. var dctSin6 = 3784;
  47610. var dctSqrt2 = 5793;
  47611. var dctSqrt1d2 = 2896;
  47612. function JpegImage() {
  47613. this.decodeTransform = null;
  47614. this.colorTransform = -1;
  47615. }
  47616. function buildHuffmanTable(codeLengths, values) {
  47617. var k = 0, code = [], i, j, length = 16;
  47618. while (length > 0 && !codeLengths[length - 1]) {
  47619. length--;
  47620. }
  47621. code.push({
  47622. children: [],
  47623. index: 0
  47624. });
  47625. var p = code[0], q;
  47626. for (i = 0; i < length; i++) {
  47627. for (j = 0; j < codeLengths[i]; j++) {
  47628. p = code.pop();
  47629. p.children[p.index] = values[k];
  47630. while (p.index > 0) {
  47631. p = code.pop();
  47632. }
  47633. p.index++;
  47634. code.push(p);
  47635. while (code.length <= i) {
  47636. code.push(q = {
  47637. children: [],
  47638. index: 0
  47639. });
  47640. p.children[p.index] = q.children;
  47641. p = q;
  47642. }
  47643. k++;
  47644. }
  47645. if (i + 1 < length) {
  47646. code.push(q = {
  47647. children: [],
  47648. index: 0
  47649. });
  47650. p.children[p.index] = q.children;
  47651. p = q;
  47652. }
  47653. }
  47654. return code[0].children;
  47655. }
  47656. function getBlockBufferOffset(component, row, col) {
  47657. return 64 * ((component.blocksPerLine + 1) * row + col);
  47658. }
  47659. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47660. var mcusPerLine = frame.mcusPerLine;
  47661. var progressive = frame.progressive;
  47662. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47663. function readBit() {
  47664. if (bitsCount > 0) {
  47665. bitsCount--;
  47666. return bitsData >> bitsCount & 1;
  47667. }
  47668. bitsData = data[offset++];
  47669. if (bitsData === 0xFF) {
  47670. var nextByte = data[offset++];
  47671. if (nextByte) {
  47672. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47673. }
  47674. }
  47675. bitsCount = 7;
  47676. return bitsData >>> 7;
  47677. }
  47678. function decodeHuffman(tree) {
  47679. var node = tree;
  47680. while (true) {
  47681. node = node[readBit()];
  47682. if (typeof node === 'number') {
  47683. return node;
  47684. }
  47685. if (typeof node !== 'object') {
  47686. error('JPEG error: invalid huffman sequence');
  47687. }
  47688. }
  47689. }
  47690. function receive(length) {
  47691. var n = 0;
  47692. while (length > 0) {
  47693. n = n << 1 | readBit();
  47694. length--;
  47695. }
  47696. return n;
  47697. }
  47698. function receiveAndExtend(length) {
  47699. if (length === 1) {
  47700. return readBit() === 1 ? 1 : -1;
  47701. }
  47702. var n = receive(length);
  47703. if (n >= 1 << length - 1) {
  47704. return n;
  47705. }
  47706. return n + (-1 << length) + 1;
  47707. }
  47708. function decodeBaseline(component, offset) {
  47709. var t = decodeHuffman(component.huffmanTableDC);
  47710. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47711. component.blockData[offset] = component.pred += diff;
  47712. var k = 1;
  47713. while (k < 64) {
  47714. var rs = decodeHuffman(component.huffmanTableAC);
  47715. var s = rs & 15, r = rs >> 4;
  47716. if (s === 0) {
  47717. if (r < 15) {
  47718. break;
  47719. }
  47720. k += 16;
  47721. continue;
  47722. }
  47723. k += r;
  47724. var z = dctZigZag[k];
  47725. component.blockData[offset + z] = receiveAndExtend(s);
  47726. k++;
  47727. }
  47728. }
  47729. function decodeDCFirst(component, offset) {
  47730. var t = decodeHuffman(component.huffmanTableDC);
  47731. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47732. component.blockData[offset] = component.pred += diff;
  47733. }
  47734. function decodeDCSuccessive(component, offset) {
  47735. component.blockData[offset] |= readBit() << successive;
  47736. }
  47737. var eobrun = 0;
  47738. function decodeACFirst(component, offset) {
  47739. if (eobrun > 0) {
  47740. eobrun--;
  47741. return;
  47742. }
  47743. var k = spectralStart, e = spectralEnd;
  47744. while (k <= e) {
  47745. var rs = decodeHuffman(component.huffmanTableAC);
  47746. var s = rs & 15, r = rs >> 4;
  47747. if (s === 0) {
  47748. if (r < 15) {
  47749. eobrun = receive(r) + (1 << r) - 1;
  47750. break;
  47751. }
  47752. k += 16;
  47753. continue;
  47754. }
  47755. k += r;
  47756. var z = dctZigZag[k];
  47757. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47758. k++;
  47759. }
  47760. }
  47761. var successiveACState = 0, successiveACNextValue;
  47762. function decodeACSuccessive(component, offset) {
  47763. var k = spectralStart;
  47764. var e = spectralEnd;
  47765. var r = 0;
  47766. var s;
  47767. var rs;
  47768. while (k <= e) {
  47769. var z = dctZigZag[k];
  47770. switch (successiveACState) {
  47771. case 0:
  47772. rs = decodeHuffman(component.huffmanTableAC);
  47773. s = rs & 15;
  47774. r = rs >> 4;
  47775. if (s === 0) {
  47776. if (r < 15) {
  47777. eobrun = receive(r) + (1 << r);
  47778. successiveACState = 4;
  47779. } else {
  47780. r = 16;
  47781. successiveACState = 1;
  47782. }
  47783. } else {
  47784. if (s !== 1) {
  47785. error('JPEG error: invalid ACn encoding');
  47786. }
  47787. successiveACNextValue = receiveAndExtend(s);
  47788. successiveACState = r ? 2 : 3;
  47789. }
  47790. continue;
  47791. case 1:
  47792. case 2:
  47793. if (component.blockData[offset + z]) {
  47794. component.blockData[offset + z] += readBit() << successive;
  47795. } else {
  47796. r--;
  47797. if (r === 0) {
  47798. successiveACState = successiveACState === 2 ? 3 : 0;
  47799. }
  47800. }
  47801. break;
  47802. case 3:
  47803. if (component.blockData[offset + z]) {
  47804. component.blockData[offset + z] += readBit() << successive;
  47805. } else {
  47806. component.blockData[offset + z] = successiveACNextValue << successive;
  47807. successiveACState = 0;
  47808. }
  47809. break;
  47810. case 4:
  47811. if (component.blockData[offset + z]) {
  47812. component.blockData[offset + z] += readBit() << successive;
  47813. }
  47814. break;
  47815. }
  47816. k++;
  47817. }
  47818. if (successiveACState === 4) {
  47819. eobrun--;
  47820. if (eobrun === 0) {
  47821. successiveACState = 0;
  47822. }
  47823. }
  47824. }
  47825. function decodeMcu(component, decode, mcu, row, col) {
  47826. var mcuRow = mcu / mcusPerLine | 0;
  47827. var mcuCol = mcu % mcusPerLine;
  47828. var blockRow = mcuRow * component.v + row;
  47829. var blockCol = mcuCol * component.h + col;
  47830. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47831. decode(component, offset);
  47832. }
  47833. function decodeBlock(component, decode, mcu) {
  47834. var blockRow = mcu / component.blocksPerLine | 0;
  47835. var blockCol = mcu % component.blocksPerLine;
  47836. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47837. decode(component, offset);
  47838. }
  47839. var componentsLength = components.length;
  47840. var component, i, j, k, n;
  47841. var decodeFn;
  47842. if (progressive) {
  47843. if (spectralStart === 0) {
  47844. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47845. } else {
  47846. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47847. }
  47848. } else {
  47849. decodeFn = decodeBaseline;
  47850. }
  47851. var mcu = 0, marker;
  47852. var mcuExpected;
  47853. if (componentsLength === 1) {
  47854. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47855. } else {
  47856. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47857. }
  47858. if (!resetInterval) {
  47859. resetInterval = mcuExpected;
  47860. }
  47861. var h, v;
  47862. while (mcu < mcuExpected) {
  47863. for (i = 0; i < componentsLength; i++) {
  47864. components[i].pred = 0;
  47865. }
  47866. eobrun = 0;
  47867. if (componentsLength === 1) {
  47868. component = components[0];
  47869. for (n = 0; n < resetInterval; n++) {
  47870. decodeBlock(component, decodeFn, mcu);
  47871. mcu++;
  47872. }
  47873. } else {
  47874. for (n = 0; n < resetInterval; n++) {
  47875. for (i = 0; i < componentsLength; i++) {
  47876. component = components[i];
  47877. h = component.h;
  47878. v = component.v;
  47879. for (j = 0; j < v; j++) {
  47880. for (k = 0; k < h; k++) {
  47881. decodeMcu(component, decodeFn, mcu, j, k);
  47882. }
  47883. }
  47884. }
  47885. mcu++;
  47886. }
  47887. }
  47888. bitsCount = 0;
  47889. marker = data[offset] << 8 | data[offset + 1];
  47890. while (data[offset] === 0x00 && offset < data.length - 1) {
  47891. offset++;
  47892. marker = data[offset] << 8 | data[offset + 1];
  47893. }
  47894. if (marker <= 0xFF00) {
  47895. error('JPEG error: marker was not found');
  47896. }
  47897. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47898. offset += 2;
  47899. } else {
  47900. break;
  47901. }
  47902. }
  47903. return offset - startOffset;
  47904. }
  47905. function quantizeAndInverse(component, blockBufferOffset, p) {
  47906. var qt = component.quantizationTable, blockData = component.blockData;
  47907. var v0, v1, v2, v3, v4, v5, v6, v7;
  47908. var p0, p1, p2, p3, p4, p5, p6, p7;
  47909. var t;
  47910. if (!qt) {
  47911. error('JPEG error: missing required Quantization Table.');
  47912. }
  47913. for (var row = 0; row < 64; row += 8) {
  47914. p0 = blockData[blockBufferOffset + row];
  47915. p1 = blockData[blockBufferOffset + row + 1];
  47916. p2 = blockData[blockBufferOffset + row + 2];
  47917. p3 = blockData[blockBufferOffset + row + 3];
  47918. p4 = blockData[blockBufferOffset + row + 4];
  47919. p5 = blockData[blockBufferOffset + row + 5];
  47920. p6 = blockData[blockBufferOffset + row + 6];
  47921. p7 = blockData[blockBufferOffset + row + 7];
  47922. p0 *= qt[row];
  47923. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47924. t = dctSqrt2 * p0 + 512 >> 10;
  47925. p[row] = t;
  47926. p[row + 1] = t;
  47927. p[row + 2] = t;
  47928. p[row + 3] = t;
  47929. p[row + 4] = t;
  47930. p[row + 5] = t;
  47931. p[row + 6] = t;
  47932. p[row + 7] = t;
  47933. continue;
  47934. }
  47935. p1 *= qt[row + 1];
  47936. p2 *= qt[row + 2];
  47937. p3 *= qt[row + 3];
  47938. p4 *= qt[row + 4];
  47939. p5 *= qt[row + 5];
  47940. p6 *= qt[row + 6];
  47941. p7 *= qt[row + 7];
  47942. v0 = dctSqrt2 * p0 + 128 >> 8;
  47943. v1 = dctSqrt2 * p4 + 128 >> 8;
  47944. v2 = p2;
  47945. v3 = p6;
  47946. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47947. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47948. v5 = p3 << 4;
  47949. v6 = p5 << 4;
  47950. v0 = v0 + v1 + 1 >> 1;
  47951. v1 = v0 - v1;
  47952. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47953. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47954. v3 = t;
  47955. v4 = v4 + v6 + 1 >> 1;
  47956. v6 = v4 - v6;
  47957. v7 = v7 + v5 + 1 >> 1;
  47958. v5 = v7 - v5;
  47959. v0 = v0 + v3 + 1 >> 1;
  47960. v3 = v0 - v3;
  47961. v1 = v1 + v2 + 1 >> 1;
  47962. v2 = v1 - v2;
  47963. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47964. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47965. v7 = t;
  47966. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47967. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47968. v6 = t;
  47969. p[row] = v0 + v7;
  47970. p[row + 7] = v0 - v7;
  47971. p[row + 1] = v1 + v6;
  47972. p[row + 6] = v1 - v6;
  47973. p[row + 2] = v2 + v5;
  47974. p[row + 5] = v2 - v5;
  47975. p[row + 3] = v3 + v4;
  47976. p[row + 4] = v3 - v4;
  47977. }
  47978. for (var col = 0; col < 8; ++col) {
  47979. p0 = p[col];
  47980. p1 = p[col + 8];
  47981. p2 = p[col + 16];
  47982. p3 = p[col + 24];
  47983. p4 = p[col + 32];
  47984. p5 = p[col + 40];
  47985. p6 = p[col + 48];
  47986. p7 = p[col + 56];
  47987. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47988. t = dctSqrt2 * p0 + 8192 >> 14;
  47989. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  47990. blockData[blockBufferOffset + col] = t;
  47991. blockData[blockBufferOffset + col + 8] = t;
  47992. blockData[blockBufferOffset + col + 16] = t;
  47993. blockData[blockBufferOffset + col + 24] = t;
  47994. blockData[blockBufferOffset + col + 32] = t;
  47995. blockData[blockBufferOffset + col + 40] = t;
  47996. blockData[blockBufferOffset + col + 48] = t;
  47997. blockData[blockBufferOffset + col + 56] = t;
  47998. continue;
  47999. }
  48000. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48001. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48002. v2 = p2;
  48003. v3 = p6;
  48004. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48005. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48006. v5 = p3;
  48007. v6 = p5;
  48008. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48009. v1 = v0 - v1;
  48010. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48011. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48012. v3 = t;
  48013. v4 = v4 + v6 + 1 >> 1;
  48014. v6 = v4 - v6;
  48015. v7 = v7 + v5 + 1 >> 1;
  48016. v5 = v7 - v5;
  48017. v0 = v0 + v3 + 1 >> 1;
  48018. v3 = v0 - v3;
  48019. v1 = v1 + v2 + 1 >> 1;
  48020. v2 = v1 - v2;
  48021. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48022. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48023. v7 = t;
  48024. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48025. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48026. v6 = t;
  48027. p0 = v0 + v7;
  48028. p7 = v0 - v7;
  48029. p1 = v1 + v6;
  48030. p6 = v1 - v6;
  48031. p2 = v2 + v5;
  48032. p5 = v2 - v5;
  48033. p3 = v3 + v4;
  48034. p4 = v3 - v4;
  48035. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48036. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48037. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48038. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48039. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48040. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48041. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48042. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48043. blockData[blockBufferOffset + col] = p0;
  48044. blockData[blockBufferOffset + col + 8] = p1;
  48045. blockData[blockBufferOffset + col + 16] = p2;
  48046. blockData[blockBufferOffset + col + 24] = p3;
  48047. blockData[blockBufferOffset + col + 32] = p4;
  48048. blockData[blockBufferOffset + col + 40] = p5;
  48049. blockData[blockBufferOffset + col + 48] = p6;
  48050. blockData[blockBufferOffset + col + 56] = p7;
  48051. }
  48052. }
  48053. function buildComponentData(frame, component) {
  48054. var blocksPerLine = component.blocksPerLine;
  48055. var blocksPerColumn = component.blocksPerColumn;
  48056. var computationBuffer = new Int16Array(64);
  48057. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48058. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48059. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48060. quantizeAndInverse(component, offset, computationBuffer);
  48061. }
  48062. }
  48063. return component.blockData;
  48064. }
  48065. function clamp0to255(a) {
  48066. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48067. }
  48068. JpegImage.prototype = {
  48069. parse: function parse(data) {
  48070. function readUint16() {
  48071. var value = data[offset] << 8 | data[offset + 1];
  48072. offset += 2;
  48073. return value;
  48074. }
  48075. function readDataBlock() {
  48076. var length = readUint16();
  48077. var array = data.subarray(offset, offset + length - 2);
  48078. offset += array.length;
  48079. return array;
  48080. }
  48081. function prepareComponents(frame) {
  48082. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48083. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48084. for (var i = 0; i < frame.components.length; i++) {
  48085. component = frame.components[i];
  48086. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48087. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48088. var blocksPerLineForMcu = mcusPerLine * component.h;
  48089. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48090. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48091. component.blockData = new Int16Array(blocksBufferSize);
  48092. component.blocksPerLine = blocksPerLine;
  48093. component.blocksPerColumn = blocksPerColumn;
  48094. }
  48095. frame.mcusPerLine = mcusPerLine;
  48096. frame.mcusPerColumn = mcusPerColumn;
  48097. }
  48098. var offset = 0;
  48099. var jfif = null;
  48100. var adobe = null;
  48101. var frame, resetInterval;
  48102. var quantizationTables = [];
  48103. var huffmanTablesAC = [], huffmanTablesDC = [];
  48104. var fileMarker = readUint16();
  48105. if (fileMarker !== 0xFFD8) {
  48106. error('JPEG error: SOI not found');
  48107. }
  48108. fileMarker = readUint16();
  48109. while (fileMarker !== 0xFFD9) {
  48110. var i, j, l;
  48111. switch (fileMarker) {
  48112. case 0xFFE0:
  48113. case 0xFFE1:
  48114. case 0xFFE2:
  48115. case 0xFFE3:
  48116. case 0xFFE4:
  48117. case 0xFFE5:
  48118. case 0xFFE6:
  48119. case 0xFFE7:
  48120. case 0xFFE8:
  48121. case 0xFFE9:
  48122. case 0xFFEA:
  48123. case 0xFFEB:
  48124. case 0xFFEC:
  48125. case 0xFFED:
  48126. case 0xFFEE:
  48127. case 0xFFEF:
  48128. case 0xFFFE:
  48129. var appData = readDataBlock();
  48130. if (fileMarker === 0xFFE0) {
  48131. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48132. jfif = {
  48133. version: {
  48134. major: appData[5],
  48135. minor: appData[6]
  48136. },
  48137. densityUnits: appData[7],
  48138. xDensity: appData[8] << 8 | appData[9],
  48139. yDensity: appData[10] << 8 | appData[11],
  48140. thumbWidth: appData[12],
  48141. thumbHeight: appData[13],
  48142. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48143. };
  48144. }
  48145. }
  48146. if (fileMarker === 0xFFEE) {
  48147. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48148. adobe = {
  48149. version: appData[5] << 8 | appData[6],
  48150. flags0: appData[7] << 8 | appData[8],
  48151. flags1: appData[9] << 8 | appData[10],
  48152. transformCode: appData[11]
  48153. };
  48154. }
  48155. }
  48156. break;
  48157. case 0xFFDB:
  48158. var quantizationTablesLength = readUint16();
  48159. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48160. var z;
  48161. while (offset < quantizationTablesEnd) {
  48162. var quantizationTableSpec = data[offset++];
  48163. var tableData = new Uint16Array(64);
  48164. if (quantizationTableSpec >> 4 === 0) {
  48165. for (j = 0; j < 64; j++) {
  48166. z = dctZigZag[j];
  48167. tableData[z] = data[offset++];
  48168. }
  48169. } else if (quantizationTableSpec >> 4 === 1) {
  48170. for (j = 0; j < 64; j++) {
  48171. z = dctZigZag[j];
  48172. tableData[z] = readUint16();
  48173. }
  48174. } else {
  48175. error('JPEG error: DQT - invalid table spec');
  48176. }
  48177. quantizationTables[quantizationTableSpec & 15] = tableData;
  48178. }
  48179. break;
  48180. case 0xFFC0:
  48181. case 0xFFC1:
  48182. case 0xFFC2:
  48183. if (frame) {
  48184. error('JPEG error: Only single frame JPEGs supported');
  48185. }
  48186. readUint16();
  48187. frame = {};
  48188. frame.extended = fileMarker === 0xFFC1;
  48189. frame.progressive = fileMarker === 0xFFC2;
  48190. frame.precision = data[offset++];
  48191. frame.scanLines = readUint16();
  48192. frame.samplesPerLine = readUint16();
  48193. frame.components = [];
  48194. frame.componentIds = {};
  48195. var componentsCount = data[offset++], componentId;
  48196. var maxH = 0, maxV = 0;
  48197. for (i = 0; i < componentsCount; i++) {
  48198. componentId = data[offset];
  48199. var h = data[offset + 1] >> 4;
  48200. var v = data[offset + 1] & 15;
  48201. if (maxH < h) {
  48202. maxH = h;
  48203. }
  48204. if (maxV < v) {
  48205. maxV = v;
  48206. }
  48207. var qId = data[offset + 2];
  48208. l = frame.components.push({
  48209. h: h,
  48210. v: v,
  48211. quantizationId: qId,
  48212. quantizationTable: null
  48213. });
  48214. frame.componentIds[componentId] = l - 1;
  48215. offset += 3;
  48216. }
  48217. frame.maxH = maxH;
  48218. frame.maxV = maxV;
  48219. prepareComponents(frame);
  48220. break;
  48221. case 0xFFC4:
  48222. var huffmanLength = readUint16();
  48223. for (i = 2; i < huffmanLength;) {
  48224. var huffmanTableSpec = data[offset++];
  48225. var codeLengths = new Uint8Array(16);
  48226. var codeLengthSum = 0;
  48227. for (j = 0; j < 16; j++, offset++) {
  48228. codeLengthSum += codeLengths[j] = data[offset];
  48229. }
  48230. var huffmanValues = new Uint8Array(codeLengthSum);
  48231. for (j = 0; j < codeLengthSum; j++, offset++) {
  48232. huffmanValues[j] = data[offset];
  48233. }
  48234. i += 17 + codeLengthSum;
  48235. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48236. }
  48237. break;
  48238. case 0xFFDD:
  48239. readUint16();
  48240. resetInterval = readUint16();
  48241. break;
  48242. case 0xFFDA:
  48243. readUint16();
  48244. var selectorsCount = data[offset++];
  48245. var components = [], component;
  48246. for (i = 0; i < selectorsCount; i++) {
  48247. var componentIndex = frame.componentIds[data[offset++]];
  48248. component = frame.components[componentIndex];
  48249. var tableSpec = data[offset++];
  48250. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48251. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48252. components.push(component);
  48253. }
  48254. var spectralStart = data[offset++];
  48255. var spectralEnd = data[offset++];
  48256. var successiveApproximation = data[offset++];
  48257. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48258. offset += processed;
  48259. break;
  48260. case 0xFFFF:
  48261. if (data[offset] !== 0xFF) {
  48262. offset--;
  48263. }
  48264. break;
  48265. default:
  48266. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48267. offset -= 3;
  48268. break;
  48269. }
  48270. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48271. }
  48272. fileMarker = readUint16();
  48273. }
  48274. this.width = frame.samplesPerLine;
  48275. this.height = frame.scanLines;
  48276. this.jfif = jfif;
  48277. this.adobe = adobe;
  48278. this.components = [];
  48279. for (i = 0; i < frame.components.length; i++) {
  48280. component = frame.components[i];
  48281. var quantizationTable = quantizationTables[component.quantizationId];
  48282. if (quantizationTable) {
  48283. component.quantizationTable = quantizationTable;
  48284. }
  48285. this.components.push({
  48286. output: buildComponentData(frame, component),
  48287. scaleX: component.h / frame.maxH,
  48288. scaleY: component.v / frame.maxV,
  48289. blocksPerLine: component.blocksPerLine,
  48290. blocksPerColumn: component.blocksPerColumn
  48291. });
  48292. }
  48293. this.numComponents = this.components.length;
  48294. },
  48295. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48296. var scaleX = this.width / width, scaleY = this.height / height;
  48297. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48298. var x, y, i, j, k;
  48299. var index;
  48300. var offset = 0;
  48301. var output;
  48302. var numComponents = this.components.length;
  48303. var dataLength = width * height * numComponents;
  48304. var data = new Uint8Array(dataLength);
  48305. var xScaleBlockOffset = new Uint32Array(width);
  48306. var mask3LSB = 0xfffffff8;
  48307. for (i = 0; i < numComponents; i++) {
  48308. component = this.components[i];
  48309. componentScaleX = component.scaleX * scaleX;
  48310. componentScaleY = component.scaleY * scaleY;
  48311. offset = i;
  48312. output = component.output;
  48313. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48314. for (x = 0; x < width; x++) {
  48315. j = 0 | x * componentScaleX;
  48316. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48317. }
  48318. for (y = 0; y < height; y++) {
  48319. j = 0 | y * componentScaleY;
  48320. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48321. for (x = 0; x < width; x++) {
  48322. data[offset] = output[index + xScaleBlockOffset[x]];
  48323. offset += numComponents;
  48324. }
  48325. }
  48326. }
  48327. var transform = this.decodeTransform;
  48328. if (transform) {
  48329. for (i = 0; i < dataLength;) {
  48330. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48331. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48332. }
  48333. }
  48334. }
  48335. return data;
  48336. },
  48337. _isColorConversionNeeded: function isColorConversionNeeded() {
  48338. if (this.adobe && this.adobe.transformCode) {
  48339. return true;
  48340. } else if (this.numComponents === 3) {
  48341. if (!this.adobe && this.colorTransform === 0) {
  48342. return false;
  48343. }
  48344. return true;
  48345. }
  48346. if (!this.adobe && this.colorTransform === 1) {
  48347. return true;
  48348. }
  48349. return false;
  48350. },
  48351. _convertYccToRgb: function convertYccToRgb(data) {
  48352. var Y, Cb, Cr;
  48353. for (var i = 0, length = data.length; i < length; i += 3) {
  48354. Y = data[i];
  48355. Cb = data[i + 1];
  48356. Cr = data[i + 2];
  48357. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48358. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48359. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48360. }
  48361. return data;
  48362. },
  48363. _convertYcckToRgb: function convertYcckToRgb(data) {
  48364. var Y, Cb, Cr, k;
  48365. var offset = 0;
  48366. for (var i = 0, length = data.length; i < length; i += 4) {
  48367. Y = data[i];
  48368. Cb = data[i + 1];
  48369. Cr = data[i + 2];
  48370. k = data[i + 3];
  48371. 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);
  48372. 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);
  48373. 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);
  48374. data[offset++] = clamp0to255(r);
  48375. data[offset++] = clamp0to255(g);
  48376. data[offset++] = clamp0to255(b);
  48377. }
  48378. return data;
  48379. },
  48380. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48381. var Y, Cb, Cr;
  48382. for (var i = 0, length = data.length; i < length; i += 4) {
  48383. Y = data[i];
  48384. Cb = data[i + 1];
  48385. Cr = data[i + 2];
  48386. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48387. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48388. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48389. }
  48390. return data;
  48391. },
  48392. _convertCmykToRgb: function convertCmykToRgb(data) {
  48393. var c, m, y, k;
  48394. var offset = 0;
  48395. var min = -255 * 255 * 255;
  48396. var scale = 1 / 255 / 255;
  48397. for (var i = 0, length = data.length; i < length; i += 4) {
  48398. c = data[i];
  48399. m = data[i + 1];
  48400. y = data[i + 2];
  48401. k = data[i + 3];
  48402. 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);
  48403. 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);
  48404. 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);
  48405. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48406. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48407. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48408. }
  48409. return data;
  48410. },
  48411. getData: function getData(width, height, forceRGBoutput) {
  48412. if (this.numComponents > 4) {
  48413. error('JPEG error: Unsupported color mode');
  48414. }
  48415. var data = this._getLinearizedBlockData(width, height);
  48416. if (this.numComponents === 1 && forceRGBoutput) {
  48417. var dataLength = data.length;
  48418. var rgbData = new Uint8Array(dataLength * 3);
  48419. var offset = 0;
  48420. for (var i = 0; i < dataLength; i++) {
  48421. var grayColor = data[i];
  48422. rgbData[offset++] = grayColor;
  48423. rgbData[offset++] = grayColor;
  48424. rgbData[offset++] = grayColor;
  48425. }
  48426. return rgbData;
  48427. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48428. return this._convertYccToRgb(data);
  48429. } else if (this.numComponents === 4) {
  48430. if (this._isColorConversionNeeded()) {
  48431. if (forceRGBoutput) {
  48432. return this._convertYcckToRgb(data);
  48433. }
  48434. return this._convertYcckToCmyk(data);
  48435. } else if (forceRGBoutput) {
  48436. return this._convertCmykToRgb(data);
  48437. }
  48438. }
  48439. return data;
  48440. }
  48441. };
  48442. return JpegImage;
  48443. }();
  48444. exports.JpegImage = JpegImage;
  48445. /***/ }),
  48446. /* 37 */
  48447. /***/ (function(module, exports, __w_pdfjs_require__) {
  48448. "use strict";
  48449. var sharedUtil = __w_pdfjs_require__(0);
  48450. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48451. var getMetrics = getLookupTableFactory(function (t) {
  48452. t['Courier'] = 600;
  48453. t['Courier-Bold'] = 600;
  48454. t['Courier-BoldOblique'] = 600;
  48455. t['Courier-Oblique'] = 600;
  48456. t['Helvetica'] = getLookupTableFactory(function (t) {
  48457. t['space'] = 278;
  48458. t['exclam'] = 278;
  48459. t['quotedbl'] = 355;
  48460. t['numbersign'] = 556;
  48461. t['dollar'] = 556;
  48462. t['percent'] = 889;
  48463. t['ampersand'] = 667;
  48464. t['quoteright'] = 222;
  48465. t['parenleft'] = 333;
  48466. t['parenright'] = 333;
  48467. t['asterisk'] = 389;
  48468. t['plus'] = 584;
  48469. t['comma'] = 278;
  48470. t['hyphen'] = 333;
  48471. t['period'] = 278;
  48472. t['slash'] = 278;
  48473. t['zero'] = 556;
  48474. t['one'] = 556;
  48475. t['two'] = 556;
  48476. t['three'] = 556;
  48477. t['four'] = 556;
  48478. t['five'] = 556;
  48479. t['six'] = 556;
  48480. t['seven'] = 556;
  48481. t['eight'] = 556;
  48482. t['nine'] = 556;
  48483. t['colon'] = 278;
  48484. t['semicolon'] = 278;
  48485. t['less'] = 584;
  48486. t['equal'] = 584;
  48487. t['greater'] = 584;
  48488. t['question'] = 556;
  48489. t['at'] = 1015;
  48490. t['A'] = 667;
  48491. t['B'] = 667;
  48492. t['C'] = 722;
  48493. t['D'] = 722;
  48494. t['E'] = 667;
  48495. t['F'] = 611;
  48496. t['G'] = 778;
  48497. t['H'] = 722;
  48498. t['I'] = 278;
  48499. t['J'] = 500;
  48500. t['K'] = 667;
  48501. t['L'] = 556;
  48502. t['M'] = 833;
  48503. t['N'] = 722;
  48504. t['O'] = 778;
  48505. t['P'] = 667;
  48506. t['Q'] = 778;
  48507. t['R'] = 722;
  48508. t['S'] = 667;
  48509. t['T'] = 611;
  48510. t['U'] = 722;
  48511. t['V'] = 667;
  48512. t['W'] = 944;
  48513. t['X'] = 667;
  48514. t['Y'] = 667;
  48515. t['Z'] = 611;
  48516. t['bracketleft'] = 278;
  48517. t['backslash'] = 278;
  48518. t['bracketright'] = 278;
  48519. t['asciicircum'] = 469;
  48520. t['underscore'] = 556;
  48521. t['quoteleft'] = 222;
  48522. t['a'] = 556;
  48523. t['b'] = 556;
  48524. t['c'] = 500;
  48525. t['d'] = 556;
  48526. t['e'] = 556;
  48527. t['f'] = 278;
  48528. t['g'] = 556;
  48529. t['h'] = 556;
  48530. t['i'] = 222;
  48531. t['j'] = 222;
  48532. t['k'] = 500;
  48533. t['l'] = 222;
  48534. t['m'] = 833;
  48535. t['n'] = 556;
  48536. t['o'] = 556;
  48537. t['p'] = 556;
  48538. t['q'] = 556;
  48539. t['r'] = 333;
  48540. t['s'] = 500;
  48541. t['t'] = 278;
  48542. t['u'] = 556;
  48543. t['v'] = 500;
  48544. t['w'] = 722;
  48545. t['x'] = 500;
  48546. t['y'] = 500;
  48547. t['z'] = 500;
  48548. t['braceleft'] = 334;
  48549. t['bar'] = 260;
  48550. t['braceright'] = 334;
  48551. t['asciitilde'] = 584;
  48552. t['exclamdown'] = 333;
  48553. t['cent'] = 556;
  48554. t['sterling'] = 556;
  48555. t['fraction'] = 167;
  48556. t['yen'] = 556;
  48557. t['florin'] = 556;
  48558. t['section'] = 556;
  48559. t['currency'] = 556;
  48560. t['quotesingle'] = 191;
  48561. t['quotedblleft'] = 333;
  48562. t['guillemotleft'] = 556;
  48563. t['guilsinglleft'] = 333;
  48564. t['guilsinglright'] = 333;
  48565. t['fi'] = 500;
  48566. t['fl'] = 500;
  48567. t['endash'] = 556;
  48568. t['dagger'] = 556;
  48569. t['daggerdbl'] = 556;
  48570. t['periodcentered'] = 278;
  48571. t['paragraph'] = 537;
  48572. t['bullet'] = 350;
  48573. t['quotesinglbase'] = 222;
  48574. t['quotedblbase'] = 333;
  48575. t['quotedblright'] = 333;
  48576. t['guillemotright'] = 556;
  48577. t['ellipsis'] = 1000;
  48578. t['perthousand'] = 1000;
  48579. t['questiondown'] = 611;
  48580. t['grave'] = 333;
  48581. t['acute'] = 333;
  48582. t['circumflex'] = 333;
  48583. t['tilde'] = 333;
  48584. t['macron'] = 333;
  48585. t['breve'] = 333;
  48586. t['dotaccent'] = 333;
  48587. t['dieresis'] = 333;
  48588. t['ring'] = 333;
  48589. t['cedilla'] = 333;
  48590. t['hungarumlaut'] = 333;
  48591. t['ogonek'] = 333;
  48592. t['caron'] = 333;
  48593. t['emdash'] = 1000;
  48594. t['AE'] = 1000;
  48595. t['ordfeminine'] = 370;
  48596. t['Lslash'] = 556;
  48597. t['Oslash'] = 778;
  48598. t['OE'] = 1000;
  48599. t['ordmasculine'] = 365;
  48600. t['ae'] = 889;
  48601. t['dotlessi'] = 278;
  48602. t['lslash'] = 222;
  48603. t['oslash'] = 611;
  48604. t['oe'] = 944;
  48605. t['germandbls'] = 611;
  48606. t['Idieresis'] = 278;
  48607. t['eacute'] = 556;
  48608. t['abreve'] = 556;
  48609. t['uhungarumlaut'] = 556;
  48610. t['ecaron'] = 556;
  48611. t['Ydieresis'] = 667;
  48612. t['divide'] = 584;
  48613. t['Yacute'] = 667;
  48614. t['Acircumflex'] = 667;
  48615. t['aacute'] = 556;
  48616. t['Ucircumflex'] = 722;
  48617. t['yacute'] = 500;
  48618. t['scommaaccent'] = 500;
  48619. t['ecircumflex'] = 556;
  48620. t['Uring'] = 722;
  48621. t['Udieresis'] = 722;
  48622. t['aogonek'] = 556;
  48623. t['Uacute'] = 722;
  48624. t['uogonek'] = 556;
  48625. t['Edieresis'] = 667;
  48626. t['Dcroat'] = 722;
  48627. t['commaaccent'] = 250;
  48628. t['copyright'] = 737;
  48629. t['Emacron'] = 667;
  48630. t['ccaron'] = 500;
  48631. t['aring'] = 556;
  48632. t['Ncommaaccent'] = 722;
  48633. t['lacute'] = 222;
  48634. t['agrave'] = 556;
  48635. t['Tcommaaccent'] = 611;
  48636. t['Cacute'] = 722;
  48637. t['atilde'] = 556;
  48638. t['Edotaccent'] = 667;
  48639. t['scaron'] = 500;
  48640. t['scedilla'] = 500;
  48641. t['iacute'] = 278;
  48642. t['lozenge'] = 471;
  48643. t['Rcaron'] = 722;
  48644. t['Gcommaaccent'] = 778;
  48645. t['ucircumflex'] = 556;
  48646. t['acircumflex'] = 556;
  48647. t['Amacron'] = 667;
  48648. t['rcaron'] = 333;
  48649. t['ccedilla'] = 500;
  48650. t['Zdotaccent'] = 611;
  48651. t['Thorn'] = 667;
  48652. t['Omacron'] = 778;
  48653. t['Racute'] = 722;
  48654. t['Sacute'] = 667;
  48655. t['dcaron'] = 643;
  48656. t['Umacron'] = 722;
  48657. t['uring'] = 556;
  48658. t['threesuperior'] = 333;
  48659. t['Ograve'] = 778;
  48660. t['Agrave'] = 667;
  48661. t['Abreve'] = 667;
  48662. t['multiply'] = 584;
  48663. t['uacute'] = 556;
  48664. t['Tcaron'] = 611;
  48665. t['partialdiff'] = 476;
  48666. t['ydieresis'] = 500;
  48667. t['Nacute'] = 722;
  48668. t['icircumflex'] = 278;
  48669. t['Ecircumflex'] = 667;
  48670. t['adieresis'] = 556;
  48671. t['edieresis'] = 556;
  48672. t['cacute'] = 500;
  48673. t['nacute'] = 556;
  48674. t['umacron'] = 556;
  48675. t['Ncaron'] = 722;
  48676. t['Iacute'] = 278;
  48677. t['plusminus'] = 584;
  48678. t['brokenbar'] = 260;
  48679. t['registered'] = 737;
  48680. t['Gbreve'] = 778;
  48681. t['Idotaccent'] = 278;
  48682. t['summation'] = 600;
  48683. t['Egrave'] = 667;
  48684. t['racute'] = 333;
  48685. t['omacron'] = 556;
  48686. t['Zacute'] = 611;
  48687. t['Zcaron'] = 611;
  48688. t['greaterequal'] = 549;
  48689. t['Eth'] = 722;
  48690. t['Ccedilla'] = 722;
  48691. t['lcommaaccent'] = 222;
  48692. t['tcaron'] = 317;
  48693. t['eogonek'] = 556;
  48694. t['Uogonek'] = 722;
  48695. t['Aacute'] = 667;
  48696. t['Adieresis'] = 667;
  48697. t['egrave'] = 556;
  48698. t['zacute'] = 500;
  48699. t['iogonek'] = 222;
  48700. t['Oacute'] = 778;
  48701. t['oacute'] = 556;
  48702. t['amacron'] = 556;
  48703. t['sacute'] = 500;
  48704. t['idieresis'] = 278;
  48705. t['Ocircumflex'] = 778;
  48706. t['Ugrave'] = 722;
  48707. t['Delta'] = 612;
  48708. t['thorn'] = 556;
  48709. t['twosuperior'] = 333;
  48710. t['Odieresis'] = 778;
  48711. t['mu'] = 556;
  48712. t['igrave'] = 278;
  48713. t['ohungarumlaut'] = 556;
  48714. t['Eogonek'] = 667;
  48715. t['dcroat'] = 556;
  48716. t['threequarters'] = 834;
  48717. t['Scedilla'] = 667;
  48718. t['lcaron'] = 299;
  48719. t['Kcommaaccent'] = 667;
  48720. t['Lacute'] = 556;
  48721. t['trademark'] = 1000;
  48722. t['edotaccent'] = 556;
  48723. t['Igrave'] = 278;
  48724. t['Imacron'] = 278;
  48725. t['Lcaron'] = 556;
  48726. t['onehalf'] = 834;
  48727. t['lessequal'] = 549;
  48728. t['ocircumflex'] = 556;
  48729. t['ntilde'] = 556;
  48730. t['Uhungarumlaut'] = 722;
  48731. t['Eacute'] = 667;
  48732. t['emacron'] = 556;
  48733. t['gbreve'] = 556;
  48734. t['onequarter'] = 834;
  48735. t['Scaron'] = 667;
  48736. t['Scommaaccent'] = 667;
  48737. t['Ohungarumlaut'] = 778;
  48738. t['degree'] = 400;
  48739. t['ograve'] = 556;
  48740. t['Ccaron'] = 722;
  48741. t['ugrave'] = 556;
  48742. t['radical'] = 453;
  48743. t['Dcaron'] = 722;
  48744. t['rcommaaccent'] = 333;
  48745. t['Ntilde'] = 722;
  48746. t['otilde'] = 556;
  48747. t['Rcommaaccent'] = 722;
  48748. t['Lcommaaccent'] = 556;
  48749. t['Atilde'] = 667;
  48750. t['Aogonek'] = 667;
  48751. t['Aring'] = 667;
  48752. t['Otilde'] = 778;
  48753. t['zdotaccent'] = 500;
  48754. t['Ecaron'] = 667;
  48755. t['Iogonek'] = 278;
  48756. t['kcommaaccent'] = 500;
  48757. t['minus'] = 584;
  48758. t['Icircumflex'] = 278;
  48759. t['ncaron'] = 556;
  48760. t['tcommaaccent'] = 278;
  48761. t['logicalnot'] = 584;
  48762. t['odieresis'] = 556;
  48763. t['udieresis'] = 556;
  48764. t['notequal'] = 549;
  48765. t['gcommaaccent'] = 556;
  48766. t['eth'] = 556;
  48767. t['zcaron'] = 500;
  48768. t['ncommaaccent'] = 556;
  48769. t['onesuperior'] = 333;
  48770. t['imacron'] = 278;
  48771. t['Euro'] = 556;
  48772. });
  48773. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48774. t['space'] = 278;
  48775. t['exclam'] = 333;
  48776. t['quotedbl'] = 474;
  48777. t['numbersign'] = 556;
  48778. t['dollar'] = 556;
  48779. t['percent'] = 889;
  48780. t['ampersand'] = 722;
  48781. t['quoteright'] = 278;
  48782. t['parenleft'] = 333;
  48783. t['parenright'] = 333;
  48784. t['asterisk'] = 389;
  48785. t['plus'] = 584;
  48786. t['comma'] = 278;
  48787. t['hyphen'] = 333;
  48788. t['period'] = 278;
  48789. t['slash'] = 278;
  48790. t['zero'] = 556;
  48791. t['one'] = 556;
  48792. t['two'] = 556;
  48793. t['three'] = 556;
  48794. t['four'] = 556;
  48795. t['five'] = 556;
  48796. t['six'] = 556;
  48797. t['seven'] = 556;
  48798. t['eight'] = 556;
  48799. t['nine'] = 556;
  48800. t['colon'] = 333;
  48801. t['semicolon'] = 333;
  48802. t['less'] = 584;
  48803. t['equal'] = 584;
  48804. t['greater'] = 584;
  48805. t['question'] = 611;
  48806. t['at'] = 975;
  48807. t['A'] = 722;
  48808. t['B'] = 722;
  48809. t['C'] = 722;
  48810. t['D'] = 722;
  48811. t['E'] = 667;
  48812. t['F'] = 611;
  48813. t['G'] = 778;
  48814. t['H'] = 722;
  48815. t['I'] = 278;
  48816. t['J'] = 556;
  48817. t['K'] = 722;
  48818. t['L'] = 611;
  48819. t['M'] = 833;
  48820. t['N'] = 722;
  48821. t['O'] = 778;
  48822. t['P'] = 667;
  48823. t['Q'] = 778;
  48824. t['R'] = 722;
  48825. t['S'] = 667;
  48826. t['T'] = 611;
  48827. t['U'] = 722;
  48828. t['V'] = 667;
  48829. t['W'] = 944;
  48830. t['X'] = 667;
  48831. t['Y'] = 667;
  48832. t['Z'] = 611;
  48833. t['bracketleft'] = 333;
  48834. t['backslash'] = 278;
  48835. t['bracketright'] = 333;
  48836. t['asciicircum'] = 584;
  48837. t['underscore'] = 556;
  48838. t['quoteleft'] = 278;
  48839. t['a'] = 556;
  48840. t['b'] = 611;
  48841. t['c'] = 556;
  48842. t['d'] = 611;
  48843. t['e'] = 556;
  48844. t['f'] = 333;
  48845. t['g'] = 611;
  48846. t['h'] = 611;
  48847. t['i'] = 278;
  48848. t['j'] = 278;
  48849. t['k'] = 556;
  48850. t['l'] = 278;
  48851. t['m'] = 889;
  48852. t['n'] = 611;
  48853. t['o'] = 611;
  48854. t['p'] = 611;
  48855. t['q'] = 611;
  48856. t['r'] = 389;
  48857. t['s'] = 556;
  48858. t['t'] = 333;
  48859. t['u'] = 611;
  48860. t['v'] = 556;
  48861. t['w'] = 778;
  48862. t['x'] = 556;
  48863. t['y'] = 556;
  48864. t['z'] = 500;
  48865. t['braceleft'] = 389;
  48866. t['bar'] = 280;
  48867. t['braceright'] = 389;
  48868. t['asciitilde'] = 584;
  48869. t['exclamdown'] = 333;
  48870. t['cent'] = 556;
  48871. t['sterling'] = 556;
  48872. t['fraction'] = 167;
  48873. t['yen'] = 556;
  48874. t['florin'] = 556;
  48875. t['section'] = 556;
  48876. t['currency'] = 556;
  48877. t['quotesingle'] = 238;
  48878. t['quotedblleft'] = 500;
  48879. t['guillemotleft'] = 556;
  48880. t['guilsinglleft'] = 333;
  48881. t['guilsinglright'] = 333;
  48882. t['fi'] = 611;
  48883. t['fl'] = 611;
  48884. t['endash'] = 556;
  48885. t['dagger'] = 556;
  48886. t['daggerdbl'] = 556;
  48887. t['periodcentered'] = 278;
  48888. t['paragraph'] = 556;
  48889. t['bullet'] = 350;
  48890. t['quotesinglbase'] = 278;
  48891. t['quotedblbase'] = 500;
  48892. t['quotedblright'] = 500;
  48893. t['guillemotright'] = 556;
  48894. t['ellipsis'] = 1000;
  48895. t['perthousand'] = 1000;
  48896. t['questiondown'] = 611;
  48897. t['grave'] = 333;
  48898. t['acute'] = 333;
  48899. t['circumflex'] = 333;
  48900. t['tilde'] = 333;
  48901. t['macron'] = 333;
  48902. t['breve'] = 333;
  48903. t['dotaccent'] = 333;
  48904. t['dieresis'] = 333;
  48905. t['ring'] = 333;
  48906. t['cedilla'] = 333;
  48907. t['hungarumlaut'] = 333;
  48908. t['ogonek'] = 333;
  48909. t['caron'] = 333;
  48910. t['emdash'] = 1000;
  48911. t['AE'] = 1000;
  48912. t['ordfeminine'] = 370;
  48913. t['Lslash'] = 611;
  48914. t['Oslash'] = 778;
  48915. t['OE'] = 1000;
  48916. t['ordmasculine'] = 365;
  48917. t['ae'] = 889;
  48918. t['dotlessi'] = 278;
  48919. t['lslash'] = 278;
  48920. t['oslash'] = 611;
  48921. t['oe'] = 944;
  48922. t['germandbls'] = 611;
  48923. t['Idieresis'] = 278;
  48924. t['eacute'] = 556;
  48925. t['abreve'] = 556;
  48926. t['uhungarumlaut'] = 611;
  48927. t['ecaron'] = 556;
  48928. t['Ydieresis'] = 667;
  48929. t['divide'] = 584;
  48930. t['Yacute'] = 667;
  48931. t['Acircumflex'] = 722;
  48932. t['aacute'] = 556;
  48933. t['Ucircumflex'] = 722;
  48934. t['yacute'] = 556;
  48935. t['scommaaccent'] = 556;
  48936. t['ecircumflex'] = 556;
  48937. t['Uring'] = 722;
  48938. t['Udieresis'] = 722;
  48939. t['aogonek'] = 556;
  48940. t['Uacute'] = 722;
  48941. t['uogonek'] = 611;
  48942. t['Edieresis'] = 667;
  48943. t['Dcroat'] = 722;
  48944. t['commaaccent'] = 250;
  48945. t['copyright'] = 737;
  48946. t['Emacron'] = 667;
  48947. t['ccaron'] = 556;
  48948. t['aring'] = 556;
  48949. t['Ncommaaccent'] = 722;
  48950. t['lacute'] = 278;
  48951. t['agrave'] = 556;
  48952. t['Tcommaaccent'] = 611;
  48953. t['Cacute'] = 722;
  48954. t['atilde'] = 556;
  48955. t['Edotaccent'] = 667;
  48956. t['scaron'] = 556;
  48957. t['scedilla'] = 556;
  48958. t['iacute'] = 278;
  48959. t['lozenge'] = 494;
  48960. t['Rcaron'] = 722;
  48961. t['Gcommaaccent'] = 778;
  48962. t['ucircumflex'] = 611;
  48963. t['acircumflex'] = 556;
  48964. t['Amacron'] = 722;
  48965. t['rcaron'] = 389;
  48966. t['ccedilla'] = 556;
  48967. t['Zdotaccent'] = 611;
  48968. t['Thorn'] = 667;
  48969. t['Omacron'] = 778;
  48970. t['Racute'] = 722;
  48971. t['Sacute'] = 667;
  48972. t['dcaron'] = 743;
  48973. t['Umacron'] = 722;
  48974. t['uring'] = 611;
  48975. t['threesuperior'] = 333;
  48976. t['Ograve'] = 778;
  48977. t['Agrave'] = 722;
  48978. t['Abreve'] = 722;
  48979. t['multiply'] = 584;
  48980. t['uacute'] = 611;
  48981. t['Tcaron'] = 611;
  48982. t['partialdiff'] = 494;
  48983. t['ydieresis'] = 556;
  48984. t['Nacute'] = 722;
  48985. t['icircumflex'] = 278;
  48986. t['Ecircumflex'] = 667;
  48987. t['adieresis'] = 556;
  48988. t['edieresis'] = 556;
  48989. t['cacute'] = 556;
  48990. t['nacute'] = 611;
  48991. t['umacron'] = 611;
  48992. t['Ncaron'] = 722;
  48993. t['Iacute'] = 278;
  48994. t['plusminus'] = 584;
  48995. t['brokenbar'] = 280;
  48996. t['registered'] = 737;
  48997. t['Gbreve'] = 778;
  48998. t['Idotaccent'] = 278;
  48999. t['summation'] = 600;
  49000. t['Egrave'] = 667;
  49001. t['racute'] = 389;
  49002. t['omacron'] = 611;
  49003. t['Zacute'] = 611;
  49004. t['Zcaron'] = 611;
  49005. t['greaterequal'] = 549;
  49006. t['Eth'] = 722;
  49007. t['Ccedilla'] = 722;
  49008. t['lcommaaccent'] = 278;
  49009. t['tcaron'] = 389;
  49010. t['eogonek'] = 556;
  49011. t['Uogonek'] = 722;
  49012. t['Aacute'] = 722;
  49013. t['Adieresis'] = 722;
  49014. t['egrave'] = 556;
  49015. t['zacute'] = 500;
  49016. t['iogonek'] = 278;
  49017. t['Oacute'] = 778;
  49018. t['oacute'] = 611;
  49019. t['amacron'] = 556;
  49020. t['sacute'] = 556;
  49021. t['idieresis'] = 278;
  49022. t['Ocircumflex'] = 778;
  49023. t['Ugrave'] = 722;
  49024. t['Delta'] = 612;
  49025. t['thorn'] = 611;
  49026. t['twosuperior'] = 333;
  49027. t['Odieresis'] = 778;
  49028. t['mu'] = 611;
  49029. t['igrave'] = 278;
  49030. t['ohungarumlaut'] = 611;
  49031. t['Eogonek'] = 667;
  49032. t['dcroat'] = 611;
  49033. t['threequarters'] = 834;
  49034. t['Scedilla'] = 667;
  49035. t['lcaron'] = 400;
  49036. t['Kcommaaccent'] = 722;
  49037. t['Lacute'] = 611;
  49038. t['trademark'] = 1000;
  49039. t['edotaccent'] = 556;
  49040. t['Igrave'] = 278;
  49041. t['Imacron'] = 278;
  49042. t['Lcaron'] = 611;
  49043. t['onehalf'] = 834;
  49044. t['lessequal'] = 549;
  49045. t['ocircumflex'] = 611;
  49046. t['ntilde'] = 611;
  49047. t['Uhungarumlaut'] = 722;
  49048. t['Eacute'] = 667;
  49049. t['emacron'] = 556;
  49050. t['gbreve'] = 611;
  49051. t['onequarter'] = 834;
  49052. t['Scaron'] = 667;
  49053. t['Scommaaccent'] = 667;
  49054. t['Ohungarumlaut'] = 778;
  49055. t['degree'] = 400;
  49056. t['ograve'] = 611;
  49057. t['Ccaron'] = 722;
  49058. t['ugrave'] = 611;
  49059. t['radical'] = 549;
  49060. t['Dcaron'] = 722;
  49061. t['rcommaaccent'] = 389;
  49062. t['Ntilde'] = 722;
  49063. t['otilde'] = 611;
  49064. t['Rcommaaccent'] = 722;
  49065. t['Lcommaaccent'] = 611;
  49066. t['Atilde'] = 722;
  49067. t['Aogonek'] = 722;
  49068. t['Aring'] = 722;
  49069. t['Otilde'] = 778;
  49070. t['zdotaccent'] = 500;
  49071. t['Ecaron'] = 667;
  49072. t['Iogonek'] = 278;
  49073. t['kcommaaccent'] = 556;
  49074. t['minus'] = 584;
  49075. t['Icircumflex'] = 278;
  49076. t['ncaron'] = 611;
  49077. t['tcommaaccent'] = 333;
  49078. t['logicalnot'] = 584;
  49079. t['odieresis'] = 611;
  49080. t['udieresis'] = 611;
  49081. t['notequal'] = 549;
  49082. t['gcommaaccent'] = 611;
  49083. t['eth'] = 611;
  49084. t['zcaron'] = 500;
  49085. t['ncommaaccent'] = 611;
  49086. t['onesuperior'] = 333;
  49087. t['imacron'] = 278;
  49088. t['Euro'] = 556;
  49089. });
  49090. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49091. t['space'] = 278;
  49092. t['exclam'] = 333;
  49093. t['quotedbl'] = 474;
  49094. t['numbersign'] = 556;
  49095. t['dollar'] = 556;
  49096. t['percent'] = 889;
  49097. t['ampersand'] = 722;
  49098. t['quoteright'] = 278;
  49099. t['parenleft'] = 333;
  49100. t['parenright'] = 333;
  49101. t['asterisk'] = 389;
  49102. t['plus'] = 584;
  49103. t['comma'] = 278;
  49104. t['hyphen'] = 333;
  49105. t['period'] = 278;
  49106. t['slash'] = 278;
  49107. t['zero'] = 556;
  49108. t['one'] = 556;
  49109. t['two'] = 556;
  49110. t['three'] = 556;
  49111. t['four'] = 556;
  49112. t['five'] = 556;
  49113. t['six'] = 556;
  49114. t['seven'] = 556;
  49115. t['eight'] = 556;
  49116. t['nine'] = 556;
  49117. t['colon'] = 333;
  49118. t['semicolon'] = 333;
  49119. t['less'] = 584;
  49120. t['equal'] = 584;
  49121. t['greater'] = 584;
  49122. t['question'] = 611;
  49123. t['at'] = 975;
  49124. t['A'] = 722;
  49125. t['B'] = 722;
  49126. t['C'] = 722;
  49127. t['D'] = 722;
  49128. t['E'] = 667;
  49129. t['F'] = 611;
  49130. t['G'] = 778;
  49131. t['H'] = 722;
  49132. t['I'] = 278;
  49133. t['J'] = 556;
  49134. t['K'] = 722;
  49135. t['L'] = 611;
  49136. t['M'] = 833;
  49137. t['N'] = 722;
  49138. t['O'] = 778;
  49139. t['P'] = 667;
  49140. t['Q'] = 778;
  49141. t['R'] = 722;
  49142. t['S'] = 667;
  49143. t['T'] = 611;
  49144. t['U'] = 722;
  49145. t['V'] = 667;
  49146. t['W'] = 944;
  49147. t['X'] = 667;
  49148. t['Y'] = 667;
  49149. t['Z'] = 611;
  49150. t['bracketleft'] = 333;
  49151. t['backslash'] = 278;
  49152. t['bracketright'] = 333;
  49153. t['asciicircum'] = 584;
  49154. t['underscore'] = 556;
  49155. t['quoteleft'] = 278;
  49156. t['a'] = 556;
  49157. t['b'] = 611;
  49158. t['c'] = 556;
  49159. t['d'] = 611;
  49160. t['e'] = 556;
  49161. t['f'] = 333;
  49162. t['g'] = 611;
  49163. t['h'] = 611;
  49164. t['i'] = 278;
  49165. t['j'] = 278;
  49166. t['k'] = 556;
  49167. t['l'] = 278;
  49168. t['m'] = 889;
  49169. t['n'] = 611;
  49170. t['o'] = 611;
  49171. t['p'] = 611;
  49172. t['q'] = 611;
  49173. t['r'] = 389;
  49174. t['s'] = 556;
  49175. t['t'] = 333;
  49176. t['u'] = 611;
  49177. t['v'] = 556;
  49178. t['w'] = 778;
  49179. t['x'] = 556;
  49180. t['y'] = 556;
  49181. t['z'] = 500;
  49182. t['braceleft'] = 389;
  49183. t['bar'] = 280;
  49184. t['braceright'] = 389;
  49185. t['asciitilde'] = 584;
  49186. t['exclamdown'] = 333;
  49187. t['cent'] = 556;
  49188. t['sterling'] = 556;
  49189. t['fraction'] = 167;
  49190. t['yen'] = 556;
  49191. t['florin'] = 556;
  49192. t['section'] = 556;
  49193. t['currency'] = 556;
  49194. t['quotesingle'] = 238;
  49195. t['quotedblleft'] = 500;
  49196. t['guillemotleft'] = 556;
  49197. t['guilsinglleft'] = 333;
  49198. t['guilsinglright'] = 333;
  49199. t['fi'] = 611;
  49200. t['fl'] = 611;
  49201. t['endash'] = 556;
  49202. t['dagger'] = 556;
  49203. t['daggerdbl'] = 556;
  49204. t['periodcentered'] = 278;
  49205. t['paragraph'] = 556;
  49206. t['bullet'] = 350;
  49207. t['quotesinglbase'] = 278;
  49208. t['quotedblbase'] = 500;
  49209. t['quotedblright'] = 500;
  49210. t['guillemotright'] = 556;
  49211. t['ellipsis'] = 1000;
  49212. t['perthousand'] = 1000;
  49213. t['questiondown'] = 611;
  49214. t['grave'] = 333;
  49215. t['acute'] = 333;
  49216. t['circumflex'] = 333;
  49217. t['tilde'] = 333;
  49218. t['macron'] = 333;
  49219. t['breve'] = 333;
  49220. t['dotaccent'] = 333;
  49221. t['dieresis'] = 333;
  49222. t['ring'] = 333;
  49223. t['cedilla'] = 333;
  49224. t['hungarumlaut'] = 333;
  49225. t['ogonek'] = 333;
  49226. t['caron'] = 333;
  49227. t['emdash'] = 1000;
  49228. t['AE'] = 1000;
  49229. t['ordfeminine'] = 370;
  49230. t['Lslash'] = 611;
  49231. t['Oslash'] = 778;
  49232. t['OE'] = 1000;
  49233. t['ordmasculine'] = 365;
  49234. t['ae'] = 889;
  49235. t['dotlessi'] = 278;
  49236. t['lslash'] = 278;
  49237. t['oslash'] = 611;
  49238. t['oe'] = 944;
  49239. t['germandbls'] = 611;
  49240. t['Idieresis'] = 278;
  49241. t['eacute'] = 556;
  49242. t['abreve'] = 556;
  49243. t['uhungarumlaut'] = 611;
  49244. t['ecaron'] = 556;
  49245. t['Ydieresis'] = 667;
  49246. t['divide'] = 584;
  49247. t['Yacute'] = 667;
  49248. t['Acircumflex'] = 722;
  49249. t['aacute'] = 556;
  49250. t['Ucircumflex'] = 722;
  49251. t['yacute'] = 556;
  49252. t['scommaaccent'] = 556;
  49253. t['ecircumflex'] = 556;
  49254. t['Uring'] = 722;
  49255. t['Udieresis'] = 722;
  49256. t['aogonek'] = 556;
  49257. t['Uacute'] = 722;
  49258. t['uogonek'] = 611;
  49259. t['Edieresis'] = 667;
  49260. t['Dcroat'] = 722;
  49261. t['commaaccent'] = 250;
  49262. t['copyright'] = 737;
  49263. t['Emacron'] = 667;
  49264. t['ccaron'] = 556;
  49265. t['aring'] = 556;
  49266. t['Ncommaaccent'] = 722;
  49267. t['lacute'] = 278;
  49268. t['agrave'] = 556;
  49269. t['Tcommaaccent'] = 611;
  49270. t['Cacute'] = 722;
  49271. t['atilde'] = 556;
  49272. t['Edotaccent'] = 667;
  49273. t['scaron'] = 556;
  49274. t['scedilla'] = 556;
  49275. t['iacute'] = 278;
  49276. t['lozenge'] = 494;
  49277. t['Rcaron'] = 722;
  49278. t['Gcommaaccent'] = 778;
  49279. t['ucircumflex'] = 611;
  49280. t['acircumflex'] = 556;
  49281. t['Amacron'] = 722;
  49282. t['rcaron'] = 389;
  49283. t['ccedilla'] = 556;
  49284. t['Zdotaccent'] = 611;
  49285. t['Thorn'] = 667;
  49286. t['Omacron'] = 778;
  49287. t['Racute'] = 722;
  49288. t['Sacute'] = 667;
  49289. t['dcaron'] = 743;
  49290. t['Umacron'] = 722;
  49291. t['uring'] = 611;
  49292. t['threesuperior'] = 333;
  49293. t['Ograve'] = 778;
  49294. t['Agrave'] = 722;
  49295. t['Abreve'] = 722;
  49296. t['multiply'] = 584;
  49297. t['uacute'] = 611;
  49298. t['Tcaron'] = 611;
  49299. t['partialdiff'] = 494;
  49300. t['ydieresis'] = 556;
  49301. t['Nacute'] = 722;
  49302. t['icircumflex'] = 278;
  49303. t['Ecircumflex'] = 667;
  49304. t['adieresis'] = 556;
  49305. t['edieresis'] = 556;
  49306. t['cacute'] = 556;
  49307. t['nacute'] = 611;
  49308. t['umacron'] = 611;
  49309. t['Ncaron'] = 722;
  49310. t['Iacute'] = 278;
  49311. t['plusminus'] = 584;
  49312. t['brokenbar'] = 280;
  49313. t['registered'] = 737;
  49314. t['Gbreve'] = 778;
  49315. t['Idotaccent'] = 278;
  49316. t['summation'] = 600;
  49317. t['Egrave'] = 667;
  49318. t['racute'] = 389;
  49319. t['omacron'] = 611;
  49320. t['Zacute'] = 611;
  49321. t['Zcaron'] = 611;
  49322. t['greaterequal'] = 549;
  49323. t['Eth'] = 722;
  49324. t['Ccedilla'] = 722;
  49325. t['lcommaaccent'] = 278;
  49326. t['tcaron'] = 389;
  49327. t['eogonek'] = 556;
  49328. t['Uogonek'] = 722;
  49329. t['Aacute'] = 722;
  49330. t['Adieresis'] = 722;
  49331. t['egrave'] = 556;
  49332. t['zacute'] = 500;
  49333. t['iogonek'] = 278;
  49334. t['Oacute'] = 778;
  49335. t['oacute'] = 611;
  49336. t['amacron'] = 556;
  49337. t['sacute'] = 556;
  49338. t['idieresis'] = 278;
  49339. t['Ocircumflex'] = 778;
  49340. t['Ugrave'] = 722;
  49341. t['Delta'] = 612;
  49342. t['thorn'] = 611;
  49343. t['twosuperior'] = 333;
  49344. t['Odieresis'] = 778;
  49345. t['mu'] = 611;
  49346. t['igrave'] = 278;
  49347. t['ohungarumlaut'] = 611;
  49348. t['Eogonek'] = 667;
  49349. t['dcroat'] = 611;
  49350. t['threequarters'] = 834;
  49351. t['Scedilla'] = 667;
  49352. t['lcaron'] = 400;
  49353. t['Kcommaaccent'] = 722;
  49354. t['Lacute'] = 611;
  49355. t['trademark'] = 1000;
  49356. t['edotaccent'] = 556;
  49357. t['Igrave'] = 278;
  49358. t['Imacron'] = 278;
  49359. t['Lcaron'] = 611;
  49360. t['onehalf'] = 834;
  49361. t['lessequal'] = 549;
  49362. t['ocircumflex'] = 611;
  49363. t['ntilde'] = 611;
  49364. t['Uhungarumlaut'] = 722;
  49365. t['Eacute'] = 667;
  49366. t['emacron'] = 556;
  49367. t['gbreve'] = 611;
  49368. t['onequarter'] = 834;
  49369. t['Scaron'] = 667;
  49370. t['Scommaaccent'] = 667;
  49371. t['Ohungarumlaut'] = 778;
  49372. t['degree'] = 400;
  49373. t['ograve'] = 611;
  49374. t['Ccaron'] = 722;
  49375. t['ugrave'] = 611;
  49376. t['radical'] = 549;
  49377. t['Dcaron'] = 722;
  49378. t['rcommaaccent'] = 389;
  49379. t['Ntilde'] = 722;
  49380. t['otilde'] = 611;
  49381. t['Rcommaaccent'] = 722;
  49382. t['Lcommaaccent'] = 611;
  49383. t['Atilde'] = 722;
  49384. t['Aogonek'] = 722;
  49385. t['Aring'] = 722;
  49386. t['Otilde'] = 778;
  49387. t['zdotaccent'] = 500;
  49388. t['Ecaron'] = 667;
  49389. t['Iogonek'] = 278;
  49390. t['kcommaaccent'] = 556;
  49391. t['minus'] = 584;
  49392. t['Icircumflex'] = 278;
  49393. t['ncaron'] = 611;
  49394. t['tcommaaccent'] = 333;
  49395. t['logicalnot'] = 584;
  49396. t['odieresis'] = 611;
  49397. t['udieresis'] = 611;
  49398. t['notequal'] = 549;
  49399. t['gcommaaccent'] = 611;
  49400. t['eth'] = 611;
  49401. t['zcaron'] = 500;
  49402. t['ncommaaccent'] = 611;
  49403. t['onesuperior'] = 333;
  49404. t['imacron'] = 278;
  49405. t['Euro'] = 556;
  49406. });
  49407. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49408. t['space'] = 278;
  49409. t['exclam'] = 278;
  49410. t['quotedbl'] = 355;
  49411. t['numbersign'] = 556;
  49412. t['dollar'] = 556;
  49413. t['percent'] = 889;
  49414. t['ampersand'] = 667;
  49415. t['quoteright'] = 222;
  49416. t['parenleft'] = 333;
  49417. t['parenright'] = 333;
  49418. t['asterisk'] = 389;
  49419. t['plus'] = 584;
  49420. t['comma'] = 278;
  49421. t['hyphen'] = 333;
  49422. t['period'] = 278;
  49423. t['slash'] = 278;
  49424. t['zero'] = 556;
  49425. t['one'] = 556;
  49426. t['two'] = 556;
  49427. t['three'] = 556;
  49428. t['four'] = 556;
  49429. t['five'] = 556;
  49430. t['six'] = 556;
  49431. t['seven'] = 556;
  49432. t['eight'] = 556;
  49433. t['nine'] = 556;
  49434. t['colon'] = 278;
  49435. t['semicolon'] = 278;
  49436. t['less'] = 584;
  49437. t['equal'] = 584;
  49438. t['greater'] = 584;
  49439. t['question'] = 556;
  49440. t['at'] = 1015;
  49441. t['A'] = 667;
  49442. t['B'] = 667;
  49443. t['C'] = 722;
  49444. t['D'] = 722;
  49445. t['E'] = 667;
  49446. t['F'] = 611;
  49447. t['G'] = 778;
  49448. t['H'] = 722;
  49449. t['I'] = 278;
  49450. t['J'] = 500;
  49451. t['K'] = 667;
  49452. t['L'] = 556;
  49453. t['M'] = 833;
  49454. t['N'] = 722;
  49455. t['O'] = 778;
  49456. t['P'] = 667;
  49457. t['Q'] = 778;
  49458. t['R'] = 722;
  49459. t['S'] = 667;
  49460. t['T'] = 611;
  49461. t['U'] = 722;
  49462. t['V'] = 667;
  49463. t['W'] = 944;
  49464. t['X'] = 667;
  49465. t['Y'] = 667;
  49466. t['Z'] = 611;
  49467. t['bracketleft'] = 278;
  49468. t['backslash'] = 278;
  49469. t['bracketright'] = 278;
  49470. t['asciicircum'] = 469;
  49471. t['underscore'] = 556;
  49472. t['quoteleft'] = 222;
  49473. t['a'] = 556;
  49474. t['b'] = 556;
  49475. t['c'] = 500;
  49476. t['d'] = 556;
  49477. t['e'] = 556;
  49478. t['f'] = 278;
  49479. t['g'] = 556;
  49480. t['h'] = 556;
  49481. t['i'] = 222;
  49482. t['j'] = 222;
  49483. t['k'] = 500;
  49484. t['l'] = 222;
  49485. t['m'] = 833;
  49486. t['n'] = 556;
  49487. t['o'] = 556;
  49488. t['p'] = 556;
  49489. t['q'] = 556;
  49490. t['r'] = 333;
  49491. t['s'] = 500;
  49492. t['t'] = 278;
  49493. t['u'] = 556;
  49494. t['v'] = 500;
  49495. t['w'] = 722;
  49496. t['x'] = 500;
  49497. t['y'] = 500;
  49498. t['z'] = 500;
  49499. t['braceleft'] = 334;
  49500. t['bar'] = 260;
  49501. t['braceright'] = 334;
  49502. t['asciitilde'] = 584;
  49503. t['exclamdown'] = 333;
  49504. t['cent'] = 556;
  49505. t['sterling'] = 556;
  49506. t['fraction'] = 167;
  49507. t['yen'] = 556;
  49508. t['florin'] = 556;
  49509. t['section'] = 556;
  49510. t['currency'] = 556;
  49511. t['quotesingle'] = 191;
  49512. t['quotedblleft'] = 333;
  49513. t['guillemotleft'] = 556;
  49514. t['guilsinglleft'] = 333;
  49515. t['guilsinglright'] = 333;
  49516. t['fi'] = 500;
  49517. t['fl'] = 500;
  49518. t['endash'] = 556;
  49519. t['dagger'] = 556;
  49520. t['daggerdbl'] = 556;
  49521. t['periodcentered'] = 278;
  49522. t['paragraph'] = 537;
  49523. t['bullet'] = 350;
  49524. t['quotesinglbase'] = 222;
  49525. t['quotedblbase'] = 333;
  49526. t['quotedblright'] = 333;
  49527. t['guillemotright'] = 556;
  49528. t['ellipsis'] = 1000;
  49529. t['perthousand'] = 1000;
  49530. t['questiondown'] = 611;
  49531. t['grave'] = 333;
  49532. t['acute'] = 333;
  49533. t['circumflex'] = 333;
  49534. t['tilde'] = 333;
  49535. t['macron'] = 333;
  49536. t['breve'] = 333;
  49537. t['dotaccent'] = 333;
  49538. t['dieresis'] = 333;
  49539. t['ring'] = 333;
  49540. t['cedilla'] = 333;
  49541. t['hungarumlaut'] = 333;
  49542. t['ogonek'] = 333;
  49543. t['caron'] = 333;
  49544. t['emdash'] = 1000;
  49545. t['AE'] = 1000;
  49546. t['ordfeminine'] = 370;
  49547. t['Lslash'] = 556;
  49548. t['Oslash'] = 778;
  49549. t['OE'] = 1000;
  49550. t['ordmasculine'] = 365;
  49551. t['ae'] = 889;
  49552. t['dotlessi'] = 278;
  49553. t['lslash'] = 222;
  49554. t['oslash'] = 611;
  49555. t['oe'] = 944;
  49556. t['germandbls'] = 611;
  49557. t['Idieresis'] = 278;
  49558. t['eacute'] = 556;
  49559. t['abreve'] = 556;
  49560. t['uhungarumlaut'] = 556;
  49561. t['ecaron'] = 556;
  49562. t['Ydieresis'] = 667;
  49563. t['divide'] = 584;
  49564. t['Yacute'] = 667;
  49565. t['Acircumflex'] = 667;
  49566. t['aacute'] = 556;
  49567. t['Ucircumflex'] = 722;
  49568. t['yacute'] = 500;
  49569. t['scommaaccent'] = 500;
  49570. t['ecircumflex'] = 556;
  49571. t['Uring'] = 722;
  49572. t['Udieresis'] = 722;
  49573. t['aogonek'] = 556;
  49574. t['Uacute'] = 722;
  49575. t['uogonek'] = 556;
  49576. t['Edieresis'] = 667;
  49577. t['Dcroat'] = 722;
  49578. t['commaaccent'] = 250;
  49579. t['copyright'] = 737;
  49580. t['Emacron'] = 667;
  49581. t['ccaron'] = 500;
  49582. t['aring'] = 556;
  49583. t['Ncommaaccent'] = 722;
  49584. t['lacute'] = 222;
  49585. t['agrave'] = 556;
  49586. t['Tcommaaccent'] = 611;
  49587. t['Cacute'] = 722;
  49588. t['atilde'] = 556;
  49589. t['Edotaccent'] = 667;
  49590. t['scaron'] = 500;
  49591. t['scedilla'] = 500;
  49592. t['iacute'] = 278;
  49593. t['lozenge'] = 471;
  49594. t['Rcaron'] = 722;
  49595. t['Gcommaaccent'] = 778;
  49596. t['ucircumflex'] = 556;
  49597. t['acircumflex'] = 556;
  49598. t['Amacron'] = 667;
  49599. t['rcaron'] = 333;
  49600. t['ccedilla'] = 500;
  49601. t['Zdotaccent'] = 611;
  49602. t['Thorn'] = 667;
  49603. t['Omacron'] = 778;
  49604. t['Racute'] = 722;
  49605. t['Sacute'] = 667;
  49606. t['dcaron'] = 643;
  49607. t['Umacron'] = 722;
  49608. t['uring'] = 556;
  49609. t['threesuperior'] = 333;
  49610. t['Ograve'] = 778;
  49611. t['Agrave'] = 667;
  49612. t['Abreve'] = 667;
  49613. t['multiply'] = 584;
  49614. t['uacute'] = 556;
  49615. t['Tcaron'] = 611;
  49616. t['partialdiff'] = 476;
  49617. t['ydieresis'] = 500;
  49618. t['Nacute'] = 722;
  49619. t['icircumflex'] = 278;
  49620. t['Ecircumflex'] = 667;
  49621. t['adieresis'] = 556;
  49622. t['edieresis'] = 556;
  49623. t['cacute'] = 500;
  49624. t['nacute'] = 556;
  49625. t['umacron'] = 556;
  49626. t['Ncaron'] = 722;
  49627. t['Iacute'] = 278;
  49628. t['plusminus'] = 584;
  49629. t['brokenbar'] = 260;
  49630. t['registered'] = 737;
  49631. t['Gbreve'] = 778;
  49632. t['Idotaccent'] = 278;
  49633. t['summation'] = 600;
  49634. t['Egrave'] = 667;
  49635. t['racute'] = 333;
  49636. t['omacron'] = 556;
  49637. t['Zacute'] = 611;
  49638. t['Zcaron'] = 611;
  49639. t['greaterequal'] = 549;
  49640. t['Eth'] = 722;
  49641. t['Ccedilla'] = 722;
  49642. t['lcommaaccent'] = 222;
  49643. t['tcaron'] = 317;
  49644. t['eogonek'] = 556;
  49645. t['Uogonek'] = 722;
  49646. t['Aacute'] = 667;
  49647. t['Adieresis'] = 667;
  49648. t['egrave'] = 556;
  49649. t['zacute'] = 500;
  49650. t['iogonek'] = 222;
  49651. t['Oacute'] = 778;
  49652. t['oacute'] = 556;
  49653. t['amacron'] = 556;
  49654. t['sacute'] = 500;
  49655. t['idieresis'] = 278;
  49656. t['Ocircumflex'] = 778;
  49657. t['Ugrave'] = 722;
  49658. t['Delta'] = 612;
  49659. t['thorn'] = 556;
  49660. t['twosuperior'] = 333;
  49661. t['Odieresis'] = 778;
  49662. t['mu'] = 556;
  49663. t['igrave'] = 278;
  49664. t['ohungarumlaut'] = 556;
  49665. t['Eogonek'] = 667;
  49666. t['dcroat'] = 556;
  49667. t['threequarters'] = 834;
  49668. t['Scedilla'] = 667;
  49669. t['lcaron'] = 299;
  49670. t['Kcommaaccent'] = 667;
  49671. t['Lacute'] = 556;
  49672. t['trademark'] = 1000;
  49673. t['edotaccent'] = 556;
  49674. t['Igrave'] = 278;
  49675. t['Imacron'] = 278;
  49676. t['Lcaron'] = 556;
  49677. t['onehalf'] = 834;
  49678. t['lessequal'] = 549;
  49679. t['ocircumflex'] = 556;
  49680. t['ntilde'] = 556;
  49681. t['Uhungarumlaut'] = 722;
  49682. t['Eacute'] = 667;
  49683. t['emacron'] = 556;
  49684. t['gbreve'] = 556;
  49685. t['onequarter'] = 834;
  49686. t['Scaron'] = 667;
  49687. t['Scommaaccent'] = 667;
  49688. t['Ohungarumlaut'] = 778;
  49689. t['degree'] = 400;
  49690. t['ograve'] = 556;
  49691. t['Ccaron'] = 722;
  49692. t['ugrave'] = 556;
  49693. t['radical'] = 453;
  49694. t['Dcaron'] = 722;
  49695. t['rcommaaccent'] = 333;
  49696. t['Ntilde'] = 722;
  49697. t['otilde'] = 556;
  49698. t['Rcommaaccent'] = 722;
  49699. t['Lcommaaccent'] = 556;
  49700. t['Atilde'] = 667;
  49701. t['Aogonek'] = 667;
  49702. t['Aring'] = 667;
  49703. t['Otilde'] = 778;
  49704. t['zdotaccent'] = 500;
  49705. t['Ecaron'] = 667;
  49706. t['Iogonek'] = 278;
  49707. t['kcommaaccent'] = 500;
  49708. t['minus'] = 584;
  49709. t['Icircumflex'] = 278;
  49710. t['ncaron'] = 556;
  49711. t['tcommaaccent'] = 278;
  49712. t['logicalnot'] = 584;
  49713. t['odieresis'] = 556;
  49714. t['udieresis'] = 556;
  49715. t['notequal'] = 549;
  49716. t['gcommaaccent'] = 556;
  49717. t['eth'] = 556;
  49718. t['zcaron'] = 500;
  49719. t['ncommaaccent'] = 556;
  49720. t['onesuperior'] = 333;
  49721. t['imacron'] = 278;
  49722. t['Euro'] = 556;
  49723. });
  49724. t['Symbol'] = getLookupTableFactory(function (t) {
  49725. t['space'] = 250;
  49726. t['exclam'] = 333;
  49727. t['universal'] = 713;
  49728. t['numbersign'] = 500;
  49729. t['existential'] = 549;
  49730. t['percent'] = 833;
  49731. t['ampersand'] = 778;
  49732. t['suchthat'] = 439;
  49733. t['parenleft'] = 333;
  49734. t['parenright'] = 333;
  49735. t['asteriskmath'] = 500;
  49736. t['plus'] = 549;
  49737. t['comma'] = 250;
  49738. t['minus'] = 549;
  49739. t['period'] = 250;
  49740. t['slash'] = 278;
  49741. t['zero'] = 500;
  49742. t['one'] = 500;
  49743. t['two'] = 500;
  49744. t['three'] = 500;
  49745. t['four'] = 500;
  49746. t['five'] = 500;
  49747. t['six'] = 500;
  49748. t['seven'] = 500;
  49749. t['eight'] = 500;
  49750. t['nine'] = 500;
  49751. t['colon'] = 278;
  49752. t['semicolon'] = 278;
  49753. t['less'] = 549;
  49754. t['equal'] = 549;
  49755. t['greater'] = 549;
  49756. t['question'] = 444;
  49757. t['congruent'] = 549;
  49758. t['Alpha'] = 722;
  49759. t['Beta'] = 667;
  49760. t['Chi'] = 722;
  49761. t['Delta'] = 612;
  49762. t['Epsilon'] = 611;
  49763. t['Phi'] = 763;
  49764. t['Gamma'] = 603;
  49765. t['Eta'] = 722;
  49766. t['Iota'] = 333;
  49767. t['theta1'] = 631;
  49768. t['Kappa'] = 722;
  49769. t['Lambda'] = 686;
  49770. t['Mu'] = 889;
  49771. t['Nu'] = 722;
  49772. t['Omicron'] = 722;
  49773. t['Pi'] = 768;
  49774. t['Theta'] = 741;
  49775. t['Rho'] = 556;
  49776. t['Sigma'] = 592;
  49777. t['Tau'] = 611;
  49778. t['Upsilon'] = 690;
  49779. t['sigma1'] = 439;
  49780. t['Omega'] = 768;
  49781. t['Xi'] = 645;
  49782. t['Psi'] = 795;
  49783. t['Zeta'] = 611;
  49784. t['bracketleft'] = 333;
  49785. t['therefore'] = 863;
  49786. t['bracketright'] = 333;
  49787. t['perpendicular'] = 658;
  49788. t['underscore'] = 500;
  49789. t['radicalex'] = 500;
  49790. t['alpha'] = 631;
  49791. t['beta'] = 549;
  49792. t['chi'] = 549;
  49793. t['delta'] = 494;
  49794. t['epsilon'] = 439;
  49795. t['phi'] = 521;
  49796. t['gamma'] = 411;
  49797. t['eta'] = 603;
  49798. t['iota'] = 329;
  49799. t['phi1'] = 603;
  49800. t['kappa'] = 549;
  49801. t['lambda'] = 549;
  49802. t['mu'] = 576;
  49803. t['nu'] = 521;
  49804. t['omicron'] = 549;
  49805. t['pi'] = 549;
  49806. t['theta'] = 521;
  49807. t['rho'] = 549;
  49808. t['sigma'] = 603;
  49809. t['tau'] = 439;
  49810. t['upsilon'] = 576;
  49811. t['omega1'] = 713;
  49812. t['omega'] = 686;
  49813. t['xi'] = 493;
  49814. t['psi'] = 686;
  49815. t['zeta'] = 494;
  49816. t['braceleft'] = 480;
  49817. t['bar'] = 200;
  49818. t['braceright'] = 480;
  49819. t['similar'] = 549;
  49820. t['Euro'] = 750;
  49821. t['Upsilon1'] = 620;
  49822. t['minute'] = 247;
  49823. t['lessequal'] = 549;
  49824. t['fraction'] = 167;
  49825. t['infinity'] = 713;
  49826. t['florin'] = 500;
  49827. t['club'] = 753;
  49828. t['diamond'] = 753;
  49829. t['heart'] = 753;
  49830. t['spade'] = 753;
  49831. t['arrowboth'] = 1042;
  49832. t['arrowleft'] = 987;
  49833. t['arrowup'] = 603;
  49834. t['arrowright'] = 987;
  49835. t['arrowdown'] = 603;
  49836. t['degree'] = 400;
  49837. t['plusminus'] = 549;
  49838. t['second'] = 411;
  49839. t['greaterequal'] = 549;
  49840. t['multiply'] = 549;
  49841. t['proportional'] = 713;
  49842. t['partialdiff'] = 494;
  49843. t['bullet'] = 460;
  49844. t['divide'] = 549;
  49845. t['notequal'] = 549;
  49846. t['equivalence'] = 549;
  49847. t['approxequal'] = 549;
  49848. t['ellipsis'] = 1000;
  49849. t['arrowvertex'] = 603;
  49850. t['arrowhorizex'] = 1000;
  49851. t['carriagereturn'] = 658;
  49852. t['aleph'] = 823;
  49853. t['Ifraktur'] = 686;
  49854. t['Rfraktur'] = 795;
  49855. t['weierstrass'] = 987;
  49856. t['circlemultiply'] = 768;
  49857. t['circleplus'] = 768;
  49858. t['emptyset'] = 823;
  49859. t['intersection'] = 768;
  49860. t['union'] = 768;
  49861. t['propersuperset'] = 713;
  49862. t['reflexsuperset'] = 713;
  49863. t['notsubset'] = 713;
  49864. t['propersubset'] = 713;
  49865. t['reflexsubset'] = 713;
  49866. t['element'] = 713;
  49867. t['notelement'] = 713;
  49868. t['angle'] = 768;
  49869. t['gradient'] = 713;
  49870. t['registerserif'] = 790;
  49871. t['copyrightserif'] = 790;
  49872. t['trademarkserif'] = 890;
  49873. t['product'] = 823;
  49874. t['radical'] = 549;
  49875. t['dotmath'] = 250;
  49876. t['logicalnot'] = 713;
  49877. t['logicaland'] = 603;
  49878. t['logicalor'] = 603;
  49879. t['arrowdblboth'] = 1042;
  49880. t['arrowdblleft'] = 987;
  49881. t['arrowdblup'] = 603;
  49882. t['arrowdblright'] = 987;
  49883. t['arrowdbldown'] = 603;
  49884. t['lozenge'] = 494;
  49885. t['angleleft'] = 329;
  49886. t['registersans'] = 790;
  49887. t['copyrightsans'] = 790;
  49888. t['trademarksans'] = 786;
  49889. t['summation'] = 713;
  49890. t['parenlefttp'] = 384;
  49891. t['parenleftex'] = 384;
  49892. t['parenleftbt'] = 384;
  49893. t['bracketlefttp'] = 384;
  49894. t['bracketleftex'] = 384;
  49895. t['bracketleftbt'] = 384;
  49896. t['bracelefttp'] = 494;
  49897. t['braceleftmid'] = 494;
  49898. t['braceleftbt'] = 494;
  49899. t['braceex'] = 494;
  49900. t['angleright'] = 329;
  49901. t['integral'] = 274;
  49902. t['integraltp'] = 686;
  49903. t['integralex'] = 686;
  49904. t['integralbt'] = 686;
  49905. t['parenrighttp'] = 384;
  49906. t['parenrightex'] = 384;
  49907. t['parenrightbt'] = 384;
  49908. t['bracketrighttp'] = 384;
  49909. t['bracketrightex'] = 384;
  49910. t['bracketrightbt'] = 384;
  49911. t['bracerighttp'] = 494;
  49912. t['bracerightmid'] = 494;
  49913. t['bracerightbt'] = 494;
  49914. t['apple'] = 790;
  49915. });
  49916. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49917. t['space'] = 250;
  49918. t['exclam'] = 333;
  49919. t['quotedbl'] = 408;
  49920. t['numbersign'] = 500;
  49921. t['dollar'] = 500;
  49922. t['percent'] = 833;
  49923. t['ampersand'] = 778;
  49924. t['quoteright'] = 333;
  49925. t['parenleft'] = 333;
  49926. t['parenright'] = 333;
  49927. t['asterisk'] = 500;
  49928. t['plus'] = 564;
  49929. t['comma'] = 250;
  49930. t['hyphen'] = 333;
  49931. t['period'] = 250;
  49932. t['slash'] = 278;
  49933. t['zero'] = 500;
  49934. t['one'] = 500;
  49935. t['two'] = 500;
  49936. t['three'] = 500;
  49937. t['four'] = 500;
  49938. t['five'] = 500;
  49939. t['six'] = 500;
  49940. t['seven'] = 500;
  49941. t['eight'] = 500;
  49942. t['nine'] = 500;
  49943. t['colon'] = 278;
  49944. t['semicolon'] = 278;
  49945. t['less'] = 564;
  49946. t['equal'] = 564;
  49947. t['greater'] = 564;
  49948. t['question'] = 444;
  49949. t['at'] = 921;
  49950. t['A'] = 722;
  49951. t['B'] = 667;
  49952. t['C'] = 667;
  49953. t['D'] = 722;
  49954. t['E'] = 611;
  49955. t['F'] = 556;
  49956. t['G'] = 722;
  49957. t['H'] = 722;
  49958. t['I'] = 333;
  49959. t['J'] = 389;
  49960. t['K'] = 722;
  49961. t['L'] = 611;
  49962. t['M'] = 889;
  49963. t['N'] = 722;
  49964. t['O'] = 722;
  49965. t['P'] = 556;
  49966. t['Q'] = 722;
  49967. t['R'] = 667;
  49968. t['S'] = 556;
  49969. t['T'] = 611;
  49970. t['U'] = 722;
  49971. t['V'] = 722;
  49972. t['W'] = 944;
  49973. t['X'] = 722;
  49974. t['Y'] = 722;
  49975. t['Z'] = 611;
  49976. t['bracketleft'] = 333;
  49977. t['backslash'] = 278;
  49978. t['bracketright'] = 333;
  49979. t['asciicircum'] = 469;
  49980. t['underscore'] = 500;
  49981. t['quoteleft'] = 333;
  49982. t['a'] = 444;
  49983. t['b'] = 500;
  49984. t['c'] = 444;
  49985. t['d'] = 500;
  49986. t['e'] = 444;
  49987. t['f'] = 333;
  49988. t['g'] = 500;
  49989. t['h'] = 500;
  49990. t['i'] = 278;
  49991. t['j'] = 278;
  49992. t['k'] = 500;
  49993. t['l'] = 278;
  49994. t['m'] = 778;
  49995. t['n'] = 500;
  49996. t['o'] = 500;
  49997. t['p'] = 500;
  49998. t['q'] = 500;
  49999. t['r'] = 333;
  50000. t['s'] = 389;
  50001. t['t'] = 278;
  50002. t['u'] = 500;
  50003. t['v'] = 500;
  50004. t['w'] = 722;
  50005. t['x'] = 500;
  50006. t['y'] = 500;
  50007. t['z'] = 444;
  50008. t['braceleft'] = 480;
  50009. t['bar'] = 200;
  50010. t['braceright'] = 480;
  50011. t['asciitilde'] = 541;
  50012. t['exclamdown'] = 333;
  50013. t['cent'] = 500;
  50014. t['sterling'] = 500;
  50015. t['fraction'] = 167;
  50016. t['yen'] = 500;
  50017. t['florin'] = 500;
  50018. t['section'] = 500;
  50019. t['currency'] = 500;
  50020. t['quotesingle'] = 180;
  50021. t['quotedblleft'] = 444;
  50022. t['guillemotleft'] = 500;
  50023. t['guilsinglleft'] = 333;
  50024. t['guilsinglright'] = 333;
  50025. t['fi'] = 556;
  50026. t['fl'] = 556;
  50027. t['endash'] = 500;
  50028. t['dagger'] = 500;
  50029. t['daggerdbl'] = 500;
  50030. t['periodcentered'] = 250;
  50031. t['paragraph'] = 453;
  50032. t['bullet'] = 350;
  50033. t['quotesinglbase'] = 333;
  50034. t['quotedblbase'] = 444;
  50035. t['quotedblright'] = 444;
  50036. t['guillemotright'] = 500;
  50037. t['ellipsis'] = 1000;
  50038. t['perthousand'] = 1000;
  50039. t['questiondown'] = 444;
  50040. t['grave'] = 333;
  50041. t['acute'] = 333;
  50042. t['circumflex'] = 333;
  50043. t['tilde'] = 333;
  50044. t['macron'] = 333;
  50045. t['breve'] = 333;
  50046. t['dotaccent'] = 333;
  50047. t['dieresis'] = 333;
  50048. t['ring'] = 333;
  50049. t['cedilla'] = 333;
  50050. t['hungarumlaut'] = 333;
  50051. t['ogonek'] = 333;
  50052. t['caron'] = 333;
  50053. t['emdash'] = 1000;
  50054. t['AE'] = 889;
  50055. t['ordfeminine'] = 276;
  50056. t['Lslash'] = 611;
  50057. t['Oslash'] = 722;
  50058. t['OE'] = 889;
  50059. t['ordmasculine'] = 310;
  50060. t['ae'] = 667;
  50061. t['dotlessi'] = 278;
  50062. t['lslash'] = 278;
  50063. t['oslash'] = 500;
  50064. t['oe'] = 722;
  50065. t['germandbls'] = 500;
  50066. t['Idieresis'] = 333;
  50067. t['eacute'] = 444;
  50068. t['abreve'] = 444;
  50069. t['uhungarumlaut'] = 500;
  50070. t['ecaron'] = 444;
  50071. t['Ydieresis'] = 722;
  50072. t['divide'] = 564;
  50073. t['Yacute'] = 722;
  50074. t['Acircumflex'] = 722;
  50075. t['aacute'] = 444;
  50076. t['Ucircumflex'] = 722;
  50077. t['yacute'] = 500;
  50078. t['scommaaccent'] = 389;
  50079. t['ecircumflex'] = 444;
  50080. t['Uring'] = 722;
  50081. t['Udieresis'] = 722;
  50082. t['aogonek'] = 444;
  50083. t['Uacute'] = 722;
  50084. t['uogonek'] = 500;
  50085. t['Edieresis'] = 611;
  50086. t['Dcroat'] = 722;
  50087. t['commaaccent'] = 250;
  50088. t['copyright'] = 760;
  50089. t['Emacron'] = 611;
  50090. t['ccaron'] = 444;
  50091. t['aring'] = 444;
  50092. t['Ncommaaccent'] = 722;
  50093. t['lacute'] = 278;
  50094. t['agrave'] = 444;
  50095. t['Tcommaaccent'] = 611;
  50096. t['Cacute'] = 667;
  50097. t['atilde'] = 444;
  50098. t['Edotaccent'] = 611;
  50099. t['scaron'] = 389;
  50100. t['scedilla'] = 389;
  50101. t['iacute'] = 278;
  50102. t['lozenge'] = 471;
  50103. t['Rcaron'] = 667;
  50104. t['Gcommaaccent'] = 722;
  50105. t['ucircumflex'] = 500;
  50106. t['acircumflex'] = 444;
  50107. t['Amacron'] = 722;
  50108. t['rcaron'] = 333;
  50109. t['ccedilla'] = 444;
  50110. t['Zdotaccent'] = 611;
  50111. t['Thorn'] = 556;
  50112. t['Omacron'] = 722;
  50113. t['Racute'] = 667;
  50114. t['Sacute'] = 556;
  50115. t['dcaron'] = 588;
  50116. t['Umacron'] = 722;
  50117. t['uring'] = 500;
  50118. t['threesuperior'] = 300;
  50119. t['Ograve'] = 722;
  50120. t['Agrave'] = 722;
  50121. t['Abreve'] = 722;
  50122. t['multiply'] = 564;
  50123. t['uacute'] = 500;
  50124. t['Tcaron'] = 611;
  50125. t['partialdiff'] = 476;
  50126. t['ydieresis'] = 500;
  50127. t['Nacute'] = 722;
  50128. t['icircumflex'] = 278;
  50129. t['Ecircumflex'] = 611;
  50130. t['adieresis'] = 444;
  50131. t['edieresis'] = 444;
  50132. t['cacute'] = 444;
  50133. t['nacute'] = 500;
  50134. t['umacron'] = 500;
  50135. t['Ncaron'] = 722;
  50136. t['Iacute'] = 333;
  50137. t['plusminus'] = 564;
  50138. t['brokenbar'] = 200;
  50139. t['registered'] = 760;
  50140. t['Gbreve'] = 722;
  50141. t['Idotaccent'] = 333;
  50142. t['summation'] = 600;
  50143. t['Egrave'] = 611;
  50144. t['racute'] = 333;
  50145. t['omacron'] = 500;
  50146. t['Zacute'] = 611;
  50147. t['Zcaron'] = 611;
  50148. t['greaterequal'] = 549;
  50149. t['Eth'] = 722;
  50150. t['Ccedilla'] = 667;
  50151. t['lcommaaccent'] = 278;
  50152. t['tcaron'] = 326;
  50153. t['eogonek'] = 444;
  50154. t['Uogonek'] = 722;
  50155. t['Aacute'] = 722;
  50156. t['Adieresis'] = 722;
  50157. t['egrave'] = 444;
  50158. t['zacute'] = 444;
  50159. t['iogonek'] = 278;
  50160. t['Oacute'] = 722;
  50161. t['oacute'] = 500;
  50162. t['amacron'] = 444;
  50163. t['sacute'] = 389;
  50164. t['idieresis'] = 278;
  50165. t['Ocircumflex'] = 722;
  50166. t['Ugrave'] = 722;
  50167. t['Delta'] = 612;
  50168. t['thorn'] = 500;
  50169. t['twosuperior'] = 300;
  50170. t['Odieresis'] = 722;
  50171. t['mu'] = 500;
  50172. t['igrave'] = 278;
  50173. t['ohungarumlaut'] = 500;
  50174. t['Eogonek'] = 611;
  50175. t['dcroat'] = 500;
  50176. t['threequarters'] = 750;
  50177. t['Scedilla'] = 556;
  50178. t['lcaron'] = 344;
  50179. t['Kcommaaccent'] = 722;
  50180. t['Lacute'] = 611;
  50181. t['trademark'] = 980;
  50182. t['edotaccent'] = 444;
  50183. t['Igrave'] = 333;
  50184. t['Imacron'] = 333;
  50185. t['Lcaron'] = 611;
  50186. t['onehalf'] = 750;
  50187. t['lessequal'] = 549;
  50188. t['ocircumflex'] = 500;
  50189. t['ntilde'] = 500;
  50190. t['Uhungarumlaut'] = 722;
  50191. t['Eacute'] = 611;
  50192. t['emacron'] = 444;
  50193. t['gbreve'] = 500;
  50194. t['onequarter'] = 750;
  50195. t['Scaron'] = 556;
  50196. t['Scommaaccent'] = 556;
  50197. t['Ohungarumlaut'] = 722;
  50198. t['degree'] = 400;
  50199. t['ograve'] = 500;
  50200. t['Ccaron'] = 667;
  50201. t['ugrave'] = 500;
  50202. t['radical'] = 453;
  50203. t['Dcaron'] = 722;
  50204. t['rcommaaccent'] = 333;
  50205. t['Ntilde'] = 722;
  50206. t['otilde'] = 500;
  50207. t['Rcommaaccent'] = 667;
  50208. t['Lcommaaccent'] = 611;
  50209. t['Atilde'] = 722;
  50210. t['Aogonek'] = 722;
  50211. t['Aring'] = 722;
  50212. t['Otilde'] = 722;
  50213. t['zdotaccent'] = 444;
  50214. t['Ecaron'] = 611;
  50215. t['Iogonek'] = 333;
  50216. t['kcommaaccent'] = 500;
  50217. t['minus'] = 564;
  50218. t['Icircumflex'] = 333;
  50219. t['ncaron'] = 500;
  50220. t['tcommaaccent'] = 278;
  50221. t['logicalnot'] = 564;
  50222. t['odieresis'] = 500;
  50223. t['udieresis'] = 500;
  50224. t['notequal'] = 549;
  50225. t['gcommaaccent'] = 500;
  50226. t['eth'] = 500;
  50227. t['zcaron'] = 444;
  50228. t['ncommaaccent'] = 500;
  50229. t['onesuperior'] = 300;
  50230. t['imacron'] = 278;
  50231. t['Euro'] = 500;
  50232. });
  50233. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50234. t['space'] = 250;
  50235. t['exclam'] = 333;
  50236. t['quotedbl'] = 555;
  50237. t['numbersign'] = 500;
  50238. t['dollar'] = 500;
  50239. t['percent'] = 1000;
  50240. t['ampersand'] = 833;
  50241. t['quoteright'] = 333;
  50242. t['parenleft'] = 333;
  50243. t['parenright'] = 333;
  50244. t['asterisk'] = 500;
  50245. t['plus'] = 570;
  50246. t['comma'] = 250;
  50247. t['hyphen'] = 333;
  50248. t['period'] = 250;
  50249. t['slash'] = 278;
  50250. t['zero'] = 500;
  50251. t['one'] = 500;
  50252. t['two'] = 500;
  50253. t['three'] = 500;
  50254. t['four'] = 500;
  50255. t['five'] = 500;
  50256. t['six'] = 500;
  50257. t['seven'] = 500;
  50258. t['eight'] = 500;
  50259. t['nine'] = 500;
  50260. t['colon'] = 333;
  50261. t['semicolon'] = 333;
  50262. t['less'] = 570;
  50263. t['equal'] = 570;
  50264. t['greater'] = 570;
  50265. t['question'] = 500;
  50266. t['at'] = 930;
  50267. t['A'] = 722;
  50268. t['B'] = 667;
  50269. t['C'] = 722;
  50270. t['D'] = 722;
  50271. t['E'] = 667;
  50272. t['F'] = 611;
  50273. t['G'] = 778;
  50274. t['H'] = 778;
  50275. t['I'] = 389;
  50276. t['J'] = 500;
  50277. t['K'] = 778;
  50278. t['L'] = 667;
  50279. t['M'] = 944;
  50280. t['N'] = 722;
  50281. t['O'] = 778;
  50282. t['P'] = 611;
  50283. t['Q'] = 778;
  50284. t['R'] = 722;
  50285. t['S'] = 556;
  50286. t['T'] = 667;
  50287. t['U'] = 722;
  50288. t['V'] = 722;
  50289. t['W'] = 1000;
  50290. t['X'] = 722;
  50291. t['Y'] = 722;
  50292. t['Z'] = 667;
  50293. t['bracketleft'] = 333;
  50294. t['backslash'] = 278;
  50295. t['bracketright'] = 333;
  50296. t['asciicircum'] = 581;
  50297. t['underscore'] = 500;
  50298. t['quoteleft'] = 333;
  50299. t['a'] = 500;
  50300. t['b'] = 556;
  50301. t['c'] = 444;
  50302. t['d'] = 556;
  50303. t['e'] = 444;
  50304. t['f'] = 333;
  50305. t['g'] = 500;
  50306. t['h'] = 556;
  50307. t['i'] = 278;
  50308. t['j'] = 333;
  50309. t['k'] = 556;
  50310. t['l'] = 278;
  50311. t['m'] = 833;
  50312. t['n'] = 556;
  50313. t['o'] = 500;
  50314. t['p'] = 556;
  50315. t['q'] = 556;
  50316. t['r'] = 444;
  50317. t['s'] = 389;
  50318. t['t'] = 333;
  50319. t['u'] = 556;
  50320. t['v'] = 500;
  50321. t['w'] = 722;
  50322. t['x'] = 500;
  50323. t['y'] = 500;
  50324. t['z'] = 444;
  50325. t['braceleft'] = 394;
  50326. t['bar'] = 220;
  50327. t['braceright'] = 394;
  50328. t['asciitilde'] = 520;
  50329. t['exclamdown'] = 333;
  50330. t['cent'] = 500;
  50331. t['sterling'] = 500;
  50332. t['fraction'] = 167;
  50333. t['yen'] = 500;
  50334. t['florin'] = 500;
  50335. t['section'] = 500;
  50336. t['currency'] = 500;
  50337. t['quotesingle'] = 278;
  50338. t['quotedblleft'] = 500;
  50339. t['guillemotleft'] = 500;
  50340. t['guilsinglleft'] = 333;
  50341. t['guilsinglright'] = 333;
  50342. t['fi'] = 556;
  50343. t['fl'] = 556;
  50344. t['endash'] = 500;
  50345. t['dagger'] = 500;
  50346. t['daggerdbl'] = 500;
  50347. t['periodcentered'] = 250;
  50348. t['paragraph'] = 540;
  50349. t['bullet'] = 350;
  50350. t['quotesinglbase'] = 333;
  50351. t['quotedblbase'] = 500;
  50352. t['quotedblright'] = 500;
  50353. t['guillemotright'] = 500;
  50354. t['ellipsis'] = 1000;
  50355. t['perthousand'] = 1000;
  50356. t['questiondown'] = 500;
  50357. t['grave'] = 333;
  50358. t['acute'] = 333;
  50359. t['circumflex'] = 333;
  50360. t['tilde'] = 333;
  50361. t['macron'] = 333;
  50362. t['breve'] = 333;
  50363. t['dotaccent'] = 333;
  50364. t['dieresis'] = 333;
  50365. t['ring'] = 333;
  50366. t['cedilla'] = 333;
  50367. t['hungarumlaut'] = 333;
  50368. t['ogonek'] = 333;
  50369. t['caron'] = 333;
  50370. t['emdash'] = 1000;
  50371. t['AE'] = 1000;
  50372. t['ordfeminine'] = 300;
  50373. t['Lslash'] = 667;
  50374. t['Oslash'] = 778;
  50375. t['OE'] = 1000;
  50376. t['ordmasculine'] = 330;
  50377. t['ae'] = 722;
  50378. t['dotlessi'] = 278;
  50379. t['lslash'] = 278;
  50380. t['oslash'] = 500;
  50381. t['oe'] = 722;
  50382. t['germandbls'] = 556;
  50383. t['Idieresis'] = 389;
  50384. t['eacute'] = 444;
  50385. t['abreve'] = 500;
  50386. t['uhungarumlaut'] = 556;
  50387. t['ecaron'] = 444;
  50388. t['Ydieresis'] = 722;
  50389. t['divide'] = 570;
  50390. t['Yacute'] = 722;
  50391. t['Acircumflex'] = 722;
  50392. t['aacute'] = 500;
  50393. t['Ucircumflex'] = 722;
  50394. t['yacute'] = 500;
  50395. t['scommaaccent'] = 389;
  50396. t['ecircumflex'] = 444;
  50397. t['Uring'] = 722;
  50398. t['Udieresis'] = 722;
  50399. t['aogonek'] = 500;
  50400. t['Uacute'] = 722;
  50401. t['uogonek'] = 556;
  50402. t['Edieresis'] = 667;
  50403. t['Dcroat'] = 722;
  50404. t['commaaccent'] = 250;
  50405. t['copyright'] = 747;
  50406. t['Emacron'] = 667;
  50407. t['ccaron'] = 444;
  50408. t['aring'] = 500;
  50409. t['Ncommaaccent'] = 722;
  50410. t['lacute'] = 278;
  50411. t['agrave'] = 500;
  50412. t['Tcommaaccent'] = 667;
  50413. t['Cacute'] = 722;
  50414. t['atilde'] = 500;
  50415. t['Edotaccent'] = 667;
  50416. t['scaron'] = 389;
  50417. t['scedilla'] = 389;
  50418. t['iacute'] = 278;
  50419. t['lozenge'] = 494;
  50420. t['Rcaron'] = 722;
  50421. t['Gcommaaccent'] = 778;
  50422. t['ucircumflex'] = 556;
  50423. t['acircumflex'] = 500;
  50424. t['Amacron'] = 722;
  50425. t['rcaron'] = 444;
  50426. t['ccedilla'] = 444;
  50427. t['Zdotaccent'] = 667;
  50428. t['Thorn'] = 611;
  50429. t['Omacron'] = 778;
  50430. t['Racute'] = 722;
  50431. t['Sacute'] = 556;
  50432. t['dcaron'] = 672;
  50433. t['Umacron'] = 722;
  50434. t['uring'] = 556;
  50435. t['threesuperior'] = 300;
  50436. t['Ograve'] = 778;
  50437. t['Agrave'] = 722;
  50438. t['Abreve'] = 722;
  50439. t['multiply'] = 570;
  50440. t['uacute'] = 556;
  50441. t['Tcaron'] = 667;
  50442. t['partialdiff'] = 494;
  50443. t['ydieresis'] = 500;
  50444. t['Nacute'] = 722;
  50445. t['icircumflex'] = 278;
  50446. t['Ecircumflex'] = 667;
  50447. t['adieresis'] = 500;
  50448. t['edieresis'] = 444;
  50449. t['cacute'] = 444;
  50450. t['nacute'] = 556;
  50451. t['umacron'] = 556;
  50452. t['Ncaron'] = 722;
  50453. t['Iacute'] = 389;
  50454. t['plusminus'] = 570;
  50455. t['brokenbar'] = 220;
  50456. t['registered'] = 747;
  50457. t['Gbreve'] = 778;
  50458. t['Idotaccent'] = 389;
  50459. t['summation'] = 600;
  50460. t['Egrave'] = 667;
  50461. t['racute'] = 444;
  50462. t['omacron'] = 500;
  50463. t['Zacute'] = 667;
  50464. t['Zcaron'] = 667;
  50465. t['greaterequal'] = 549;
  50466. t['Eth'] = 722;
  50467. t['Ccedilla'] = 722;
  50468. t['lcommaaccent'] = 278;
  50469. t['tcaron'] = 416;
  50470. t['eogonek'] = 444;
  50471. t['Uogonek'] = 722;
  50472. t['Aacute'] = 722;
  50473. t['Adieresis'] = 722;
  50474. t['egrave'] = 444;
  50475. t['zacute'] = 444;
  50476. t['iogonek'] = 278;
  50477. t['Oacute'] = 778;
  50478. t['oacute'] = 500;
  50479. t['amacron'] = 500;
  50480. t['sacute'] = 389;
  50481. t['idieresis'] = 278;
  50482. t['Ocircumflex'] = 778;
  50483. t['Ugrave'] = 722;
  50484. t['Delta'] = 612;
  50485. t['thorn'] = 556;
  50486. t['twosuperior'] = 300;
  50487. t['Odieresis'] = 778;
  50488. t['mu'] = 556;
  50489. t['igrave'] = 278;
  50490. t['ohungarumlaut'] = 500;
  50491. t['Eogonek'] = 667;
  50492. t['dcroat'] = 556;
  50493. t['threequarters'] = 750;
  50494. t['Scedilla'] = 556;
  50495. t['lcaron'] = 394;
  50496. t['Kcommaaccent'] = 778;
  50497. t['Lacute'] = 667;
  50498. t['trademark'] = 1000;
  50499. t['edotaccent'] = 444;
  50500. t['Igrave'] = 389;
  50501. t['Imacron'] = 389;
  50502. t['Lcaron'] = 667;
  50503. t['onehalf'] = 750;
  50504. t['lessequal'] = 549;
  50505. t['ocircumflex'] = 500;
  50506. t['ntilde'] = 556;
  50507. t['Uhungarumlaut'] = 722;
  50508. t['Eacute'] = 667;
  50509. t['emacron'] = 444;
  50510. t['gbreve'] = 500;
  50511. t['onequarter'] = 750;
  50512. t['Scaron'] = 556;
  50513. t['Scommaaccent'] = 556;
  50514. t['Ohungarumlaut'] = 778;
  50515. t['degree'] = 400;
  50516. t['ograve'] = 500;
  50517. t['Ccaron'] = 722;
  50518. t['ugrave'] = 556;
  50519. t['radical'] = 549;
  50520. t['Dcaron'] = 722;
  50521. t['rcommaaccent'] = 444;
  50522. t['Ntilde'] = 722;
  50523. t['otilde'] = 500;
  50524. t['Rcommaaccent'] = 722;
  50525. t['Lcommaaccent'] = 667;
  50526. t['Atilde'] = 722;
  50527. t['Aogonek'] = 722;
  50528. t['Aring'] = 722;
  50529. t['Otilde'] = 778;
  50530. t['zdotaccent'] = 444;
  50531. t['Ecaron'] = 667;
  50532. t['Iogonek'] = 389;
  50533. t['kcommaaccent'] = 556;
  50534. t['minus'] = 570;
  50535. t['Icircumflex'] = 389;
  50536. t['ncaron'] = 556;
  50537. t['tcommaaccent'] = 333;
  50538. t['logicalnot'] = 570;
  50539. t['odieresis'] = 500;
  50540. t['udieresis'] = 556;
  50541. t['notequal'] = 549;
  50542. t['gcommaaccent'] = 500;
  50543. t['eth'] = 500;
  50544. t['zcaron'] = 444;
  50545. t['ncommaaccent'] = 556;
  50546. t['onesuperior'] = 300;
  50547. t['imacron'] = 278;
  50548. t['Euro'] = 500;
  50549. });
  50550. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50551. t['space'] = 250;
  50552. t['exclam'] = 389;
  50553. t['quotedbl'] = 555;
  50554. t['numbersign'] = 500;
  50555. t['dollar'] = 500;
  50556. t['percent'] = 833;
  50557. t['ampersand'] = 778;
  50558. t['quoteright'] = 333;
  50559. t['parenleft'] = 333;
  50560. t['parenright'] = 333;
  50561. t['asterisk'] = 500;
  50562. t['plus'] = 570;
  50563. t['comma'] = 250;
  50564. t['hyphen'] = 333;
  50565. t['period'] = 250;
  50566. t['slash'] = 278;
  50567. t['zero'] = 500;
  50568. t['one'] = 500;
  50569. t['two'] = 500;
  50570. t['three'] = 500;
  50571. t['four'] = 500;
  50572. t['five'] = 500;
  50573. t['six'] = 500;
  50574. t['seven'] = 500;
  50575. t['eight'] = 500;
  50576. t['nine'] = 500;
  50577. t['colon'] = 333;
  50578. t['semicolon'] = 333;
  50579. t['less'] = 570;
  50580. t['equal'] = 570;
  50581. t['greater'] = 570;
  50582. t['question'] = 500;
  50583. t['at'] = 832;
  50584. t['A'] = 667;
  50585. t['B'] = 667;
  50586. t['C'] = 667;
  50587. t['D'] = 722;
  50588. t['E'] = 667;
  50589. t['F'] = 667;
  50590. t['G'] = 722;
  50591. t['H'] = 778;
  50592. t['I'] = 389;
  50593. t['J'] = 500;
  50594. t['K'] = 667;
  50595. t['L'] = 611;
  50596. t['M'] = 889;
  50597. t['N'] = 722;
  50598. t['O'] = 722;
  50599. t['P'] = 611;
  50600. t['Q'] = 722;
  50601. t['R'] = 667;
  50602. t['S'] = 556;
  50603. t['T'] = 611;
  50604. t['U'] = 722;
  50605. t['V'] = 667;
  50606. t['W'] = 889;
  50607. t['X'] = 667;
  50608. t['Y'] = 611;
  50609. t['Z'] = 611;
  50610. t['bracketleft'] = 333;
  50611. t['backslash'] = 278;
  50612. t['bracketright'] = 333;
  50613. t['asciicircum'] = 570;
  50614. t['underscore'] = 500;
  50615. t['quoteleft'] = 333;
  50616. t['a'] = 500;
  50617. t['b'] = 500;
  50618. t['c'] = 444;
  50619. t['d'] = 500;
  50620. t['e'] = 444;
  50621. t['f'] = 333;
  50622. t['g'] = 500;
  50623. t['h'] = 556;
  50624. t['i'] = 278;
  50625. t['j'] = 278;
  50626. t['k'] = 500;
  50627. t['l'] = 278;
  50628. t['m'] = 778;
  50629. t['n'] = 556;
  50630. t['o'] = 500;
  50631. t['p'] = 500;
  50632. t['q'] = 500;
  50633. t['r'] = 389;
  50634. t['s'] = 389;
  50635. t['t'] = 278;
  50636. t['u'] = 556;
  50637. t['v'] = 444;
  50638. t['w'] = 667;
  50639. t['x'] = 500;
  50640. t['y'] = 444;
  50641. t['z'] = 389;
  50642. t['braceleft'] = 348;
  50643. t['bar'] = 220;
  50644. t['braceright'] = 348;
  50645. t['asciitilde'] = 570;
  50646. t['exclamdown'] = 389;
  50647. t['cent'] = 500;
  50648. t['sterling'] = 500;
  50649. t['fraction'] = 167;
  50650. t['yen'] = 500;
  50651. t['florin'] = 500;
  50652. t['section'] = 500;
  50653. t['currency'] = 500;
  50654. t['quotesingle'] = 278;
  50655. t['quotedblleft'] = 500;
  50656. t['guillemotleft'] = 500;
  50657. t['guilsinglleft'] = 333;
  50658. t['guilsinglright'] = 333;
  50659. t['fi'] = 556;
  50660. t['fl'] = 556;
  50661. t['endash'] = 500;
  50662. t['dagger'] = 500;
  50663. t['daggerdbl'] = 500;
  50664. t['periodcentered'] = 250;
  50665. t['paragraph'] = 500;
  50666. t['bullet'] = 350;
  50667. t['quotesinglbase'] = 333;
  50668. t['quotedblbase'] = 500;
  50669. t['quotedblright'] = 500;
  50670. t['guillemotright'] = 500;
  50671. t['ellipsis'] = 1000;
  50672. t['perthousand'] = 1000;
  50673. t['questiondown'] = 500;
  50674. t['grave'] = 333;
  50675. t['acute'] = 333;
  50676. t['circumflex'] = 333;
  50677. t['tilde'] = 333;
  50678. t['macron'] = 333;
  50679. t['breve'] = 333;
  50680. t['dotaccent'] = 333;
  50681. t['dieresis'] = 333;
  50682. t['ring'] = 333;
  50683. t['cedilla'] = 333;
  50684. t['hungarumlaut'] = 333;
  50685. t['ogonek'] = 333;
  50686. t['caron'] = 333;
  50687. t['emdash'] = 1000;
  50688. t['AE'] = 944;
  50689. t['ordfeminine'] = 266;
  50690. t['Lslash'] = 611;
  50691. t['Oslash'] = 722;
  50692. t['OE'] = 944;
  50693. t['ordmasculine'] = 300;
  50694. t['ae'] = 722;
  50695. t['dotlessi'] = 278;
  50696. t['lslash'] = 278;
  50697. t['oslash'] = 500;
  50698. t['oe'] = 722;
  50699. t['germandbls'] = 500;
  50700. t['Idieresis'] = 389;
  50701. t['eacute'] = 444;
  50702. t['abreve'] = 500;
  50703. t['uhungarumlaut'] = 556;
  50704. t['ecaron'] = 444;
  50705. t['Ydieresis'] = 611;
  50706. t['divide'] = 570;
  50707. t['Yacute'] = 611;
  50708. t['Acircumflex'] = 667;
  50709. t['aacute'] = 500;
  50710. t['Ucircumflex'] = 722;
  50711. t['yacute'] = 444;
  50712. t['scommaaccent'] = 389;
  50713. t['ecircumflex'] = 444;
  50714. t['Uring'] = 722;
  50715. t['Udieresis'] = 722;
  50716. t['aogonek'] = 500;
  50717. t['Uacute'] = 722;
  50718. t['uogonek'] = 556;
  50719. t['Edieresis'] = 667;
  50720. t['Dcroat'] = 722;
  50721. t['commaaccent'] = 250;
  50722. t['copyright'] = 747;
  50723. t['Emacron'] = 667;
  50724. t['ccaron'] = 444;
  50725. t['aring'] = 500;
  50726. t['Ncommaaccent'] = 722;
  50727. t['lacute'] = 278;
  50728. t['agrave'] = 500;
  50729. t['Tcommaaccent'] = 611;
  50730. t['Cacute'] = 667;
  50731. t['atilde'] = 500;
  50732. t['Edotaccent'] = 667;
  50733. t['scaron'] = 389;
  50734. t['scedilla'] = 389;
  50735. t['iacute'] = 278;
  50736. t['lozenge'] = 494;
  50737. t['Rcaron'] = 667;
  50738. t['Gcommaaccent'] = 722;
  50739. t['ucircumflex'] = 556;
  50740. t['acircumflex'] = 500;
  50741. t['Amacron'] = 667;
  50742. t['rcaron'] = 389;
  50743. t['ccedilla'] = 444;
  50744. t['Zdotaccent'] = 611;
  50745. t['Thorn'] = 611;
  50746. t['Omacron'] = 722;
  50747. t['Racute'] = 667;
  50748. t['Sacute'] = 556;
  50749. t['dcaron'] = 608;
  50750. t['Umacron'] = 722;
  50751. t['uring'] = 556;
  50752. t['threesuperior'] = 300;
  50753. t['Ograve'] = 722;
  50754. t['Agrave'] = 667;
  50755. t['Abreve'] = 667;
  50756. t['multiply'] = 570;
  50757. t['uacute'] = 556;
  50758. t['Tcaron'] = 611;
  50759. t['partialdiff'] = 494;
  50760. t['ydieresis'] = 444;
  50761. t['Nacute'] = 722;
  50762. t['icircumflex'] = 278;
  50763. t['Ecircumflex'] = 667;
  50764. t['adieresis'] = 500;
  50765. t['edieresis'] = 444;
  50766. t['cacute'] = 444;
  50767. t['nacute'] = 556;
  50768. t['umacron'] = 556;
  50769. t['Ncaron'] = 722;
  50770. t['Iacute'] = 389;
  50771. t['plusminus'] = 570;
  50772. t['brokenbar'] = 220;
  50773. t['registered'] = 747;
  50774. t['Gbreve'] = 722;
  50775. t['Idotaccent'] = 389;
  50776. t['summation'] = 600;
  50777. t['Egrave'] = 667;
  50778. t['racute'] = 389;
  50779. t['omacron'] = 500;
  50780. t['Zacute'] = 611;
  50781. t['Zcaron'] = 611;
  50782. t['greaterequal'] = 549;
  50783. t['Eth'] = 722;
  50784. t['Ccedilla'] = 667;
  50785. t['lcommaaccent'] = 278;
  50786. t['tcaron'] = 366;
  50787. t['eogonek'] = 444;
  50788. t['Uogonek'] = 722;
  50789. t['Aacute'] = 667;
  50790. t['Adieresis'] = 667;
  50791. t['egrave'] = 444;
  50792. t['zacute'] = 389;
  50793. t['iogonek'] = 278;
  50794. t['Oacute'] = 722;
  50795. t['oacute'] = 500;
  50796. t['amacron'] = 500;
  50797. t['sacute'] = 389;
  50798. t['idieresis'] = 278;
  50799. t['Ocircumflex'] = 722;
  50800. t['Ugrave'] = 722;
  50801. t['Delta'] = 612;
  50802. t['thorn'] = 500;
  50803. t['twosuperior'] = 300;
  50804. t['Odieresis'] = 722;
  50805. t['mu'] = 576;
  50806. t['igrave'] = 278;
  50807. t['ohungarumlaut'] = 500;
  50808. t['Eogonek'] = 667;
  50809. t['dcroat'] = 500;
  50810. t['threequarters'] = 750;
  50811. t['Scedilla'] = 556;
  50812. t['lcaron'] = 382;
  50813. t['Kcommaaccent'] = 667;
  50814. t['Lacute'] = 611;
  50815. t['trademark'] = 1000;
  50816. t['edotaccent'] = 444;
  50817. t['Igrave'] = 389;
  50818. t['Imacron'] = 389;
  50819. t['Lcaron'] = 611;
  50820. t['onehalf'] = 750;
  50821. t['lessequal'] = 549;
  50822. t['ocircumflex'] = 500;
  50823. t['ntilde'] = 556;
  50824. t['Uhungarumlaut'] = 722;
  50825. t['Eacute'] = 667;
  50826. t['emacron'] = 444;
  50827. t['gbreve'] = 500;
  50828. t['onequarter'] = 750;
  50829. t['Scaron'] = 556;
  50830. t['Scommaaccent'] = 556;
  50831. t['Ohungarumlaut'] = 722;
  50832. t['degree'] = 400;
  50833. t['ograve'] = 500;
  50834. t['Ccaron'] = 667;
  50835. t['ugrave'] = 556;
  50836. t['radical'] = 549;
  50837. t['Dcaron'] = 722;
  50838. t['rcommaaccent'] = 389;
  50839. t['Ntilde'] = 722;
  50840. t['otilde'] = 500;
  50841. t['Rcommaaccent'] = 667;
  50842. t['Lcommaaccent'] = 611;
  50843. t['Atilde'] = 667;
  50844. t['Aogonek'] = 667;
  50845. t['Aring'] = 667;
  50846. t['Otilde'] = 722;
  50847. t['zdotaccent'] = 389;
  50848. t['Ecaron'] = 667;
  50849. t['Iogonek'] = 389;
  50850. t['kcommaaccent'] = 500;
  50851. t['minus'] = 606;
  50852. t['Icircumflex'] = 389;
  50853. t['ncaron'] = 556;
  50854. t['tcommaaccent'] = 278;
  50855. t['logicalnot'] = 606;
  50856. t['odieresis'] = 500;
  50857. t['udieresis'] = 556;
  50858. t['notequal'] = 549;
  50859. t['gcommaaccent'] = 500;
  50860. t['eth'] = 500;
  50861. t['zcaron'] = 389;
  50862. t['ncommaaccent'] = 556;
  50863. t['onesuperior'] = 300;
  50864. t['imacron'] = 278;
  50865. t['Euro'] = 500;
  50866. });
  50867. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50868. t['space'] = 250;
  50869. t['exclam'] = 333;
  50870. t['quotedbl'] = 420;
  50871. t['numbersign'] = 500;
  50872. t['dollar'] = 500;
  50873. t['percent'] = 833;
  50874. t['ampersand'] = 778;
  50875. t['quoteright'] = 333;
  50876. t['parenleft'] = 333;
  50877. t['parenright'] = 333;
  50878. t['asterisk'] = 500;
  50879. t['plus'] = 675;
  50880. t['comma'] = 250;
  50881. t['hyphen'] = 333;
  50882. t['period'] = 250;
  50883. t['slash'] = 278;
  50884. t['zero'] = 500;
  50885. t['one'] = 500;
  50886. t['two'] = 500;
  50887. t['three'] = 500;
  50888. t['four'] = 500;
  50889. t['five'] = 500;
  50890. t['six'] = 500;
  50891. t['seven'] = 500;
  50892. t['eight'] = 500;
  50893. t['nine'] = 500;
  50894. t['colon'] = 333;
  50895. t['semicolon'] = 333;
  50896. t['less'] = 675;
  50897. t['equal'] = 675;
  50898. t['greater'] = 675;
  50899. t['question'] = 500;
  50900. t['at'] = 920;
  50901. t['A'] = 611;
  50902. t['B'] = 611;
  50903. t['C'] = 667;
  50904. t['D'] = 722;
  50905. t['E'] = 611;
  50906. t['F'] = 611;
  50907. t['G'] = 722;
  50908. t['H'] = 722;
  50909. t['I'] = 333;
  50910. t['J'] = 444;
  50911. t['K'] = 667;
  50912. t['L'] = 556;
  50913. t['M'] = 833;
  50914. t['N'] = 667;
  50915. t['O'] = 722;
  50916. t['P'] = 611;
  50917. t['Q'] = 722;
  50918. t['R'] = 611;
  50919. t['S'] = 500;
  50920. t['T'] = 556;
  50921. t['U'] = 722;
  50922. t['V'] = 611;
  50923. t['W'] = 833;
  50924. t['X'] = 611;
  50925. t['Y'] = 556;
  50926. t['Z'] = 556;
  50927. t['bracketleft'] = 389;
  50928. t['backslash'] = 278;
  50929. t['bracketright'] = 389;
  50930. t['asciicircum'] = 422;
  50931. t['underscore'] = 500;
  50932. t['quoteleft'] = 333;
  50933. t['a'] = 500;
  50934. t['b'] = 500;
  50935. t['c'] = 444;
  50936. t['d'] = 500;
  50937. t['e'] = 444;
  50938. t['f'] = 278;
  50939. t['g'] = 500;
  50940. t['h'] = 500;
  50941. t['i'] = 278;
  50942. t['j'] = 278;
  50943. t['k'] = 444;
  50944. t['l'] = 278;
  50945. t['m'] = 722;
  50946. t['n'] = 500;
  50947. t['o'] = 500;
  50948. t['p'] = 500;
  50949. t['q'] = 500;
  50950. t['r'] = 389;
  50951. t['s'] = 389;
  50952. t['t'] = 278;
  50953. t['u'] = 500;
  50954. t['v'] = 444;
  50955. t['w'] = 667;
  50956. t['x'] = 444;
  50957. t['y'] = 444;
  50958. t['z'] = 389;
  50959. t['braceleft'] = 400;
  50960. t['bar'] = 275;
  50961. t['braceright'] = 400;
  50962. t['asciitilde'] = 541;
  50963. t['exclamdown'] = 389;
  50964. t['cent'] = 500;
  50965. t['sterling'] = 500;
  50966. t['fraction'] = 167;
  50967. t['yen'] = 500;
  50968. t['florin'] = 500;
  50969. t['section'] = 500;
  50970. t['currency'] = 500;
  50971. t['quotesingle'] = 214;
  50972. t['quotedblleft'] = 556;
  50973. t['guillemotleft'] = 500;
  50974. t['guilsinglleft'] = 333;
  50975. t['guilsinglright'] = 333;
  50976. t['fi'] = 500;
  50977. t['fl'] = 500;
  50978. t['endash'] = 500;
  50979. t['dagger'] = 500;
  50980. t['daggerdbl'] = 500;
  50981. t['periodcentered'] = 250;
  50982. t['paragraph'] = 523;
  50983. t['bullet'] = 350;
  50984. t['quotesinglbase'] = 333;
  50985. t['quotedblbase'] = 556;
  50986. t['quotedblright'] = 556;
  50987. t['guillemotright'] = 500;
  50988. t['ellipsis'] = 889;
  50989. t['perthousand'] = 1000;
  50990. t['questiondown'] = 500;
  50991. t['grave'] = 333;
  50992. t['acute'] = 333;
  50993. t['circumflex'] = 333;
  50994. t['tilde'] = 333;
  50995. t['macron'] = 333;
  50996. t['breve'] = 333;
  50997. t['dotaccent'] = 333;
  50998. t['dieresis'] = 333;
  50999. t['ring'] = 333;
  51000. t['cedilla'] = 333;
  51001. t['hungarumlaut'] = 333;
  51002. t['ogonek'] = 333;
  51003. t['caron'] = 333;
  51004. t['emdash'] = 889;
  51005. t['AE'] = 889;
  51006. t['ordfeminine'] = 276;
  51007. t['Lslash'] = 556;
  51008. t['Oslash'] = 722;
  51009. t['OE'] = 944;
  51010. t['ordmasculine'] = 310;
  51011. t['ae'] = 667;
  51012. t['dotlessi'] = 278;
  51013. t['lslash'] = 278;
  51014. t['oslash'] = 500;
  51015. t['oe'] = 667;
  51016. t['germandbls'] = 500;
  51017. t['Idieresis'] = 333;
  51018. t['eacute'] = 444;
  51019. t['abreve'] = 500;
  51020. t['uhungarumlaut'] = 500;
  51021. t['ecaron'] = 444;
  51022. t['Ydieresis'] = 556;
  51023. t['divide'] = 675;
  51024. t['Yacute'] = 556;
  51025. t['Acircumflex'] = 611;
  51026. t['aacute'] = 500;
  51027. t['Ucircumflex'] = 722;
  51028. t['yacute'] = 444;
  51029. t['scommaaccent'] = 389;
  51030. t['ecircumflex'] = 444;
  51031. t['Uring'] = 722;
  51032. t['Udieresis'] = 722;
  51033. t['aogonek'] = 500;
  51034. t['Uacute'] = 722;
  51035. t['uogonek'] = 500;
  51036. t['Edieresis'] = 611;
  51037. t['Dcroat'] = 722;
  51038. t['commaaccent'] = 250;
  51039. t['copyright'] = 760;
  51040. t['Emacron'] = 611;
  51041. t['ccaron'] = 444;
  51042. t['aring'] = 500;
  51043. t['Ncommaaccent'] = 667;
  51044. t['lacute'] = 278;
  51045. t['agrave'] = 500;
  51046. t['Tcommaaccent'] = 556;
  51047. t['Cacute'] = 667;
  51048. t['atilde'] = 500;
  51049. t['Edotaccent'] = 611;
  51050. t['scaron'] = 389;
  51051. t['scedilla'] = 389;
  51052. t['iacute'] = 278;
  51053. t['lozenge'] = 471;
  51054. t['Rcaron'] = 611;
  51055. t['Gcommaaccent'] = 722;
  51056. t['ucircumflex'] = 500;
  51057. t['acircumflex'] = 500;
  51058. t['Amacron'] = 611;
  51059. t['rcaron'] = 389;
  51060. t['ccedilla'] = 444;
  51061. t['Zdotaccent'] = 556;
  51062. t['Thorn'] = 611;
  51063. t['Omacron'] = 722;
  51064. t['Racute'] = 611;
  51065. t['Sacute'] = 500;
  51066. t['dcaron'] = 544;
  51067. t['Umacron'] = 722;
  51068. t['uring'] = 500;
  51069. t['threesuperior'] = 300;
  51070. t['Ograve'] = 722;
  51071. t['Agrave'] = 611;
  51072. t['Abreve'] = 611;
  51073. t['multiply'] = 675;
  51074. t['uacute'] = 500;
  51075. t['Tcaron'] = 556;
  51076. t['partialdiff'] = 476;
  51077. t['ydieresis'] = 444;
  51078. t['Nacute'] = 667;
  51079. t['icircumflex'] = 278;
  51080. t['Ecircumflex'] = 611;
  51081. t['adieresis'] = 500;
  51082. t['edieresis'] = 444;
  51083. t['cacute'] = 444;
  51084. t['nacute'] = 500;
  51085. t['umacron'] = 500;
  51086. t['Ncaron'] = 667;
  51087. t['Iacute'] = 333;
  51088. t['plusminus'] = 675;
  51089. t['brokenbar'] = 275;
  51090. t['registered'] = 760;
  51091. t['Gbreve'] = 722;
  51092. t['Idotaccent'] = 333;
  51093. t['summation'] = 600;
  51094. t['Egrave'] = 611;
  51095. t['racute'] = 389;
  51096. t['omacron'] = 500;
  51097. t['Zacute'] = 556;
  51098. t['Zcaron'] = 556;
  51099. t['greaterequal'] = 549;
  51100. t['Eth'] = 722;
  51101. t['Ccedilla'] = 667;
  51102. t['lcommaaccent'] = 278;
  51103. t['tcaron'] = 300;
  51104. t['eogonek'] = 444;
  51105. t['Uogonek'] = 722;
  51106. t['Aacute'] = 611;
  51107. t['Adieresis'] = 611;
  51108. t['egrave'] = 444;
  51109. t['zacute'] = 389;
  51110. t['iogonek'] = 278;
  51111. t['Oacute'] = 722;
  51112. t['oacute'] = 500;
  51113. t['amacron'] = 500;
  51114. t['sacute'] = 389;
  51115. t['idieresis'] = 278;
  51116. t['Ocircumflex'] = 722;
  51117. t['Ugrave'] = 722;
  51118. t['Delta'] = 612;
  51119. t['thorn'] = 500;
  51120. t['twosuperior'] = 300;
  51121. t['Odieresis'] = 722;
  51122. t['mu'] = 500;
  51123. t['igrave'] = 278;
  51124. t['ohungarumlaut'] = 500;
  51125. t['Eogonek'] = 611;
  51126. t['dcroat'] = 500;
  51127. t['threequarters'] = 750;
  51128. t['Scedilla'] = 500;
  51129. t['lcaron'] = 300;
  51130. t['Kcommaaccent'] = 667;
  51131. t['Lacute'] = 556;
  51132. t['trademark'] = 980;
  51133. t['edotaccent'] = 444;
  51134. t['Igrave'] = 333;
  51135. t['Imacron'] = 333;
  51136. t['Lcaron'] = 611;
  51137. t['onehalf'] = 750;
  51138. t['lessequal'] = 549;
  51139. t['ocircumflex'] = 500;
  51140. t['ntilde'] = 500;
  51141. t['Uhungarumlaut'] = 722;
  51142. t['Eacute'] = 611;
  51143. t['emacron'] = 444;
  51144. t['gbreve'] = 500;
  51145. t['onequarter'] = 750;
  51146. t['Scaron'] = 500;
  51147. t['Scommaaccent'] = 500;
  51148. t['Ohungarumlaut'] = 722;
  51149. t['degree'] = 400;
  51150. t['ograve'] = 500;
  51151. t['Ccaron'] = 667;
  51152. t['ugrave'] = 500;
  51153. t['radical'] = 453;
  51154. t['Dcaron'] = 722;
  51155. t['rcommaaccent'] = 389;
  51156. t['Ntilde'] = 667;
  51157. t['otilde'] = 500;
  51158. t['Rcommaaccent'] = 611;
  51159. t['Lcommaaccent'] = 556;
  51160. t['Atilde'] = 611;
  51161. t['Aogonek'] = 611;
  51162. t['Aring'] = 611;
  51163. t['Otilde'] = 722;
  51164. t['zdotaccent'] = 389;
  51165. t['Ecaron'] = 611;
  51166. t['Iogonek'] = 333;
  51167. t['kcommaaccent'] = 444;
  51168. t['minus'] = 675;
  51169. t['Icircumflex'] = 333;
  51170. t['ncaron'] = 500;
  51171. t['tcommaaccent'] = 278;
  51172. t['logicalnot'] = 675;
  51173. t['odieresis'] = 500;
  51174. t['udieresis'] = 500;
  51175. t['notequal'] = 549;
  51176. t['gcommaaccent'] = 500;
  51177. t['eth'] = 500;
  51178. t['zcaron'] = 389;
  51179. t['ncommaaccent'] = 500;
  51180. t['onesuperior'] = 300;
  51181. t['imacron'] = 278;
  51182. t['Euro'] = 500;
  51183. });
  51184. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51185. t['space'] = 278;
  51186. t['a1'] = 974;
  51187. t['a2'] = 961;
  51188. t['a202'] = 974;
  51189. t['a3'] = 980;
  51190. t['a4'] = 719;
  51191. t['a5'] = 789;
  51192. t['a119'] = 790;
  51193. t['a118'] = 791;
  51194. t['a117'] = 690;
  51195. t['a11'] = 960;
  51196. t['a12'] = 939;
  51197. t['a13'] = 549;
  51198. t['a14'] = 855;
  51199. t['a15'] = 911;
  51200. t['a16'] = 933;
  51201. t['a105'] = 911;
  51202. t['a17'] = 945;
  51203. t['a18'] = 974;
  51204. t['a19'] = 755;
  51205. t['a20'] = 846;
  51206. t['a21'] = 762;
  51207. t['a22'] = 761;
  51208. t['a23'] = 571;
  51209. t['a24'] = 677;
  51210. t['a25'] = 763;
  51211. t['a26'] = 760;
  51212. t['a27'] = 759;
  51213. t['a28'] = 754;
  51214. t['a6'] = 494;
  51215. t['a7'] = 552;
  51216. t['a8'] = 537;
  51217. t['a9'] = 577;
  51218. t['a10'] = 692;
  51219. t['a29'] = 786;
  51220. t['a30'] = 788;
  51221. t['a31'] = 788;
  51222. t['a32'] = 790;
  51223. t['a33'] = 793;
  51224. t['a34'] = 794;
  51225. t['a35'] = 816;
  51226. t['a36'] = 823;
  51227. t['a37'] = 789;
  51228. t['a38'] = 841;
  51229. t['a39'] = 823;
  51230. t['a40'] = 833;
  51231. t['a41'] = 816;
  51232. t['a42'] = 831;
  51233. t['a43'] = 923;
  51234. t['a44'] = 744;
  51235. t['a45'] = 723;
  51236. t['a46'] = 749;
  51237. t['a47'] = 790;
  51238. t['a48'] = 792;
  51239. t['a49'] = 695;
  51240. t['a50'] = 776;
  51241. t['a51'] = 768;
  51242. t['a52'] = 792;
  51243. t['a53'] = 759;
  51244. t['a54'] = 707;
  51245. t['a55'] = 708;
  51246. t['a56'] = 682;
  51247. t['a57'] = 701;
  51248. t['a58'] = 826;
  51249. t['a59'] = 815;
  51250. t['a60'] = 789;
  51251. t['a61'] = 789;
  51252. t['a62'] = 707;
  51253. t['a63'] = 687;
  51254. t['a64'] = 696;
  51255. t['a65'] = 689;
  51256. t['a66'] = 786;
  51257. t['a67'] = 787;
  51258. t['a68'] = 713;
  51259. t['a69'] = 791;
  51260. t['a70'] = 785;
  51261. t['a71'] = 791;
  51262. t['a72'] = 873;
  51263. t['a73'] = 761;
  51264. t['a74'] = 762;
  51265. t['a203'] = 762;
  51266. t['a75'] = 759;
  51267. t['a204'] = 759;
  51268. t['a76'] = 892;
  51269. t['a77'] = 892;
  51270. t['a78'] = 788;
  51271. t['a79'] = 784;
  51272. t['a81'] = 438;
  51273. t['a82'] = 138;
  51274. t['a83'] = 277;
  51275. t['a84'] = 415;
  51276. t['a97'] = 392;
  51277. t['a98'] = 392;
  51278. t['a99'] = 668;
  51279. t['a100'] = 668;
  51280. t['a89'] = 390;
  51281. t['a90'] = 390;
  51282. t['a93'] = 317;
  51283. t['a94'] = 317;
  51284. t['a91'] = 276;
  51285. t['a92'] = 276;
  51286. t['a205'] = 509;
  51287. t['a85'] = 509;
  51288. t['a206'] = 410;
  51289. t['a86'] = 410;
  51290. t['a87'] = 234;
  51291. t['a88'] = 234;
  51292. t['a95'] = 334;
  51293. t['a96'] = 334;
  51294. t['a101'] = 732;
  51295. t['a102'] = 544;
  51296. t['a103'] = 544;
  51297. t['a104'] = 910;
  51298. t['a106'] = 667;
  51299. t['a107'] = 760;
  51300. t['a108'] = 760;
  51301. t['a112'] = 776;
  51302. t['a111'] = 595;
  51303. t['a110'] = 694;
  51304. t['a109'] = 626;
  51305. t['a120'] = 788;
  51306. t['a121'] = 788;
  51307. t['a122'] = 788;
  51308. t['a123'] = 788;
  51309. t['a124'] = 788;
  51310. t['a125'] = 788;
  51311. t['a126'] = 788;
  51312. t['a127'] = 788;
  51313. t['a128'] = 788;
  51314. t['a129'] = 788;
  51315. t['a130'] = 788;
  51316. t['a131'] = 788;
  51317. t['a132'] = 788;
  51318. t['a133'] = 788;
  51319. t['a134'] = 788;
  51320. t['a135'] = 788;
  51321. t['a136'] = 788;
  51322. t['a137'] = 788;
  51323. t['a138'] = 788;
  51324. t['a139'] = 788;
  51325. t['a140'] = 788;
  51326. t['a141'] = 788;
  51327. t['a142'] = 788;
  51328. t['a143'] = 788;
  51329. t['a144'] = 788;
  51330. t['a145'] = 788;
  51331. t['a146'] = 788;
  51332. t['a147'] = 788;
  51333. t['a148'] = 788;
  51334. t['a149'] = 788;
  51335. t['a150'] = 788;
  51336. t['a151'] = 788;
  51337. t['a152'] = 788;
  51338. t['a153'] = 788;
  51339. t['a154'] = 788;
  51340. t['a155'] = 788;
  51341. t['a156'] = 788;
  51342. t['a157'] = 788;
  51343. t['a158'] = 788;
  51344. t['a159'] = 788;
  51345. t['a160'] = 894;
  51346. t['a161'] = 838;
  51347. t['a163'] = 1016;
  51348. t['a164'] = 458;
  51349. t['a196'] = 748;
  51350. t['a165'] = 924;
  51351. t['a192'] = 748;
  51352. t['a166'] = 918;
  51353. t['a167'] = 927;
  51354. t['a168'] = 928;
  51355. t['a169'] = 928;
  51356. t['a170'] = 834;
  51357. t['a171'] = 873;
  51358. t['a172'] = 828;
  51359. t['a173'] = 924;
  51360. t['a162'] = 924;
  51361. t['a174'] = 917;
  51362. t['a175'] = 930;
  51363. t['a176'] = 931;
  51364. t['a177'] = 463;
  51365. t['a178'] = 883;
  51366. t['a179'] = 836;
  51367. t['a193'] = 836;
  51368. t['a180'] = 867;
  51369. t['a199'] = 867;
  51370. t['a181'] = 696;
  51371. t['a200'] = 696;
  51372. t['a182'] = 874;
  51373. t['a201'] = 874;
  51374. t['a183'] = 760;
  51375. t['a184'] = 946;
  51376. t['a197'] = 771;
  51377. t['a185'] = 865;
  51378. t['a194'] = 771;
  51379. t['a198'] = 888;
  51380. t['a186'] = 967;
  51381. t['a195'] = 888;
  51382. t['a187'] = 831;
  51383. t['a188'] = 873;
  51384. t['a189'] = 927;
  51385. t['a190'] = 970;
  51386. t['a191'] = 918;
  51387. });
  51388. });
  51389. exports.getMetrics = getMetrics;
  51390. /***/ }),
  51391. /* 38 */
  51392. /***/ (function(module, exports, __w_pdfjs_require__) {
  51393. "use strict";
  51394. var sharedUtil = __w_pdfjs_require__(0);
  51395. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51396. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51397. var MASK_HIGH = 0xffff0000;
  51398. var MASK_LOW = 0xffff;
  51399. function MurmurHash3_64(seed) {
  51400. var SEED = 0xc3d2e1f0;
  51401. this.h1 = seed ? seed & 0xffffffff : SEED;
  51402. this.h2 = seed ? seed & 0xffffffff : SEED;
  51403. }
  51404. var alwaysUseUint32ArrayView = false;
  51405. try {
  51406. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51407. } catch (e) {
  51408. alwaysUseUint32ArrayView = true;
  51409. }
  51410. MurmurHash3_64.prototype = {
  51411. update: function MurmurHash3_64_update(input) {
  51412. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51413. var i;
  51414. if (typeof input === 'string') {
  51415. var data = new Uint8Array(input.length * 2);
  51416. var length = 0;
  51417. for (i = 0; i < input.length; i++) {
  51418. var code = input.charCodeAt(i);
  51419. if (code <= 0xff) {
  51420. data[length++] = code;
  51421. } else {
  51422. data[length++] = code >>> 8;
  51423. data[length++] = code & 0xff;
  51424. }
  51425. }
  51426. } else if (input instanceof Uint8Array) {
  51427. data = input;
  51428. length = data.length;
  51429. } else if (typeof input === 'object' && 'length' in input) {
  51430. data = input;
  51431. length = data.length;
  51432. useUint32ArrayView = true;
  51433. } else {
  51434. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51435. }
  51436. var blockCounts = length >> 2;
  51437. var tailLength = length - blockCounts * 4;
  51438. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51439. var k1 = 0;
  51440. var k2 = 0;
  51441. var h1 = this.h1;
  51442. var h2 = this.h2;
  51443. var C1 = 0xcc9e2d51;
  51444. var C2 = 0x1b873593;
  51445. var C1_LOW = C1 & MASK_LOW;
  51446. var C2_LOW = C2 & MASK_LOW;
  51447. for (i = 0; i < blockCounts; i++) {
  51448. if (i & 1) {
  51449. k1 = dataUint32[i];
  51450. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51451. k1 = k1 << 15 | k1 >>> 17;
  51452. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51453. h1 ^= k1;
  51454. h1 = h1 << 13 | h1 >>> 19;
  51455. h1 = h1 * 5 + 0xe6546b64;
  51456. } else {
  51457. k2 = dataUint32[i];
  51458. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51459. k2 = k2 << 15 | k2 >>> 17;
  51460. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51461. h2 ^= k2;
  51462. h2 = h2 << 13 | h2 >>> 19;
  51463. h2 = h2 * 5 + 0xe6546b64;
  51464. }
  51465. }
  51466. k1 = 0;
  51467. switch (tailLength) {
  51468. case 3:
  51469. k1 ^= data[blockCounts * 4 + 2] << 16;
  51470. case 2:
  51471. k1 ^= data[blockCounts * 4 + 1] << 8;
  51472. case 1:
  51473. k1 ^= data[blockCounts * 4];
  51474. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51475. k1 = k1 << 15 | k1 >>> 17;
  51476. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51477. if (blockCounts & 1) {
  51478. h1 ^= k1;
  51479. } else {
  51480. h2 ^= k1;
  51481. }
  51482. }
  51483. this.h1 = h1;
  51484. this.h2 = h2;
  51485. return this;
  51486. },
  51487. hexdigest: function MurmurHash3_64_hexdigest() {
  51488. var h1 = this.h1;
  51489. var h2 = this.h2;
  51490. h1 ^= h2 >>> 1;
  51491. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51492. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51493. h1 ^= h2 >>> 1;
  51494. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51495. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51496. h1 ^= h2 >>> 1;
  51497. for (var i = 0, arr = [
  51498. h1,
  51499. h2
  51500. ], str = ''; i < arr.length; i++) {
  51501. var hex = (arr[i] >>> 0).toString(16);
  51502. while (hex.length < 8) {
  51503. hex = '0' + hex;
  51504. }
  51505. str += hex;
  51506. }
  51507. return str;
  51508. }
  51509. };
  51510. return MurmurHash3_64;
  51511. }();
  51512. exports.MurmurHash3_64 = MurmurHash3_64;
  51513. /***/ }),
  51514. /* 39 */
  51515. /***/ (function(module, exports, __w_pdfjs_require__) {
  51516. "use strict";
  51517. var sharedUtil = __w_pdfjs_require__(0);
  51518. var coreWorker = __w_pdfjs_require__(23);
  51519. var globalScope = sharedUtil.globalScope;
  51520. var OK_RESPONSE = 200;
  51521. var PARTIAL_CONTENT_RESPONSE = 206;
  51522. function NetworkManager(url, args) {
  51523. this.url = url;
  51524. args = args || {};
  51525. this.isHttp = /^https?:/i.test(url);
  51526. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51527. this.withCredentials = args.withCredentials || false;
  51528. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51529. return new XMLHttpRequest();
  51530. };
  51531. this.currXhrId = 0;
  51532. this.pendingRequests = Object.create(null);
  51533. this.loadedRequests = Object.create(null);
  51534. }
  51535. function getArrayBuffer(xhr) {
  51536. var data = xhr.response;
  51537. if (typeof data !== 'string') {
  51538. return data;
  51539. }
  51540. var length = data.length;
  51541. var array = new Uint8Array(length);
  51542. for (var i = 0; i < length; i++) {
  51543. array[i] = data.charCodeAt(i) & 0xFF;
  51544. }
  51545. return array.buffer;
  51546. }
  51547. var supportsMozChunked = function supportsMozChunkedClosure() {
  51548. try {
  51549. var x = new XMLHttpRequest();
  51550. x.open('GET', globalScope.location.href);
  51551. x.responseType = 'moz-chunked-arraybuffer';
  51552. return x.responseType === 'moz-chunked-arraybuffer';
  51553. } catch (e) {
  51554. return false;
  51555. }
  51556. }();
  51557. NetworkManager.prototype = {
  51558. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51559. var args = {
  51560. begin: begin,
  51561. end: end
  51562. };
  51563. for (var prop in listeners) {
  51564. args[prop] = listeners[prop];
  51565. }
  51566. return this.request(args);
  51567. },
  51568. requestFull: function NetworkManager_requestFull(listeners) {
  51569. return this.request(listeners);
  51570. },
  51571. request: function NetworkManager_request(args) {
  51572. var xhr = this.getXhr();
  51573. var xhrId = this.currXhrId++;
  51574. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51575. xhr.open('GET', this.url);
  51576. xhr.withCredentials = this.withCredentials;
  51577. for (var property in this.httpHeaders) {
  51578. var value = this.httpHeaders[property];
  51579. if (typeof value === 'undefined') {
  51580. continue;
  51581. }
  51582. xhr.setRequestHeader(property, value);
  51583. }
  51584. if (this.isHttp && 'begin' in args && 'end' in args) {
  51585. var rangeStr = args.begin + '-' + (args.end - 1);
  51586. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51587. pendingRequest.expectedStatus = 206;
  51588. } else {
  51589. pendingRequest.expectedStatus = 200;
  51590. }
  51591. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51592. if (useMozChunkedLoading) {
  51593. xhr.responseType = 'moz-chunked-arraybuffer';
  51594. pendingRequest.onProgressiveData = args.onProgressiveData;
  51595. pendingRequest.mozChunked = true;
  51596. } else {
  51597. xhr.responseType = 'arraybuffer';
  51598. }
  51599. if (args.onError) {
  51600. xhr.onerror = function (evt) {
  51601. args.onError(xhr.status);
  51602. };
  51603. }
  51604. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51605. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51606. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51607. pendingRequest.onDone = args.onDone;
  51608. pendingRequest.onError = args.onError;
  51609. pendingRequest.onProgress = args.onProgress;
  51610. xhr.send(null);
  51611. return xhrId;
  51612. },
  51613. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51614. var pendingRequest = this.pendingRequests[xhrId];
  51615. if (!pendingRequest) {
  51616. return;
  51617. }
  51618. if (pendingRequest.mozChunked) {
  51619. var chunk = getArrayBuffer(pendingRequest.xhr);
  51620. pendingRequest.onProgressiveData(chunk);
  51621. }
  51622. var onProgress = pendingRequest.onProgress;
  51623. if (onProgress) {
  51624. onProgress(evt);
  51625. }
  51626. },
  51627. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51628. var pendingRequest = this.pendingRequests[xhrId];
  51629. if (!pendingRequest) {
  51630. return;
  51631. }
  51632. var xhr = pendingRequest.xhr;
  51633. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51634. pendingRequest.onHeadersReceived();
  51635. delete pendingRequest.onHeadersReceived;
  51636. }
  51637. if (xhr.readyState !== 4) {
  51638. return;
  51639. }
  51640. if (!(xhrId in this.pendingRequests)) {
  51641. return;
  51642. }
  51643. delete this.pendingRequests[xhrId];
  51644. if (xhr.status === 0 && this.isHttp) {
  51645. if (pendingRequest.onError) {
  51646. pendingRequest.onError(xhr.status);
  51647. }
  51648. return;
  51649. }
  51650. var xhrStatus = xhr.status || OK_RESPONSE;
  51651. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51652. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51653. if (pendingRequest.onError) {
  51654. pendingRequest.onError(xhr.status);
  51655. }
  51656. return;
  51657. }
  51658. this.loadedRequests[xhrId] = true;
  51659. var chunk = getArrayBuffer(xhr);
  51660. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51661. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51662. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51663. var begin = parseInt(matches[1], 10);
  51664. pendingRequest.onDone({
  51665. begin: begin,
  51666. chunk: chunk
  51667. });
  51668. } else if (pendingRequest.onProgressiveData) {
  51669. pendingRequest.onDone(null);
  51670. } else if (chunk) {
  51671. pendingRequest.onDone({
  51672. begin: 0,
  51673. chunk: chunk
  51674. });
  51675. } else if (pendingRequest.onError) {
  51676. pendingRequest.onError(xhr.status);
  51677. }
  51678. },
  51679. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51680. for (var xhrId in this.pendingRequests) {
  51681. return true;
  51682. }
  51683. return false;
  51684. },
  51685. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51686. return this.pendingRequests[xhrId].xhr;
  51687. },
  51688. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51689. return !!this.pendingRequests[xhrId].onProgressiveData;
  51690. },
  51691. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51692. return xhrId in this.pendingRequests;
  51693. },
  51694. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51695. return xhrId in this.loadedRequests;
  51696. },
  51697. abortAllRequests: function NetworkManager_abortAllRequests() {
  51698. for (var xhrId in this.pendingRequests) {
  51699. this.abortRequest(xhrId | 0);
  51700. }
  51701. },
  51702. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51703. var xhr = this.pendingRequests[xhrId].xhr;
  51704. delete this.pendingRequests[xhrId];
  51705. xhr.abort();
  51706. }
  51707. };
  51708. var assert = sharedUtil.assert;
  51709. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51710. var isInt = sharedUtil.isInt;
  51711. var MissingPDFException = sharedUtil.MissingPDFException;
  51712. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51713. function PDFNetworkStream(options) {
  51714. this._options = options;
  51715. var source = options.source;
  51716. this._manager = new NetworkManager(source.url, {
  51717. httpHeaders: source.httpHeaders,
  51718. withCredentials: source.withCredentials
  51719. });
  51720. this._rangeChunkSize = source.rangeChunkSize;
  51721. this._fullRequestReader = null;
  51722. this._rangeRequestReaders = [];
  51723. }
  51724. PDFNetworkStream.prototype = {
  51725. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51726. var i = this._rangeRequestReaders.indexOf(reader);
  51727. if (i >= 0) {
  51728. this._rangeRequestReaders.splice(i, 1);
  51729. }
  51730. },
  51731. getFullReader: function PDFNetworkStream_getFullReader() {
  51732. assert(!this._fullRequestReader);
  51733. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51734. return this._fullRequestReader;
  51735. },
  51736. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51737. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51738. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51739. this._rangeRequestReaders.push(reader);
  51740. return reader;
  51741. },
  51742. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51743. if (this._fullRequestReader) {
  51744. this._fullRequestReader.cancel(reason);
  51745. }
  51746. var readers = this._rangeRequestReaders.slice(0);
  51747. readers.forEach(function (reader) {
  51748. reader.cancel(reason);
  51749. });
  51750. }
  51751. };
  51752. function PDFNetworkStreamFullRequestReader(manager, options) {
  51753. this._manager = manager;
  51754. var source = options.source;
  51755. var args = {
  51756. onHeadersReceived: this._onHeadersReceived.bind(this),
  51757. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51758. onDone: this._onDone.bind(this),
  51759. onError: this._onError.bind(this),
  51760. onProgress: this._onProgress.bind(this)
  51761. };
  51762. this._url = source.url;
  51763. this._fullRequestId = manager.requestFull(args);
  51764. this._headersReceivedCapability = createPromiseCapability();
  51765. this._disableRange = options.disableRange || false;
  51766. this._contentLength = source.length;
  51767. this._rangeChunkSize = source.rangeChunkSize;
  51768. if (!this._rangeChunkSize && !this._disableRange) {
  51769. this._disableRange = true;
  51770. }
  51771. this._isStreamingSupported = false;
  51772. this._isRangeSupported = false;
  51773. this._cachedChunks = [];
  51774. this._requests = [];
  51775. this._done = false;
  51776. this._storedError = undefined;
  51777. this.onProgress = null;
  51778. }
  51779. PDFNetworkStreamFullRequestReader.prototype = {
  51780. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51781. if (this._disableRange) {
  51782. return false;
  51783. }
  51784. var networkManager = this._manager;
  51785. if (!networkManager.isHttp) {
  51786. return false;
  51787. }
  51788. var fullRequestXhrId = this._fullRequestId;
  51789. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51790. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51791. return false;
  51792. }
  51793. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51794. if (contentEncoding !== 'identity') {
  51795. return false;
  51796. }
  51797. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51798. length = parseInt(length, 10);
  51799. if (!isInt(length)) {
  51800. return false;
  51801. }
  51802. this._contentLength = length;
  51803. if (length <= 2 * this._rangeChunkSize) {
  51804. return false;
  51805. }
  51806. return true;
  51807. },
  51808. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51809. if (this._validateRangeRequestCapabilities()) {
  51810. this._isRangeSupported = true;
  51811. }
  51812. var networkManager = this._manager;
  51813. var fullRequestXhrId = this._fullRequestId;
  51814. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51815. this._isStreamingSupported = true;
  51816. } else if (this._isRangeSupported) {
  51817. networkManager.abortRequest(fullRequestXhrId);
  51818. }
  51819. this._headersReceivedCapability.resolve();
  51820. },
  51821. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51822. if (this._requests.length > 0) {
  51823. var requestCapability = this._requests.shift();
  51824. requestCapability.resolve({
  51825. value: chunk,
  51826. done: false
  51827. });
  51828. } else {
  51829. this._cachedChunks.push(chunk);
  51830. }
  51831. },
  51832. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51833. if (args) {
  51834. this._onProgressiveData(args.chunk);
  51835. }
  51836. this._done = true;
  51837. if (this._cachedChunks.length > 0) {
  51838. return;
  51839. }
  51840. this._requests.forEach(function (requestCapability) {
  51841. requestCapability.resolve({
  51842. value: undefined,
  51843. done: true
  51844. });
  51845. });
  51846. this._requests = [];
  51847. },
  51848. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51849. var url = this._url;
  51850. var exception;
  51851. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51852. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51853. } else {
  51854. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51855. }
  51856. this._storedError = exception;
  51857. this._headersReceivedCapability.reject(exception);
  51858. this._requests.forEach(function (requestCapability) {
  51859. requestCapability.reject(exception);
  51860. });
  51861. this._requests = [];
  51862. this._cachedChunks = [];
  51863. },
  51864. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51865. if (this.onProgress) {
  51866. this.onProgress({
  51867. loaded: data.loaded,
  51868. total: data.lengthComputable ? data.total : this._contentLength
  51869. });
  51870. }
  51871. },
  51872. get isRangeSupported() {
  51873. return this._isRangeSupported;
  51874. },
  51875. get isStreamingSupported() {
  51876. return this._isStreamingSupported;
  51877. },
  51878. get contentLength() {
  51879. return this._contentLength;
  51880. },
  51881. get headersReady() {
  51882. return this._headersReceivedCapability.promise;
  51883. },
  51884. read: function PDFNetworkStreamFullRequestReader_read() {
  51885. if (this._storedError) {
  51886. return Promise.reject(this._storedError);
  51887. }
  51888. if (this._cachedChunks.length > 0) {
  51889. var chunk = this._cachedChunks.shift();
  51890. return Promise.resolve(chunk);
  51891. }
  51892. if (this._done) {
  51893. return Promise.resolve({
  51894. value: undefined,
  51895. done: true
  51896. });
  51897. }
  51898. var requestCapability = createPromiseCapability();
  51899. this._requests.push(requestCapability);
  51900. return requestCapability.promise;
  51901. },
  51902. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51903. this._done = true;
  51904. this._headersReceivedCapability.reject(reason);
  51905. this._requests.forEach(function (requestCapability) {
  51906. requestCapability.resolve({
  51907. value: undefined,
  51908. done: true
  51909. });
  51910. });
  51911. this._requests = [];
  51912. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51913. this._manager.abortRequest(this._fullRequestId);
  51914. }
  51915. this._fullRequestReader = null;
  51916. }
  51917. };
  51918. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51919. this._manager = manager;
  51920. var args = {
  51921. onDone: this._onDone.bind(this),
  51922. onProgress: this._onProgress.bind(this)
  51923. };
  51924. this._requestId = manager.requestRange(begin, end, args);
  51925. this._requests = [];
  51926. this._queuedChunk = null;
  51927. this._done = false;
  51928. this.onProgress = null;
  51929. this.onClosed = null;
  51930. }
  51931. PDFNetworkStreamRangeRequestReader.prototype = {
  51932. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51933. if (this.onClosed) {
  51934. this.onClosed(this);
  51935. }
  51936. },
  51937. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51938. var chunk = data.chunk;
  51939. if (this._requests.length > 0) {
  51940. var requestCapability = this._requests.shift();
  51941. requestCapability.resolve({
  51942. value: chunk,
  51943. done: false
  51944. });
  51945. } else {
  51946. this._queuedChunk = chunk;
  51947. }
  51948. this._done = true;
  51949. this._requests.forEach(function (requestCapability) {
  51950. requestCapability.resolve({
  51951. value: undefined,
  51952. done: true
  51953. });
  51954. });
  51955. this._requests = [];
  51956. this._close();
  51957. },
  51958. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51959. if (!this.isStreamingSupported && this.onProgress) {
  51960. this.onProgress({ loaded: evt.loaded });
  51961. }
  51962. },
  51963. get isStreamingSupported() {
  51964. return false;
  51965. },
  51966. read: function PDFNetworkStreamRangeRequestReader_read() {
  51967. if (this._queuedChunk !== null) {
  51968. var chunk = this._queuedChunk;
  51969. this._queuedChunk = null;
  51970. return Promise.resolve({
  51971. value: chunk,
  51972. done: false
  51973. });
  51974. }
  51975. if (this._done) {
  51976. return Promise.resolve({
  51977. value: undefined,
  51978. done: true
  51979. });
  51980. }
  51981. var requestCapability = createPromiseCapability();
  51982. this._requests.push(requestCapability);
  51983. return requestCapability.promise;
  51984. },
  51985. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  51986. this._done = true;
  51987. this._requests.forEach(function (requestCapability) {
  51988. requestCapability.resolve({
  51989. value: undefined,
  51990. done: true
  51991. });
  51992. });
  51993. this._requests = [];
  51994. if (this._manager.isPendingRequest(this._requestId)) {
  51995. this._manager.abortRequest(this._requestId);
  51996. }
  51997. this._close();
  51998. }
  51999. };
  52000. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52001. exports.PDFNetworkStream = PDFNetworkStream;
  52002. exports.NetworkManager = NetworkManager;
  52003. /***/ }),
  52004. /* 40 */
  52005. /***/ (function(module, exports, __w_pdfjs_require__) {
  52006. "use strict";
  52007. var sharedUtil = __w_pdfjs_require__(0);
  52008. var corePrimitives = __w_pdfjs_require__(1);
  52009. var coreFunction = __w_pdfjs_require__(7);
  52010. var coreColorSpace = __w_pdfjs_require__(4);
  52011. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52012. var MissingDataException = sharedUtil.MissingDataException;
  52013. var Util = sharedUtil.Util;
  52014. var assert = sharedUtil.assert;
  52015. var error = sharedUtil.error;
  52016. var info = sharedUtil.info;
  52017. var warn = sharedUtil.warn;
  52018. var isStream = corePrimitives.isStream;
  52019. var PDFFunction = coreFunction.PDFFunction;
  52020. var ColorSpace = coreColorSpace.ColorSpace;
  52021. var ShadingType = {
  52022. FUNCTION_BASED: 1,
  52023. AXIAL: 2,
  52024. RADIAL: 3,
  52025. FREE_FORM_MESH: 4,
  52026. LATTICE_FORM_MESH: 5,
  52027. COONS_PATCH_MESH: 6,
  52028. TENSOR_PATCH_MESH: 7
  52029. };
  52030. var Pattern = function PatternClosure() {
  52031. function Pattern() {
  52032. error('should not call Pattern constructor');
  52033. }
  52034. Pattern.prototype = {
  52035. getPattern: function Pattern_getPattern(ctx) {
  52036. error('Should not call Pattern.getStyle: ' + ctx);
  52037. }
  52038. };
  52039. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52040. var dict = isStream(shading) ? shading.dict : shading;
  52041. var type = dict.get('ShadingType');
  52042. try {
  52043. switch (type) {
  52044. case ShadingType.AXIAL:
  52045. case ShadingType.RADIAL:
  52046. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52047. case ShadingType.FREE_FORM_MESH:
  52048. case ShadingType.LATTICE_FORM_MESH:
  52049. case ShadingType.COONS_PATCH_MESH:
  52050. case ShadingType.TENSOR_PATCH_MESH:
  52051. return new Shadings.Mesh(shading, matrix, xref, res);
  52052. default:
  52053. throw new Error('Unsupported ShadingType: ' + type);
  52054. }
  52055. } catch (ex) {
  52056. if (ex instanceof MissingDataException) {
  52057. throw ex;
  52058. }
  52059. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52060. warn(ex);
  52061. return new Shadings.Dummy();
  52062. }
  52063. };
  52064. return Pattern;
  52065. }();
  52066. var Shadings = {};
  52067. Shadings.SMALL_NUMBER = 1e-6;
  52068. Shadings.RadialAxial = function RadialAxialClosure() {
  52069. function RadialAxial(dict, matrix, xref, res) {
  52070. this.matrix = matrix;
  52071. this.coordsArr = dict.getArray('Coords');
  52072. this.shadingType = dict.get('ShadingType');
  52073. this.type = 'Pattern';
  52074. var cs = dict.get('ColorSpace', 'CS');
  52075. cs = ColorSpace.parse(cs, xref, res);
  52076. this.cs = cs;
  52077. var t0 = 0.0, t1 = 1.0;
  52078. if (dict.has('Domain')) {
  52079. var domainArr = dict.getArray('Domain');
  52080. t0 = domainArr[0];
  52081. t1 = domainArr[1];
  52082. }
  52083. var extendStart = false, extendEnd = false;
  52084. if (dict.has('Extend')) {
  52085. var extendArr = dict.getArray('Extend');
  52086. extendStart = extendArr[0];
  52087. extendEnd = extendArr[1];
  52088. }
  52089. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52090. var x1 = this.coordsArr[0];
  52091. var y1 = this.coordsArr[1];
  52092. var r1 = this.coordsArr[2];
  52093. var x2 = this.coordsArr[3];
  52094. var y2 = this.coordsArr[4];
  52095. var r2 = this.coordsArr[5];
  52096. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52097. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52098. warn('Unsupported radial gradient.');
  52099. }
  52100. }
  52101. this.extendStart = extendStart;
  52102. this.extendEnd = extendEnd;
  52103. var fnObj = dict.get('Function');
  52104. var fn = PDFFunction.parseArray(xref, fnObj);
  52105. var diff = t1 - t0;
  52106. var step = diff / 10;
  52107. var colorStops = this.colorStops = [];
  52108. if (t0 >= t1 || step <= 0) {
  52109. info('Bad shading domain.');
  52110. return;
  52111. }
  52112. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52113. var rgbColor;
  52114. for (var i = t0; i <= t1; i += step) {
  52115. ratio[0] = i;
  52116. fn(ratio, 0, color, 0);
  52117. rgbColor = cs.getRgb(color, 0);
  52118. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52119. colorStops.push([
  52120. (i - t0) / diff,
  52121. cssColor
  52122. ]);
  52123. }
  52124. var background = 'transparent';
  52125. if (dict.has('Background')) {
  52126. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52127. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52128. }
  52129. if (!extendStart) {
  52130. colorStops.unshift([
  52131. 0,
  52132. background
  52133. ]);
  52134. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52135. }
  52136. if (!extendEnd) {
  52137. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52138. colorStops.push([
  52139. 1,
  52140. background
  52141. ]);
  52142. }
  52143. this.colorStops = colorStops;
  52144. }
  52145. RadialAxial.prototype = {
  52146. getIR: function RadialAxial_getIR() {
  52147. var coordsArr = this.coordsArr;
  52148. var shadingType = this.shadingType;
  52149. var type, p0, p1, r0, r1;
  52150. if (shadingType === ShadingType.AXIAL) {
  52151. p0 = [
  52152. coordsArr[0],
  52153. coordsArr[1]
  52154. ];
  52155. p1 = [
  52156. coordsArr[2],
  52157. coordsArr[3]
  52158. ];
  52159. r0 = null;
  52160. r1 = null;
  52161. type = 'axial';
  52162. } else if (shadingType === ShadingType.RADIAL) {
  52163. p0 = [
  52164. coordsArr[0],
  52165. coordsArr[1]
  52166. ];
  52167. p1 = [
  52168. coordsArr[3],
  52169. coordsArr[4]
  52170. ];
  52171. r0 = coordsArr[2];
  52172. r1 = coordsArr[5];
  52173. type = 'radial';
  52174. } else {
  52175. error('getPattern type unknown: ' + shadingType);
  52176. }
  52177. var matrix = this.matrix;
  52178. if (matrix) {
  52179. p0 = Util.applyTransform(p0, matrix);
  52180. p1 = Util.applyTransform(p1, matrix);
  52181. if (shadingType === ShadingType.RADIAL) {
  52182. var scale = Util.singularValueDecompose2dScale(matrix);
  52183. r0 *= scale[0];
  52184. r1 *= scale[1];
  52185. }
  52186. }
  52187. return [
  52188. 'RadialAxial',
  52189. type,
  52190. this.colorStops,
  52191. p0,
  52192. p1,
  52193. r0,
  52194. r1
  52195. ];
  52196. }
  52197. };
  52198. return RadialAxial;
  52199. }();
  52200. Shadings.Mesh = function MeshClosure() {
  52201. function MeshStreamReader(stream, context) {
  52202. this.stream = stream;
  52203. this.context = context;
  52204. this.buffer = 0;
  52205. this.bufferLength = 0;
  52206. var numComps = context.numComps;
  52207. this.tmpCompsBuf = new Float32Array(numComps);
  52208. var csNumComps = context.colorSpace.numComps;
  52209. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52210. }
  52211. MeshStreamReader.prototype = {
  52212. get hasData() {
  52213. if (this.stream.end) {
  52214. return this.stream.pos < this.stream.end;
  52215. }
  52216. if (this.bufferLength > 0) {
  52217. return true;
  52218. }
  52219. var nextByte = this.stream.getByte();
  52220. if (nextByte < 0) {
  52221. return false;
  52222. }
  52223. this.buffer = nextByte;
  52224. this.bufferLength = 8;
  52225. return true;
  52226. },
  52227. readBits: function MeshStreamReader_readBits(n) {
  52228. var buffer = this.buffer;
  52229. var bufferLength = this.bufferLength;
  52230. if (n === 32) {
  52231. if (bufferLength === 0) {
  52232. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52233. }
  52234. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52235. var nextByte = this.stream.getByte();
  52236. this.buffer = nextByte & (1 << bufferLength) - 1;
  52237. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52238. }
  52239. if (n === 8 && bufferLength === 0) {
  52240. return this.stream.getByte();
  52241. }
  52242. while (bufferLength < n) {
  52243. buffer = buffer << 8 | this.stream.getByte();
  52244. bufferLength += 8;
  52245. }
  52246. bufferLength -= n;
  52247. this.bufferLength = bufferLength;
  52248. this.buffer = buffer & (1 << bufferLength) - 1;
  52249. return buffer >> bufferLength;
  52250. },
  52251. align: function MeshStreamReader_align() {
  52252. this.buffer = 0;
  52253. this.bufferLength = 0;
  52254. },
  52255. readFlag: function MeshStreamReader_readFlag() {
  52256. return this.readBits(this.context.bitsPerFlag);
  52257. },
  52258. readCoordinate: function MeshStreamReader_readCoordinate() {
  52259. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52260. var xi = this.readBits(bitsPerCoordinate);
  52261. var yi = this.readBits(bitsPerCoordinate);
  52262. var decode = this.context.decode;
  52263. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52264. return [
  52265. xi * scale * (decode[1] - decode[0]) + decode[0],
  52266. yi * scale * (decode[3] - decode[2]) + decode[2]
  52267. ];
  52268. },
  52269. readComponents: function MeshStreamReader_readComponents() {
  52270. var numComps = this.context.numComps;
  52271. var bitsPerComponent = this.context.bitsPerComponent;
  52272. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52273. var decode = this.context.decode;
  52274. var components = this.tmpCompsBuf;
  52275. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52276. var ci = this.readBits(bitsPerComponent);
  52277. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52278. }
  52279. var color = this.tmpCsCompsBuf;
  52280. if (this.context.colorFn) {
  52281. this.context.colorFn(components, 0, color, 0);
  52282. }
  52283. return this.context.colorSpace.getRgb(color, 0);
  52284. }
  52285. };
  52286. function decodeType4Shading(mesh, reader) {
  52287. var coords = mesh.coords;
  52288. var colors = mesh.colors;
  52289. var operators = [];
  52290. var ps = [];
  52291. var verticesLeft = 0;
  52292. while (reader.hasData) {
  52293. var f = reader.readFlag();
  52294. var coord = reader.readCoordinate();
  52295. var color = reader.readComponents();
  52296. if (verticesLeft === 0) {
  52297. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52298. switch (f) {
  52299. case 0:
  52300. verticesLeft = 3;
  52301. break;
  52302. case 1:
  52303. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52304. verticesLeft = 1;
  52305. break;
  52306. case 2:
  52307. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52308. verticesLeft = 1;
  52309. break;
  52310. }
  52311. operators.push(f);
  52312. }
  52313. ps.push(coords.length);
  52314. coords.push(coord);
  52315. colors.push(color);
  52316. verticesLeft--;
  52317. reader.align();
  52318. }
  52319. mesh.figures.push({
  52320. type: 'triangles',
  52321. coords: new Int32Array(ps),
  52322. colors: new Int32Array(ps)
  52323. });
  52324. }
  52325. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52326. var coords = mesh.coords;
  52327. var colors = mesh.colors;
  52328. var ps = [];
  52329. while (reader.hasData) {
  52330. var coord = reader.readCoordinate();
  52331. var color = reader.readComponents();
  52332. ps.push(coords.length);
  52333. coords.push(coord);
  52334. colors.push(color);
  52335. }
  52336. mesh.figures.push({
  52337. type: 'lattice',
  52338. coords: new Int32Array(ps),
  52339. colors: new Int32Array(ps),
  52340. verticesPerRow: verticesPerRow
  52341. });
  52342. }
  52343. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52344. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52345. var TRIANGLE_DENSITY = 20;
  52346. var getB = function getBClosure() {
  52347. function buildB(count) {
  52348. var lut = [];
  52349. for (var i = 0; i <= count; i++) {
  52350. var t = i / count, t_ = 1 - t;
  52351. lut.push(new Float32Array([
  52352. t_ * t_ * t_,
  52353. 3 * t * t_ * t_,
  52354. 3 * t * t * t_,
  52355. t * t * t
  52356. ]));
  52357. }
  52358. return lut;
  52359. }
  52360. var cache = [];
  52361. return function getB(count) {
  52362. if (!cache[count]) {
  52363. cache[count] = buildB(count);
  52364. }
  52365. return cache[count];
  52366. };
  52367. }();
  52368. function buildFigureFromPatch(mesh, index) {
  52369. var figure = mesh.figures[index];
  52370. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52371. var coords = mesh.coords, colors = mesh.colors;
  52372. var pi = figure.coords;
  52373. var ci = figure.colors;
  52374. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52375. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52376. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52377. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52378. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52379. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52380. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52381. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52382. var verticesPerRow = splitXBy + 1;
  52383. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52384. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52385. var k = 0;
  52386. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52387. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52388. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52389. for (var row = 0; row <= splitYBy; row++) {
  52390. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52391. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52392. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52393. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52394. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52395. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52396. for (var col = 0; col <= splitXBy; col++, k++) {
  52397. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52398. continue;
  52399. }
  52400. var x = 0, y = 0;
  52401. var q = 0;
  52402. for (var i = 0; i <= 3; i++) {
  52403. for (var j = 0; j <= 3; j++, q++) {
  52404. var m = bRow[row][i] * bCol[col][j];
  52405. x += coords[pi[q]][0] * m;
  52406. y += coords[pi[q]][1] * m;
  52407. }
  52408. }
  52409. figureCoords[k] = coords.length;
  52410. coords.push([
  52411. x,
  52412. y
  52413. ]);
  52414. figureColors[k] = colors.length;
  52415. var newColor = new Uint8Array(3);
  52416. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52417. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52418. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52419. colors.push(newColor);
  52420. }
  52421. }
  52422. figureCoords[0] = pi[0];
  52423. figureColors[0] = ci[0];
  52424. figureCoords[splitXBy] = pi[3];
  52425. figureColors[splitXBy] = ci[1];
  52426. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52427. figureColors[verticesPerRow * splitYBy] = ci[2];
  52428. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52429. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52430. mesh.figures[index] = {
  52431. type: 'lattice',
  52432. coords: figureCoords,
  52433. colors: figureColors,
  52434. verticesPerRow: verticesPerRow
  52435. };
  52436. }
  52437. function decodeType6Shading(mesh, reader) {
  52438. var coords = mesh.coords;
  52439. var colors = mesh.colors;
  52440. var ps = new Int32Array(16);
  52441. var cs = new Int32Array(4);
  52442. while (reader.hasData) {
  52443. var f = reader.readFlag();
  52444. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52445. var i, ii;
  52446. var pi = coords.length;
  52447. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52448. coords.push(reader.readCoordinate());
  52449. }
  52450. var ci = colors.length;
  52451. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52452. colors.push(reader.readComponents());
  52453. }
  52454. var tmp1, tmp2, tmp3, tmp4;
  52455. switch (f) {
  52456. case 0:
  52457. ps[12] = pi + 3;
  52458. ps[13] = pi + 4;
  52459. ps[14] = pi + 5;
  52460. ps[15] = pi + 6;
  52461. ps[8] = pi + 2;
  52462. ps[11] = pi + 7;
  52463. ps[4] = pi + 1;
  52464. ps[7] = pi + 8;
  52465. ps[0] = pi;
  52466. ps[1] = pi + 11;
  52467. ps[2] = pi + 10;
  52468. ps[3] = pi + 9;
  52469. cs[2] = ci + 1;
  52470. cs[3] = ci + 2;
  52471. cs[0] = ci;
  52472. cs[1] = ci + 3;
  52473. break;
  52474. case 1:
  52475. tmp1 = ps[12];
  52476. tmp2 = ps[13];
  52477. tmp3 = ps[14];
  52478. tmp4 = ps[15];
  52479. ps[12] = tmp4;
  52480. ps[13] = pi + 0;
  52481. ps[14] = pi + 1;
  52482. ps[15] = pi + 2;
  52483. ps[8] = tmp3;
  52484. ps[11] = pi + 3;
  52485. ps[4] = tmp2;
  52486. ps[7] = pi + 4;
  52487. ps[0] = tmp1;
  52488. ps[1] = pi + 7;
  52489. ps[2] = pi + 6;
  52490. ps[3] = pi + 5;
  52491. tmp1 = cs[2];
  52492. tmp2 = cs[3];
  52493. cs[2] = tmp2;
  52494. cs[3] = ci;
  52495. cs[0] = tmp1;
  52496. cs[1] = ci + 1;
  52497. break;
  52498. case 2:
  52499. tmp1 = ps[15];
  52500. tmp2 = ps[11];
  52501. ps[12] = ps[3];
  52502. ps[13] = pi + 0;
  52503. ps[14] = pi + 1;
  52504. ps[15] = pi + 2;
  52505. ps[8] = ps[7];
  52506. ps[11] = pi + 3;
  52507. ps[4] = tmp2;
  52508. ps[7] = pi + 4;
  52509. ps[0] = tmp1;
  52510. ps[1] = pi + 7;
  52511. ps[2] = pi + 6;
  52512. ps[3] = pi + 5;
  52513. tmp1 = cs[3];
  52514. cs[2] = cs[1];
  52515. cs[3] = ci;
  52516. cs[0] = tmp1;
  52517. cs[1] = ci + 1;
  52518. break;
  52519. case 3:
  52520. ps[12] = ps[0];
  52521. ps[13] = pi + 0;
  52522. ps[14] = pi + 1;
  52523. ps[15] = pi + 2;
  52524. ps[8] = ps[1];
  52525. ps[11] = pi + 3;
  52526. ps[4] = ps[2];
  52527. ps[7] = pi + 4;
  52528. ps[0] = ps[3];
  52529. ps[1] = pi + 7;
  52530. ps[2] = pi + 6;
  52531. ps[3] = pi + 5;
  52532. cs[2] = cs[0];
  52533. cs[3] = ci;
  52534. cs[0] = cs[1];
  52535. cs[1] = ci + 1;
  52536. break;
  52537. }
  52538. ps[5] = coords.length;
  52539. coords.push([
  52540. (-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,
  52541. (-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
  52542. ]);
  52543. ps[6] = coords.length;
  52544. coords.push([
  52545. (-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,
  52546. (-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
  52547. ]);
  52548. ps[9] = coords.length;
  52549. coords.push([
  52550. (-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,
  52551. (-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
  52552. ]);
  52553. ps[10] = coords.length;
  52554. coords.push([
  52555. (-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,
  52556. (-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
  52557. ]);
  52558. mesh.figures.push({
  52559. type: 'patch',
  52560. coords: new Int32Array(ps),
  52561. colors: new Int32Array(cs)
  52562. });
  52563. }
  52564. }
  52565. function decodeType7Shading(mesh, reader) {
  52566. var coords = mesh.coords;
  52567. var colors = mesh.colors;
  52568. var ps = new Int32Array(16);
  52569. var cs = new Int32Array(4);
  52570. while (reader.hasData) {
  52571. var f = reader.readFlag();
  52572. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52573. var i, ii;
  52574. var pi = coords.length;
  52575. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52576. coords.push(reader.readCoordinate());
  52577. }
  52578. var ci = colors.length;
  52579. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52580. colors.push(reader.readComponents());
  52581. }
  52582. var tmp1, tmp2, tmp3, tmp4;
  52583. switch (f) {
  52584. case 0:
  52585. ps[12] = pi + 3;
  52586. ps[13] = pi + 4;
  52587. ps[14] = pi + 5;
  52588. ps[15] = pi + 6;
  52589. ps[8] = pi + 2;
  52590. ps[9] = pi + 13;
  52591. ps[10] = pi + 14;
  52592. ps[11] = pi + 7;
  52593. ps[4] = pi + 1;
  52594. ps[5] = pi + 12;
  52595. ps[6] = pi + 15;
  52596. ps[7] = pi + 8;
  52597. ps[0] = pi;
  52598. ps[1] = pi + 11;
  52599. ps[2] = pi + 10;
  52600. ps[3] = pi + 9;
  52601. cs[2] = ci + 1;
  52602. cs[3] = ci + 2;
  52603. cs[0] = ci;
  52604. cs[1] = ci + 3;
  52605. break;
  52606. case 1:
  52607. tmp1 = ps[12];
  52608. tmp2 = ps[13];
  52609. tmp3 = ps[14];
  52610. tmp4 = ps[15];
  52611. ps[12] = tmp4;
  52612. ps[13] = pi + 0;
  52613. ps[14] = pi + 1;
  52614. ps[15] = pi + 2;
  52615. ps[8] = tmp3;
  52616. ps[9] = pi + 9;
  52617. ps[10] = pi + 10;
  52618. ps[11] = pi + 3;
  52619. ps[4] = tmp2;
  52620. ps[5] = pi + 8;
  52621. ps[6] = pi + 11;
  52622. ps[7] = pi + 4;
  52623. ps[0] = tmp1;
  52624. ps[1] = pi + 7;
  52625. ps[2] = pi + 6;
  52626. ps[3] = pi + 5;
  52627. tmp1 = cs[2];
  52628. tmp2 = cs[3];
  52629. cs[2] = tmp2;
  52630. cs[3] = ci;
  52631. cs[0] = tmp1;
  52632. cs[1] = ci + 1;
  52633. break;
  52634. case 2:
  52635. tmp1 = ps[15];
  52636. tmp2 = ps[11];
  52637. ps[12] = ps[3];
  52638. ps[13] = pi + 0;
  52639. ps[14] = pi + 1;
  52640. ps[15] = pi + 2;
  52641. ps[8] = ps[7];
  52642. ps[9] = pi + 9;
  52643. ps[10] = pi + 10;
  52644. ps[11] = pi + 3;
  52645. ps[4] = tmp2;
  52646. ps[5] = pi + 8;
  52647. ps[6] = pi + 11;
  52648. ps[7] = pi + 4;
  52649. ps[0] = tmp1;
  52650. ps[1] = pi + 7;
  52651. ps[2] = pi + 6;
  52652. ps[3] = pi + 5;
  52653. tmp1 = cs[3];
  52654. cs[2] = cs[1];
  52655. cs[3] = ci;
  52656. cs[0] = tmp1;
  52657. cs[1] = ci + 1;
  52658. break;
  52659. case 3:
  52660. ps[12] = ps[0];
  52661. ps[13] = pi + 0;
  52662. ps[14] = pi + 1;
  52663. ps[15] = pi + 2;
  52664. ps[8] = ps[1];
  52665. ps[9] = pi + 9;
  52666. ps[10] = pi + 10;
  52667. ps[11] = pi + 3;
  52668. ps[4] = ps[2];
  52669. ps[5] = pi + 8;
  52670. ps[6] = pi + 11;
  52671. ps[7] = pi + 4;
  52672. ps[0] = ps[3];
  52673. ps[1] = pi + 7;
  52674. ps[2] = pi + 6;
  52675. ps[3] = pi + 5;
  52676. cs[2] = cs[0];
  52677. cs[3] = ci;
  52678. cs[0] = cs[1];
  52679. cs[1] = ci + 1;
  52680. break;
  52681. }
  52682. mesh.figures.push({
  52683. type: 'patch',
  52684. coords: new Int32Array(ps),
  52685. colors: new Int32Array(cs)
  52686. });
  52687. }
  52688. }
  52689. function updateBounds(mesh) {
  52690. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52691. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52692. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52693. minX = minX > x ? x : minX;
  52694. minY = minY > y ? y : minY;
  52695. maxX = maxX < x ? x : maxX;
  52696. maxY = maxY < y ? y : maxY;
  52697. }
  52698. mesh.bounds = [
  52699. minX,
  52700. minY,
  52701. maxX,
  52702. maxY
  52703. ];
  52704. }
  52705. function packData(mesh) {
  52706. var i, ii, j, jj;
  52707. var coords = mesh.coords;
  52708. var coordsPacked = new Float32Array(coords.length * 2);
  52709. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52710. var xy = coords[i];
  52711. coordsPacked[j++] = xy[0];
  52712. coordsPacked[j++] = xy[1];
  52713. }
  52714. mesh.coords = coordsPacked;
  52715. var colors = mesh.colors;
  52716. var colorsPacked = new Uint8Array(colors.length * 3);
  52717. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52718. var c = colors[i];
  52719. colorsPacked[j++] = c[0];
  52720. colorsPacked[j++] = c[1];
  52721. colorsPacked[j++] = c[2];
  52722. }
  52723. mesh.colors = colorsPacked;
  52724. var figures = mesh.figures;
  52725. for (i = 0, ii = figures.length; i < ii; i++) {
  52726. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52727. for (j = 0, jj = ps.length; j < jj; j++) {
  52728. ps[j] *= 2;
  52729. cs[j] *= 3;
  52730. }
  52731. }
  52732. }
  52733. function Mesh(stream, matrix, xref, res) {
  52734. assert(isStream(stream), 'Mesh data is not a stream');
  52735. var dict = stream.dict;
  52736. this.matrix = matrix;
  52737. this.shadingType = dict.get('ShadingType');
  52738. this.type = 'Pattern';
  52739. this.bbox = dict.getArray('BBox');
  52740. var cs = dict.get('ColorSpace', 'CS');
  52741. cs = ColorSpace.parse(cs, xref, res);
  52742. this.cs = cs;
  52743. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52744. var fnObj = dict.get('Function');
  52745. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52746. this.coords = [];
  52747. this.colors = [];
  52748. this.figures = [];
  52749. var decodeContext = {
  52750. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52751. bitsPerComponent: dict.get('BitsPerComponent'),
  52752. bitsPerFlag: dict.get('BitsPerFlag'),
  52753. decode: dict.getArray('Decode'),
  52754. colorFn: fn,
  52755. colorSpace: cs,
  52756. numComps: fn ? 1 : cs.numComps
  52757. };
  52758. var reader = new MeshStreamReader(stream, decodeContext);
  52759. var patchMesh = false;
  52760. switch (this.shadingType) {
  52761. case ShadingType.FREE_FORM_MESH:
  52762. decodeType4Shading(this, reader);
  52763. break;
  52764. case ShadingType.LATTICE_FORM_MESH:
  52765. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52766. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52767. decodeType5Shading(this, reader, verticesPerRow);
  52768. break;
  52769. case ShadingType.COONS_PATCH_MESH:
  52770. decodeType6Shading(this, reader);
  52771. patchMesh = true;
  52772. break;
  52773. case ShadingType.TENSOR_PATCH_MESH:
  52774. decodeType7Shading(this, reader);
  52775. patchMesh = true;
  52776. break;
  52777. default:
  52778. error('Unsupported mesh type.');
  52779. break;
  52780. }
  52781. if (patchMesh) {
  52782. updateBounds(this);
  52783. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52784. buildFigureFromPatch(this, i);
  52785. }
  52786. }
  52787. updateBounds(this);
  52788. packData(this);
  52789. }
  52790. Mesh.prototype = {
  52791. getIR: function Mesh_getIR() {
  52792. return [
  52793. 'Mesh',
  52794. this.shadingType,
  52795. this.coords,
  52796. this.colors,
  52797. this.figures,
  52798. this.bounds,
  52799. this.matrix,
  52800. this.bbox,
  52801. this.background
  52802. ];
  52803. }
  52804. };
  52805. return Mesh;
  52806. }();
  52807. Shadings.Dummy = function DummyClosure() {
  52808. function Dummy() {
  52809. this.type = 'Pattern';
  52810. }
  52811. Dummy.prototype = {
  52812. getIR: function Dummy_getIR() {
  52813. return ['Dummy'];
  52814. }
  52815. };
  52816. return Dummy;
  52817. }();
  52818. function getTilingPatternIR(operatorList, dict, args) {
  52819. var matrix = dict.getArray('Matrix');
  52820. var bbox = dict.getArray('BBox');
  52821. var xstep = dict.get('XStep');
  52822. var ystep = dict.get('YStep');
  52823. var paintType = dict.get('PaintType');
  52824. var tilingType = dict.get('TilingType');
  52825. return [
  52826. 'TilingPattern',
  52827. args,
  52828. operatorList,
  52829. matrix,
  52830. bbox,
  52831. xstep,
  52832. ystep,
  52833. paintType,
  52834. tilingType
  52835. ];
  52836. }
  52837. exports.Pattern = Pattern;
  52838. exports.getTilingPatternIR = getTilingPatternIR;
  52839. /***/ }),
  52840. /* 41 */
  52841. /***/ (function(module, exports, __w_pdfjs_require__) {
  52842. "use strict";
  52843. var sharedUtil = __w_pdfjs_require__(0);
  52844. var coreStream = __w_pdfjs_require__(2);
  52845. var coreChunkedStream = __w_pdfjs_require__(16);
  52846. var coreDocument = __w_pdfjs_require__(31);
  52847. var warn = sharedUtil.warn;
  52848. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52849. var shadow = sharedUtil.shadow;
  52850. var NotImplementedException = sharedUtil.NotImplementedException;
  52851. var MissingDataException = sharedUtil.MissingDataException;
  52852. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52853. var Util = sharedUtil.Util;
  52854. var Stream = coreStream.Stream;
  52855. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52856. var PDFDocument = coreDocument.PDFDocument;
  52857. var BasePdfManager = function BasePdfManagerClosure() {
  52858. function BasePdfManager() {
  52859. throw new Error('Cannot initialize BaseManagerManager');
  52860. }
  52861. BasePdfManager.prototype = {
  52862. get docId() {
  52863. return this._docId;
  52864. },
  52865. get password() {
  52866. return this._password;
  52867. },
  52868. get docBaseUrl() {
  52869. var docBaseUrl = null;
  52870. if (this._docBaseUrl) {
  52871. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52872. if (absoluteUrl) {
  52873. docBaseUrl = absoluteUrl.href;
  52874. } else {
  52875. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52876. }
  52877. }
  52878. return shadow(this, 'docBaseUrl', docBaseUrl);
  52879. },
  52880. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52881. throw new NotImplementedException();
  52882. },
  52883. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52884. return this.ensure(this.pdfDocument, prop, args);
  52885. },
  52886. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52887. return this.ensure(this.pdfDocument.xref, prop, args);
  52888. },
  52889. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52890. return this.ensure(this.pdfDocument.catalog, prop, args);
  52891. },
  52892. getPage: function BasePdfManager_getPage(pageIndex) {
  52893. return this.pdfDocument.getPage(pageIndex);
  52894. },
  52895. cleanup: function BasePdfManager_cleanup() {
  52896. return this.pdfDocument.cleanup();
  52897. },
  52898. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52899. return new NotImplementedException();
  52900. },
  52901. requestRange: function BasePdfManager_requestRange(begin, end) {
  52902. return new NotImplementedException();
  52903. },
  52904. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52905. return new NotImplementedException();
  52906. },
  52907. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52908. return new NotImplementedException();
  52909. },
  52910. updatePassword: function BasePdfManager_updatePassword(password) {
  52911. this._password = password;
  52912. },
  52913. terminate: function BasePdfManager_terminate() {
  52914. return new NotImplementedException();
  52915. }
  52916. };
  52917. return BasePdfManager;
  52918. }();
  52919. var LocalPdfManager = function LocalPdfManagerClosure() {
  52920. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52921. this._docId = docId;
  52922. this._password = password;
  52923. this._docBaseUrl = docBaseUrl;
  52924. this.evaluatorOptions = evaluatorOptions;
  52925. var stream = new Stream(data);
  52926. this.pdfDocument = new PDFDocument(this, stream);
  52927. this._loadedStreamCapability = createPromiseCapability();
  52928. this._loadedStreamCapability.resolve(stream);
  52929. }
  52930. Util.inherit(LocalPdfManager, BasePdfManager, {
  52931. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52932. return new Promise(function (resolve, reject) {
  52933. try {
  52934. var value = obj[prop];
  52935. var result;
  52936. if (typeof value === 'function') {
  52937. result = value.apply(obj, args);
  52938. } else {
  52939. result = value;
  52940. }
  52941. resolve(result);
  52942. } catch (e) {
  52943. reject(e);
  52944. }
  52945. });
  52946. },
  52947. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52948. return Promise.resolve();
  52949. },
  52950. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52951. },
  52952. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52953. return this._loadedStreamCapability.promise;
  52954. },
  52955. terminate: function LocalPdfManager_terminate() {
  52956. }
  52957. });
  52958. return LocalPdfManager;
  52959. }();
  52960. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52961. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52962. this._docId = docId;
  52963. this._password = args.password;
  52964. this._docBaseUrl = docBaseUrl;
  52965. this.msgHandler = args.msgHandler;
  52966. this.evaluatorOptions = evaluatorOptions;
  52967. var params = {
  52968. msgHandler: args.msgHandler,
  52969. url: args.url,
  52970. length: args.length,
  52971. disableAutoFetch: args.disableAutoFetch,
  52972. rangeChunkSize: args.rangeChunkSize
  52973. };
  52974. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  52975. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  52976. }
  52977. Util.inherit(NetworkPdfManager, BasePdfManager, {
  52978. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  52979. var pdfManager = this;
  52980. return new Promise(function (resolve, reject) {
  52981. function ensureHelper() {
  52982. try {
  52983. var result;
  52984. var value = obj[prop];
  52985. if (typeof value === 'function') {
  52986. result = value.apply(obj, args);
  52987. } else {
  52988. result = value;
  52989. }
  52990. resolve(result);
  52991. } catch (e) {
  52992. if (!(e instanceof MissingDataException)) {
  52993. reject(e);
  52994. return;
  52995. }
  52996. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  52997. }
  52998. }
  52999. ensureHelper();
  53000. });
  53001. },
  53002. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53003. return this.streamManager.requestRange(begin, end);
  53004. },
  53005. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53006. this.streamManager.requestAllChunks();
  53007. },
  53008. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53009. this.streamManager.onReceiveData({ chunk: chunk });
  53010. },
  53011. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53012. return this.streamManager.onLoadedStream();
  53013. },
  53014. terminate: function NetworkPdfManager_terminate() {
  53015. this.streamManager.abort();
  53016. }
  53017. });
  53018. return NetworkPdfManager;
  53019. }();
  53020. exports.LocalPdfManager = LocalPdfManager;
  53021. exports.NetworkPdfManager = NetworkPdfManager;
  53022. /***/ }),
  53023. /* 42 */
  53024. /***/ (function(module, exports, __w_pdfjs_require__) {
  53025. "use strict";
  53026. var sharedUtil = __w_pdfjs_require__(0);
  53027. var corePrimitives = __w_pdfjs_require__(1);
  53028. var error = sharedUtil.error;
  53029. var isSpace = sharedUtil.isSpace;
  53030. var EOF = corePrimitives.EOF;
  53031. var PostScriptParser = function PostScriptParserClosure() {
  53032. function PostScriptParser(lexer) {
  53033. this.lexer = lexer;
  53034. this.operators = [];
  53035. this.token = null;
  53036. this.prev = null;
  53037. }
  53038. PostScriptParser.prototype = {
  53039. nextToken: function PostScriptParser_nextToken() {
  53040. this.prev = this.token;
  53041. this.token = this.lexer.getToken();
  53042. },
  53043. accept: function PostScriptParser_accept(type) {
  53044. if (this.token.type === type) {
  53045. this.nextToken();
  53046. return true;
  53047. }
  53048. return false;
  53049. },
  53050. expect: function PostScriptParser_expect(type) {
  53051. if (this.accept(type)) {
  53052. return true;
  53053. }
  53054. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53055. },
  53056. parse: function PostScriptParser_parse() {
  53057. this.nextToken();
  53058. this.expect(PostScriptTokenTypes.LBRACE);
  53059. this.parseBlock();
  53060. this.expect(PostScriptTokenTypes.RBRACE);
  53061. return this.operators;
  53062. },
  53063. parseBlock: function PostScriptParser_parseBlock() {
  53064. while (true) {
  53065. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53066. this.operators.push(this.prev.value);
  53067. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53068. this.operators.push(this.prev.value);
  53069. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53070. this.parseCondition();
  53071. } else {
  53072. return;
  53073. }
  53074. }
  53075. },
  53076. parseCondition: function PostScriptParser_parseCondition() {
  53077. var conditionLocation = this.operators.length;
  53078. this.operators.push(null, null);
  53079. this.parseBlock();
  53080. this.expect(PostScriptTokenTypes.RBRACE);
  53081. if (this.accept(PostScriptTokenTypes.IF)) {
  53082. this.operators[conditionLocation] = this.operators.length;
  53083. this.operators[conditionLocation + 1] = 'jz';
  53084. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53085. var jumpLocation = this.operators.length;
  53086. this.operators.push(null, null);
  53087. var endOfTrue = this.operators.length;
  53088. this.parseBlock();
  53089. this.expect(PostScriptTokenTypes.RBRACE);
  53090. this.expect(PostScriptTokenTypes.IFELSE);
  53091. this.operators[jumpLocation] = this.operators.length;
  53092. this.operators[jumpLocation + 1] = 'j';
  53093. this.operators[conditionLocation] = endOfTrue;
  53094. this.operators[conditionLocation + 1] = 'jz';
  53095. } else {
  53096. error('PS Function: error parsing conditional.');
  53097. }
  53098. }
  53099. };
  53100. return PostScriptParser;
  53101. }();
  53102. var PostScriptTokenTypes = {
  53103. LBRACE: 0,
  53104. RBRACE: 1,
  53105. NUMBER: 2,
  53106. OPERATOR: 3,
  53107. IF: 4,
  53108. IFELSE: 5
  53109. };
  53110. var PostScriptToken = function PostScriptTokenClosure() {
  53111. function PostScriptToken(type, value) {
  53112. this.type = type;
  53113. this.value = value;
  53114. }
  53115. var opCache = Object.create(null);
  53116. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53117. var opValue = opCache[op];
  53118. if (opValue) {
  53119. return opValue;
  53120. }
  53121. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53122. };
  53123. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53124. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53125. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53126. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53127. return PostScriptToken;
  53128. }();
  53129. var PostScriptLexer = function PostScriptLexerClosure() {
  53130. function PostScriptLexer(stream) {
  53131. this.stream = stream;
  53132. this.nextChar();
  53133. this.strBuf = [];
  53134. }
  53135. PostScriptLexer.prototype = {
  53136. nextChar: function PostScriptLexer_nextChar() {
  53137. return this.currentChar = this.stream.getByte();
  53138. },
  53139. getToken: function PostScriptLexer_getToken() {
  53140. var comment = false;
  53141. var ch = this.currentChar;
  53142. while (true) {
  53143. if (ch < 0) {
  53144. return EOF;
  53145. }
  53146. if (comment) {
  53147. if (ch === 0x0A || ch === 0x0D) {
  53148. comment = false;
  53149. }
  53150. } else if (ch === 0x25) {
  53151. comment = true;
  53152. } else if (!isSpace(ch)) {
  53153. break;
  53154. }
  53155. ch = this.nextChar();
  53156. }
  53157. switch (ch | 0) {
  53158. case 0x30:
  53159. case 0x31:
  53160. case 0x32:
  53161. case 0x33:
  53162. case 0x34:
  53163. case 0x35:
  53164. case 0x36:
  53165. case 0x37:
  53166. case 0x38:
  53167. case 0x39:
  53168. case 0x2B:
  53169. case 0x2D:
  53170. case 0x2E:
  53171. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53172. case 0x7B:
  53173. this.nextChar();
  53174. return PostScriptToken.LBRACE;
  53175. case 0x7D:
  53176. this.nextChar();
  53177. return PostScriptToken.RBRACE;
  53178. }
  53179. var strBuf = this.strBuf;
  53180. strBuf.length = 0;
  53181. strBuf[0] = String.fromCharCode(ch);
  53182. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53183. strBuf.push(String.fromCharCode(ch));
  53184. }
  53185. var str = strBuf.join('');
  53186. switch (str.toLowerCase()) {
  53187. case 'if':
  53188. return PostScriptToken.IF;
  53189. case 'ifelse':
  53190. return PostScriptToken.IFELSE;
  53191. default:
  53192. return PostScriptToken.getOperator(str);
  53193. }
  53194. },
  53195. getNumber: function PostScriptLexer_getNumber() {
  53196. var ch = this.currentChar;
  53197. var strBuf = this.strBuf;
  53198. strBuf.length = 0;
  53199. strBuf[0] = String.fromCharCode(ch);
  53200. while ((ch = this.nextChar()) >= 0) {
  53201. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53202. strBuf.push(String.fromCharCode(ch));
  53203. } else {
  53204. break;
  53205. }
  53206. }
  53207. var value = parseFloat(strBuf.join(''));
  53208. if (isNaN(value)) {
  53209. error('Invalid floating point number: ' + value);
  53210. }
  53211. return value;
  53212. }
  53213. };
  53214. return PostScriptLexer;
  53215. }();
  53216. exports.PostScriptLexer = PostScriptLexer;
  53217. exports.PostScriptParser = PostScriptParser;
  53218. /***/ }),
  53219. /* 43 */
  53220. /***/ (function(module, exports, __w_pdfjs_require__) {
  53221. "use strict";
  53222. var sharedUtil = __w_pdfjs_require__(0);
  53223. var coreStream = __w_pdfjs_require__(2);
  53224. var coreEncodings = __w_pdfjs_require__(5);
  53225. var warn = sharedUtil.warn;
  53226. var isSpace = sharedUtil.isSpace;
  53227. var Stream = coreStream.Stream;
  53228. var getEncoding = coreEncodings.getEncoding;
  53229. var HINTING_ENABLED = false;
  53230. var Type1CharString = function Type1CharStringClosure() {
  53231. var COMMAND_MAP = {
  53232. 'hstem': [1],
  53233. 'vstem': [3],
  53234. 'vmoveto': [4],
  53235. 'rlineto': [5],
  53236. 'hlineto': [6],
  53237. 'vlineto': [7],
  53238. 'rrcurveto': [8],
  53239. 'callsubr': [10],
  53240. 'flex': [
  53241. 12,
  53242. 35
  53243. ],
  53244. 'drop': [
  53245. 12,
  53246. 18
  53247. ],
  53248. 'endchar': [14],
  53249. 'rmoveto': [21],
  53250. 'hmoveto': [22],
  53251. 'vhcurveto': [30],
  53252. 'hvcurveto': [31]
  53253. };
  53254. function Type1CharString() {
  53255. this.width = 0;
  53256. this.lsb = 0;
  53257. this.flexing = false;
  53258. this.output = [];
  53259. this.stack = [];
  53260. }
  53261. Type1CharString.prototype = {
  53262. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53263. var count = encoded.length;
  53264. var error = false;
  53265. var wx, sbx, subrNumber;
  53266. for (var i = 0; i < count; i++) {
  53267. var value = encoded[i];
  53268. if (value < 32) {
  53269. if (value === 12) {
  53270. value = (value << 8) + encoded[++i];
  53271. }
  53272. switch (value) {
  53273. case 1:
  53274. if (!HINTING_ENABLED) {
  53275. this.stack = [];
  53276. break;
  53277. }
  53278. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53279. break;
  53280. case 3:
  53281. if (!HINTING_ENABLED) {
  53282. this.stack = [];
  53283. break;
  53284. }
  53285. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53286. break;
  53287. case 4:
  53288. if (this.flexing) {
  53289. if (this.stack.length < 1) {
  53290. error = true;
  53291. break;
  53292. }
  53293. var dy = this.stack.pop();
  53294. this.stack.push(0, dy);
  53295. break;
  53296. }
  53297. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53298. break;
  53299. case 5:
  53300. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53301. break;
  53302. case 6:
  53303. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53304. break;
  53305. case 7:
  53306. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53307. break;
  53308. case 8:
  53309. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53310. break;
  53311. case 9:
  53312. this.stack = [];
  53313. break;
  53314. case 10:
  53315. if (this.stack.length < 1) {
  53316. error = true;
  53317. break;
  53318. }
  53319. subrNumber = this.stack.pop();
  53320. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53321. break;
  53322. case 11:
  53323. return error;
  53324. case 13:
  53325. if (this.stack.length < 2) {
  53326. error = true;
  53327. break;
  53328. }
  53329. wx = this.stack.pop();
  53330. sbx = this.stack.pop();
  53331. this.lsb = sbx;
  53332. this.width = wx;
  53333. this.stack.push(wx, sbx);
  53334. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53335. break;
  53336. case 14:
  53337. this.output.push(COMMAND_MAP.endchar[0]);
  53338. break;
  53339. case 21:
  53340. if (this.flexing) {
  53341. break;
  53342. }
  53343. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53344. break;
  53345. case 22:
  53346. if (this.flexing) {
  53347. this.stack.push(0);
  53348. break;
  53349. }
  53350. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53351. break;
  53352. case 30:
  53353. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53354. break;
  53355. case 31:
  53356. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53357. break;
  53358. case (12 << 8) + 0:
  53359. this.stack = [];
  53360. break;
  53361. case (12 << 8) + 1:
  53362. if (!HINTING_ENABLED) {
  53363. this.stack = [];
  53364. break;
  53365. }
  53366. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53367. break;
  53368. case (12 << 8) + 2:
  53369. if (!HINTING_ENABLED) {
  53370. this.stack = [];
  53371. break;
  53372. }
  53373. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53374. break;
  53375. case (12 << 8) + 6:
  53376. if (seacAnalysisEnabled) {
  53377. this.seac = this.stack.splice(-4, 4);
  53378. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53379. } else {
  53380. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53381. }
  53382. break;
  53383. case (12 << 8) + 7:
  53384. if (this.stack.length < 4) {
  53385. error = true;
  53386. break;
  53387. }
  53388. this.stack.pop();
  53389. wx = this.stack.pop();
  53390. var sby = this.stack.pop();
  53391. sbx = this.stack.pop();
  53392. this.lsb = sbx;
  53393. this.width = wx;
  53394. this.stack.push(wx, sbx, sby);
  53395. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53396. break;
  53397. case (12 << 8) + 12:
  53398. if (this.stack.length < 2) {
  53399. error = true;
  53400. break;
  53401. }
  53402. var num2 = this.stack.pop();
  53403. var num1 = this.stack.pop();
  53404. this.stack.push(num1 / num2);
  53405. break;
  53406. case (12 << 8) + 16:
  53407. if (this.stack.length < 2) {
  53408. error = true;
  53409. break;
  53410. }
  53411. subrNumber = this.stack.pop();
  53412. var numArgs = this.stack.pop();
  53413. if (subrNumber === 0 && numArgs === 3) {
  53414. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53415. 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]);
  53416. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53417. this.flexing = false;
  53418. this.stack.push(flexArgs[15], flexArgs[16]);
  53419. } else if (subrNumber === 1 && numArgs === 0) {
  53420. this.flexing = true;
  53421. }
  53422. break;
  53423. case (12 << 8) + 17:
  53424. break;
  53425. case (12 << 8) + 33:
  53426. this.stack = [];
  53427. break;
  53428. default:
  53429. warn('Unknown type 1 charstring command of "' + value + '"');
  53430. break;
  53431. }
  53432. if (error) {
  53433. break;
  53434. }
  53435. continue;
  53436. } else if (value <= 246) {
  53437. value = value - 139;
  53438. } else if (value <= 250) {
  53439. value = (value - 247) * 256 + encoded[++i] + 108;
  53440. } else if (value <= 254) {
  53441. value = -((value - 251) * 256) - encoded[++i] - 108;
  53442. } else {
  53443. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53444. }
  53445. this.stack.push(value);
  53446. }
  53447. return error;
  53448. },
  53449. executeCommand: function (howManyArgs, command, keepStack) {
  53450. var stackLength = this.stack.length;
  53451. if (howManyArgs > stackLength) {
  53452. return true;
  53453. }
  53454. var start = stackLength - howManyArgs;
  53455. for (var i = start; i < stackLength; i++) {
  53456. var value = this.stack[i];
  53457. if (value === (value | 0)) {
  53458. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53459. } else {
  53460. value = 65536 * value | 0;
  53461. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53462. }
  53463. }
  53464. this.output.push.apply(this.output, command);
  53465. if (keepStack) {
  53466. this.stack.splice(start, howManyArgs);
  53467. } else {
  53468. this.stack.length = 0;
  53469. }
  53470. return false;
  53471. }
  53472. };
  53473. return Type1CharString;
  53474. }();
  53475. var Type1Parser = function Type1ParserClosure() {
  53476. var EEXEC_ENCRYPT_KEY = 55665;
  53477. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53478. function isHexDigit(code) {
  53479. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53480. }
  53481. function decrypt(data, key, discardNumber) {
  53482. if (discardNumber >= data.length) {
  53483. return new Uint8Array(0);
  53484. }
  53485. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53486. for (i = 0; i < discardNumber; i++) {
  53487. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53488. }
  53489. var count = data.length - discardNumber;
  53490. var decrypted = new Uint8Array(count);
  53491. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53492. var value = data[i];
  53493. decrypted[j] = value ^ r >> 8;
  53494. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53495. }
  53496. return decrypted;
  53497. }
  53498. function decryptAscii(data, key, discardNumber) {
  53499. var r = key | 0, c1 = 52845, c2 = 22719;
  53500. var count = data.length, maybeLength = count >>> 1;
  53501. var decrypted = new Uint8Array(maybeLength);
  53502. var i, j;
  53503. for (i = 0, j = 0; i < count; i++) {
  53504. var digit1 = data[i];
  53505. if (!isHexDigit(digit1)) {
  53506. continue;
  53507. }
  53508. i++;
  53509. var digit2;
  53510. while (i < count && !isHexDigit(digit2 = data[i])) {
  53511. i++;
  53512. }
  53513. if (i < count) {
  53514. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53515. decrypted[j++] = value ^ r >> 8;
  53516. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53517. }
  53518. }
  53519. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53520. }
  53521. function isSpecial(c) {
  53522. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53523. }
  53524. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53525. if (encrypted) {
  53526. var data = stream.getBytes();
  53527. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53528. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53529. }
  53530. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53531. this.stream = stream;
  53532. this.nextChar();
  53533. }
  53534. Type1Parser.prototype = {
  53535. readNumberArray: function Type1Parser_readNumberArray() {
  53536. this.getToken();
  53537. var array = [];
  53538. while (true) {
  53539. var token = this.getToken();
  53540. if (token === null || token === ']' || token === '}') {
  53541. break;
  53542. }
  53543. array.push(parseFloat(token || 0));
  53544. }
  53545. return array;
  53546. },
  53547. readNumber: function Type1Parser_readNumber() {
  53548. var token = this.getToken();
  53549. return parseFloat(token || 0);
  53550. },
  53551. readInt: function Type1Parser_readInt() {
  53552. var token = this.getToken();
  53553. return parseInt(token || 0, 10) | 0;
  53554. },
  53555. readBoolean: function Type1Parser_readBoolean() {
  53556. var token = this.getToken();
  53557. return token === 'true' ? 1 : 0;
  53558. },
  53559. nextChar: function Type1_nextChar() {
  53560. return this.currentChar = this.stream.getByte();
  53561. },
  53562. getToken: function Type1Parser_getToken() {
  53563. var comment = false;
  53564. var ch = this.currentChar;
  53565. while (true) {
  53566. if (ch === -1) {
  53567. return null;
  53568. }
  53569. if (comment) {
  53570. if (ch === 0x0A || ch === 0x0D) {
  53571. comment = false;
  53572. }
  53573. } else if (ch === 0x25) {
  53574. comment = true;
  53575. } else if (!isSpace(ch)) {
  53576. break;
  53577. }
  53578. ch = this.nextChar();
  53579. }
  53580. if (isSpecial(ch)) {
  53581. this.nextChar();
  53582. return String.fromCharCode(ch);
  53583. }
  53584. var token = '';
  53585. do {
  53586. token += String.fromCharCode(ch);
  53587. ch = this.nextChar();
  53588. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53589. return token;
  53590. },
  53591. extractFontProgram: function Type1Parser_extractFontProgram() {
  53592. var stream = this.stream;
  53593. var subrs = [], charstrings = [];
  53594. var privateData = Object.create(null);
  53595. privateData['lenIV'] = 4;
  53596. var program = {
  53597. subrs: [],
  53598. charstrings: [],
  53599. properties: { 'privateData': privateData }
  53600. };
  53601. var token, length, data, lenIV, encoded;
  53602. while ((token = this.getToken()) !== null) {
  53603. if (token !== '/') {
  53604. continue;
  53605. }
  53606. token = this.getToken();
  53607. switch (token) {
  53608. case 'CharStrings':
  53609. this.getToken();
  53610. this.getToken();
  53611. this.getToken();
  53612. this.getToken();
  53613. while (true) {
  53614. token = this.getToken();
  53615. if (token === null || token === 'end') {
  53616. break;
  53617. }
  53618. if (token !== '/') {
  53619. continue;
  53620. }
  53621. var glyph = this.getToken();
  53622. length = this.readInt();
  53623. this.getToken();
  53624. data = stream.makeSubStream(stream.pos, length);
  53625. lenIV = program.properties.privateData['lenIV'];
  53626. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53627. stream.skip(length);
  53628. this.nextChar();
  53629. token = this.getToken();
  53630. if (token === 'noaccess') {
  53631. this.getToken();
  53632. }
  53633. charstrings.push({
  53634. glyph: glyph,
  53635. encoded: encoded
  53636. });
  53637. }
  53638. break;
  53639. case 'Subrs':
  53640. this.readInt();
  53641. this.getToken();
  53642. while ((token = this.getToken()) === 'dup') {
  53643. var index = this.readInt();
  53644. length = this.readInt();
  53645. this.getToken();
  53646. data = stream.makeSubStream(stream.pos, length);
  53647. lenIV = program.properties.privateData['lenIV'];
  53648. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53649. stream.skip(length);
  53650. this.nextChar();
  53651. token = this.getToken();
  53652. if (token === 'noaccess') {
  53653. this.getToken();
  53654. }
  53655. subrs[index] = encoded;
  53656. }
  53657. break;
  53658. case 'BlueValues':
  53659. case 'OtherBlues':
  53660. case 'FamilyBlues':
  53661. case 'FamilyOtherBlues':
  53662. var blueArray = this.readNumberArray();
  53663. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53664. program.properties.privateData[token] = blueArray;
  53665. }
  53666. break;
  53667. case 'StemSnapH':
  53668. case 'StemSnapV':
  53669. program.properties.privateData[token] = this.readNumberArray();
  53670. break;
  53671. case 'StdHW':
  53672. case 'StdVW':
  53673. program.properties.privateData[token] = this.readNumberArray()[0];
  53674. break;
  53675. case 'BlueShift':
  53676. case 'lenIV':
  53677. case 'BlueFuzz':
  53678. case 'BlueScale':
  53679. case 'LanguageGroup':
  53680. case 'ExpansionFactor':
  53681. program.properties.privateData[token] = this.readNumber();
  53682. break;
  53683. case 'ForceBold':
  53684. program.properties.privateData[token] = this.readBoolean();
  53685. break;
  53686. }
  53687. }
  53688. for (var i = 0; i < charstrings.length; i++) {
  53689. glyph = charstrings[i].glyph;
  53690. encoded = charstrings[i].encoded;
  53691. var charString = new Type1CharString();
  53692. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53693. var output = charString.output;
  53694. if (error) {
  53695. output = [14];
  53696. }
  53697. program.charstrings.push({
  53698. glyphName: glyph,
  53699. charstring: output,
  53700. width: charString.width,
  53701. lsb: charString.lsb,
  53702. seac: charString.seac
  53703. });
  53704. }
  53705. return program;
  53706. },
  53707. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53708. var token;
  53709. while ((token = this.getToken()) !== null) {
  53710. if (token !== '/') {
  53711. continue;
  53712. }
  53713. token = this.getToken();
  53714. switch (token) {
  53715. case 'FontMatrix':
  53716. var matrix = this.readNumberArray();
  53717. properties.fontMatrix = matrix;
  53718. break;
  53719. case 'Encoding':
  53720. var encodingArg = this.getToken();
  53721. var encoding;
  53722. if (!/^\d+$/.test(encodingArg)) {
  53723. encoding = getEncoding(encodingArg);
  53724. } else {
  53725. encoding = [];
  53726. var size = parseInt(encodingArg, 10) | 0;
  53727. this.getToken();
  53728. for (var j = 0; j < size; j++) {
  53729. token = this.getToken();
  53730. while (token !== 'dup' && token !== 'def') {
  53731. token = this.getToken();
  53732. if (token === null) {
  53733. return;
  53734. }
  53735. }
  53736. if (token === 'def') {
  53737. break;
  53738. }
  53739. var index = this.readInt();
  53740. this.getToken();
  53741. var glyph = this.getToken();
  53742. encoding[index] = glyph;
  53743. this.getToken();
  53744. }
  53745. }
  53746. properties.builtInEncoding = encoding;
  53747. break;
  53748. case 'FontBBox':
  53749. var fontBBox = this.readNumberArray();
  53750. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53751. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53752. properties.ascentScaled = true;
  53753. break;
  53754. }
  53755. }
  53756. }
  53757. };
  53758. return Type1Parser;
  53759. }();
  53760. exports.Type1Parser = Type1Parser;
  53761. /***/ }),
  53762. /* 44 */
  53763. /***/ (function(module, exports, __w_pdfjs_require__) {
  53764. "use strict";
  53765. var sharedUtil = __w_pdfjs_require__(0);
  53766. var displayDOMUtils = __w_pdfjs_require__(3);
  53767. var displayPatternHelper = __w_pdfjs_require__(46);
  53768. var displayWebGL = __w_pdfjs_require__(25);
  53769. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53770. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53771. var ImageKind = sharedUtil.ImageKind;
  53772. var OPS = sharedUtil.OPS;
  53773. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53774. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53775. var Util = sharedUtil.Util;
  53776. var assert = sharedUtil.assert;
  53777. var info = sharedUtil.info;
  53778. var isNum = sharedUtil.isNum;
  53779. var isArray = sharedUtil.isArray;
  53780. var isLittleEndian = sharedUtil.isLittleEndian;
  53781. var error = sharedUtil.error;
  53782. var shadow = sharedUtil.shadow;
  53783. var warn = sharedUtil.warn;
  53784. var TilingPattern = displayPatternHelper.TilingPattern;
  53785. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53786. var WebGLUtils = displayWebGL.WebGLUtils;
  53787. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53788. var MIN_FONT_SIZE = 16;
  53789. var MAX_FONT_SIZE = 100;
  53790. var MAX_GROUP_SIZE = 4096;
  53791. var MIN_WIDTH_FACTOR = 0.65;
  53792. var COMPILE_TYPE3_GLYPHS = true;
  53793. var MAX_SIZE_TO_COMPILE = 1000;
  53794. var FULL_CHUNK_HEIGHT = 16;
  53795. var HasCanvasTypedArraysCached = {
  53796. get value() {
  53797. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53798. }
  53799. };
  53800. var IsLittleEndianCached = {
  53801. get value() {
  53802. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53803. }
  53804. };
  53805. function addContextCurrentTransform(ctx) {
  53806. if (!ctx.mozCurrentTransform) {
  53807. ctx._originalSave = ctx.save;
  53808. ctx._originalRestore = ctx.restore;
  53809. ctx._originalRotate = ctx.rotate;
  53810. ctx._originalScale = ctx.scale;
  53811. ctx._originalTranslate = ctx.translate;
  53812. ctx._originalTransform = ctx.transform;
  53813. ctx._originalSetTransform = ctx.setTransform;
  53814. ctx._transformMatrix = ctx._transformMatrix || [
  53815. 1,
  53816. 0,
  53817. 0,
  53818. 1,
  53819. 0,
  53820. 0
  53821. ];
  53822. ctx._transformStack = [];
  53823. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53824. get: function getCurrentTransform() {
  53825. return this._transformMatrix;
  53826. }
  53827. });
  53828. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53829. get: function getCurrentTransformInverse() {
  53830. var m = this._transformMatrix;
  53831. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53832. var ad_bc = a * d - b * c;
  53833. var bc_ad = b * c - a * d;
  53834. return [
  53835. d / ad_bc,
  53836. b / bc_ad,
  53837. c / bc_ad,
  53838. a / ad_bc,
  53839. (d * e - c * f) / bc_ad,
  53840. (b * e - a * f) / ad_bc
  53841. ];
  53842. }
  53843. });
  53844. ctx.save = function ctxSave() {
  53845. var old = this._transformMatrix;
  53846. this._transformStack.push(old);
  53847. this._transformMatrix = old.slice(0, 6);
  53848. this._originalSave();
  53849. };
  53850. ctx.restore = function ctxRestore() {
  53851. var prev = this._transformStack.pop();
  53852. if (prev) {
  53853. this._transformMatrix = prev;
  53854. this._originalRestore();
  53855. }
  53856. };
  53857. ctx.translate = function ctxTranslate(x, y) {
  53858. var m = this._transformMatrix;
  53859. m[4] = m[0] * x + m[2] * y + m[4];
  53860. m[5] = m[1] * x + m[3] * y + m[5];
  53861. this._originalTranslate(x, y);
  53862. };
  53863. ctx.scale = function ctxScale(x, y) {
  53864. var m = this._transformMatrix;
  53865. m[0] = m[0] * x;
  53866. m[1] = m[1] * x;
  53867. m[2] = m[2] * y;
  53868. m[3] = m[3] * y;
  53869. this._originalScale(x, y);
  53870. };
  53871. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53872. var m = this._transformMatrix;
  53873. this._transformMatrix = [
  53874. m[0] * a + m[2] * b,
  53875. m[1] * a + m[3] * b,
  53876. m[0] * c + m[2] * d,
  53877. m[1] * c + m[3] * d,
  53878. m[0] * e + m[2] * f + m[4],
  53879. m[1] * e + m[3] * f + m[5]
  53880. ];
  53881. ctx._originalTransform(a, b, c, d, e, f);
  53882. };
  53883. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53884. this._transformMatrix = [
  53885. a,
  53886. b,
  53887. c,
  53888. d,
  53889. e,
  53890. f
  53891. ];
  53892. ctx._originalSetTransform(a, b, c, d, e, f);
  53893. };
  53894. ctx.rotate = function ctxRotate(angle) {
  53895. var cosValue = Math.cos(angle);
  53896. var sinValue = Math.sin(angle);
  53897. var m = this._transformMatrix;
  53898. this._transformMatrix = [
  53899. m[0] * cosValue + m[2] * sinValue,
  53900. m[1] * cosValue + m[3] * sinValue,
  53901. m[0] * -sinValue + m[2] * cosValue,
  53902. m[1] * -sinValue + m[3] * cosValue,
  53903. m[4],
  53904. m[5]
  53905. ];
  53906. this._originalRotate(angle);
  53907. };
  53908. }
  53909. }
  53910. var CachedCanvases = function CachedCanvasesClosure() {
  53911. function CachedCanvases(canvasFactory) {
  53912. this.canvasFactory = canvasFactory;
  53913. this.cache = Object.create(null);
  53914. }
  53915. CachedCanvases.prototype = {
  53916. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53917. var canvasEntry;
  53918. if (this.cache[id] !== undefined) {
  53919. canvasEntry = this.cache[id];
  53920. this.canvasFactory.reset(canvasEntry, width, height);
  53921. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53922. } else {
  53923. canvasEntry = this.canvasFactory.create(width, height);
  53924. this.cache[id] = canvasEntry;
  53925. }
  53926. if (trackTransform) {
  53927. addContextCurrentTransform(canvasEntry.context);
  53928. }
  53929. return canvasEntry;
  53930. },
  53931. clear: function () {
  53932. for (var id in this.cache) {
  53933. var canvasEntry = this.cache[id];
  53934. this.canvasFactory.destroy(canvasEntry);
  53935. delete this.cache[id];
  53936. }
  53937. }
  53938. };
  53939. return CachedCanvases;
  53940. }();
  53941. function compileType3Glyph(imgData) {
  53942. var POINT_TO_PROCESS_LIMIT = 1000;
  53943. var width = imgData.width, height = imgData.height;
  53944. var i, j, j0, width1 = width + 1;
  53945. var points = new Uint8Array(width1 * (height + 1));
  53946. var POINT_TYPES = new Uint8Array([
  53947. 0,
  53948. 2,
  53949. 4,
  53950. 0,
  53951. 1,
  53952. 0,
  53953. 5,
  53954. 4,
  53955. 8,
  53956. 10,
  53957. 0,
  53958. 8,
  53959. 0,
  53960. 2,
  53961. 1,
  53962. 0
  53963. ]);
  53964. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53965. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  53966. for (i = 0, ii = data0.length; i < ii; i++) {
  53967. var mask = 128, elem = data0[i];
  53968. while (mask > 0) {
  53969. data[pos++] = elem & mask ? 0 : 255;
  53970. mask >>= 1;
  53971. }
  53972. }
  53973. var count = 0;
  53974. pos = 0;
  53975. if (data[pos] !== 0) {
  53976. points[0] = 1;
  53977. ++count;
  53978. }
  53979. for (j = 1; j < width; j++) {
  53980. if (data[pos] !== data[pos + 1]) {
  53981. points[j] = data[pos] ? 2 : 1;
  53982. ++count;
  53983. }
  53984. pos++;
  53985. }
  53986. if (data[pos] !== 0) {
  53987. points[j] = 2;
  53988. ++count;
  53989. }
  53990. for (i = 1; i < height; i++) {
  53991. pos = i * lineSize;
  53992. j0 = i * width1;
  53993. if (data[pos - lineSize] !== data[pos]) {
  53994. points[j0] = data[pos] ? 1 : 8;
  53995. ++count;
  53996. }
  53997. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  53998. for (j = 1; j < width; j++) {
  53999. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54000. if (POINT_TYPES[sum]) {
  54001. points[j0 + j] = POINT_TYPES[sum];
  54002. ++count;
  54003. }
  54004. pos++;
  54005. }
  54006. if (data[pos - lineSize] !== data[pos]) {
  54007. points[j0 + j] = data[pos] ? 2 : 4;
  54008. ++count;
  54009. }
  54010. if (count > POINT_TO_PROCESS_LIMIT) {
  54011. return null;
  54012. }
  54013. }
  54014. pos = lineSize * (height - 1);
  54015. j0 = i * width1;
  54016. if (data[pos] !== 0) {
  54017. points[j0] = 8;
  54018. ++count;
  54019. }
  54020. for (j = 1; j < width; j++) {
  54021. if (data[pos] !== data[pos + 1]) {
  54022. points[j0 + j] = data[pos] ? 4 : 8;
  54023. ++count;
  54024. }
  54025. pos++;
  54026. }
  54027. if (data[pos] !== 0) {
  54028. points[j0 + j] = 4;
  54029. ++count;
  54030. }
  54031. if (count > POINT_TO_PROCESS_LIMIT) {
  54032. return null;
  54033. }
  54034. var steps = new Int32Array([
  54035. 0,
  54036. width1,
  54037. -1,
  54038. 0,
  54039. -width1,
  54040. 0,
  54041. 0,
  54042. 0,
  54043. 1
  54044. ]);
  54045. var outlines = [];
  54046. for (i = 0; count && i <= height; i++) {
  54047. var p = i * width1;
  54048. var end = p + width;
  54049. while (p < end && !points[p]) {
  54050. p++;
  54051. }
  54052. if (p === end) {
  54053. continue;
  54054. }
  54055. var coords = [
  54056. p % width1,
  54057. i
  54058. ];
  54059. var type = points[p], p0 = p, pp;
  54060. do {
  54061. var step = steps[type];
  54062. do {
  54063. p += step;
  54064. } while (!points[p]);
  54065. pp = points[p];
  54066. if (pp !== 5 && pp !== 10) {
  54067. type = pp;
  54068. points[p] = 0;
  54069. } else {
  54070. type = pp & 0x33 * type >> 4;
  54071. points[p] &= type >> 2 | type << 2;
  54072. }
  54073. coords.push(p % width1);
  54074. coords.push(p / width1 | 0);
  54075. --count;
  54076. } while (p0 !== p);
  54077. outlines.push(coords);
  54078. --i;
  54079. }
  54080. var drawOutline = function (c) {
  54081. c.save();
  54082. c.scale(1 / width, -1 / height);
  54083. c.translate(0, -height);
  54084. c.beginPath();
  54085. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54086. var o = outlines[i];
  54087. c.moveTo(o[0], o[1]);
  54088. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54089. c.lineTo(o[j], o[j + 1]);
  54090. }
  54091. }
  54092. c.fill();
  54093. c.beginPath();
  54094. c.restore();
  54095. };
  54096. return drawOutline;
  54097. }
  54098. var CanvasExtraState = function CanvasExtraStateClosure() {
  54099. function CanvasExtraState(old) {
  54100. this.alphaIsShape = false;
  54101. this.fontSize = 0;
  54102. this.fontSizeScale = 1;
  54103. this.textMatrix = IDENTITY_MATRIX;
  54104. this.textMatrixScale = 1;
  54105. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54106. this.leading = 0;
  54107. this.x = 0;
  54108. this.y = 0;
  54109. this.lineX = 0;
  54110. this.lineY = 0;
  54111. this.charSpacing = 0;
  54112. this.wordSpacing = 0;
  54113. this.textHScale = 1;
  54114. this.textRenderingMode = TextRenderingMode.FILL;
  54115. this.textRise = 0;
  54116. this.fillColor = '#000000';
  54117. this.strokeColor = '#000000';
  54118. this.patternFill = false;
  54119. this.fillAlpha = 1;
  54120. this.strokeAlpha = 1;
  54121. this.lineWidth = 1;
  54122. this.activeSMask = null;
  54123. this.resumeSMaskCtx = null;
  54124. this.old = old;
  54125. }
  54126. CanvasExtraState.prototype = {
  54127. clone: function CanvasExtraState_clone() {
  54128. return Object.create(this);
  54129. },
  54130. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54131. this.x = x;
  54132. this.y = y;
  54133. }
  54134. };
  54135. return CanvasExtraState;
  54136. }();
  54137. var CanvasGraphics = function CanvasGraphicsClosure() {
  54138. var EXECUTION_TIME = 15;
  54139. var EXECUTION_STEPS = 10;
  54140. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54141. this.ctx = canvasCtx;
  54142. this.current = new CanvasExtraState();
  54143. this.stateStack = [];
  54144. this.pendingClip = null;
  54145. this.pendingEOFill = false;
  54146. this.res = null;
  54147. this.xobjs = null;
  54148. this.commonObjs = commonObjs;
  54149. this.objs = objs;
  54150. this.canvasFactory = canvasFactory;
  54151. this.imageLayer = imageLayer;
  54152. this.groupStack = [];
  54153. this.processingType3 = null;
  54154. this.baseTransform = null;
  54155. this.baseTransformStack = [];
  54156. this.groupLevel = 0;
  54157. this.smaskStack = [];
  54158. this.smaskCounter = 0;
  54159. this.tempSMask = null;
  54160. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54161. if (canvasCtx) {
  54162. addContextCurrentTransform(canvasCtx);
  54163. }
  54164. this.cachedGetSinglePixelWidth = null;
  54165. }
  54166. function putBinaryImageData(ctx, imgData) {
  54167. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54168. ctx.putImageData(imgData, 0, 0);
  54169. return;
  54170. }
  54171. var height = imgData.height, width = imgData.width;
  54172. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54173. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54174. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54175. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54176. var srcPos = 0, destPos;
  54177. var src = imgData.data;
  54178. var dest = chunkImgData.data;
  54179. var i, j, thisChunkHeight, elemsInThisChunk;
  54180. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54181. var srcLength = src.byteLength;
  54182. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54183. var dest32DataLength = dest32.length;
  54184. var fullSrcDiff = width + 7 >> 3;
  54185. var white = 0xFFFFFFFF;
  54186. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54187. for (i = 0; i < totalChunks; i++) {
  54188. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54189. destPos = 0;
  54190. for (j = 0; j < thisChunkHeight; j++) {
  54191. var srcDiff = srcLength - srcPos;
  54192. var k = 0;
  54193. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54194. var kEndUnrolled = kEnd & ~7;
  54195. var mask = 0;
  54196. var srcByte = 0;
  54197. for (; k < kEndUnrolled; k += 8) {
  54198. srcByte = src[srcPos++];
  54199. dest32[destPos++] = srcByte & 128 ? white : black;
  54200. dest32[destPos++] = srcByte & 64 ? white : black;
  54201. dest32[destPos++] = srcByte & 32 ? white : black;
  54202. dest32[destPos++] = srcByte & 16 ? white : black;
  54203. dest32[destPos++] = srcByte & 8 ? white : black;
  54204. dest32[destPos++] = srcByte & 4 ? white : black;
  54205. dest32[destPos++] = srcByte & 2 ? white : black;
  54206. dest32[destPos++] = srcByte & 1 ? white : black;
  54207. }
  54208. for (; k < kEnd; k++) {
  54209. if (mask === 0) {
  54210. srcByte = src[srcPos++];
  54211. mask = 128;
  54212. }
  54213. dest32[destPos++] = srcByte & mask ? white : black;
  54214. mask >>= 1;
  54215. }
  54216. }
  54217. while (destPos < dest32DataLength) {
  54218. dest32[destPos++] = 0;
  54219. }
  54220. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54221. }
  54222. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54223. j = 0;
  54224. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54225. for (i = 0; i < fullChunks; i++) {
  54226. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54227. srcPos += elemsInThisChunk;
  54228. ctx.putImageData(chunkImgData, 0, j);
  54229. j += FULL_CHUNK_HEIGHT;
  54230. }
  54231. if (i < totalChunks) {
  54232. elemsInThisChunk = width * partialChunkHeight * 4;
  54233. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54234. ctx.putImageData(chunkImgData, 0, j);
  54235. }
  54236. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54237. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54238. elemsInThisChunk = width * thisChunkHeight;
  54239. for (i = 0; i < totalChunks; i++) {
  54240. if (i >= fullChunks) {
  54241. thisChunkHeight = partialChunkHeight;
  54242. elemsInThisChunk = width * thisChunkHeight;
  54243. }
  54244. destPos = 0;
  54245. for (j = elemsInThisChunk; j--;) {
  54246. dest[destPos++] = src[srcPos++];
  54247. dest[destPos++] = src[srcPos++];
  54248. dest[destPos++] = src[srcPos++];
  54249. dest[destPos++] = 255;
  54250. }
  54251. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54252. }
  54253. } else {
  54254. error('bad image kind: ' + imgData.kind);
  54255. }
  54256. }
  54257. function putBinaryImageMask(ctx, imgData) {
  54258. var height = imgData.height, width = imgData.width;
  54259. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54260. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54261. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54262. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54263. var srcPos = 0;
  54264. var src = imgData.data;
  54265. var dest = chunkImgData.data;
  54266. for (var i = 0; i < totalChunks; i++) {
  54267. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54268. var destPos = 3;
  54269. for (var j = 0; j < thisChunkHeight; j++) {
  54270. var mask = 0;
  54271. for (var k = 0; k < width; k++) {
  54272. if (!mask) {
  54273. var elem = src[srcPos++];
  54274. mask = 128;
  54275. }
  54276. dest[destPos] = elem & mask ? 0 : 255;
  54277. destPos += 4;
  54278. mask >>= 1;
  54279. }
  54280. }
  54281. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54282. }
  54283. }
  54284. function copyCtxState(sourceCtx, destCtx) {
  54285. var properties = [
  54286. 'strokeStyle',
  54287. 'fillStyle',
  54288. 'fillRule',
  54289. 'globalAlpha',
  54290. 'lineWidth',
  54291. 'lineCap',
  54292. 'lineJoin',
  54293. 'miterLimit',
  54294. 'globalCompositeOperation',
  54295. 'font'
  54296. ];
  54297. for (var i = 0, ii = properties.length; i < ii; i++) {
  54298. var property = properties[i];
  54299. if (sourceCtx[property] !== undefined) {
  54300. destCtx[property] = sourceCtx[property];
  54301. }
  54302. }
  54303. if (sourceCtx.setLineDash !== undefined) {
  54304. destCtx.setLineDash(sourceCtx.getLineDash());
  54305. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54306. }
  54307. }
  54308. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54309. var length = bytes.length;
  54310. for (var i = 3; i < length; i += 4) {
  54311. var alpha = bytes[i];
  54312. if (alpha === 0) {
  54313. bytes[i - 3] = r0;
  54314. bytes[i - 2] = g0;
  54315. bytes[i - 1] = b0;
  54316. } else if (alpha < 255) {
  54317. var alpha_ = 255 - alpha;
  54318. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54319. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54320. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54321. }
  54322. }
  54323. }
  54324. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54325. var length = maskData.length;
  54326. var scale = 1 / 255;
  54327. for (var i = 3; i < length; i += 4) {
  54328. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54329. layerData[i] = layerData[i] * alpha * scale | 0;
  54330. }
  54331. }
  54332. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54333. var length = maskData.length;
  54334. for (var i = 3; i < length; i += 4) {
  54335. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54336. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54337. }
  54338. }
  54339. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54340. var hasBackdrop = !!backdrop;
  54341. var r0 = hasBackdrop ? backdrop[0] : 0;
  54342. var g0 = hasBackdrop ? backdrop[1] : 0;
  54343. var b0 = hasBackdrop ? backdrop[2] : 0;
  54344. var composeFn;
  54345. if (subtype === 'Luminosity') {
  54346. composeFn = composeSMaskLuminosity;
  54347. } else {
  54348. composeFn = composeSMaskAlpha;
  54349. }
  54350. var PIXELS_TO_PROCESS = 1048576;
  54351. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54352. for (var row = 0; row < height; row += chunkSize) {
  54353. var chunkHeight = Math.min(chunkSize, height - row);
  54354. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54355. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54356. if (hasBackdrop) {
  54357. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54358. }
  54359. composeFn(maskData.data, layerData.data, transferMap);
  54360. maskCtx.putImageData(layerData, 0, row);
  54361. }
  54362. }
  54363. function composeSMask(ctx, smask, layerCtx) {
  54364. var mask = smask.canvas;
  54365. var maskCtx = smask.context;
  54366. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54367. var backdrop = smask.backdrop || null;
  54368. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54369. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54370. subtype: smask.subtype,
  54371. backdrop: backdrop
  54372. });
  54373. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54374. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54375. return;
  54376. }
  54377. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54378. ctx.drawImage(mask, 0, 0);
  54379. }
  54380. var LINE_CAP_STYLES = [
  54381. 'butt',
  54382. 'round',
  54383. 'square'
  54384. ];
  54385. var LINE_JOIN_STYLES = [
  54386. 'miter',
  54387. 'round',
  54388. 'bevel'
  54389. ];
  54390. var NORMAL_CLIP = {};
  54391. var EO_CLIP = {};
  54392. CanvasGraphics.prototype = {
  54393. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54394. var width = this.ctx.canvas.width;
  54395. var height = this.ctx.canvas.height;
  54396. this.ctx.save();
  54397. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54398. this.ctx.fillRect(0, 0, width, height);
  54399. this.ctx.restore();
  54400. if (transparency) {
  54401. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54402. this.compositeCtx = this.ctx;
  54403. this.transparentCanvas = transparentCanvas.canvas;
  54404. this.ctx = transparentCanvas.context;
  54405. this.ctx.save();
  54406. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54407. }
  54408. this.ctx.save();
  54409. if (transform) {
  54410. this.ctx.transform.apply(this.ctx, transform);
  54411. }
  54412. this.ctx.transform.apply(this.ctx, viewport.transform);
  54413. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54414. if (this.imageLayer) {
  54415. this.imageLayer.beginLayout();
  54416. }
  54417. },
  54418. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54419. var argsArray = operatorList.argsArray;
  54420. var fnArray = operatorList.fnArray;
  54421. var i = executionStartIdx || 0;
  54422. var argsArrayLen = argsArray.length;
  54423. if (argsArrayLen === i) {
  54424. return i;
  54425. }
  54426. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54427. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54428. var steps = 0;
  54429. var commonObjs = this.commonObjs;
  54430. var objs = this.objs;
  54431. var fnId;
  54432. while (true) {
  54433. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54434. stepper.breakIt(i, continueCallback);
  54435. return i;
  54436. }
  54437. fnId = fnArray[i];
  54438. if (fnId !== OPS.dependency) {
  54439. this[fnId].apply(this, argsArray[i]);
  54440. } else {
  54441. var deps = argsArray[i];
  54442. for (var n = 0, nn = deps.length; n < nn; n++) {
  54443. var depObjId = deps[n];
  54444. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54445. var objsPool = common ? commonObjs : objs;
  54446. if (!objsPool.isResolved(depObjId)) {
  54447. objsPool.get(depObjId, continueCallback);
  54448. return i;
  54449. }
  54450. }
  54451. }
  54452. i++;
  54453. if (i === argsArrayLen) {
  54454. return i;
  54455. }
  54456. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54457. if (Date.now() > endTime) {
  54458. continueCallback();
  54459. return i;
  54460. }
  54461. steps = 0;
  54462. }
  54463. }
  54464. },
  54465. endDrawing: function CanvasGraphics_endDrawing() {
  54466. if (this.current.activeSMask !== null) {
  54467. this.endSMaskGroup();
  54468. }
  54469. this.ctx.restore();
  54470. if (this.transparentCanvas) {
  54471. this.ctx = this.compositeCtx;
  54472. this.ctx.save();
  54473. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54474. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54475. this.ctx.restore();
  54476. this.transparentCanvas = null;
  54477. }
  54478. this.cachedCanvases.clear();
  54479. WebGLUtils.clear();
  54480. if (this.imageLayer) {
  54481. this.imageLayer.endLayout();
  54482. }
  54483. },
  54484. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54485. this.current.lineWidth = width;
  54486. this.ctx.lineWidth = width;
  54487. },
  54488. setLineCap: function CanvasGraphics_setLineCap(style) {
  54489. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54490. },
  54491. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54492. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54493. },
  54494. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54495. this.ctx.miterLimit = limit;
  54496. },
  54497. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54498. var ctx = this.ctx;
  54499. if (ctx.setLineDash !== undefined) {
  54500. ctx.setLineDash(dashArray);
  54501. ctx.lineDashOffset = dashPhase;
  54502. }
  54503. },
  54504. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54505. },
  54506. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54507. },
  54508. setGState: function CanvasGraphics_setGState(states) {
  54509. for (var i = 0, ii = states.length; i < ii; i++) {
  54510. var state = states[i];
  54511. var key = state[0];
  54512. var value = state[1];
  54513. switch (key) {
  54514. case 'LW':
  54515. this.setLineWidth(value);
  54516. break;
  54517. case 'LC':
  54518. this.setLineCap(value);
  54519. break;
  54520. case 'LJ':
  54521. this.setLineJoin(value);
  54522. break;
  54523. case 'ML':
  54524. this.setMiterLimit(value);
  54525. break;
  54526. case 'D':
  54527. this.setDash(value[0], value[1]);
  54528. break;
  54529. case 'RI':
  54530. this.setRenderingIntent(value);
  54531. break;
  54532. case 'FL':
  54533. this.setFlatness(value);
  54534. break;
  54535. case 'Font':
  54536. this.setFont(value[0], value[1]);
  54537. break;
  54538. case 'CA':
  54539. this.current.strokeAlpha = state[1];
  54540. break;
  54541. case 'ca':
  54542. this.current.fillAlpha = state[1];
  54543. this.ctx.globalAlpha = state[1];
  54544. break;
  54545. case 'BM':
  54546. if (value && value.name && value.name !== 'Normal') {
  54547. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54548. return '-' + c.toLowerCase();
  54549. }).substring(1);
  54550. this.ctx.globalCompositeOperation = mode;
  54551. if (this.ctx.globalCompositeOperation !== mode) {
  54552. warn('globalCompositeOperation "' + mode + '" is not supported');
  54553. }
  54554. } else {
  54555. this.ctx.globalCompositeOperation = 'source-over';
  54556. }
  54557. break;
  54558. case 'SMask':
  54559. if (this.current.activeSMask) {
  54560. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54561. this.suspendSMaskGroup();
  54562. } else {
  54563. this.endSMaskGroup();
  54564. }
  54565. }
  54566. this.current.activeSMask = value ? this.tempSMask : null;
  54567. if (this.current.activeSMask) {
  54568. this.beginSMaskGroup();
  54569. }
  54570. this.tempSMask = null;
  54571. break;
  54572. }
  54573. }
  54574. },
  54575. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54576. var activeSMask = this.current.activeSMask;
  54577. var drawnWidth = activeSMask.canvas.width;
  54578. var drawnHeight = activeSMask.canvas.height;
  54579. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54580. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54581. var currentCtx = this.ctx;
  54582. var currentTransform = currentCtx.mozCurrentTransform;
  54583. this.ctx.save();
  54584. var groupCtx = scratchCanvas.context;
  54585. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54586. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54587. groupCtx.transform.apply(groupCtx, currentTransform);
  54588. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54589. copyCtxState(currentCtx, groupCtx);
  54590. this.ctx = groupCtx;
  54591. this.setGState([
  54592. [
  54593. 'BM',
  54594. 'Normal'
  54595. ],
  54596. [
  54597. 'ca',
  54598. 1
  54599. ],
  54600. [
  54601. 'CA',
  54602. 1
  54603. ]
  54604. ]);
  54605. this.groupStack.push(currentCtx);
  54606. this.groupLevel++;
  54607. },
  54608. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54609. var groupCtx = this.ctx;
  54610. this.groupLevel--;
  54611. this.ctx = this.groupStack.pop();
  54612. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54613. this.ctx.restore();
  54614. this.ctx.save();
  54615. copyCtxState(groupCtx, this.ctx);
  54616. this.current.resumeSMaskCtx = groupCtx;
  54617. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54618. this.ctx.transform.apply(this.ctx, deltaTransform);
  54619. groupCtx.save();
  54620. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54621. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54622. groupCtx.restore();
  54623. },
  54624. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54625. var groupCtx = this.current.resumeSMaskCtx;
  54626. var currentCtx = this.ctx;
  54627. this.ctx = groupCtx;
  54628. this.groupStack.push(currentCtx);
  54629. this.groupLevel++;
  54630. },
  54631. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54632. var groupCtx = this.ctx;
  54633. this.groupLevel--;
  54634. this.ctx = this.groupStack.pop();
  54635. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54636. this.ctx.restore();
  54637. copyCtxState(groupCtx, this.ctx);
  54638. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54639. this.ctx.transform.apply(this.ctx, deltaTransform);
  54640. },
  54641. save: function CanvasGraphics_save() {
  54642. this.ctx.save();
  54643. var old = this.current;
  54644. this.stateStack.push(old);
  54645. this.current = old.clone();
  54646. this.current.resumeSMaskCtx = null;
  54647. },
  54648. restore: function CanvasGraphics_restore() {
  54649. if (this.current.resumeSMaskCtx) {
  54650. this.resumeSMaskGroup();
  54651. }
  54652. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54653. this.endSMaskGroup();
  54654. }
  54655. if (this.stateStack.length !== 0) {
  54656. this.current = this.stateStack.pop();
  54657. this.ctx.restore();
  54658. this.pendingClip = null;
  54659. this.cachedGetSinglePixelWidth = null;
  54660. }
  54661. },
  54662. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54663. this.ctx.transform(a, b, c, d, e, f);
  54664. this.cachedGetSinglePixelWidth = null;
  54665. },
  54666. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54667. var ctx = this.ctx;
  54668. var current = this.current;
  54669. var x = current.x, y = current.y;
  54670. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54671. switch (ops[i] | 0) {
  54672. case OPS.rectangle:
  54673. x = args[j++];
  54674. y = args[j++];
  54675. var width = args[j++];
  54676. var height = args[j++];
  54677. if (width === 0) {
  54678. width = this.getSinglePixelWidth();
  54679. }
  54680. if (height === 0) {
  54681. height = this.getSinglePixelWidth();
  54682. }
  54683. var xw = x + width;
  54684. var yh = y + height;
  54685. this.ctx.moveTo(x, y);
  54686. this.ctx.lineTo(xw, y);
  54687. this.ctx.lineTo(xw, yh);
  54688. this.ctx.lineTo(x, yh);
  54689. this.ctx.lineTo(x, y);
  54690. this.ctx.closePath();
  54691. break;
  54692. case OPS.moveTo:
  54693. x = args[j++];
  54694. y = args[j++];
  54695. ctx.moveTo(x, y);
  54696. break;
  54697. case OPS.lineTo:
  54698. x = args[j++];
  54699. y = args[j++];
  54700. ctx.lineTo(x, y);
  54701. break;
  54702. case OPS.curveTo:
  54703. x = args[j + 4];
  54704. y = args[j + 5];
  54705. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54706. j += 6;
  54707. break;
  54708. case OPS.curveTo2:
  54709. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54710. x = args[j + 2];
  54711. y = args[j + 3];
  54712. j += 4;
  54713. break;
  54714. case OPS.curveTo3:
  54715. x = args[j + 2];
  54716. y = args[j + 3];
  54717. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54718. j += 4;
  54719. break;
  54720. case OPS.closePath:
  54721. ctx.closePath();
  54722. break;
  54723. }
  54724. }
  54725. current.setCurrentPoint(x, y);
  54726. },
  54727. closePath: function CanvasGraphics_closePath() {
  54728. this.ctx.closePath();
  54729. },
  54730. stroke: function CanvasGraphics_stroke(consumePath) {
  54731. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54732. var ctx = this.ctx;
  54733. var strokeColor = this.current.strokeColor;
  54734. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54735. ctx.globalAlpha = this.current.strokeAlpha;
  54736. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54737. ctx.save();
  54738. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54739. ctx.stroke();
  54740. ctx.restore();
  54741. } else {
  54742. ctx.stroke();
  54743. }
  54744. if (consumePath) {
  54745. this.consumePath();
  54746. }
  54747. ctx.globalAlpha = this.current.fillAlpha;
  54748. },
  54749. closeStroke: function CanvasGraphics_closeStroke() {
  54750. this.closePath();
  54751. this.stroke();
  54752. },
  54753. fill: function CanvasGraphics_fill(consumePath) {
  54754. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54755. var ctx = this.ctx;
  54756. var fillColor = this.current.fillColor;
  54757. var isPatternFill = this.current.patternFill;
  54758. var needRestore = false;
  54759. if (isPatternFill) {
  54760. ctx.save();
  54761. if (this.baseTransform) {
  54762. ctx.setTransform.apply(ctx, this.baseTransform);
  54763. }
  54764. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54765. needRestore = true;
  54766. }
  54767. if (this.pendingEOFill) {
  54768. ctx.fill('evenodd');
  54769. this.pendingEOFill = false;
  54770. } else {
  54771. ctx.fill();
  54772. }
  54773. if (needRestore) {
  54774. ctx.restore();
  54775. }
  54776. if (consumePath) {
  54777. this.consumePath();
  54778. }
  54779. },
  54780. eoFill: function CanvasGraphics_eoFill() {
  54781. this.pendingEOFill = true;
  54782. this.fill();
  54783. },
  54784. fillStroke: function CanvasGraphics_fillStroke() {
  54785. this.fill(false);
  54786. this.stroke(false);
  54787. this.consumePath();
  54788. },
  54789. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54790. this.pendingEOFill = true;
  54791. this.fillStroke();
  54792. },
  54793. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54794. this.closePath();
  54795. this.fillStroke();
  54796. },
  54797. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54798. this.pendingEOFill = true;
  54799. this.closePath();
  54800. this.fillStroke();
  54801. },
  54802. endPath: function CanvasGraphics_endPath() {
  54803. this.consumePath();
  54804. },
  54805. clip: function CanvasGraphics_clip() {
  54806. this.pendingClip = NORMAL_CLIP;
  54807. },
  54808. eoClip: function CanvasGraphics_eoClip() {
  54809. this.pendingClip = EO_CLIP;
  54810. },
  54811. beginText: function CanvasGraphics_beginText() {
  54812. this.current.textMatrix = IDENTITY_MATRIX;
  54813. this.current.textMatrixScale = 1;
  54814. this.current.x = this.current.lineX = 0;
  54815. this.current.y = this.current.lineY = 0;
  54816. },
  54817. endText: function CanvasGraphics_endText() {
  54818. var paths = this.pendingTextPaths;
  54819. var ctx = this.ctx;
  54820. if (paths === undefined) {
  54821. ctx.beginPath();
  54822. return;
  54823. }
  54824. ctx.save();
  54825. ctx.beginPath();
  54826. for (var i = 0; i < paths.length; i++) {
  54827. var path = paths[i];
  54828. ctx.setTransform.apply(ctx, path.transform);
  54829. ctx.translate(path.x, path.y);
  54830. path.addToPath(ctx, path.fontSize);
  54831. }
  54832. ctx.restore();
  54833. ctx.clip();
  54834. ctx.beginPath();
  54835. delete this.pendingTextPaths;
  54836. },
  54837. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54838. this.current.charSpacing = spacing;
  54839. },
  54840. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54841. this.current.wordSpacing = spacing;
  54842. },
  54843. setHScale: function CanvasGraphics_setHScale(scale) {
  54844. this.current.textHScale = scale / 100;
  54845. },
  54846. setLeading: function CanvasGraphics_setLeading(leading) {
  54847. this.current.leading = -leading;
  54848. },
  54849. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54850. var fontObj = this.commonObjs.get(fontRefName);
  54851. var current = this.current;
  54852. if (!fontObj) {
  54853. error('Can\'t find font for ' + fontRefName);
  54854. }
  54855. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54856. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54857. warn('Invalid font matrix for font ' + fontRefName);
  54858. }
  54859. if (size < 0) {
  54860. size = -size;
  54861. current.fontDirection = -1;
  54862. } else {
  54863. current.fontDirection = 1;
  54864. }
  54865. this.current.font = fontObj;
  54866. this.current.fontSize = size;
  54867. if (fontObj.isType3Font) {
  54868. return;
  54869. }
  54870. var name = fontObj.loadedName || 'sans-serif';
  54871. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54872. var italic = fontObj.italic ? 'italic' : 'normal';
  54873. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54874. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54875. this.current.fontSizeScale = size / browserFontSize;
  54876. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54877. this.ctx.font = rule;
  54878. },
  54879. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54880. this.current.textRenderingMode = mode;
  54881. },
  54882. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54883. this.current.textRise = rise;
  54884. },
  54885. moveText: function CanvasGraphics_moveText(x, y) {
  54886. this.current.x = this.current.lineX += x;
  54887. this.current.y = this.current.lineY += y;
  54888. },
  54889. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54890. this.setLeading(-y);
  54891. this.moveText(x, y);
  54892. },
  54893. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54894. this.current.textMatrix = [
  54895. a,
  54896. b,
  54897. c,
  54898. d,
  54899. e,
  54900. f
  54901. ];
  54902. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54903. this.current.x = this.current.lineX = 0;
  54904. this.current.y = this.current.lineY = 0;
  54905. },
  54906. nextLine: function CanvasGraphics_nextLine() {
  54907. this.moveText(0, this.current.leading);
  54908. },
  54909. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54910. var ctx = this.ctx;
  54911. var current = this.current;
  54912. var font = current.font;
  54913. var textRenderingMode = current.textRenderingMode;
  54914. var fontSize = current.fontSize / current.fontSizeScale;
  54915. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54916. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54917. var addToPath;
  54918. if (font.disableFontFace || isAddToPathSet) {
  54919. addToPath = font.getPathGenerator(this.commonObjs, character);
  54920. }
  54921. if (font.disableFontFace) {
  54922. ctx.save();
  54923. ctx.translate(x, y);
  54924. ctx.beginPath();
  54925. addToPath(ctx, fontSize);
  54926. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54927. ctx.fill();
  54928. }
  54929. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54930. ctx.stroke();
  54931. }
  54932. ctx.restore();
  54933. } else {
  54934. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54935. ctx.fillText(character, x, y);
  54936. }
  54937. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54938. ctx.strokeText(character, x, y);
  54939. }
  54940. }
  54941. if (isAddToPathSet) {
  54942. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54943. paths.push({
  54944. transform: ctx.mozCurrentTransform,
  54945. x: x,
  54946. y: y,
  54947. fontSize: fontSize,
  54948. addToPath: addToPath
  54949. });
  54950. }
  54951. },
  54952. get isFontSubpixelAAEnabled() {
  54953. var ctx = this.canvasFactory.create(10, 10).context;
  54954. ctx.scale(1.5, 1);
  54955. ctx.fillText('I', 0, 10);
  54956. var data = ctx.getImageData(0, 0, 10, 10).data;
  54957. var enabled = false;
  54958. for (var i = 3; i < data.length; i += 4) {
  54959. if (data[i] > 0 && data[i] < 255) {
  54960. enabled = true;
  54961. break;
  54962. }
  54963. }
  54964. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54965. },
  54966. showText: function CanvasGraphics_showText(glyphs) {
  54967. var current = this.current;
  54968. var font = current.font;
  54969. if (font.isType3Font) {
  54970. return this.showType3Text(glyphs);
  54971. }
  54972. var fontSize = current.fontSize;
  54973. if (fontSize === 0) {
  54974. return;
  54975. }
  54976. var ctx = this.ctx;
  54977. var fontSizeScale = current.fontSizeScale;
  54978. var charSpacing = current.charSpacing;
  54979. var wordSpacing = current.wordSpacing;
  54980. var fontDirection = current.fontDirection;
  54981. var textHScale = current.textHScale * fontDirection;
  54982. var glyphsLength = glyphs.length;
  54983. var vertical = font.vertical;
  54984. var spacingDir = vertical ? 1 : -1;
  54985. var defaultVMetrics = font.defaultVMetrics;
  54986. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  54987. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  54988. ctx.save();
  54989. ctx.transform.apply(ctx, current.textMatrix);
  54990. ctx.translate(current.x, current.y + current.textRise);
  54991. if (current.patternFill) {
  54992. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  54993. }
  54994. if (fontDirection > 0) {
  54995. ctx.scale(textHScale, -1);
  54996. } else {
  54997. ctx.scale(textHScale, 1);
  54998. }
  54999. var lineWidth = current.lineWidth;
  55000. var scale = current.textMatrixScale;
  55001. if (scale === 0 || lineWidth === 0) {
  55002. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55003. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55004. this.cachedGetSinglePixelWidth = null;
  55005. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55006. }
  55007. } else {
  55008. lineWidth /= scale;
  55009. }
  55010. if (fontSizeScale !== 1.0) {
  55011. ctx.scale(fontSizeScale, fontSizeScale);
  55012. lineWidth /= fontSizeScale;
  55013. }
  55014. ctx.lineWidth = lineWidth;
  55015. var x = 0, i;
  55016. for (i = 0; i < glyphsLength; ++i) {
  55017. var glyph = glyphs[i];
  55018. if (isNum(glyph)) {
  55019. x += spacingDir * glyph * fontSize / 1000;
  55020. continue;
  55021. }
  55022. var restoreNeeded = false;
  55023. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55024. var character = glyph.fontChar;
  55025. var accent = glyph.accent;
  55026. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55027. var width = glyph.width;
  55028. if (vertical) {
  55029. var vmetric, vx, vy;
  55030. vmetric = glyph.vmetric || defaultVMetrics;
  55031. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55032. vx = -vx * widthAdvanceScale;
  55033. vy = vmetric[2] * widthAdvanceScale;
  55034. width = vmetric ? -vmetric[0] : width;
  55035. scaledX = vx / fontSizeScale;
  55036. scaledY = (x + vy) / fontSizeScale;
  55037. } else {
  55038. scaledX = x / fontSizeScale;
  55039. scaledY = 0;
  55040. }
  55041. if (font.remeasure && width > 0) {
  55042. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55043. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55044. var characterScaleX = width / measuredWidth;
  55045. restoreNeeded = true;
  55046. ctx.save();
  55047. ctx.scale(characterScaleX, 1);
  55048. scaledX /= characterScaleX;
  55049. } else if (width !== measuredWidth) {
  55050. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55051. }
  55052. }
  55053. if (glyph.isInFont || font.missingFile) {
  55054. if (simpleFillText && !accent) {
  55055. ctx.fillText(character, scaledX, scaledY);
  55056. } else {
  55057. this.paintChar(character, scaledX, scaledY);
  55058. if (accent) {
  55059. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55060. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55061. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55062. }
  55063. }
  55064. }
  55065. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55066. x += charWidth;
  55067. if (restoreNeeded) {
  55068. ctx.restore();
  55069. }
  55070. }
  55071. if (vertical) {
  55072. current.y -= x * textHScale;
  55073. } else {
  55074. current.x += x * textHScale;
  55075. }
  55076. ctx.restore();
  55077. },
  55078. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55079. var ctx = this.ctx;
  55080. var current = this.current;
  55081. var font = current.font;
  55082. var fontSize = current.fontSize;
  55083. var fontDirection = current.fontDirection;
  55084. var spacingDir = font.vertical ? 1 : -1;
  55085. var charSpacing = current.charSpacing;
  55086. var wordSpacing = current.wordSpacing;
  55087. var textHScale = current.textHScale * fontDirection;
  55088. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55089. var glyphsLength = glyphs.length;
  55090. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55091. var i, glyph, width, spacingLength;
  55092. if (isTextInvisible || fontSize === 0) {
  55093. return;
  55094. }
  55095. this.cachedGetSinglePixelWidth = null;
  55096. ctx.save();
  55097. ctx.transform.apply(ctx, current.textMatrix);
  55098. ctx.translate(current.x, current.y);
  55099. ctx.scale(textHScale, fontDirection);
  55100. for (i = 0; i < glyphsLength; ++i) {
  55101. glyph = glyphs[i];
  55102. if (isNum(glyph)) {
  55103. spacingLength = spacingDir * glyph * fontSize / 1000;
  55104. this.ctx.translate(spacingLength, 0);
  55105. current.x += spacingLength * textHScale;
  55106. continue;
  55107. }
  55108. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55109. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55110. if (!operatorList) {
  55111. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55112. continue;
  55113. }
  55114. this.processingType3 = glyph;
  55115. this.save();
  55116. ctx.scale(fontSize, fontSize);
  55117. ctx.transform.apply(ctx, fontMatrix);
  55118. this.executeOperatorList(operatorList);
  55119. this.restore();
  55120. var transformed = Util.applyTransform([
  55121. glyph.width,
  55122. 0
  55123. ], fontMatrix);
  55124. width = transformed[0] * fontSize + spacing;
  55125. ctx.translate(width, 0);
  55126. current.x += width * textHScale;
  55127. }
  55128. ctx.restore();
  55129. this.processingType3 = null;
  55130. },
  55131. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55132. },
  55133. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55134. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55135. this.clip();
  55136. this.endPath();
  55137. },
  55138. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55139. var pattern;
  55140. if (IR[0] === 'TilingPattern') {
  55141. var color = IR[1];
  55142. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55143. var self = this;
  55144. var canvasGraphicsFactory = {
  55145. createCanvasGraphics: function (ctx) {
  55146. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55147. }
  55148. };
  55149. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55150. } else {
  55151. pattern = getShadingPatternFromIR(IR);
  55152. }
  55153. return pattern;
  55154. },
  55155. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55156. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55157. },
  55158. setFillColorN: function CanvasGraphics_setFillColorN() {
  55159. this.current.fillColor = this.getColorN_Pattern(arguments);
  55160. this.current.patternFill = true;
  55161. },
  55162. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55163. var color = Util.makeCssRgb(r, g, b);
  55164. this.ctx.strokeStyle = color;
  55165. this.current.strokeColor = color;
  55166. },
  55167. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55168. var color = Util.makeCssRgb(r, g, b);
  55169. this.ctx.fillStyle = color;
  55170. this.current.fillColor = color;
  55171. this.current.patternFill = false;
  55172. },
  55173. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55174. var ctx = this.ctx;
  55175. this.save();
  55176. var pattern = getShadingPatternFromIR(patternIR);
  55177. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55178. var inv = ctx.mozCurrentTransformInverse;
  55179. if (inv) {
  55180. var canvas = ctx.canvas;
  55181. var width = canvas.width;
  55182. var height = canvas.height;
  55183. var bl = Util.applyTransform([
  55184. 0,
  55185. 0
  55186. ], inv);
  55187. var br = Util.applyTransform([
  55188. 0,
  55189. height
  55190. ], inv);
  55191. var ul = Util.applyTransform([
  55192. width,
  55193. 0
  55194. ], inv);
  55195. var ur = Util.applyTransform([
  55196. width,
  55197. height
  55198. ], inv);
  55199. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55200. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55201. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55202. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55203. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55204. } else {
  55205. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55206. }
  55207. this.restore();
  55208. },
  55209. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55210. error('Should not call beginInlineImage');
  55211. },
  55212. beginImageData: function CanvasGraphics_beginImageData() {
  55213. error('Should not call beginImageData');
  55214. },
  55215. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55216. this.save();
  55217. this.baseTransformStack.push(this.baseTransform);
  55218. if (isArray(matrix) && matrix.length === 6) {
  55219. this.transform.apply(this, matrix);
  55220. }
  55221. this.baseTransform = this.ctx.mozCurrentTransform;
  55222. if (isArray(bbox) && bbox.length === 4) {
  55223. var width = bbox[2] - bbox[0];
  55224. var height = bbox[3] - bbox[1];
  55225. this.ctx.rect(bbox[0], bbox[1], width, height);
  55226. this.clip();
  55227. this.endPath();
  55228. }
  55229. },
  55230. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55231. this.restore();
  55232. this.baseTransform = this.baseTransformStack.pop();
  55233. },
  55234. beginGroup: function CanvasGraphics_beginGroup(group) {
  55235. this.save();
  55236. var currentCtx = this.ctx;
  55237. if (!group.isolated) {
  55238. info('TODO: Support non-isolated groups.');
  55239. }
  55240. if (group.knockout) {
  55241. warn('Knockout groups not supported.');
  55242. }
  55243. var currentTransform = currentCtx.mozCurrentTransform;
  55244. if (group.matrix) {
  55245. currentCtx.transform.apply(currentCtx, group.matrix);
  55246. }
  55247. assert(group.bbox, 'Bounding box is required.');
  55248. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55249. var canvasBounds = [
  55250. 0,
  55251. 0,
  55252. currentCtx.canvas.width,
  55253. currentCtx.canvas.height
  55254. ];
  55255. bounds = Util.intersect(bounds, canvasBounds) || [
  55256. 0,
  55257. 0,
  55258. 0,
  55259. 0
  55260. ];
  55261. var offsetX = Math.floor(bounds[0]);
  55262. var offsetY = Math.floor(bounds[1]);
  55263. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55264. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55265. var scaleX = 1, scaleY = 1;
  55266. if (drawnWidth > MAX_GROUP_SIZE) {
  55267. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55268. drawnWidth = MAX_GROUP_SIZE;
  55269. }
  55270. if (drawnHeight > MAX_GROUP_SIZE) {
  55271. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55272. drawnHeight = MAX_GROUP_SIZE;
  55273. }
  55274. var cacheId = 'groupAt' + this.groupLevel;
  55275. if (group.smask) {
  55276. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55277. }
  55278. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55279. var groupCtx = scratchCanvas.context;
  55280. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55281. groupCtx.translate(-offsetX, -offsetY);
  55282. groupCtx.transform.apply(groupCtx, currentTransform);
  55283. if (group.smask) {
  55284. this.smaskStack.push({
  55285. canvas: scratchCanvas.canvas,
  55286. context: groupCtx,
  55287. offsetX: offsetX,
  55288. offsetY: offsetY,
  55289. scaleX: scaleX,
  55290. scaleY: scaleY,
  55291. subtype: group.smask.subtype,
  55292. backdrop: group.smask.backdrop,
  55293. transferMap: group.smask.transferMap || null,
  55294. startTransformInverse: null
  55295. });
  55296. } else {
  55297. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55298. currentCtx.translate(offsetX, offsetY);
  55299. currentCtx.scale(scaleX, scaleY);
  55300. }
  55301. copyCtxState(currentCtx, groupCtx);
  55302. this.ctx = groupCtx;
  55303. this.setGState([
  55304. [
  55305. 'BM',
  55306. 'Normal'
  55307. ],
  55308. [
  55309. 'ca',
  55310. 1
  55311. ],
  55312. [
  55313. 'CA',
  55314. 1
  55315. ]
  55316. ]);
  55317. this.groupStack.push(currentCtx);
  55318. this.groupLevel++;
  55319. this.current.activeSMask = null;
  55320. },
  55321. endGroup: function CanvasGraphics_endGroup(group) {
  55322. this.groupLevel--;
  55323. var groupCtx = this.ctx;
  55324. this.ctx = this.groupStack.pop();
  55325. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55326. this.ctx.imageSmoothingEnabled = false;
  55327. } else {
  55328. this.ctx.mozImageSmoothingEnabled = false;
  55329. }
  55330. if (group.smask) {
  55331. this.tempSMask = this.smaskStack.pop();
  55332. } else {
  55333. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55334. }
  55335. this.restore();
  55336. },
  55337. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55338. this.save();
  55339. this.current = new CanvasExtraState();
  55340. if (this.baseTransform) {
  55341. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55342. }
  55343. },
  55344. endAnnotations: function CanvasGraphics_endAnnotations() {
  55345. this.restore();
  55346. },
  55347. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55348. this.save();
  55349. if (isArray(rect) && rect.length === 4) {
  55350. var width = rect[2] - rect[0];
  55351. var height = rect[3] - rect[1];
  55352. this.ctx.rect(rect[0], rect[1], width, height);
  55353. this.clip();
  55354. this.endPath();
  55355. }
  55356. this.transform.apply(this, transform);
  55357. this.transform.apply(this, matrix);
  55358. },
  55359. endAnnotation: function CanvasGraphics_endAnnotation() {
  55360. this.restore();
  55361. },
  55362. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55363. var domImage = this.objs.get(objId);
  55364. if (!domImage) {
  55365. warn('Dependent image isn\'t ready yet');
  55366. return;
  55367. }
  55368. this.save();
  55369. var ctx = this.ctx;
  55370. ctx.scale(1 / w, -1 / h);
  55371. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55372. if (this.imageLayer) {
  55373. var currentTransform = ctx.mozCurrentTransformInverse;
  55374. var position = this.getCanvasPosition(0, 0);
  55375. this.imageLayer.appendImage({
  55376. objId: objId,
  55377. left: position[0],
  55378. top: position[1],
  55379. width: w / currentTransform[0],
  55380. height: h / currentTransform[3]
  55381. });
  55382. }
  55383. this.restore();
  55384. },
  55385. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55386. var ctx = this.ctx;
  55387. var width = img.width, height = img.height;
  55388. var fillColor = this.current.fillColor;
  55389. var isPatternFill = this.current.patternFill;
  55390. var glyph = this.processingType3;
  55391. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55392. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55393. glyph.compiled = compileType3Glyph({
  55394. data: img.data,
  55395. width: width,
  55396. height: height
  55397. });
  55398. } else {
  55399. glyph.compiled = null;
  55400. }
  55401. }
  55402. if (glyph && glyph.compiled) {
  55403. glyph.compiled(ctx);
  55404. return;
  55405. }
  55406. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55407. var maskCtx = maskCanvas.context;
  55408. maskCtx.save();
  55409. putBinaryImageMask(maskCtx, img);
  55410. maskCtx.globalCompositeOperation = 'source-in';
  55411. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55412. maskCtx.fillRect(0, 0, width, height);
  55413. maskCtx.restore();
  55414. this.paintInlineImageXObject(maskCanvas.canvas);
  55415. },
  55416. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55417. var width = imgData.width;
  55418. var height = imgData.height;
  55419. var fillColor = this.current.fillColor;
  55420. var isPatternFill = this.current.patternFill;
  55421. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55422. var maskCtx = maskCanvas.context;
  55423. maskCtx.save();
  55424. putBinaryImageMask(maskCtx, imgData);
  55425. maskCtx.globalCompositeOperation = 'source-in';
  55426. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55427. maskCtx.fillRect(0, 0, width, height);
  55428. maskCtx.restore();
  55429. var ctx = this.ctx;
  55430. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55431. ctx.save();
  55432. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55433. ctx.scale(1, -1);
  55434. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55435. ctx.restore();
  55436. }
  55437. },
  55438. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55439. var ctx = this.ctx;
  55440. var fillColor = this.current.fillColor;
  55441. var isPatternFill = this.current.patternFill;
  55442. for (var i = 0, ii = images.length; i < ii; i++) {
  55443. var image = images[i];
  55444. var width = image.width, height = image.height;
  55445. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55446. var maskCtx = maskCanvas.context;
  55447. maskCtx.save();
  55448. putBinaryImageMask(maskCtx, image);
  55449. maskCtx.globalCompositeOperation = 'source-in';
  55450. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55451. maskCtx.fillRect(0, 0, width, height);
  55452. maskCtx.restore();
  55453. ctx.save();
  55454. ctx.transform.apply(ctx, image.transform);
  55455. ctx.scale(1, -1);
  55456. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55457. ctx.restore();
  55458. }
  55459. },
  55460. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55461. var imgData = this.objs.get(objId);
  55462. if (!imgData) {
  55463. warn('Dependent image isn\'t ready yet');
  55464. return;
  55465. }
  55466. this.paintInlineImageXObject(imgData);
  55467. },
  55468. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55469. var imgData = this.objs.get(objId);
  55470. if (!imgData) {
  55471. warn('Dependent image isn\'t ready yet');
  55472. return;
  55473. }
  55474. var width = imgData.width;
  55475. var height = imgData.height;
  55476. var map = [];
  55477. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55478. map.push({
  55479. transform: [
  55480. scaleX,
  55481. 0,
  55482. 0,
  55483. scaleY,
  55484. positions[i],
  55485. positions[i + 1]
  55486. ],
  55487. x: 0,
  55488. y: 0,
  55489. w: width,
  55490. h: height
  55491. });
  55492. }
  55493. this.paintInlineImageXObjectGroup(imgData, map);
  55494. },
  55495. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55496. var width = imgData.width;
  55497. var height = imgData.height;
  55498. var ctx = this.ctx;
  55499. this.save();
  55500. ctx.scale(1 / width, -1 / height);
  55501. var currentTransform = ctx.mozCurrentTransformInverse;
  55502. var a = currentTransform[0], b = currentTransform[1];
  55503. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55504. var c = currentTransform[2], d = currentTransform[3];
  55505. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55506. var imgToPaint, tmpCanvas;
  55507. if (imgData instanceof HTMLElement || !imgData.data) {
  55508. imgToPaint = imgData;
  55509. } else {
  55510. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55511. var tmpCtx = tmpCanvas.context;
  55512. putBinaryImageData(tmpCtx, imgData);
  55513. imgToPaint = tmpCanvas.canvas;
  55514. }
  55515. var paintWidth = width, paintHeight = height;
  55516. var tmpCanvasId = 'prescale1';
  55517. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55518. var newWidth = paintWidth, newHeight = paintHeight;
  55519. if (widthScale > 2 && paintWidth > 1) {
  55520. newWidth = Math.ceil(paintWidth / 2);
  55521. widthScale /= paintWidth / newWidth;
  55522. }
  55523. if (heightScale > 2 && paintHeight > 1) {
  55524. newHeight = Math.ceil(paintHeight / 2);
  55525. heightScale /= paintHeight / newHeight;
  55526. }
  55527. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55528. tmpCtx = tmpCanvas.context;
  55529. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55530. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55531. imgToPaint = tmpCanvas.canvas;
  55532. paintWidth = newWidth;
  55533. paintHeight = newHeight;
  55534. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55535. }
  55536. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55537. if (this.imageLayer) {
  55538. var position = this.getCanvasPosition(0, -height);
  55539. this.imageLayer.appendImage({
  55540. imgData: imgData,
  55541. left: position[0],
  55542. top: position[1],
  55543. width: width / currentTransform[0],
  55544. height: height / currentTransform[3]
  55545. });
  55546. }
  55547. this.restore();
  55548. },
  55549. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55550. var ctx = this.ctx;
  55551. var w = imgData.width;
  55552. var h = imgData.height;
  55553. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55554. var tmpCtx = tmpCanvas.context;
  55555. putBinaryImageData(tmpCtx, imgData);
  55556. for (var i = 0, ii = map.length; i < ii; i++) {
  55557. var entry = map[i];
  55558. ctx.save();
  55559. ctx.transform.apply(ctx, entry.transform);
  55560. ctx.scale(1, -1);
  55561. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55562. if (this.imageLayer) {
  55563. var position = this.getCanvasPosition(entry.x, entry.y);
  55564. this.imageLayer.appendImage({
  55565. imgData: imgData,
  55566. left: position[0],
  55567. top: position[1],
  55568. width: w,
  55569. height: h
  55570. });
  55571. }
  55572. ctx.restore();
  55573. }
  55574. },
  55575. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55576. this.ctx.fillRect(0, 0, 1, 1);
  55577. },
  55578. paintXObject: function CanvasGraphics_paintXObject() {
  55579. warn('Unsupported \'paintXObject\' command.');
  55580. },
  55581. markPoint: function CanvasGraphics_markPoint(tag) {
  55582. },
  55583. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55584. },
  55585. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55586. },
  55587. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55588. },
  55589. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55590. },
  55591. beginCompat: function CanvasGraphics_beginCompat() {
  55592. },
  55593. endCompat: function CanvasGraphics_endCompat() {
  55594. },
  55595. consumePath: function CanvasGraphics_consumePath() {
  55596. var ctx = this.ctx;
  55597. if (this.pendingClip) {
  55598. if (this.pendingClip === EO_CLIP) {
  55599. ctx.clip('evenodd');
  55600. } else {
  55601. ctx.clip();
  55602. }
  55603. this.pendingClip = null;
  55604. }
  55605. ctx.beginPath();
  55606. },
  55607. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55608. if (this.cachedGetSinglePixelWidth === null) {
  55609. this.ctx.save();
  55610. var inverse = this.ctx.mozCurrentTransformInverse;
  55611. this.ctx.restore();
  55612. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55613. }
  55614. return this.cachedGetSinglePixelWidth;
  55615. },
  55616. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55617. var transform = this.ctx.mozCurrentTransform;
  55618. return [
  55619. transform[0] * x + transform[2] * y + transform[4],
  55620. transform[1] * x + transform[3] * y + transform[5]
  55621. ];
  55622. }
  55623. };
  55624. for (var op in OPS) {
  55625. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55626. }
  55627. return CanvasGraphics;
  55628. }();
  55629. exports.CanvasGraphics = CanvasGraphics;
  55630. /***/ }),
  55631. /* 45 */
  55632. /***/ (function(module, exports, __w_pdfjs_require__) {
  55633. "use strict";
  55634. var sharedUtil = __w_pdfjs_require__(0);
  55635. var assert = sharedUtil.assert;
  55636. var bytesToString = sharedUtil.bytesToString;
  55637. var string32 = sharedUtil.string32;
  55638. var shadow = sharedUtil.shadow;
  55639. var warn = sharedUtil.warn;
  55640. function FontLoader(docId) {
  55641. this.docId = docId;
  55642. this.styleElement = null;
  55643. this.nativeFontFaces = [];
  55644. this.loadTestFontId = 0;
  55645. this.loadingContext = {
  55646. requests: [],
  55647. nextRequestId: 0
  55648. };
  55649. }
  55650. FontLoader.prototype = {
  55651. insertRule: function fontLoaderInsertRule(rule) {
  55652. var styleElement = this.styleElement;
  55653. if (!styleElement) {
  55654. styleElement = this.styleElement = document.createElement('style');
  55655. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55656. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55657. }
  55658. var styleSheet = styleElement.sheet;
  55659. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55660. },
  55661. clear: function fontLoaderClear() {
  55662. if (this.styleElement) {
  55663. this.styleElement.remove();
  55664. this.styleElement = null;
  55665. }
  55666. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55667. document.fonts.delete(nativeFontFace);
  55668. });
  55669. this.nativeFontFaces.length = 0;
  55670. }
  55671. };
  55672. var getLoadTestFont = function () {
  55673. 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==');
  55674. };
  55675. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55676. get: function () {
  55677. return shadow(this, 'loadTestFont', getLoadTestFont());
  55678. },
  55679. configurable: true
  55680. });
  55681. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55682. this.nativeFontFaces.push(nativeFontFace);
  55683. document.fonts.add(nativeFontFace);
  55684. };
  55685. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55686. var rules = [];
  55687. var fontsToLoad = [];
  55688. var fontLoadPromises = [];
  55689. var getNativeFontPromise = function (nativeFontFace) {
  55690. return nativeFontFace.loaded.catch(function (e) {
  55691. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55692. });
  55693. };
  55694. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55695. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55696. var font = fonts[i];
  55697. if (font.attached || font.loading === false) {
  55698. continue;
  55699. }
  55700. font.attached = true;
  55701. if (isFontLoadingAPISupported) {
  55702. var nativeFontFace = font.createNativeFontFace();
  55703. if (nativeFontFace) {
  55704. this.addNativeFontFace(nativeFontFace);
  55705. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55706. }
  55707. } else {
  55708. var rule = font.createFontFaceRule();
  55709. if (rule) {
  55710. this.insertRule(rule);
  55711. rules.push(rule);
  55712. fontsToLoad.push(font);
  55713. }
  55714. }
  55715. }
  55716. var request = this.queueLoadingCallback(callback);
  55717. if (isFontLoadingAPISupported) {
  55718. Promise.all(fontLoadPromises).then(function () {
  55719. request.complete();
  55720. });
  55721. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55722. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55723. } else {
  55724. request.complete();
  55725. }
  55726. };
  55727. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55728. function LoadLoader_completeRequest() {
  55729. assert(!request.end, 'completeRequest() cannot be called twice');
  55730. request.end = Date.now();
  55731. while (context.requests.length > 0 && context.requests[0].end) {
  55732. var otherRequest = context.requests.shift();
  55733. setTimeout(otherRequest.callback, 0);
  55734. }
  55735. }
  55736. var context = this.loadingContext;
  55737. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55738. var request = {
  55739. id: requestId,
  55740. complete: LoadLoader_completeRequest,
  55741. callback: callback,
  55742. started: Date.now()
  55743. };
  55744. context.requests.push(request);
  55745. return request;
  55746. };
  55747. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55748. function int32(data, offset) {
  55749. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55750. }
  55751. function spliceString(s, offset, remove, insert) {
  55752. var chunk1 = s.substr(0, offset);
  55753. var chunk2 = s.substr(offset + remove);
  55754. return chunk1 + insert + chunk2;
  55755. }
  55756. var i, ii;
  55757. var canvas = document.createElement('canvas');
  55758. canvas.width = 1;
  55759. canvas.height = 1;
  55760. var ctx = canvas.getContext('2d');
  55761. var called = 0;
  55762. function isFontReady(name, callback) {
  55763. called++;
  55764. if (called > 30) {
  55765. warn('Load test font never loaded.');
  55766. callback();
  55767. return;
  55768. }
  55769. ctx.font = '30px ' + name;
  55770. ctx.fillText('.', 0, 20);
  55771. var imageData = ctx.getImageData(0, 0, 1, 1);
  55772. if (imageData.data[3] > 0) {
  55773. callback();
  55774. return;
  55775. }
  55776. setTimeout(isFontReady.bind(null, name, callback));
  55777. }
  55778. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55779. var data = this.loadTestFont;
  55780. var COMMENT_OFFSET = 976;
  55781. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55782. var CFF_CHECKSUM_OFFSET = 16;
  55783. var XXXX_VALUE = 0x58585858;
  55784. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55785. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55786. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55787. }
  55788. if (i < loadTestFontId.length) {
  55789. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55790. }
  55791. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55792. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55793. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55794. this.insertRule(rule);
  55795. var names = [];
  55796. for (i = 0, ii = fonts.length; i < ii; i++) {
  55797. names.push(fonts[i].loadedName);
  55798. }
  55799. names.push(loadTestFontId);
  55800. var div = document.createElement('div');
  55801. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55802. for (i = 0, ii = names.length; i < ii; ++i) {
  55803. var span = document.createElement('span');
  55804. span.textContent = 'Hi';
  55805. span.style.fontFamily = names[i];
  55806. div.appendChild(span);
  55807. }
  55808. document.body.appendChild(div);
  55809. isFontReady(loadTestFontId, function () {
  55810. document.body.removeChild(div);
  55811. request.complete();
  55812. });
  55813. };
  55814. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55815. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55816. if (typeof navigator === 'undefined') {
  55817. return true;
  55818. }
  55819. var supported = false;
  55820. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55821. if (m && m[1] >= 14) {
  55822. supported = true;
  55823. }
  55824. return supported;
  55825. };
  55826. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55827. get: function () {
  55828. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55829. },
  55830. enumerable: true,
  55831. configurable: true
  55832. });
  55833. var IsEvalSupportedCached = {
  55834. get value() {
  55835. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55836. }
  55837. };
  55838. var FontFaceObject = function FontFaceObjectClosure() {
  55839. function FontFaceObject(translatedData, options) {
  55840. this.compiledGlyphs = Object.create(null);
  55841. for (var i in translatedData) {
  55842. this[i] = translatedData[i];
  55843. }
  55844. this.options = options;
  55845. }
  55846. FontFaceObject.prototype = {
  55847. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55848. if (!this.data) {
  55849. return null;
  55850. }
  55851. if (this.options.disableFontFace) {
  55852. this.disableFontFace = true;
  55853. return null;
  55854. }
  55855. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55856. if (this.options.fontRegistry) {
  55857. this.options.fontRegistry.registerFont(this);
  55858. }
  55859. return nativeFontFace;
  55860. },
  55861. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55862. if (!this.data) {
  55863. return null;
  55864. }
  55865. if (this.options.disableFontFace) {
  55866. this.disableFontFace = true;
  55867. return null;
  55868. }
  55869. var data = bytesToString(new Uint8Array(this.data));
  55870. var fontName = this.loadedName;
  55871. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55872. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55873. if (this.options.fontRegistry) {
  55874. this.options.fontRegistry.registerFont(this, url);
  55875. }
  55876. return rule;
  55877. },
  55878. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55879. if (!(character in this.compiledGlyphs)) {
  55880. var cmds = objs.get(this.loadedName + '_path_' + character);
  55881. var current, i, len;
  55882. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55883. var args, js = '';
  55884. for (i = 0, len = cmds.length; i < len; i++) {
  55885. current = cmds[i];
  55886. if (current.args !== undefined) {
  55887. args = current.args.join(',');
  55888. } else {
  55889. args = '';
  55890. }
  55891. js += 'c.' + current.cmd + '(' + args + ');\n';
  55892. }
  55893. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55894. } else {
  55895. this.compiledGlyphs[character] = function (c, size) {
  55896. for (i = 0, len = cmds.length; i < len; i++) {
  55897. current = cmds[i];
  55898. if (current.cmd === 'scale') {
  55899. current.args = [
  55900. size,
  55901. -size
  55902. ];
  55903. }
  55904. c[current.cmd].apply(c, current.args);
  55905. }
  55906. };
  55907. }
  55908. }
  55909. return this.compiledGlyphs[character];
  55910. }
  55911. };
  55912. return FontFaceObject;
  55913. }();
  55914. exports.FontFaceObject = FontFaceObject;
  55915. exports.FontLoader = FontLoader;
  55916. /***/ }),
  55917. /* 46 */
  55918. /***/ (function(module, exports, __w_pdfjs_require__) {
  55919. "use strict";
  55920. var sharedUtil = __w_pdfjs_require__(0);
  55921. var displayWebGL = __w_pdfjs_require__(25);
  55922. var Util = sharedUtil.Util;
  55923. var info = sharedUtil.info;
  55924. var isArray = sharedUtil.isArray;
  55925. var error = sharedUtil.error;
  55926. var WebGLUtils = displayWebGL.WebGLUtils;
  55927. var ShadingIRs = {};
  55928. ShadingIRs.RadialAxial = {
  55929. fromIR: function RadialAxial_fromIR(raw) {
  55930. var type = raw[1];
  55931. var colorStops = raw[2];
  55932. var p0 = raw[3];
  55933. var p1 = raw[4];
  55934. var r0 = raw[5];
  55935. var r1 = raw[6];
  55936. return {
  55937. type: 'Pattern',
  55938. getPattern: function RadialAxial_getPattern(ctx) {
  55939. var grad;
  55940. if (type === 'axial') {
  55941. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55942. } else if (type === 'radial') {
  55943. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55944. }
  55945. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55946. var c = colorStops[i];
  55947. grad.addColorStop(c[0], c[1]);
  55948. }
  55949. return grad;
  55950. }
  55951. };
  55952. }
  55953. };
  55954. var createMeshCanvas = function createMeshCanvasClosure() {
  55955. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55956. var coords = context.coords, colors = context.colors;
  55957. var bytes = data.data, rowSize = data.width * 4;
  55958. var tmp;
  55959. if (coords[p1 + 1] > coords[p2 + 1]) {
  55960. tmp = p1;
  55961. p1 = p2;
  55962. p2 = tmp;
  55963. tmp = c1;
  55964. c1 = c2;
  55965. c2 = tmp;
  55966. }
  55967. if (coords[p2 + 1] > coords[p3 + 1]) {
  55968. tmp = p2;
  55969. p2 = p3;
  55970. p3 = tmp;
  55971. tmp = c2;
  55972. c2 = c3;
  55973. c3 = tmp;
  55974. }
  55975. if (coords[p1 + 1] > coords[p2 + 1]) {
  55976. tmp = p1;
  55977. p1 = p2;
  55978. p2 = tmp;
  55979. tmp = c1;
  55980. c1 = c2;
  55981. c2 = tmp;
  55982. }
  55983. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  55984. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  55985. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  55986. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  55987. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  55988. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  55989. if (y1 >= y3) {
  55990. return;
  55991. }
  55992. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  55993. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  55994. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  55995. var minY = Math.round(y1), maxY = Math.round(y3);
  55996. var xa, car, cag, cab;
  55997. var xb, cbr, cbg, cbb;
  55998. var k;
  55999. for (var y = minY; y <= maxY; y++) {
  56000. if (y < y2) {
  56001. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56002. xa = x1 - (x1 - x2) * k;
  56003. car = c1r - (c1r - c2r) * k;
  56004. cag = c1g - (c1g - c2g) * k;
  56005. cab = c1b - (c1b - c2b) * k;
  56006. } else {
  56007. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56008. xa = x2 - (x2 - x3) * k;
  56009. car = c2r - (c2r - c3r) * k;
  56010. cag = c2g - (c2g - c3g) * k;
  56011. cab = c2b - (c2b - c3b) * k;
  56012. }
  56013. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56014. xb = x1 - (x1 - x3) * k;
  56015. cbr = c1r - (c1r - c3r) * k;
  56016. cbg = c1g - (c1g - c3g) * k;
  56017. cbb = c1b - (c1b - c3b) * k;
  56018. var x1_ = Math.round(Math.min(xa, xb));
  56019. var x2_ = Math.round(Math.max(xa, xb));
  56020. var j = rowSize * y + x1_ * 4;
  56021. for (var x = x1_; x <= x2_; x++) {
  56022. k = (xa - x) / (xa - xb);
  56023. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56024. bytes[j++] = car - (car - cbr) * k | 0;
  56025. bytes[j++] = cag - (cag - cbg) * k | 0;
  56026. bytes[j++] = cab - (cab - cbb) * k | 0;
  56027. bytes[j++] = 255;
  56028. }
  56029. }
  56030. }
  56031. function drawFigure(data, figure, context) {
  56032. var ps = figure.coords;
  56033. var cs = figure.colors;
  56034. var i, ii;
  56035. switch (figure.type) {
  56036. case 'lattice':
  56037. var verticesPerRow = figure.verticesPerRow;
  56038. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56039. var cols = verticesPerRow - 1;
  56040. for (i = 0; i < rows; i++) {
  56041. var q = i * verticesPerRow;
  56042. for (var j = 0; j < cols; j++, q++) {
  56043. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56044. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56045. }
  56046. }
  56047. break;
  56048. case 'triangles':
  56049. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56050. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56051. }
  56052. break;
  56053. default:
  56054. error('illigal figure');
  56055. break;
  56056. }
  56057. }
  56058. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56059. var EXPECTED_SCALE = 1.1;
  56060. var MAX_PATTERN_SIZE = 3000;
  56061. var BORDER_SIZE = 2;
  56062. var offsetX = Math.floor(bounds[0]);
  56063. var offsetY = Math.floor(bounds[1]);
  56064. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56065. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56066. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56067. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56068. var scaleX = boundsWidth / width;
  56069. var scaleY = boundsHeight / height;
  56070. var context = {
  56071. coords: coords,
  56072. colors: colors,
  56073. offsetX: -offsetX,
  56074. offsetY: -offsetY,
  56075. scaleX: 1 / scaleX,
  56076. scaleY: 1 / scaleY
  56077. };
  56078. var paddedWidth = width + BORDER_SIZE * 2;
  56079. var paddedHeight = height + BORDER_SIZE * 2;
  56080. var canvas, tmpCanvas, i, ii;
  56081. if (WebGLUtils.isEnabled) {
  56082. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56083. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56084. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56085. canvas = tmpCanvas.canvas;
  56086. } else {
  56087. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56088. var tmpCtx = tmpCanvas.context;
  56089. var data = tmpCtx.createImageData(width, height);
  56090. if (backgroundColor) {
  56091. var bytes = data.data;
  56092. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56093. bytes[i] = backgroundColor[0];
  56094. bytes[i + 1] = backgroundColor[1];
  56095. bytes[i + 2] = backgroundColor[2];
  56096. bytes[i + 3] = 255;
  56097. }
  56098. }
  56099. for (i = 0; i < figures.length; i++) {
  56100. drawFigure(data, figures[i], context);
  56101. }
  56102. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56103. canvas = tmpCanvas.canvas;
  56104. }
  56105. return {
  56106. canvas: canvas,
  56107. offsetX: offsetX - BORDER_SIZE * scaleX,
  56108. offsetY: offsetY - BORDER_SIZE * scaleY,
  56109. scaleX: scaleX,
  56110. scaleY: scaleY
  56111. };
  56112. }
  56113. return createMeshCanvas;
  56114. }();
  56115. ShadingIRs.Mesh = {
  56116. fromIR: function Mesh_fromIR(raw) {
  56117. var coords = raw[2];
  56118. var colors = raw[3];
  56119. var figures = raw[4];
  56120. var bounds = raw[5];
  56121. var matrix = raw[6];
  56122. var background = raw[8];
  56123. return {
  56124. type: 'Pattern',
  56125. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56126. var scale;
  56127. if (shadingFill) {
  56128. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56129. } else {
  56130. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56131. if (matrix) {
  56132. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56133. scale = [
  56134. scale[0] * matrixScale[0],
  56135. scale[1] * matrixScale[1]
  56136. ];
  56137. }
  56138. }
  56139. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56140. if (!shadingFill) {
  56141. ctx.setTransform.apply(ctx, owner.baseTransform);
  56142. if (matrix) {
  56143. ctx.transform.apply(ctx, matrix);
  56144. }
  56145. }
  56146. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56147. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56148. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56149. }
  56150. };
  56151. }
  56152. };
  56153. ShadingIRs.Dummy = {
  56154. fromIR: function Dummy_fromIR() {
  56155. return {
  56156. type: 'Pattern',
  56157. getPattern: function Dummy_fromIR_getPattern() {
  56158. return 'hotpink';
  56159. }
  56160. };
  56161. }
  56162. };
  56163. function getShadingPatternFromIR(raw) {
  56164. var shadingIR = ShadingIRs[raw[0]];
  56165. if (!shadingIR) {
  56166. error('Unknown IR type: ' + raw[0]);
  56167. }
  56168. return shadingIR.fromIR(raw);
  56169. }
  56170. var TilingPattern = function TilingPatternClosure() {
  56171. var PaintType = {
  56172. COLORED: 1,
  56173. UNCOLORED: 2
  56174. };
  56175. var MAX_PATTERN_SIZE = 3000;
  56176. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56177. this.operatorList = IR[2];
  56178. this.matrix = IR[3] || [
  56179. 1,
  56180. 0,
  56181. 0,
  56182. 1,
  56183. 0,
  56184. 0
  56185. ];
  56186. this.bbox = IR[4];
  56187. this.xstep = IR[5];
  56188. this.ystep = IR[6];
  56189. this.paintType = IR[7];
  56190. this.tilingType = IR[8];
  56191. this.color = color;
  56192. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56193. this.baseTransform = baseTransform;
  56194. this.type = 'Pattern';
  56195. this.ctx = ctx;
  56196. }
  56197. TilingPattern.prototype = {
  56198. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56199. var operatorList = this.operatorList;
  56200. var bbox = this.bbox;
  56201. var xstep = this.xstep;
  56202. var ystep = this.ystep;
  56203. var paintType = this.paintType;
  56204. var tilingType = this.tilingType;
  56205. var color = this.color;
  56206. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56207. info('TilingType: ' + tilingType);
  56208. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56209. var topLeft = [
  56210. x0,
  56211. y0
  56212. ];
  56213. var botRight = [
  56214. x0 + xstep,
  56215. y0 + ystep
  56216. ];
  56217. var width = botRight[0] - topLeft[0];
  56218. var height = botRight[1] - topLeft[1];
  56219. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56220. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56221. var combinedScale = [
  56222. matrixScale[0] * curMatrixScale[0],
  56223. matrixScale[1] * curMatrixScale[1]
  56224. ];
  56225. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56226. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56227. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56228. var tmpCtx = tmpCanvas.context;
  56229. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56230. graphics.groupLevel = owner.groupLevel;
  56231. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56232. this.setScale(width, height, xstep, ystep);
  56233. this.transformToScale(graphics);
  56234. var tmpTranslate = [
  56235. 1,
  56236. 0,
  56237. 0,
  56238. 1,
  56239. -topLeft[0],
  56240. -topLeft[1]
  56241. ];
  56242. graphics.transform.apply(graphics, tmpTranslate);
  56243. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56244. graphics.executeOperatorList(operatorList);
  56245. return tmpCanvas.canvas;
  56246. },
  56247. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56248. this.scale = [
  56249. width / xstep,
  56250. height / ystep
  56251. ];
  56252. },
  56253. transformToScale: function TilingPattern_transformToScale(graphics) {
  56254. var scale = this.scale;
  56255. var tmpScale = [
  56256. scale[0],
  56257. 0,
  56258. 0,
  56259. scale[1],
  56260. 0,
  56261. 0
  56262. ];
  56263. graphics.transform.apply(graphics, tmpScale);
  56264. },
  56265. scaleToContext: function TilingPattern_scaleToContext() {
  56266. var scale = this.scale;
  56267. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56268. },
  56269. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56270. if (bbox && isArray(bbox) && bbox.length === 4) {
  56271. var bboxWidth = x1 - x0;
  56272. var bboxHeight = y1 - y0;
  56273. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56274. graphics.clip();
  56275. graphics.endPath();
  56276. }
  56277. },
  56278. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56279. switch (paintType) {
  56280. case PaintType.COLORED:
  56281. var ctx = this.ctx;
  56282. context.fillStyle = ctx.fillStyle;
  56283. context.strokeStyle = ctx.strokeStyle;
  56284. break;
  56285. case PaintType.UNCOLORED:
  56286. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56287. context.fillStyle = cssColor;
  56288. context.strokeStyle = cssColor;
  56289. break;
  56290. default:
  56291. error('Unsupported paint type: ' + paintType);
  56292. }
  56293. },
  56294. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56295. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56296. ctx = this.ctx;
  56297. ctx.setTransform.apply(ctx, this.baseTransform);
  56298. ctx.transform.apply(ctx, this.matrix);
  56299. this.scaleToContext();
  56300. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56301. }
  56302. };
  56303. return TilingPattern;
  56304. }();
  56305. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56306. exports.TilingPattern = TilingPattern;
  56307. /***/ }),
  56308. /* 47 */
  56309. /***/ (function(module, exports, __w_pdfjs_require__) {
  56310. "use strict";
  56311. /* WEBPACK VAR INJECTION */(function(global) {
  56312. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56313. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56314. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56315. var isAndroid = /Android/.test(userAgent);
  56316. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56317. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56318. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56319. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56320. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56321. var isIE = userAgent.indexOf('Trident') >= 0;
  56322. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56323. var isOpera = userAgent.indexOf('Opera') >= 0;
  56324. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56325. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56326. if (typeof PDFJS === 'undefined') {
  56327. globalScope.PDFJS = {};
  56328. }
  56329. PDFJS.compatibilityChecked = true;
  56330. (function checkTypedArrayCompatibility() {
  56331. if (typeof Uint8Array !== 'undefined') {
  56332. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56333. Uint8Array.prototype.subarray = function subarray(start, end) {
  56334. return new Uint8Array(this.slice(start, end));
  56335. };
  56336. Float32Array.prototype.subarray = function subarray(start, end) {
  56337. return new Float32Array(this.slice(start, end));
  56338. };
  56339. }
  56340. if (typeof Float64Array === 'undefined') {
  56341. globalScope.Float64Array = Float32Array;
  56342. }
  56343. return;
  56344. }
  56345. function subarray(start, end) {
  56346. return new TypedArray(this.slice(start, end));
  56347. }
  56348. function setArrayOffset(array, offset) {
  56349. if (arguments.length < 2) {
  56350. offset = 0;
  56351. }
  56352. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56353. this[offset] = array[i] & 0xFF;
  56354. }
  56355. }
  56356. function TypedArray(arg1) {
  56357. var result, i, n;
  56358. if (typeof arg1 === 'number') {
  56359. result = [];
  56360. for (i = 0; i < arg1; ++i) {
  56361. result[i] = 0;
  56362. }
  56363. } else if ('slice' in arg1) {
  56364. result = arg1.slice(0);
  56365. } else {
  56366. result = [];
  56367. for (i = 0, n = arg1.length; i < n; ++i) {
  56368. result[i] = arg1[i];
  56369. }
  56370. }
  56371. result.subarray = subarray;
  56372. result.buffer = result;
  56373. result.byteLength = result.length;
  56374. result.set = setArrayOffset;
  56375. if (typeof arg1 === 'object' && arg1.buffer) {
  56376. result.buffer = arg1.buffer;
  56377. }
  56378. return result;
  56379. }
  56380. globalScope.Uint8Array = TypedArray;
  56381. globalScope.Int8Array = TypedArray;
  56382. globalScope.Uint32Array = TypedArray;
  56383. globalScope.Int32Array = TypedArray;
  56384. globalScope.Uint16Array = TypedArray;
  56385. globalScope.Float32Array = TypedArray;
  56386. globalScope.Float64Array = TypedArray;
  56387. }());
  56388. (function normalizeURLObject() {
  56389. if (!globalScope.URL) {
  56390. globalScope.URL = globalScope.webkitURL;
  56391. }
  56392. }());
  56393. (function checkObjectDefinePropertyCompatibility() {
  56394. if (typeof Object.defineProperty !== 'undefined') {
  56395. var definePropertyPossible = true;
  56396. try {
  56397. if (hasDOM) {
  56398. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56399. }
  56400. var Test = function Test() {
  56401. };
  56402. Test.prototype = {
  56403. get id() {
  56404. }
  56405. };
  56406. Object.defineProperty(new Test(), 'id', {
  56407. value: '',
  56408. configurable: true,
  56409. enumerable: true,
  56410. writable: false
  56411. });
  56412. } catch (e) {
  56413. definePropertyPossible = false;
  56414. }
  56415. if (definePropertyPossible) {
  56416. return;
  56417. }
  56418. }
  56419. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56420. delete obj[name];
  56421. if ('get' in def) {
  56422. obj.__defineGetter__(name, def['get']);
  56423. }
  56424. if ('set' in def) {
  56425. obj.__defineSetter__(name, def['set']);
  56426. }
  56427. if ('value' in def) {
  56428. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56429. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56430. return value;
  56431. });
  56432. return value;
  56433. });
  56434. obj[name] = def.value;
  56435. }
  56436. };
  56437. }());
  56438. (function checkXMLHttpRequestResponseCompatibility() {
  56439. if (typeof XMLHttpRequest === 'undefined') {
  56440. return;
  56441. }
  56442. var xhrPrototype = XMLHttpRequest.prototype;
  56443. var xhr = new XMLHttpRequest();
  56444. if (!('overrideMimeType' in xhr)) {
  56445. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56446. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56447. }
  56448. });
  56449. }
  56450. if ('responseType' in xhr) {
  56451. return;
  56452. }
  56453. Object.defineProperty(xhrPrototype, 'responseType', {
  56454. get: function xmlHttpRequestGetResponseType() {
  56455. return this._responseType || 'text';
  56456. },
  56457. set: function xmlHttpRequestSetResponseType(value) {
  56458. if (value === 'text' || value === 'arraybuffer') {
  56459. this._responseType = value;
  56460. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56461. this.overrideMimeType('text/plain; charset=x-user-defined');
  56462. }
  56463. }
  56464. }
  56465. });
  56466. if (typeof VBArray !== 'undefined') {
  56467. Object.defineProperty(xhrPrototype, 'response', {
  56468. get: function xmlHttpRequestResponseGet() {
  56469. if (this.responseType === 'arraybuffer') {
  56470. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56471. }
  56472. return this.responseText;
  56473. }
  56474. });
  56475. return;
  56476. }
  56477. Object.defineProperty(xhrPrototype, 'response', {
  56478. get: function xmlHttpRequestResponseGet() {
  56479. if (this.responseType !== 'arraybuffer') {
  56480. return this.responseText;
  56481. }
  56482. var text = this.responseText;
  56483. var i, n = text.length;
  56484. var result = new Uint8Array(n);
  56485. for (i = 0; i < n; ++i) {
  56486. result[i] = text.charCodeAt(i) & 0xFF;
  56487. }
  56488. return result.buffer;
  56489. }
  56490. });
  56491. }());
  56492. (function checkWindowBtoaCompatibility() {
  56493. if ('btoa' in globalScope) {
  56494. return;
  56495. }
  56496. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56497. globalScope.btoa = function (chars) {
  56498. var buffer = '';
  56499. var i, n;
  56500. for (i = 0, n = chars.length; i < n; i += 3) {
  56501. var b1 = chars.charCodeAt(i) & 0xFF;
  56502. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56503. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56504. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56505. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56506. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56507. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56508. }
  56509. return buffer;
  56510. };
  56511. }());
  56512. (function checkWindowAtobCompatibility() {
  56513. if ('atob' in globalScope) {
  56514. return;
  56515. }
  56516. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56517. globalScope.atob = function (input) {
  56518. input = input.replace(/=+$/, '');
  56519. if (input.length % 4 === 1) {
  56520. throw new Error('bad atob input');
  56521. }
  56522. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  56523. buffer = digits.indexOf(buffer);
  56524. }
  56525. return output;
  56526. };
  56527. }());
  56528. (function checkFunctionPrototypeBindCompatibility() {
  56529. if (typeof Function.prototype.bind !== 'undefined') {
  56530. return;
  56531. }
  56532. Function.prototype.bind = function functionPrototypeBind(obj) {
  56533. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56534. var bound = function functionPrototypeBindBound() {
  56535. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56536. return fn.apply(obj, args);
  56537. };
  56538. return bound;
  56539. };
  56540. }());
  56541. (function checkDatasetProperty() {
  56542. if (!hasDOM) {
  56543. return;
  56544. }
  56545. var div = document.createElement('div');
  56546. if ('dataset' in div) {
  56547. return;
  56548. }
  56549. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56550. get: function () {
  56551. if (this._dataset) {
  56552. return this._dataset;
  56553. }
  56554. var dataset = {};
  56555. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56556. var attribute = this.attributes[j];
  56557. if (attribute.name.substring(0, 5) !== 'data-') {
  56558. continue;
  56559. }
  56560. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56561. return ch.toUpperCase();
  56562. });
  56563. dataset[key] = attribute.value;
  56564. }
  56565. Object.defineProperty(this, '_dataset', {
  56566. value: dataset,
  56567. writable: false,
  56568. enumerable: false
  56569. });
  56570. return dataset;
  56571. },
  56572. enumerable: true
  56573. });
  56574. }());
  56575. (function checkClassListProperty() {
  56576. function changeList(element, itemName, add, remove) {
  56577. var s = element.className || '';
  56578. var list = s.split(/\s+/g);
  56579. if (list[0] === '') {
  56580. list.shift();
  56581. }
  56582. var index = list.indexOf(itemName);
  56583. if (index < 0 && add) {
  56584. list.push(itemName);
  56585. }
  56586. if (index >= 0 && remove) {
  56587. list.splice(index, 1);
  56588. }
  56589. element.className = list.join(' ');
  56590. return index >= 0;
  56591. }
  56592. if (!hasDOM) {
  56593. return;
  56594. }
  56595. var div = document.createElement('div');
  56596. if ('classList' in div) {
  56597. return;
  56598. }
  56599. var classListPrototype = {
  56600. add: function (name) {
  56601. changeList(this.element, name, true, false);
  56602. },
  56603. contains: function (name) {
  56604. return changeList(this.element, name, false, false);
  56605. },
  56606. remove: function (name) {
  56607. changeList(this.element, name, false, true);
  56608. },
  56609. toggle: function (name) {
  56610. changeList(this.element, name, true, true);
  56611. }
  56612. };
  56613. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56614. get: function () {
  56615. if (this._classList) {
  56616. return this._classList;
  56617. }
  56618. var classList = Object.create(classListPrototype, {
  56619. element: {
  56620. value: this,
  56621. writable: false,
  56622. enumerable: true
  56623. }
  56624. });
  56625. Object.defineProperty(this, '_classList', {
  56626. value: classList,
  56627. writable: false,
  56628. enumerable: false
  56629. });
  56630. return classList;
  56631. },
  56632. enumerable: true
  56633. });
  56634. }());
  56635. (function checkWorkerConsoleCompatibility() {
  56636. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56637. return;
  56638. }
  56639. var consoleTimer = {};
  56640. var workerConsole = {
  56641. log: function log() {
  56642. var args = Array.prototype.slice.call(arguments);
  56643. globalScope.postMessage({
  56644. targetName: 'main',
  56645. action: 'console_log',
  56646. data: args
  56647. });
  56648. },
  56649. error: function error() {
  56650. var args = Array.prototype.slice.call(arguments);
  56651. globalScope.postMessage({
  56652. targetName: 'main',
  56653. action: 'console_error',
  56654. data: args
  56655. });
  56656. },
  56657. time: function time(name) {
  56658. consoleTimer[name] = Date.now();
  56659. },
  56660. timeEnd: function timeEnd(name) {
  56661. var time = consoleTimer[name];
  56662. if (!time) {
  56663. throw new Error('Unknown timer name ' + name);
  56664. }
  56665. this.log('Timer:', name, Date.now() - time);
  56666. }
  56667. };
  56668. globalScope.console = workerConsole;
  56669. }());
  56670. (function checkConsoleCompatibility() {
  56671. if (!hasDOM) {
  56672. return;
  56673. }
  56674. if (!('console' in window)) {
  56675. window.console = {
  56676. log: function () {
  56677. },
  56678. error: function () {
  56679. },
  56680. warn: function () {
  56681. }
  56682. };
  56683. return;
  56684. }
  56685. if (!('bind' in console.log)) {
  56686. console.log = function (fn) {
  56687. return function (msg) {
  56688. return fn(msg);
  56689. };
  56690. }(console.log);
  56691. console.error = function (fn) {
  56692. return function (msg) {
  56693. return fn(msg);
  56694. };
  56695. }(console.error);
  56696. console.warn = function (fn) {
  56697. return function (msg) {
  56698. return fn(msg);
  56699. };
  56700. }(console.warn);
  56701. return;
  56702. }
  56703. }());
  56704. (function checkOnClickCompatibility() {
  56705. function ignoreIfTargetDisabled(event) {
  56706. if (isDisabled(event.target)) {
  56707. event.stopPropagation();
  56708. }
  56709. }
  56710. function isDisabled(node) {
  56711. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56712. }
  56713. if (isOpera) {
  56714. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56715. }
  56716. }());
  56717. (function checkOnBlobSupport() {
  56718. if (isIE || isIOSChrome) {
  56719. PDFJS.disableCreateObjectURL = true;
  56720. }
  56721. }());
  56722. (function checkNavigatorLanguage() {
  56723. if (typeof navigator === 'undefined') {
  56724. return;
  56725. }
  56726. if ('language' in navigator) {
  56727. return;
  56728. }
  56729. PDFJS.locale = navigator.userLanguage || 'en-US';
  56730. }());
  56731. (function checkRangeRequests() {
  56732. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56733. PDFJS.disableRange = true;
  56734. PDFJS.disableStream = true;
  56735. }
  56736. }());
  56737. (function checkHistoryManipulation() {
  56738. if (!hasDOM) {
  56739. return;
  56740. }
  56741. if (!history.pushState || isAndroidPre3) {
  56742. PDFJS.disableHistory = true;
  56743. }
  56744. }());
  56745. (function checkSetPresenceInImageData() {
  56746. if (!hasDOM) {
  56747. return;
  56748. }
  56749. if (window.CanvasPixelArray) {
  56750. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56751. window.CanvasPixelArray.prototype.set = function (arr) {
  56752. for (var i = 0, ii = this.length; i < ii; i++) {
  56753. this[i] = arr[i];
  56754. }
  56755. };
  56756. }
  56757. } else {
  56758. var polyfill = false, versionMatch;
  56759. if (isChrome) {
  56760. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56761. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56762. } else if (isAndroid) {
  56763. polyfill = isAndroidPre5;
  56764. } else if (isSafari) {
  56765. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56766. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56767. }
  56768. if (polyfill) {
  56769. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56770. var createImageData = contextPrototype.createImageData;
  56771. contextPrototype.createImageData = function (w, h) {
  56772. var imageData = createImageData.call(this, w, h);
  56773. imageData.data.set = function (arr) {
  56774. for (var i = 0, ii = this.length; i < ii; i++) {
  56775. this[i] = arr[i];
  56776. }
  56777. };
  56778. return imageData;
  56779. };
  56780. contextPrototype = null;
  56781. }
  56782. }
  56783. }());
  56784. (function checkRequestAnimationFrame() {
  56785. function fakeRequestAnimationFrame(callback) {
  56786. window.setTimeout(callback, 20);
  56787. }
  56788. if (!hasDOM) {
  56789. return;
  56790. }
  56791. if (isIOS) {
  56792. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56793. return;
  56794. }
  56795. if ('requestAnimationFrame' in window) {
  56796. return;
  56797. }
  56798. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56799. }());
  56800. (function checkCanvasSizeLimitation() {
  56801. if (isIOS || isAndroid) {
  56802. PDFJS.maxCanvasPixels = 5242880;
  56803. }
  56804. }());
  56805. (function checkFullscreenSupport() {
  56806. if (!hasDOM) {
  56807. return;
  56808. }
  56809. if (isIE && window.parent !== window) {
  56810. PDFJS.disableFullscreen = true;
  56811. }
  56812. }());
  56813. (function checkCurrentScript() {
  56814. if (!hasDOM) {
  56815. return;
  56816. }
  56817. if ('currentScript' in document) {
  56818. return;
  56819. }
  56820. Object.defineProperty(document, 'currentScript', {
  56821. get: function () {
  56822. var scripts = document.getElementsByTagName('script');
  56823. return scripts[scripts.length - 1];
  56824. },
  56825. enumerable: true,
  56826. configurable: true
  56827. });
  56828. }());
  56829. (function checkInputTypeNumberAssign() {
  56830. if (!hasDOM) {
  56831. return;
  56832. }
  56833. var el = document.createElement('input');
  56834. try {
  56835. el.type = 'number';
  56836. } catch (ex) {
  56837. var inputProto = el.constructor.prototype;
  56838. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56839. Object.defineProperty(inputProto, 'type', {
  56840. get: function () {
  56841. return typeProperty.get.call(this);
  56842. },
  56843. set: function (value) {
  56844. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56845. },
  56846. enumerable: true,
  56847. configurable: true
  56848. });
  56849. }
  56850. }());
  56851. (function checkDocumentReadyState() {
  56852. if (!hasDOM) {
  56853. return;
  56854. }
  56855. if (!document.attachEvent) {
  56856. return;
  56857. }
  56858. var documentProto = document.constructor.prototype;
  56859. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56860. Object.defineProperty(documentProto, 'readyState', {
  56861. get: function () {
  56862. var value = readyStateProto.get.call(this);
  56863. return value === 'interactive' ? 'loading' : value;
  56864. },
  56865. set: function (value) {
  56866. readyStateProto.set.call(this, value);
  56867. },
  56868. enumerable: true,
  56869. configurable: true
  56870. });
  56871. }());
  56872. (function checkChildNodeRemove() {
  56873. if (!hasDOM) {
  56874. return;
  56875. }
  56876. if (typeof Element.prototype.remove !== 'undefined') {
  56877. return;
  56878. }
  56879. Element.prototype.remove = function () {
  56880. if (this.parentNode) {
  56881. this.parentNode.removeChild(this);
  56882. }
  56883. };
  56884. }());
  56885. (function checkPromise() {
  56886. if (globalScope.Promise) {
  56887. if (typeof globalScope.Promise.all !== 'function') {
  56888. globalScope.Promise.all = function (iterable) {
  56889. var count = 0, results = [], resolve, reject;
  56890. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56891. resolve = resolve_;
  56892. reject = reject_;
  56893. });
  56894. iterable.forEach(function (p, i) {
  56895. count++;
  56896. p.then(function (result) {
  56897. results[i] = result;
  56898. count--;
  56899. if (count === 0) {
  56900. resolve(results);
  56901. }
  56902. }, reject);
  56903. });
  56904. if (count === 0) {
  56905. resolve(results);
  56906. }
  56907. return promise;
  56908. };
  56909. }
  56910. if (typeof globalScope.Promise.resolve !== 'function') {
  56911. globalScope.Promise.resolve = function (value) {
  56912. return new globalScope.Promise(function (resolve) {
  56913. resolve(value);
  56914. });
  56915. };
  56916. }
  56917. if (typeof globalScope.Promise.reject !== 'function') {
  56918. globalScope.Promise.reject = function (reason) {
  56919. return new globalScope.Promise(function (resolve, reject) {
  56920. reject(reason);
  56921. });
  56922. };
  56923. }
  56924. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56925. globalScope.Promise.prototype.catch = function (onReject) {
  56926. return globalScope.Promise.prototype.then(undefined, onReject);
  56927. };
  56928. }
  56929. return;
  56930. }
  56931. var STATUS_PENDING = 0;
  56932. var STATUS_RESOLVED = 1;
  56933. var STATUS_REJECTED = 2;
  56934. var REJECTION_TIMEOUT = 500;
  56935. var HandlerManager = {
  56936. handlers: [],
  56937. running: false,
  56938. unhandledRejections: [],
  56939. pendingRejectionCheck: false,
  56940. scheduleHandlers: function scheduleHandlers(promise) {
  56941. if (promise._status === STATUS_PENDING) {
  56942. return;
  56943. }
  56944. this.handlers = this.handlers.concat(promise._handlers);
  56945. promise._handlers = [];
  56946. if (this.running) {
  56947. return;
  56948. }
  56949. this.running = true;
  56950. setTimeout(this.runHandlers.bind(this), 0);
  56951. },
  56952. runHandlers: function runHandlers() {
  56953. var RUN_TIMEOUT = 1;
  56954. var timeoutAt = Date.now() + RUN_TIMEOUT;
  56955. while (this.handlers.length > 0) {
  56956. var handler = this.handlers.shift();
  56957. var nextStatus = handler.thisPromise._status;
  56958. var nextValue = handler.thisPromise._value;
  56959. try {
  56960. if (nextStatus === STATUS_RESOLVED) {
  56961. if (typeof handler.onResolve === 'function') {
  56962. nextValue = handler.onResolve(nextValue);
  56963. }
  56964. } else if (typeof handler.onReject === 'function') {
  56965. nextValue = handler.onReject(nextValue);
  56966. nextStatus = STATUS_RESOLVED;
  56967. if (handler.thisPromise._unhandledRejection) {
  56968. this.removeUnhandeledRejection(handler.thisPromise);
  56969. }
  56970. }
  56971. } catch (ex) {
  56972. nextStatus = STATUS_REJECTED;
  56973. nextValue = ex;
  56974. }
  56975. handler.nextPromise._updateStatus(nextStatus, nextValue);
  56976. if (Date.now() >= timeoutAt) {
  56977. break;
  56978. }
  56979. }
  56980. if (this.handlers.length > 0) {
  56981. setTimeout(this.runHandlers.bind(this), 0);
  56982. return;
  56983. }
  56984. this.running = false;
  56985. },
  56986. addUnhandledRejection: function addUnhandledRejection(promise) {
  56987. this.unhandledRejections.push({
  56988. promise: promise,
  56989. time: Date.now()
  56990. });
  56991. this.scheduleRejectionCheck();
  56992. },
  56993. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  56994. promise._unhandledRejection = false;
  56995. for (var i = 0; i < this.unhandledRejections.length; i++) {
  56996. if (this.unhandledRejections[i].promise === promise) {
  56997. this.unhandledRejections.splice(i);
  56998. i--;
  56999. }
  57000. }
  57001. },
  57002. scheduleRejectionCheck: function scheduleRejectionCheck() {
  57003. if (this.pendingRejectionCheck) {
  57004. return;
  57005. }
  57006. this.pendingRejectionCheck = true;
  57007. setTimeout(function rejectionCheck() {
  57008. this.pendingRejectionCheck = false;
  57009. var now = Date.now();
  57010. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57011. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  57012. var unhandled = this.unhandledRejections[i].promise._value;
  57013. var msg = 'Unhandled rejection: ' + unhandled;
  57014. if (unhandled.stack) {
  57015. msg += '\n' + unhandled.stack;
  57016. }
  57017. try {
  57018. throw new Error(msg);
  57019. } catch (_) {
  57020. console.warn(msg);
  57021. }
  57022. this.unhandledRejections.splice(i);
  57023. i--;
  57024. }
  57025. }
  57026. if (this.unhandledRejections.length) {
  57027. this.scheduleRejectionCheck();
  57028. }
  57029. }.bind(this), REJECTION_TIMEOUT);
  57030. }
  57031. };
  57032. var Promise = function Promise(resolver) {
  57033. this._status = STATUS_PENDING;
  57034. this._handlers = [];
  57035. try {
  57036. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57037. } catch (e) {
  57038. this._reject(e);
  57039. }
  57040. };
  57041. Promise.all = function Promise_all(promises) {
  57042. var resolveAll, rejectAll;
  57043. var deferred = new Promise(function (resolve, reject) {
  57044. resolveAll = resolve;
  57045. rejectAll = reject;
  57046. });
  57047. var unresolved = promises.length;
  57048. var results = [];
  57049. if (unresolved === 0) {
  57050. resolveAll(results);
  57051. return deferred;
  57052. }
  57053. function reject(reason) {
  57054. if (deferred._status === STATUS_REJECTED) {
  57055. return;
  57056. }
  57057. results = [];
  57058. rejectAll(reason);
  57059. }
  57060. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57061. var promise = promises[i];
  57062. var resolve = function (i) {
  57063. return function (value) {
  57064. if (deferred._status === STATUS_REJECTED) {
  57065. return;
  57066. }
  57067. results[i] = value;
  57068. unresolved--;
  57069. if (unresolved === 0) {
  57070. resolveAll(results);
  57071. }
  57072. };
  57073. }(i);
  57074. if (Promise.isPromise(promise)) {
  57075. promise.then(resolve, reject);
  57076. } else {
  57077. resolve(promise);
  57078. }
  57079. }
  57080. return deferred;
  57081. };
  57082. Promise.isPromise = function Promise_isPromise(value) {
  57083. return value && typeof value.then === 'function';
  57084. };
  57085. Promise.resolve = function Promise_resolve(value) {
  57086. return new Promise(function (resolve) {
  57087. resolve(value);
  57088. });
  57089. };
  57090. Promise.reject = function Promise_reject(reason) {
  57091. return new Promise(function (resolve, reject) {
  57092. reject(reason);
  57093. });
  57094. };
  57095. Promise.prototype = {
  57096. _status: null,
  57097. _value: null,
  57098. _handlers: null,
  57099. _unhandledRejection: null,
  57100. _updateStatus: function Promise__updateStatus(status, value) {
  57101. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57102. return;
  57103. }
  57104. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57105. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57106. return;
  57107. }
  57108. this._status = status;
  57109. this._value = value;
  57110. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57111. this._unhandledRejection = true;
  57112. HandlerManager.addUnhandledRejection(this);
  57113. }
  57114. HandlerManager.scheduleHandlers(this);
  57115. },
  57116. _resolve: function Promise_resolve(value) {
  57117. this._updateStatus(STATUS_RESOLVED, value);
  57118. },
  57119. _reject: function Promise_reject(reason) {
  57120. this._updateStatus(STATUS_REJECTED, reason);
  57121. },
  57122. then: function Promise_then(onResolve, onReject) {
  57123. var nextPromise = new Promise(function (resolve, reject) {
  57124. this.resolve = resolve;
  57125. this.reject = reject;
  57126. });
  57127. this._handlers.push({
  57128. thisPromise: this,
  57129. onResolve: onResolve,
  57130. onReject: onReject,
  57131. nextPromise: nextPromise
  57132. });
  57133. HandlerManager.scheduleHandlers(this);
  57134. return nextPromise;
  57135. },
  57136. catch: function Promise_catch(onReject) {
  57137. return this.then(undefined, onReject);
  57138. }
  57139. };
  57140. globalScope.Promise = Promise;
  57141. }());
  57142. (function checkWeakMap() {
  57143. if (globalScope.WeakMap) {
  57144. return;
  57145. }
  57146. var id = 0;
  57147. function WeakMap() {
  57148. this.id = '$weakmap' + id++;
  57149. }
  57150. WeakMap.prototype = {
  57151. has: function (obj) {
  57152. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57153. },
  57154. get: function (obj, defaultValue) {
  57155. return this.has(obj) ? obj[this.id] : defaultValue;
  57156. },
  57157. set: function (obj, value) {
  57158. Object.defineProperty(obj, this.id, {
  57159. value: value,
  57160. enumerable: false,
  57161. configurable: true
  57162. });
  57163. },
  57164. delete: function (obj) {
  57165. delete obj[this.id];
  57166. }
  57167. };
  57168. globalScope.WeakMap = WeakMap;
  57169. }());
  57170. (function checkURLConstructor() {
  57171. var hasWorkingUrl = false;
  57172. try {
  57173. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57174. var u = new URL('b', 'http://a');
  57175. u.pathname = 'c%20d';
  57176. hasWorkingUrl = u.href === 'http://a/c%20d';
  57177. }
  57178. } catch (e) {
  57179. }
  57180. if (hasWorkingUrl) {
  57181. return;
  57182. }
  57183. var relative = Object.create(null);
  57184. relative['ftp'] = 21;
  57185. relative['file'] = 0;
  57186. relative['gopher'] = 70;
  57187. relative['http'] = 80;
  57188. relative['https'] = 443;
  57189. relative['ws'] = 80;
  57190. relative['wss'] = 443;
  57191. var relativePathDotMapping = Object.create(null);
  57192. relativePathDotMapping['%2e'] = '.';
  57193. relativePathDotMapping['.%2e'] = '..';
  57194. relativePathDotMapping['%2e.'] = '..';
  57195. relativePathDotMapping['%2e%2e'] = '..';
  57196. function isRelativeScheme(scheme) {
  57197. return relative[scheme] !== undefined;
  57198. }
  57199. function invalid() {
  57200. clear.call(this);
  57201. this._isInvalid = true;
  57202. }
  57203. function IDNAToASCII(h) {
  57204. if (h === '') {
  57205. invalid.call(this);
  57206. }
  57207. return h.toLowerCase();
  57208. }
  57209. function percentEscape(c) {
  57210. var unicode = c.charCodeAt(0);
  57211. if (unicode > 0x20 && unicode < 0x7F && [
  57212. 0x22,
  57213. 0x23,
  57214. 0x3C,
  57215. 0x3E,
  57216. 0x3F,
  57217. 0x60
  57218. ].indexOf(unicode) === -1) {
  57219. return c;
  57220. }
  57221. return encodeURIComponent(c);
  57222. }
  57223. function percentEscapeQuery(c) {
  57224. var unicode = c.charCodeAt(0);
  57225. if (unicode > 0x20 && unicode < 0x7F && [
  57226. 0x22,
  57227. 0x23,
  57228. 0x3C,
  57229. 0x3E,
  57230. 0x60
  57231. ].indexOf(unicode) === -1) {
  57232. return c;
  57233. }
  57234. return encodeURIComponent(c);
  57235. }
  57236. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57237. function parse(input, stateOverride, base) {
  57238. function err(message) {
  57239. errors.push(message);
  57240. }
  57241. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57242. loop:
  57243. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57244. var c = input[cursor];
  57245. switch (state) {
  57246. case 'scheme start':
  57247. if (c && ALPHA.test(c)) {
  57248. buffer += c.toLowerCase();
  57249. state = 'scheme';
  57250. } else if (!stateOverride) {
  57251. buffer = '';
  57252. state = 'no scheme';
  57253. continue;
  57254. } else {
  57255. err('Invalid scheme.');
  57256. break loop;
  57257. }
  57258. break;
  57259. case 'scheme':
  57260. if (c && ALPHANUMERIC.test(c)) {
  57261. buffer += c.toLowerCase();
  57262. } else if (c === ':') {
  57263. this._scheme = buffer;
  57264. buffer = '';
  57265. if (stateOverride) {
  57266. break loop;
  57267. }
  57268. if (isRelativeScheme(this._scheme)) {
  57269. this._isRelative = true;
  57270. }
  57271. if (this._scheme === 'file') {
  57272. state = 'relative';
  57273. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57274. state = 'relative or authority';
  57275. } else if (this._isRelative) {
  57276. state = 'authority first slash';
  57277. } else {
  57278. state = 'scheme data';
  57279. }
  57280. } else if (!stateOverride) {
  57281. buffer = '';
  57282. cursor = 0;
  57283. state = 'no scheme';
  57284. continue;
  57285. } else if (EOF === c) {
  57286. break loop;
  57287. } else {
  57288. err('Code point not allowed in scheme: ' + c);
  57289. break loop;
  57290. }
  57291. break;
  57292. case 'scheme data':
  57293. if (c === '?') {
  57294. this._query = '?';
  57295. state = 'query';
  57296. } else if (c === '#') {
  57297. this._fragment = '#';
  57298. state = 'fragment';
  57299. } else {
  57300. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57301. this._schemeData += percentEscape(c);
  57302. }
  57303. }
  57304. break;
  57305. case 'no scheme':
  57306. if (!base || !isRelativeScheme(base._scheme)) {
  57307. err('Missing scheme.');
  57308. invalid.call(this);
  57309. } else {
  57310. state = 'relative';
  57311. continue;
  57312. }
  57313. break;
  57314. case 'relative or authority':
  57315. if (c === '/' && input[cursor + 1] === '/') {
  57316. state = 'authority ignore slashes';
  57317. } else {
  57318. err('Expected /, got: ' + c);
  57319. state = 'relative';
  57320. continue;
  57321. }
  57322. break;
  57323. case 'relative':
  57324. this._isRelative = true;
  57325. if ('file' !== this._scheme) {
  57326. this._scheme = base._scheme;
  57327. }
  57328. if (EOF === c) {
  57329. this._host = base._host;
  57330. this._port = base._port;
  57331. this._path = base._path.slice();
  57332. this._query = base._query;
  57333. this._username = base._username;
  57334. this._password = base._password;
  57335. break loop;
  57336. } else if (c === '/' || c === '\\') {
  57337. if (c === '\\') {
  57338. err('\\ is an invalid code point.');
  57339. }
  57340. state = 'relative slash';
  57341. } else if (c === '?') {
  57342. this._host = base._host;
  57343. this._port = base._port;
  57344. this._path = base._path.slice();
  57345. this._query = '?';
  57346. this._username = base._username;
  57347. this._password = base._password;
  57348. state = 'query';
  57349. } else if (c === '#') {
  57350. this._host = base._host;
  57351. this._port = base._port;
  57352. this._path = base._path.slice();
  57353. this._query = base._query;
  57354. this._fragment = '#';
  57355. this._username = base._username;
  57356. this._password = base._password;
  57357. state = 'fragment';
  57358. } else {
  57359. var nextC = input[cursor + 1];
  57360. var nextNextC = input[cursor + 2];
  57361. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  57362. this._host = base._host;
  57363. this._port = base._port;
  57364. this._username = base._username;
  57365. this._password = base._password;
  57366. this._path = base._path.slice();
  57367. this._path.pop();
  57368. }
  57369. state = 'relative path';
  57370. continue;
  57371. }
  57372. break;
  57373. case 'relative slash':
  57374. if (c === '/' || c === '\\') {
  57375. if (c === '\\') {
  57376. err('\\ is an invalid code point.');
  57377. }
  57378. if (this._scheme === 'file') {
  57379. state = 'file host';
  57380. } else {
  57381. state = 'authority ignore slashes';
  57382. }
  57383. } else {
  57384. if ('file' !== this._scheme) {
  57385. this._host = base._host;
  57386. this._port = base._port;
  57387. this._username = base._username;
  57388. this._password = base._password;
  57389. }
  57390. state = 'relative path';
  57391. continue;
  57392. }
  57393. break;
  57394. case 'authority first slash':
  57395. if (c === '/') {
  57396. state = 'authority second slash';
  57397. } else {
  57398. err('Expected \'/\', got: ' + c);
  57399. state = 'authority ignore slashes';
  57400. continue;
  57401. }
  57402. break;
  57403. case 'authority second slash':
  57404. state = 'authority ignore slashes';
  57405. if ('/' !== c) {
  57406. err('Expected \'/\', got: ' + c);
  57407. continue;
  57408. }
  57409. break;
  57410. case 'authority ignore slashes':
  57411. if ('/' !== c && '\\' !== c) {
  57412. state = 'authority';
  57413. continue;
  57414. } else {
  57415. err('Expected authority, got: ' + c);
  57416. }
  57417. break;
  57418. case 'authority':
  57419. if (c === '@') {
  57420. if (seenAt) {
  57421. err('@ already seen.');
  57422. buffer += '%40';
  57423. }
  57424. seenAt = true;
  57425. for (var i = 0; i < buffer.length; i++) {
  57426. var cp = buffer[i];
  57427. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57428. err('Invalid whitespace in authority.');
  57429. continue;
  57430. }
  57431. if (cp === ':' && this._password === null) {
  57432. this._password = '';
  57433. continue;
  57434. }
  57435. var tempC = percentEscape(cp);
  57436. if (null !== this._password) {
  57437. this._password += tempC;
  57438. } else {
  57439. this._username += tempC;
  57440. }
  57441. }
  57442. buffer = '';
  57443. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57444. cursor -= buffer.length;
  57445. buffer = '';
  57446. state = 'host';
  57447. continue;
  57448. } else {
  57449. buffer += c;
  57450. }
  57451. break;
  57452. case 'file host':
  57453. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57454. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57455. state = 'relative path';
  57456. } else if (buffer.length === 0) {
  57457. state = 'relative path start';
  57458. } else {
  57459. this._host = IDNAToASCII.call(this, buffer);
  57460. buffer = '';
  57461. state = 'relative path start';
  57462. }
  57463. continue;
  57464. } else if (c === '\t' || c === '\n' || c === '\r') {
  57465. err('Invalid whitespace in file host.');
  57466. } else {
  57467. buffer += c;
  57468. }
  57469. break;
  57470. case 'host':
  57471. case 'hostname':
  57472. if (c === ':' && !seenBracket) {
  57473. this._host = IDNAToASCII.call(this, buffer);
  57474. buffer = '';
  57475. state = 'port';
  57476. if (stateOverride === 'hostname') {
  57477. break loop;
  57478. }
  57479. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57480. this._host = IDNAToASCII.call(this, buffer);
  57481. buffer = '';
  57482. state = 'relative path start';
  57483. if (stateOverride) {
  57484. break loop;
  57485. }
  57486. continue;
  57487. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57488. if (c === '[') {
  57489. seenBracket = true;
  57490. } else if (c === ']') {
  57491. seenBracket = false;
  57492. }
  57493. buffer += c;
  57494. } else {
  57495. err('Invalid code point in host/hostname: ' + c);
  57496. }
  57497. break;
  57498. case 'port':
  57499. if (/[0-9]/.test(c)) {
  57500. buffer += c;
  57501. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57502. if ('' !== buffer) {
  57503. var temp = parseInt(buffer, 10);
  57504. if (temp !== relative[this._scheme]) {
  57505. this._port = temp + '';
  57506. }
  57507. buffer = '';
  57508. }
  57509. if (stateOverride) {
  57510. break loop;
  57511. }
  57512. state = 'relative path start';
  57513. continue;
  57514. } else if (c === '\t' || c === '\n' || c === '\r') {
  57515. err('Invalid code point in port: ' + c);
  57516. } else {
  57517. invalid.call(this);
  57518. }
  57519. break;
  57520. case 'relative path start':
  57521. if (c === '\\') {
  57522. err('\'\\\' not allowed in path.');
  57523. }
  57524. state = 'relative path';
  57525. if ('/' !== c && '\\' !== c) {
  57526. continue;
  57527. }
  57528. break;
  57529. case 'relative path':
  57530. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57531. if (c === '\\') {
  57532. err('\\ not allowed in relative path.');
  57533. }
  57534. var tmp;
  57535. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57536. buffer = tmp;
  57537. }
  57538. if (buffer === '..') {
  57539. this._path.pop();
  57540. if ('/' !== c && '\\' !== c) {
  57541. this._path.push('');
  57542. }
  57543. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  57544. this._path.push('');
  57545. } else if ('.' !== buffer) {
  57546. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57547. buffer = buffer[0] + ':';
  57548. }
  57549. this._path.push(buffer);
  57550. }
  57551. buffer = '';
  57552. if (c === '?') {
  57553. this._query = '?';
  57554. state = 'query';
  57555. } else if (c === '#') {
  57556. this._fragment = '#';
  57557. state = 'fragment';
  57558. }
  57559. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57560. buffer += percentEscape(c);
  57561. }
  57562. break;
  57563. case 'query':
  57564. if (!stateOverride && c === '#') {
  57565. this._fragment = '#';
  57566. state = 'fragment';
  57567. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57568. this._query += percentEscapeQuery(c);
  57569. }
  57570. break;
  57571. case 'fragment':
  57572. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57573. this._fragment += c;
  57574. }
  57575. break;
  57576. }
  57577. cursor++;
  57578. }
  57579. }
  57580. function clear() {
  57581. this._scheme = '';
  57582. this._schemeData = '';
  57583. this._username = '';
  57584. this._password = null;
  57585. this._host = '';
  57586. this._port = '';
  57587. this._path = [];
  57588. this._query = '';
  57589. this._fragment = '';
  57590. this._isInvalid = false;
  57591. this._isRelative = false;
  57592. }
  57593. function JURL(url, base) {
  57594. if (base !== undefined && !(base instanceof JURL)) {
  57595. base = new JURL(String(base));
  57596. }
  57597. this._url = url;
  57598. clear.call(this);
  57599. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57600. parse.call(this, input, null, base);
  57601. }
  57602. JURL.prototype = {
  57603. toString: function () {
  57604. return this.href;
  57605. },
  57606. get href() {
  57607. if (this._isInvalid) {
  57608. return this._url;
  57609. }
  57610. var authority = '';
  57611. if ('' !== this._username || null !== this._password) {
  57612. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  57613. }
  57614. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57615. },
  57616. set href(href) {
  57617. clear.call(this);
  57618. parse.call(this, href);
  57619. },
  57620. get protocol() {
  57621. return this._scheme + ':';
  57622. },
  57623. set protocol(protocol) {
  57624. if (this._isInvalid) {
  57625. return;
  57626. }
  57627. parse.call(this, protocol + ':', 'scheme start');
  57628. },
  57629. get host() {
  57630. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57631. },
  57632. set host(host) {
  57633. if (this._isInvalid || !this._isRelative) {
  57634. return;
  57635. }
  57636. parse.call(this, host, 'host');
  57637. },
  57638. get hostname() {
  57639. return this._host;
  57640. },
  57641. set hostname(hostname) {
  57642. if (this._isInvalid || !this._isRelative) {
  57643. return;
  57644. }
  57645. parse.call(this, hostname, 'hostname');
  57646. },
  57647. get port() {
  57648. return this._port;
  57649. },
  57650. set port(port) {
  57651. if (this._isInvalid || !this._isRelative) {
  57652. return;
  57653. }
  57654. parse.call(this, port, 'port');
  57655. },
  57656. get pathname() {
  57657. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57658. },
  57659. set pathname(pathname) {
  57660. if (this._isInvalid || !this._isRelative) {
  57661. return;
  57662. }
  57663. this._path = [];
  57664. parse.call(this, pathname, 'relative path start');
  57665. },
  57666. get search() {
  57667. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57668. },
  57669. set search(search) {
  57670. if (this._isInvalid || !this._isRelative) {
  57671. return;
  57672. }
  57673. this._query = '?';
  57674. if (search[0] === '?') {
  57675. search = search.slice(1);
  57676. }
  57677. parse.call(this, search, 'query');
  57678. },
  57679. get hash() {
  57680. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57681. },
  57682. set hash(hash) {
  57683. if (this._isInvalid) {
  57684. return;
  57685. }
  57686. this._fragment = '#';
  57687. if (hash[0] === '#') {
  57688. hash = hash.slice(1);
  57689. }
  57690. parse.call(this, hash, 'fragment');
  57691. },
  57692. get origin() {
  57693. var host;
  57694. if (this._isInvalid || !this._scheme) {
  57695. return '';
  57696. }
  57697. switch (this._scheme) {
  57698. case 'data':
  57699. case 'file':
  57700. case 'javascript':
  57701. case 'mailto':
  57702. return 'null';
  57703. }
  57704. host = this.host;
  57705. if (!host) {
  57706. return '';
  57707. }
  57708. return this._scheme + '://' + host;
  57709. }
  57710. };
  57711. var OriginalURL = globalScope.URL;
  57712. if (OriginalURL) {
  57713. JURL.createObjectURL = function (blob) {
  57714. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57715. };
  57716. JURL.revokeObjectURL = function (url) {
  57717. OriginalURL.revokeObjectURL(url);
  57718. };
  57719. }
  57720. globalScope.URL = JURL;
  57721. }());
  57722. }
  57723. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57724. /***/ }),
  57725. /* 48 */
  57726. /***/ (function(module, exports, __w_pdfjs_require__) {
  57727. "use strict";
  57728. var pdfjsVersion = '1.7.344';
  57729. var pdfjsBuild = 'c2905614';
  57730. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57731. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57732. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57733. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57734. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57735. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57736. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57737. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57738. exports.build = pdfjsDisplayAPI.build;
  57739. exports.version = pdfjsDisplayAPI.version;
  57740. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57741. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57742. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57743. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57744. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57745. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57746. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57747. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57748. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57749. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57750. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57751. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57752. exports.OPS = pdfjsSharedUtil.OPS;
  57753. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57754. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57755. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57756. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57757. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57758. exports.shadow = pdfjsSharedUtil.shadow;
  57759. exports.createBlob = pdfjsSharedUtil.createBlob;
  57760. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57761. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57762. /***/ })
  57763. /******/ ]);
  57764. });