pdf.combined.js 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916
  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.331';
  19979. exports.build = 'b75d53a7';
  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('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34037. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34038. if (jsUrl && jsUrl[1]) {
  34039. url = jsUrl[1];
  34040. break;
  34041. }
  34042. }
  34043. default:
  34044. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34045. break;
  34046. }
  34047. } else if (destDict.has('Dest')) {
  34048. dest = destDict.get('Dest');
  34049. }
  34050. if (isString(url)) {
  34051. url = tryConvertUrlEncoding(url);
  34052. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34053. if (absoluteUrl) {
  34054. resultObj.url = absoluteUrl.href;
  34055. }
  34056. resultObj.unsafeUrl = url;
  34057. }
  34058. if (dest) {
  34059. if (isName(dest)) {
  34060. dest = dest.name;
  34061. }
  34062. if (isString(dest) || isArray(dest)) {
  34063. resultObj.dest = dest;
  34064. }
  34065. }
  34066. };
  34067. return Catalog;
  34068. }();
  34069. var XRef = function XRefClosure() {
  34070. function XRef(stream, pdfManager) {
  34071. this.stream = stream;
  34072. this.pdfManager = pdfManager;
  34073. this.entries = [];
  34074. this.xrefstms = Object.create(null);
  34075. this.cache = [];
  34076. this.stats = {
  34077. streamTypes: [],
  34078. fontTypes: []
  34079. };
  34080. }
  34081. XRef.prototype = {
  34082. setStartXRef: function XRef_setStartXRef(startXRef) {
  34083. this.startXRefQueue = [startXRef];
  34084. },
  34085. parse: function XRef_parse(recoveryMode) {
  34086. var trailerDict;
  34087. if (!recoveryMode) {
  34088. trailerDict = this.readXRef();
  34089. } else {
  34090. warn('Indexing all PDF objects');
  34091. trailerDict = this.indexObjects();
  34092. }
  34093. trailerDict.assignXref(this);
  34094. this.trailer = trailerDict;
  34095. var encrypt = trailerDict.get('Encrypt');
  34096. if (isDict(encrypt)) {
  34097. var ids = trailerDict.get('ID');
  34098. var fileId = ids && ids.length ? ids[0] : '';
  34099. encrypt.suppressEncryption = true;
  34100. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34101. }
  34102. if (!(this.root = trailerDict.get('Root'))) {
  34103. error('Invalid root reference');
  34104. }
  34105. },
  34106. processXRefTable: function XRef_processXRefTable(parser) {
  34107. if (!('tableState' in this)) {
  34108. this.tableState = {
  34109. entryNum: 0,
  34110. streamPos: parser.lexer.stream.pos,
  34111. parserBuf1: parser.buf1,
  34112. parserBuf2: parser.buf2
  34113. };
  34114. }
  34115. var obj = this.readXRefTable(parser);
  34116. if (!isCmd(obj, 'trailer')) {
  34117. error('Invalid XRef table: could not find trailer dictionary');
  34118. }
  34119. var dict = parser.getObj();
  34120. if (!isDict(dict) && dict.dict) {
  34121. dict = dict.dict;
  34122. }
  34123. if (!isDict(dict)) {
  34124. error('Invalid XRef table: could not parse trailer dictionary');
  34125. }
  34126. delete this.tableState;
  34127. return dict;
  34128. },
  34129. readXRefTable: function XRef_readXRefTable(parser) {
  34130. var stream = parser.lexer.stream;
  34131. var tableState = this.tableState;
  34132. stream.pos = tableState.streamPos;
  34133. parser.buf1 = tableState.parserBuf1;
  34134. parser.buf2 = tableState.parserBuf2;
  34135. var obj;
  34136. while (true) {
  34137. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34138. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34139. break;
  34140. }
  34141. tableState.firstEntryNum = obj;
  34142. tableState.entryCount = parser.getObj();
  34143. }
  34144. var first = tableState.firstEntryNum;
  34145. var count = tableState.entryCount;
  34146. if (!isInt(first) || !isInt(count)) {
  34147. error('Invalid XRef table: wrong types in subsection header');
  34148. }
  34149. for (var i = tableState.entryNum; i < count; i++) {
  34150. tableState.streamPos = stream.pos;
  34151. tableState.entryNum = i;
  34152. tableState.parserBuf1 = parser.buf1;
  34153. tableState.parserBuf2 = parser.buf2;
  34154. var entry = {};
  34155. entry.offset = parser.getObj();
  34156. entry.gen = parser.getObj();
  34157. var type = parser.getObj();
  34158. if (isCmd(type, 'f')) {
  34159. entry.free = true;
  34160. } else if (isCmd(type, 'n')) {
  34161. entry.uncompressed = true;
  34162. }
  34163. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34164. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34165. }
  34166. if (i === 0 && entry.free && first === 1) {
  34167. first = 0;
  34168. }
  34169. if (!this.entries[i + first]) {
  34170. this.entries[i + first] = entry;
  34171. }
  34172. }
  34173. tableState.entryNum = 0;
  34174. tableState.streamPos = stream.pos;
  34175. tableState.parserBuf1 = parser.buf1;
  34176. tableState.parserBuf2 = parser.buf2;
  34177. delete tableState.firstEntryNum;
  34178. delete tableState.entryCount;
  34179. }
  34180. if (this.entries[0] && !this.entries[0].free) {
  34181. error('Invalid XRef table: unexpected first object');
  34182. }
  34183. return obj;
  34184. },
  34185. processXRefStream: function XRef_processXRefStream(stream) {
  34186. if (!('streamState' in this)) {
  34187. var streamParameters = stream.dict;
  34188. var byteWidths = streamParameters.get('W');
  34189. var range = streamParameters.get('Index');
  34190. if (!range) {
  34191. range = [
  34192. 0,
  34193. streamParameters.get('Size')
  34194. ];
  34195. }
  34196. this.streamState = {
  34197. entryRanges: range,
  34198. byteWidths: byteWidths,
  34199. entryNum: 0,
  34200. streamPos: stream.pos
  34201. };
  34202. }
  34203. this.readXRefStream(stream);
  34204. delete this.streamState;
  34205. return stream.dict;
  34206. },
  34207. readXRefStream: function XRef_readXRefStream(stream) {
  34208. var i, j;
  34209. var streamState = this.streamState;
  34210. stream.pos = streamState.streamPos;
  34211. var byteWidths = streamState.byteWidths;
  34212. var typeFieldWidth = byteWidths[0];
  34213. var offsetFieldWidth = byteWidths[1];
  34214. var generationFieldWidth = byteWidths[2];
  34215. var entryRanges = streamState.entryRanges;
  34216. while (entryRanges.length > 0) {
  34217. var first = entryRanges[0];
  34218. var n = entryRanges[1];
  34219. if (!isInt(first) || !isInt(n)) {
  34220. error('Invalid XRef range fields: ' + first + ', ' + n);
  34221. }
  34222. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34223. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34224. }
  34225. for (i = streamState.entryNum; i < n; ++i) {
  34226. streamState.entryNum = i;
  34227. streamState.streamPos = stream.pos;
  34228. var type = 0, offset = 0, generation = 0;
  34229. for (j = 0; j < typeFieldWidth; ++j) {
  34230. type = type << 8 | stream.getByte();
  34231. }
  34232. if (typeFieldWidth === 0) {
  34233. type = 1;
  34234. }
  34235. for (j = 0; j < offsetFieldWidth; ++j) {
  34236. offset = offset << 8 | stream.getByte();
  34237. }
  34238. for (j = 0; j < generationFieldWidth; ++j) {
  34239. generation = generation << 8 | stream.getByte();
  34240. }
  34241. var entry = {};
  34242. entry.offset = offset;
  34243. entry.gen = generation;
  34244. switch (type) {
  34245. case 0:
  34246. entry.free = true;
  34247. break;
  34248. case 1:
  34249. entry.uncompressed = true;
  34250. break;
  34251. case 2:
  34252. break;
  34253. default:
  34254. error('Invalid XRef entry type: ' + type);
  34255. }
  34256. if (!this.entries[first + i]) {
  34257. this.entries[first + i] = entry;
  34258. }
  34259. }
  34260. streamState.entryNum = 0;
  34261. streamState.streamPos = stream.pos;
  34262. entryRanges.splice(0, 2);
  34263. }
  34264. },
  34265. indexObjects: function XRef_indexObjects() {
  34266. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34267. var PERCENT = 0x25, LT = 0x3C;
  34268. function readToken(data, offset) {
  34269. var token = '', ch = data[offset];
  34270. while (ch !== LF && ch !== CR && ch !== LT) {
  34271. if (++offset >= data.length) {
  34272. break;
  34273. }
  34274. token += String.fromCharCode(ch);
  34275. ch = data[offset];
  34276. }
  34277. return token;
  34278. }
  34279. function skipUntil(data, offset, what) {
  34280. var length = what.length, dataLength = data.length;
  34281. var skipped = 0;
  34282. while (offset < dataLength) {
  34283. var i = 0;
  34284. while (i < length && data[offset + i] === what[i]) {
  34285. ++i;
  34286. }
  34287. if (i >= length) {
  34288. break;
  34289. }
  34290. offset++;
  34291. skipped++;
  34292. }
  34293. return skipped;
  34294. }
  34295. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34296. var trailerBytes = new Uint8Array([
  34297. 116,
  34298. 114,
  34299. 97,
  34300. 105,
  34301. 108,
  34302. 101,
  34303. 114
  34304. ]);
  34305. var startxrefBytes = new Uint8Array([
  34306. 115,
  34307. 116,
  34308. 97,
  34309. 114,
  34310. 116,
  34311. 120,
  34312. 114,
  34313. 101,
  34314. 102
  34315. ]);
  34316. var endobjBytes = new Uint8Array([
  34317. 101,
  34318. 110,
  34319. 100,
  34320. 111,
  34321. 98,
  34322. 106
  34323. ]);
  34324. var xrefBytes = new Uint8Array([
  34325. 47,
  34326. 88,
  34327. 82,
  34328. 101,
  34329. 102
  34330. ]);
  34331. this.entries.length = 0;
  34332. var stream = this.stream;
  34333. stream.pos = 0;
  34334. var buffer = stream.getBytes();
  34335. var position = stream.start, length = buffer.length;
  34336. var trailers = [], xrefStms = [];
  34337. while (position < length) {
  34338. var ch = buffer[position];
  34339. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34340. ++position;
  34341. continue;
  34342. }
  34343. if (ch === PERCENT) {
  34344. do {
  34345. ++position;
  34346. if (position >= length) {
  34347. break;
  34348. }
  34349. ch = buffer[position];
  34350. } while (ch !== LF && ch !== CR);
  34351. continue;
  34352. }
  34353. var token = readToken(buffer, position);
  34354. var m;
  34355. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34356. position += skipUntil(buffer, position, trailerBytes);
  34357. trailers.push(position);
  34358. position += skipUntil(buffer, position, startxrefBytes);
  34359. } else if (m = objRegExp.exec(token)) {
  34360. if (typeof this.entries[m[1]] === 'undefined') {
  34361. this.entries[m[1]] = {
  34362. offset: position - stream.start,
  34363. gen: m[2] | 0,
  34364. uncompressed: true
  34365. };
  34366. }
  34367. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34368. var content = buffer.subarray(position, position + contentLength);
  34369. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34370. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34371. xrefStms.push(position - stream.start);
  34372. this.xrefstms[position - stream.start] = 1;
  34373. }
  34374. position += contentLength;
  34375. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34376. trailers.push(position);
  34377. position += skipUntil(buffer, position, startxrefBytes);
  34378. } else {
  34379. position += token.length + 1;
  34380. }
  34381. }
  34382. var i, ii;
  34383. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34384. this.startXRefQueue.push(xrefStms[i]);
  34385. this.readXRef(true);
  34386. }
  34387. var dict;
  34388. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34389. stream.pos = trailers[i];
  34390. var parser = new Parser(new Lexer(stream), true, this, true);
  34391. var obj = parser.getObj();
  34392. if (!isCmd(obj, 'trailer')) {
  34393. continue;
  34394. }
  34395. dict = parser.getObj();
  34396. if (!isDict(dict)) {
  34397. continue;
  34398. }
  34399. if (dict.has('ID')) {
  34400. return dict;
  34401. }
  34402. }
  34403. if (dict) {
  34404. return dict;
  34405. }
  34406. throw new InvalidPDFException('Invalid PDF structure');
  34407. },
  34408. readXRef: function XRef_readXRef(recoveryMode) {
  34409. var stream = this.stream;
  34410. try {
  34411. while (this.startXRefQueue.length) {
  34412. var startXRef = this.startXRefQueue[0];
  34413. stream.pos = startXRef + stream.start;
  34414. var parser = new Parser(new Lexer(stream), true, this);
  34415. var obj = parser.getObj();
  34416. var dict;
  34417. if (isCmd(obj, 'xref')) {
  34418. dict = this.processXRefTable(parser);
  34419. if (!this.topDict) {
  34420. this.topDict = dict;
  34421. }
  34422. obj = dict.get('XRefStm');
  34423. if (isInt(obj)) {
  34424. var pos = obj;
  34425. if (!(pos in this.xrefstms)) {
  34426. this.xrefstms[pos] = 1;
  34427. this.startXRefQueue.push(pos);
  34428. }
  34429. }
  34430. } else if (isInt(obj)) {
  34431. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34432. error('Invalid XRef stream');
  34433. }
  34434. dict = this.processXRefStream(obj);
  34435. if (!this.topDict) {
  34436. this.topDict = dict;
  34437. }
  34438. if (!dict) {
  34439. error('Failed to read XRef stream');
  34440. }
  34441. } else {
  34442. error('Invalid XRef stream header');
  34443. }
  34444. obj = dict.get('Prev');
  34445. if (isInt(obj)) {
  34446. this.startXRefQueue.push(obj);
  34447. } else if (isRef(obj)) {
  34448. this.startXRefQueue.push(obj.num);
  34449. }
  34450. this.startXRefQueue.shift();
  34451. }
  34452. return this.topDict;
  34453. } catch (e) {
  34454. if (e instanceof MissingDataException) {
  34455. throw e;
  34456. }
  34457. info('(while reading XRef): ' + e);
  34458. }
  34459. if (recoveryMode) {
  34460. return;
  34461. }
  34462. throw new XRefParseException();
  34463. },
  34464. getEntry: function XRef_getEntry(i) {
  34465. var xrefEntry = this.entries[i];
  34466. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34467. return xrefEntry;
  34468. }
  34469. return null;
  34470. },
  34471. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34472. if (!isRef(obj)) {
  34473. return obj;
  34474. }
  34475. return this.fetch(obj, suppressEncryption);
  34476. },
  34477. fetch: function XRef_fetch(ref, suppressEncryption) {
  34478. assert(isRef(ref), 'ref object is not a reference');
  34479. var num = ref.num;
  34480. if (num in this.cache) {
  34481. var cacheEntry = this.cache[num];
  34482. if (isDict(cacheEntry) && !cacheEntry.objId) {
  34483. cacheEntry.objId = ref.toString();
  34484. }
  34485. return cacheEntry;
  34486. }
  34487. var xrefEntry = this.getEntry(num);
  34488. if (xrefEntry === null) {
  34489. return this.cache[num] = null;
  34490. }
  34491. if (xrefEntry.uncompressed) {
  34492. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34493. } else {
  34494. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34495. }
  34496. if (isDict(xrefEntry)) {
  34497. xrefEntry.objId = ref.toString();
  34498. } else if (isStream(xrefEntry)) {
  34499. xrefEntry.dict.objId = ref.toString();
  34500. }
  34501. return xrefEntry;
  34502. },
  34503. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34504. var gen = ref.gen;
  34505. var num = ref.num;
  34506. if (xrefEntry.gen !== gen) {
  34507. error('inconsistent generation in XRef');
  34508. }
  34509. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34510. var parser = new Parser(new Lexer(stream), true, this);
  34511. var obj1 = parser.getObj();
  34512. var obj2 = parser.getObj();
  34513. var obj3 = parser.getObj();
  34514. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34515. error('bad XRef entry');
  34516. }
  34517. if (!isCmd(obj3, 'obj')) {
  34518. if (obj3.cmd.indexOf('obj') === 0) {
  34519. num = parseInt(obj3.cmd.substring(3), 10);
  34520. if (!isNaN(num)) {
  34521. return num;
  34522. }
  34523. }
  34524. error('bad XRef entry');
  34525. }
  34526. if (this.encrypt && !suppressEncryption) {
  34527. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34528. } else {
  34529. xrefEntry = parser.getObj();
  34530. }
  34531. if (!isStream(xrefEntry)) {
  34532. this.cache[num] = xrefEntry;
  34533. }
  34534. return xrefEntry;
  34535. },
  34536. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34537. var tableOffset = xrefEntry.offset;
  34538. var stream = this.fetch(new Ref(tableOffset, 0));
  34539. if (!isStream(stream)) {
  34540. error('bad ObjStm stream');
  34541. }
  34542. var first = stream.dict.get('First');
  34543. var n = stream.dict.get('N');
  34544. if (!isInt(first) || !isInt(n)) {
  34545. error('invalid first and n parameters for ObjStm stream');
  34546. }
  34547. var parser = new Parser(new Lexer(stream), false, this);
  34548. parser.allowStreams = true;
  34549. var i, entries = [], num, nums = [];
  34550. for (i = 0; i < n; ++i) {
  34551. num = parser.getObj();
  34552. if (!isInt(num)) {
  34553. error('invalid object number in the ObjStm stream: ' + num);
  34554. }
  34555. nums.push(num);
  34556. var offset = parser.getObj();
  34557. if (!isInt(offset)) {
  34558. error('invalid object offset in the ObjStm stream: ' + offset);
  34559. }
  34560. }
  34561. for (i = 0; i < n; ++i) {
  34562. entries.push(parser.getObj());
  34563. if (isCmd(parser.buf1, 'endobj')) {
  34564. parser.shift();
  34565. }
  34566. num = nums[i];
  34567. var entry = this.entries[num];
  34568. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34569. this.cache[num] = entries[i];
  34570. }
  34571. }
  34572. xrefEntry = entries[xrefEntry.gen];
  34573. if (xrefEntry === undefined) {
  34574. error('bad XRef entry for compressed object');
  34575. }
  34576. return xrefEntry;
  34577. },
  34578. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34579. if (!isRef(obj)) {
  34580. return Promise.resolve(obj);
  34581. }
  34582. return this.fetchAsync(obj, suppressEncryption);
  34583. },
  34584. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34585. var streamManager = this.stream.manager;
  34586. var xref = this;
  34587. return new Promise(function tryFetch(resolve, reject) {
  34588. try {
  34589. resolve(xref.fetch(ref, suppressEncryption));
  34590. } catch (e) {
  34591. if (e instanceof MissingDataException) {
  34592. streamManager.requestRange(e.begin, e.end).then(function () {
  34593. tryFetch(resolve, reject);
  34594. }, reject);
  34595. return;
  34596. }
  34597. reject(e);
  34598. }
  34599. });
  34600. },
  34601. getCatalogObj: function XRef_getCatalogObj() {
  34602. return this.root;
  34603. }
  34604. };
  34605. return XRef;
  34606. }();
  34607. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34608. function NameOrNumberTree(root, xref) {
  34609. throw new Error('Cannot initialize NameOrNumberTree.');
  34610. }
  34611. NameOrNumberTree.prototype = {
  34612. getAll: function NameOrNumberTree_getAll() {
  34613. var dict = Object.create(null);
  34614. if (!this.root) {
  34615. return dict;
  34616. }
  34617. var xref = this.xref;
  34618. var processed = new RefSet();
  34619. processed.put(this.root);
  34620. var queue = [this.root];
  34621. while (queue.length > 0) {
  34622. var i, n;
  34623. var obj = xref.fetchIfRef(queue.shift());
  34624. if (!isDict(obj)) {
  34625. continue;
  34626. }
  34627. if (obj.has('Kids')) {
  34628. var kids = obj.get('Kids');
  34629. for (i = 0, n = kids.length; i < n; i++) {
  34630. var kid = kids[i];
  34631. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34632. queue.push(kid);
  34633. processed.put(kid);
  34634. }
  34635. continue;
  34636. }
  34637. var entries = obj.get(this._type);
  34638. if (isArray(entries)) {
  34639. for (i = 0, n = entries.length; i < n; i += 2) {
  34640. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34641. }
  34642. }
  34643. }
  34644. return dict;
  34645. },
  34646. get: function NameOrNumberTree_get(key) {
  34647. if (!this.root) {
  34648. return null;
  34649. }
  34650. var xref = this.xref;
  34651. var kidsOrEntries = xref.fetchIfRef(this.root);
  34652. var loopCount = 0;
  34653. var MAX_LEVELS = 10;
  34654. var l, r, m;
  34655. while (kidsOrEntries.has('Kids')) {
  34656. if (++loopCount > MAX_LEVELS) {
  34657. warn('Search depth limit reached for "' + this._type + '" tree.');
  34658. return null;
  34659. }
  34660. var kids = kidsOrEntries.get('Kids');
  34661. if (!isArray(kids)) {
  34662. return null;
  34663. }
  34664. l = 0;
  34665. r = kids.length - 1;
  34666. while (l <= r) {
  34667. m = l + r >> 1;
  34668. var kid = xref.fetchIfRef(kids[m]);
  34669. var limits = kid.get('Limits');
  34670. if (key < xref.fetchIfRef(limits[0])) {
  34671. r = m - 1;
  34672. } else if (key > xref.fetchIfRef(limits[1])) {
  34673. l = m + 1;
  34674. } else {
  34675. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34676. break;
  34677. }
  34678. }
  34679. if (l > r) {
  34680. return null;
  34681. }
  34682. }
  34683. var entries = kidsOrEntries.get(this._type);
  34684. if (isArray(entries)) {
  34685. l = 0;
  34686. r = entries.length - 2;
  34687. while (l <= r) {
  34688. m = l + r & ~1;
  34689. var currentKey = xref.fetchIfRef(entries[m]);
  34690. if (key < currentKey) {
  34691. r = m - 2;
  34692. } else if (key > currentKey) {
  34693. l = m + 2;
  34694. } else {
  34695. return xref.fetchIfRef(entries[m + 1]);
  34696. }
  34697. }
  34698. }
  34699. return null;
  34700. }
  34701. };
  34702. return NameOrNumberTree;
  34703. }();
  34704. var NameTree = function NameTreeClosure() {
  34705. function NameTree(root, xref) {
  34706. this.root = root;
  34707. this.xref = xref;
  34708. this._type = 'Names';
  34709. }
  34710. Util.inherit(NameTree, NameOrNumberTree, {});
  34711. return NameTree;
  34712. }();
  34713. var NumberTree = function NumberTreeClosure() {
  34714. function NumberTree(root, xref) {
  34715. this.root = root;
  34716. this.xref = xref;
  34717. this._type = 'Nums';
  34718. }
  34719. Util.inherit(NumberTree, NameOrNumberTree, {});
  34720. return NumberTree;
  34721. }();
  34722. var FileSpec = function FileSpecClosure() {
  34723. function FileSpec(root, xref) {
  34724. if (!root || !isDict(root)) {
  34725. return;
  34726. }
  34727. this.xref = xref;
  34728. this.root = root;
  34729. if (root.has('FS')) {
  34730. this.fs = root.get('FS');
  34731. }
  34732. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34733. if (root.has('RF')) {
  34734. warn('Related file specifications are not supported');
  34735. }
  34736. this.contentAvailable = true;
  34737. if (!root.has('EF')) {
  34738. this.contentAvailable = false;
  34739. warn('Non-embedded file specifications are not supported');
  34740. }
  34741. }
  34742. function pickPlatformItem(dict) {
  34743. if (dict.has('UF')) {
  34744. return dict.get('UF');
  34745. } else if (dict.has('F')) {
  34746. return dict.get('F');
  34747. } else if (dict.has('Unix')) {
  34748. return dict.get('Unix');
  34749. } else if (dict.has('Mac')) {
  34750. return dict.get('Mac');
  34751. } else if (dict.has('DOS')) {
  34752. return dict.get('DOS');
  34753. }
  34754. return null;
  34755. }
  34756. FileSpec.prototype = {
  34757. get filename() {
  34758. if (!this._filename && this.root) {
  34759. var filename = pickPlatformItem(this.root) || 'unnamed';
  34760. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34761. }
  34762. return this._filename;
  34763. },
  34764. get content() {
  34765. if (!this.contentAvailable) {
  34766. return null;
  34767. }
  34768. if (!this.contentRef && this.root) {
  34769. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34770. }
  34771. var content = null;
  34772. if (this.contentRef) {
  34773. var xref = this.xref;
  34774. var fileObj = xref.fetchIfRef(this.contentRef);
  34775. if (fileObj && isStream(fileObj)) {
  34776. content = fileObj.getBytes();
  34777. } else {
  34778. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34779. }
  34780. } else {
  34781. warn('Embedded file specification does not have a content');
  34782. }
  34783. return content;
  34784. },
  34785. get serializable() {
  34786. return {
  34787. filename: this.filename,
  34788. content: this.content
  34789. };
  34790. }
  34791. };
  34792. return FileSpec;
  34793. }();
  34794. var ObjectLoader = function () {
  34795. function mayHaveChildren(value) {
  34796. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34797. }
  34798. function addChildren(node, nodesToVisit) {
  34799. var value;
  34800. if (isDict(node) || isStream(node)) {
  34801. var map;
  34802. if (isDict(node)) {
  34803. map = node.map;
  34804. } else {
  34805. map = node.dict.map;
  34806. }
  34807. for (var key in map) {
  34808. value = map[key];
  34809. if (mayHaveChildren(value)) {
  34810. nodesToVisit.push(value);
  34811. }
  34812. }
  34813. } else if (isArray(node)) {
  34814. for (var i = 0, ii = node.length; i < ii; i++) {
  34815. value = node[i];
  34816. if (mayHaveChildren(value)) {
  34817. nodesToVisit.push(value);
  34818. }
  34819. }
  34820. }
  34821. }
  34822. function ObjectLoader(obj, keys, xref) {
  34823. this.obj = obj;
  34824. this.keys = keys;
  34825. this.xref = xref;
  34826. this.refSet = null;
  34827. this.capability = null;
  34828. }
  34829. ObjectLoader.prototype = {
  34830. load: function ObjectLoader_load() {
  34831. var keys = this.keys;
  34832. this.capability = createPromiseCapability();
  34833. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34834. this.capability.resolve();
  34835. return this.capability.promise;
  34836. }
  34837. this.refSet = new RefSet();
  34838. var nodesToVisit = [];
  34839. for (var i = 0; i < keys.length; i++) {
  34840. nodesToVisit.push(this.obj[keys[i]]);
  34841. }
  34842. this._walk(nodesToVisit);
  34843. return this.capability.promise;
  34844. },
  34845. _walk: function ObjectLoader_walk(nodesToVisit) {
  34846. var nodesToRevisit = [];
  34847. var pendingRequests = [];
  34848. while (nodesToVisit.length) {
  34849. var currentNode = nodesToVisit.pop();
  34850. if (isRef(currentNode)) {
  34851. if (this.refSet.has(currentNode)) {
  34852. continue;
  34853. }
  34854. try {
  34855. var ref = currentNode;
  34856. this.refSet.put(ref);
  34857. currentNode = this.xref.fetch(currentNode);
  34858. } catch (e) {
  34859. if (!(e instanceof MissingDataException)) {
  34860. throw e;
  34861. }
  34862. nodesToRevisit.push(currentNode);
  34863. pendingRequests.push({
  34864. begin: e.begin,
  34865. end: e.end
  34866. });
  34867. }
  34868. }
  34869. if (currentNode && currentNode.getBaseStreams) {
  34870. var baseStreams = currentNode.getBaseStreams();
  34871. var foundMissingData = false;
  34872. for (var i = 0; i < baseStreams.length; i++) {
  34873. var stream = baseStreams[i];
  34874. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34875. foundMissingData = true;
  34876. pendingRequests.push({
  34877. begin: stream.start,
  34878. end: stream.end
  34879. });
  34880. }
  34881. }
  34882. if (foundMissingData) {
  34883. nodesToRevisit.push(currentNode);
  34884. }
  34885. }
  34886. addChildren(currentNode, nodesToVisit);
  34887. }
  34888. if (pendingRequests.length) {
  34889. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34890. nodesToVisit = nodesToRevisit;
  34891. for (var i = 0; i < nodesToRevisit.length; i++) {
  34892. var node = nodesToRevisit[i];
  34893. if (isRef(node)) {
  34894. this.refSet.remove(node);
  34895. }
  34896. }
  34897. this._walk(nodesToVisit);
  34898. }.bind(this), this.capability.reject);
  34899. return;
  34900. }
  34901. this.refSet = null;
  34902. this.capability.resolve();
  34903. }
  34904. };
  34905. return ObjectLoader;
  34906. }();
  34907. exports.Catalog = Catalog;
  34908. exports.ObjectLoader = ObjectLoader;
  34909. exports.XRef = XRef;
  34910. exports.FileSpec = FileSpec;
  34911. /***/ }),
  34912. /* 21 */
  34913. /***/ (function(module, exports, __w_pdfjs_require__) {
  34914. "use strict";
  34915. var sharedUtil = __w_pdfjs_require__(0);
  34916. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34917. var getStdFontMap = getLookupTableFactory(function (t) {
  34918. t['ArialNarrow'] = 'Helvetica';
  34919. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34920. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34921. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34922. t['ArialBlack'] = 'Helvetica';
  34923. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34924. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34925. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34926. t['Arial-Black'] = 'Helvetica';
  34927. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34928. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34929. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34930. t['Arial'] = 'Helvetica';
  34931. t['Arial-Bold'] = 'Helvetica-Bold';
  34932. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34933. t['Arial-Italic'] = 'Helvetica-Oblique';
  34934. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34935. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34936. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34937. t['ArialMT'] = 'Helvetica';
  34938. t['Courier-Bold'] = 'Courier-Bold';
  34939. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34940. t['Courier-Italic'] = 'Courier-Oblique';
  34941. t['CourierNew'] = 'Courier';
  34942. t['CourierNew-Bold'] = 'Courier-Bold';
  34943. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34944. t['CourierNew-Italic'] = 'Courier-Oblique';
  34945. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34946. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34947. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34948. t['CourierNewPSMT'] = 'Courier';
  34949. t['Helvetica'] = 'Helvetica';
  34950. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34951. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34952. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34953. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34954. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34955. t['Symbol-Bold'] = 'Symbol';
  34956. t['Symbol-BoldItalic'] = 'Symbol';
  34957. t['Symbol-Italic'] = 'Symbol';
  34958. t['TimesNewRoman'] = 'Times-Roman';
  34959. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34960. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34961. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34962. t['TimesNewRomanPS'] = 'Times-Roman';
  34963. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34964. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34965. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34966. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34967. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34968. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34969. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34970. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34971. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34972. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34973. });
  34974. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34975. t['CenturyGothic'] = 'Helvetica';
  34976. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34977. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34978. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34979. t['ComicSansMS'] = 'Comic Sans MS';
  34980. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34981. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  34982. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  34983. t['LucidaConsole'] = 'Courier';
  34984. t['LucidaConsole-Bold'] = 'Courier-Bold';
  34985. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  34986. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  34987. t['MS-Gothic'] = 'MS Gothic';
  34988. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  34989. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  34990. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  34991. t['MS-Mincho'] = 'MS Mincho';
  34992. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  34993. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  34994. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  34995. t['MS-PGothic'] = 'MS PGothic';
  34996. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  34997. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  34998. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  34999. t['MS-PMincho'] = 'MS PMincho';
  35000. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35001. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35002. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35003. t['NuptialScript'] = 'Times-Italic';
  35004. t['Wingdings'] = 'ZapfDingbats';
  35005. });
  35006. var getSerifFonts = getLookupTableFactory(function (t) {
  35007. t['Adobe Jenson'] = true;
  35008. t['Adobe Text'] = true;
  35009. t['Albertus'] = true;
  35010. t['Aldus'] = true;
  35011. t['Alexandria'] = true;
  35012. t['Algerian'] = true;
  35013. t['American Typewriter'] = true;
  35014. t['Antiqua'] = true;
  35015. t['Apex'] = true;
  35016. t['Arno'] = true;
  35017. t['Aster'] = true;
  35018. t['Aurora'] = true;
  35019. t['Baskerville'] = true;
  35020. t['Bell'] = true;
  35021. t['Bembo'] = true;
  35022. t['Bembo Schoolbook'] = true;
  35023. t['Benguiat'] = true;
  35024. t['Berkeley Old Style'] = true;
  35025. t['Bernhard Modern'] = true;
  35026. t['Berthold City'] = true;
  35027. t['Bodoni'] = true;
  35028. t['Bauer Bodoni'] = true;
  35029. t['Book Antiqua'] = true;
  35030. t['Bookman'] = true;
  35031. t['Bordeaux Roman'] = true;
  35032. t['Californian FB'] = true;
  35033. t['Calisto'] = true;
  35034. t['Calvert'] = true;
  35035. t['Capitals'] = true;
  35036. t['Cambria'] = true;
  35037. t['Cartier'] = true;
  35038. t['Caslon'] = true;
  35039. t['Catull'] = true;
  35040. t['Centaur'] = true;
  35041. t['Century Old Style'] = true;
  35042. t['Century Schoolbook'] = true;
  35043. t['Chaparral'] = true;
  35044. t['Charis SIL'] = true;
  35045. t['Cheltenham'] = true;
  35046. t['Cholla Slab'] = true;
  35047. t['Clarendon'] = true;
  35048. t['Clearface'] = true;
  35049. t['Cochin'] = true;
  35050. t['Colonna'] = true;
  35051. t['Computer Modern'] = true;
  35052. t['Concrete Roman'] = true;
  35053. t['Constantia'] = true;
  35054. t['Cooper Black'] = true;
  35055. t['Corona'] = true;
  35056. t['Ecotype'] = true;
  35057. t['Egyptienne'] = true;
  35058. t['Elephant'] = true;
  35059. t['Excelsior'] = true;
  35060. t['Fairfield'] = true;
  35061. t['FF Scala'] = true;
  35062. t['Folkard'] = true;
  35063. t['Footlight'] = true;
  35064. t['FreeSerif'] = true;
  35065. t['Friz Quadrata'] = true;
  35066. t['Garamond'] = true;
  35067. t['Gentium'] = true;
  35068. t['Georgia'] = true;
  35069. t['Gloucester'] = true;
  35070. t['Goudy Old Style'] = true;
  35071. t['Goudy Schoolbook'] = true;
  35072. t['Goudy Pro Font'] = true;
  35073. t['Granjon'] = true;
  35074. t['Guardian Egyptian'] = true;
  35075. t['Heather'] = true;
  35076. t['Hercules'] = true;
  35077. t['High Tower Text'] = true;
  35078. t['Hiroshige'] = true;
  35079. t['Hoefler Text'] = true;
  35080. t['Humana Serif'] = true;
  35081. t['Imprint'] = true;
  35082. t['Ionic No. 5'] = true;
  35083. t['Janson'] = true;
  35084. t['Joanna'] = true;
  35085. t['Korinna'] = true;
  35086. t['Lexicon'] = true;
  35087. t['Liberation Serif'] = true;
  35088. t['Linux Libertine'] = true;
  35089. t['Literaturnaya'] = true;
  35090. t['Lucida'] = true;
  35091. t['Lucida Bright'] = true;
  35092. t['Melior'] = true;
  35093. t['Memphis'] = true;
  35094. t['Miller'] = true;
  35095. t['Minion'] = true;
  35096. t['Modern'] = true;
  35097. t['Mona Lisa'] = true;
  35098. t['Mrs Eaves'] = true;
  35099. t['MS Serif'] = true;
  35100. t['Museo Slab'] = true;
  35101. t['New York'] = true;
  35102. t['Nimbus Roman'] = true;
  35103. t['NPS Rawlinson Roadway'] = true;
  35104. t['NuptialScript'] = true;
  35105. t['Palatino'] = true;
  35106. t['Perpetua'] = true;
  35107. t['Plantin'] = true;
  35108. t['Plantin Schoolbook'] = true;
  35109. t['Playbill'] = true;
  35110. t['Poor Richard'] = true;
  35111. t['Rawlinson Roadway'] = true;
  35112. t['Renault'] = true;
  35113. t['Requiem'] = true;
  35114. t['Rockwell'] = true;
  35115. t['Roman'] = true;
  35116. t['Rotis Serif'] = true;
  35117. t['Sabon'] = true;
  35118. t['Scala'] = true;
  35119. t['Seagull'] = true;
  35120. t['Sistina'] = true;
  35121. t['Souvenir'] = true;
  35122. t['STIX'] = true;
  35123. t['Stone Informal'] = true;
  35124. t['Stone Serif'] = true;
  35125. t['Sylfaen'] = true;
  35126. t['Times'] = true;
  35127. t['Trajan'] = true;
  35128. t['Trinité'] = true;
  35129. t['Trump Mediaeval'] = true;
  35130. t['Utopia'] = true;
  35131. t['Vale Type'] = true;
  35132. t['Bitstream Vera'] = true;
  35133. t['Vera Serif'] = true;
  35134. t['Versailles'] = true;
  35135. t['Wanted'] = true;
  35136. t['Weiss'] = true;
  35137. t['Wide Latin'] = true;
  35138. t['Windsor'] = true;
  35139. t['XITS'] = true;
  35140. });
  35141. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35142. t['Dingbats'] = true;
  35143. t['Symbol'] = true;
  35144. t['ZapfDingbats'] = true;
  35145. });
  35146. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35147. t[2] = 10;
  35148. t[3] = 32;
  35149. t[4] = 33;
  35150. t[5] = 34;
  35151. t[6] = 35;
  35152. t[7] = 36;
  35153. t[8] = 37;
  35154. t[9] = 38;
  35155. t[10] = 39;
  35156. t[11] = 40;
  35157. t[12] = 41;
  35158. t[13] = 42;
  35159. t[14] = 43;
  35160. t[15] = 44;
  35161. t[16] = 45;
  35162. t[17] = 46;
  35163. t[18] = 47;
  35164. t[19] = 48;
  35165. t[20] = 49;
  35166. t[21] = 50;
  35167. t[22] = 51;
  35168. t[23] = 52;
  35169. t[24] = 53;
  35170. t[25] = 54;
  35171. t[26] = 55;
  35172. t[27] = 56;
  35173. t[28] = 57;
  35174. t[29] = 58;
  35175. t[30] = 894;
  35176. t[31] = 60;
  35177. t[32] = 61;
  35178. t[33] = 62;
  35179. t[34] = 63;
  35180. t[35] = 64;
  35181. t[36] = 65;
  35182. t[37] = 66;
  35183. t[38] = 67;
  35184. t[39] = 68;
  35185. t[40] = 69;
  35186. t[41] = 70;
  35187. t[42] = 71;
  35188. t[43] = 72;
  35189. t[44] = 73;
  35190. t[45] = 74;
  35191. t[46] = 75;
  35192. t[47] = 76;
  35193. t[48] = 77;
  35194. t[49] = 78;
  35195. t[50] = 79;
  35196. t[51] = 80;
  35197. t[52] = 81;
  35198. t[53] = 82;
  35199. t[54] = 83;
  35200. t[55] = 84;
  35201. t[56] = 85;
  35202. t[57] = 86;
  35203. t[58] = 87;
  35204. t[59] = 88;
  35205. t[60] = 89;
  35206. t[61] = 90;
  35207. t[62] = 91;
  35208. t[63] = 92;
  35209. t[64] = 93;
  35210. t[65] = 94;
  35211. t[66] = 95;
  35212. t[67] = 96;
  35213. t[68] = 97;
  35214. t[69] = 98;
  35215. t[70] = 99;
  35216. t[71] = 100;
  35217. t[72] = 101;
  35218. t[73] = 102;
  35219. t[74] = 103;
  35220. t[75] = 104;
  35221. t[76] = 105;
  35222. t[77] = 106;
  35223. t[78] = 107;
  35224. t[79] = 108;
  35225. t[80] = 109;
  35226. t[81] = 110;
  35227. t[82] = 111;
  35228. t[83] = 112;
  35229. t[84] = 113;
  35230. t[85] = 114;
  35231. t[86] = 115;
  35232. t[87] = 116;
  35233. t[88] = 117;
  35234. t[89] = 118;
  35235. t[90] = 119;
  35236. t[91] = 120;
  35237. t[92] = 121;
  35238. t[93] = 122;
  35239. t[94] = 123;
  35240. t[95] = 124;
  35241. t[96] = 125;
  35242. t[97] = 126;
  35243. t[98] = 196;
  35244. t[99] = 197;
  35245. t[100] = 199;
  35246. t[101] = 201;
  35247. t[102] = 209;
  35248. t[103] = 214;
  35249. t[104] = 220;
  35250. t[105] = 225;
  35251. t[106] = 224;
  35252. t[107] = 226;
  35253. t[108] = 228;
  35254. t[109] = 227;
  35255. t[110] = 229;
  35256. t[111] = 231;
  35257. t[112] = 233;
  35258. t[113] = 232;
  35259. t[114] = 234;
  35260. t[115] = 235;
  35261. t[116] = 237;
  35262. t[117] = 236;
  35263. t[118] = 238;
  35264. t[119] = 239;
  35265. t[120] = 241;
  35266. t[121] = 243;
  35267. t[122] = 242;
  35268. t[123] = 244;
  35269. t[124] = 246;
  35270. t[125] = 245;
  35271. t[126] = 250;
  35272. t[127] = 249;
  35273. t[128] = 251;
  35274. t[129] = 252;
  35275. t[130] = 8224;
  35276. t[131] = 176;
  35277. t[132] = 162;
  35278. t[133] = 163;
  35279. t[134] = 167;
  35280. t[135] = 8226;
  35281. t[136] = 182;
  35282. t[137] = 223;
  35283. t[138] = 174;
  35284. t[139] = 169;
  35285. t[140] = 8482;
  35286. t[141] = 180;
  35287. t[142] = 168;
  35288. t[143] = 8800;
  35289. t[144] = 198;
  35290. t[145] = 216;
  35291. t[146] = 8734;
  35292. t[147] = 177;
  35293. t[148] = 8804;
  35294. t[149] = 8805;
  35295. t[150] = 165;
  35296. t[151] = 181;
  35297. t[152] = 8706;
  35298. t[153] = 8721;
  35299. t[154] = 8719;
  35300. t[156] = 8747;
  35301. t[157] = 170;
  35302. t[158] = 186;
  35303. t[159] = 8486;
  35304. t[160] = 230;
  35305. t[161] = 248;
  35306. t[162] = 191;
  35307. t[163] = 161;
  35308. t[164] = 172;
  35309. t[165] = 8730;
  35310. t[166] = 402;
  35311. t[167] = 8776;
  35312. t[168] = 8710;
  35313. t[169] = 171;
  35314. t[170] = 187;
  35315. t[171] = 8230;
  35316. t[210] = 218;
  35317. t[223] = 711;
  35318. t[224] = 321;
  35319. t[225] = 322;
  35320. t[227] = 353;
  35321. t[229] = 382;
  35322. t[234] = 253;
  35323. t[252] = 263;
  35324. t[253] = 268;
  35325. t[254] = 269;
  35326. t[258] = 258;
  35327. t[260] = 260;
  35328. t[261] = 261;
  35329. t[265] = 280;
  35330. t[266] = 281;
  35331. t[268] = 283;
  35332. t[269] = 313;
  35333. t[275] = 323;
  35334. t[276] = 324;
  35335. t[278] = 328;
  35336. t[284] = 345;
  35337. t[285] = 346;
  35338. t[286] = 347;
  35339. t[292] = 367;
  35340. t[295] = 377;
  35341. t[296] = 378;
  35342. t[298] = 380;
  35343. t[305] = 963;
  35344. t[306] = 964;
  35345. t[307] = 966;
  35346. t[308] = 8215;
  35347. t[309] = 8252;
  35348. t[310] = 8319;
  35349. t[311] = 8359;
  35350. t[312] = 8592;
  35351. t[313] = 8593;
  35352. t[337] = 9552;
  35353. t[493] = 1039;
  35354. t[494] = 1040;
  35355. t[705] = 1524;
  35356. t[706] = 8362;
  35357. t[710] = 64288;
  35358. t[711] = 64298;
  35359. t[759] = 1617;
  35360. t[761] = 1776;
  35361. t[763] = 1778;
  35362. t[775] = 1652;
  35363. t[777] = 1764;
  35364. t[778] = 1780;
  35365. t[779] = 1781;
  35366. t[780] = 1782;
  35367. t[782] = 771;
  35368. t[783] = 64726;
  35369. t[786] = 8363;
  35370. t[788] = 8532;
  35371. t[790] = 768;
  35372. t[791] = 769;
  35373. t[792] = 768;
  35374. t[795] = 803;
  35375. t[797] = 64336;
  35376. t[798] = 64337;
  35377. t[799] = 64342;
  35378. t[800] = 64343;
  35379. t[801] = 64344;
  35380. t[802] = 64345;
  35381. t[803] = 64362;
  35382. t[804] = 64363;
  35383. t[805] = 64364;
  35384. t[2424] = 7821;
  35385. t[2425] = 7822;
  35386. t[2426] = 7823;
  35387. t[2427] = 7824;
  35388. t[2428] = 7825;
  35389. t[2429] = 7826;
  35390. t[2430] = 7827;
  35391. t[2433] = 7682;
  35392. t[2678] = 8045;
  35393. t[2679] = 8046;
  35394. t[2830] = 1552;
  35395. t[2838] = 686;
  35396. t[2840] = 751;
  35397. t[2842] = 753;
  35398. t[2843] = 754;
  35399. t[2844] = 755;
  35400. t[2846] = 757;
  35401. t[2856] = 767;
  35402. t[2857] = 848;
  35403. t[2858] = 849;
  35404. t[2862] = 853;
  35405. t[2863] = 854;
  35406. t[2864] = 855;
  35407. t[2865] = 861;
  35408. t[2866] = 862;
  35409. t[2906] = 7460;
  35410. t[2908] = 7462;
  35411. t[2909] = 7463;
  35412. t[2910] = 7464;
  35413. t[2912] = 7466;
  35414. t[2913] = 7467;
  35415. t[2914] = 7468;
  35416. t[2916] = 7470;
  35417. t[2917] = 7471;
  35418. t[2918] = 7472;
  35419. t[2920] = 7474;
  35420. t[2921] = 7475;
  35421. t[2922] = 7476;
  35422. t[2924] = 7478;
  35423. t[2925] = 7479;
  35424. t[2926] = 7480;
  35425. t[2928] = 7482;
  35426. t[2929] = 7483;
  35427. t[2930] = 7484;
  35428. t[2932] = 7486;
  35429. t[2933] = 7487;
  35430. t[2934] = 7488;
  35431. t[2936] = 7490;
  35432. t[2937] = 7491;
  35433. t[2938] = 7492;
  35434. t[2940] = 7494;
  35435. t[2941] = 7495;
  35436. t[2942] = 7496;
  35437. t[2944] = 7498;
  35438. t[2946] = 7500;
  35439. t[2948] = 7502;
  35440. t[2950] = 7504;
  35441. t[2951] = 7505;
  35442. t[2952] = 7506;
  35443. t[2954] = 7508;
  35444. t[2955] = 7509;
  35445. t[2956] = 7510;
  35446. t[2958] = 7512;
  35447. t[2959] = 7513;
  35448. t[2960] = 7514;
  35449. t[2962] = 7516;
  35450. t[2963] = 7517;
  35451. t[2964] = 7518;
  35452. t[2966] = 7520;
  35453. t[2967] = 7521;
  35454. t[2968] = 7522;
  35455. t[2970] = 7524;
  35456. t[2971] = 7525;
  35457. t[2972] = 7526;
  35458. t[2974] = 7528;
  35459. t[2975] = 7529;
  35460. t[2976] = 7530;
  35461. t[2978] = 1537;
  35462. t[2979] = 1538;
  35463. t[2980] = 1539;
  35464. t[2982] = 1549;
  35465. t[2983] = 1551;
  35466. t[2984] = 1552;
  35467. t[2986] = 1554;
  35468. t[2987] = 1555;
  35469. t[2988] = 1556;
  35470. t[2990] = 1623;
  35471. t[2991] = 1624;
  35472. t[2995] = 1775;
  35473. t[2999] = 1791;
  35474. t[3002] = 64290;
  35475. t[3003] = 64291;
  35476. t[3004] = 64292;
  35477. t[3006] = 64294;
  35478. t[3007] = 64295;
  35479. t[3008] = 64296;
  35480. t[3011] = 1900;
  35481. t[3014] = 8223;
  35482. t[3015] = 8244;
  35483. t[3017] = 7532;
  35484. t[3018] = 7533;
  35485. t[3019] = 7534;
  35486. t[3075] = 7590;
  35487. t[3076] = 7591;
  35488. t[3079] = 7594;
  35489. t[3080] = 7595;
  35490. t[3083] = 7598;
  35491. t[3084] = 7599;
  35492. t[3087] = 7602;
  35493. t[3088] = 7603;
  35494. t[3091] = 7606;
  35495. t[3092] = 7607;
  35496. t[3095] = 7610;
  35497. t[3096] = 7611;
  35498. t[3099] = 7614;
  35499. t[3100] = 7615;
  35500. t[3103] = 7618;
  35501. t[3104] = 7619;
  35502. t[3107] = 8337;
  35503. t[3108] = 8338;
  35504. t[3116] = 1884;
  35505. t[3119] = 1885;
  35506. t[3120] = 1885;
  35507. t[3123] = 1886;
  35508. t[3124] = 1886;
  35509. t[3127] = 1887;
  35510. t[3128] = 1887;
  35511. t[3131] = 1888;
  35512. t[3132] = 1888;
  35513. t[3135] = 1889;
  35514. t[3136] = 1889;
  35515. t[3139] = 1890;
  35516. t[3140] = 1890;
  35517. t[3143] = 1891;
  35518. t[3144] = 1891;
  35519. t[3147] = 1892;
  35520. t[3148] = 1892;
  35521. t[3153] = 580;
  35522. t[3154] = 581;
  35523. t[3157] = 584;
  35524. t[3158] = 585;
  35525. t[3161] = 588;
  35526. t[3162] = 589;
  35527. t[3165] = 891;
  35528. t[3166] = 892;
  35529. t[3169] = 1274;
  35530. t[3170] = 1275;
  35531. t[3173] = 1278;
  35532. t[3174] = 1279;
  35533. t[3181] = 7622;
  35534. t[3182] = 7623;
  35535. t[3282] = 11799;
  35536. t[3316] = 578;
  35537. t[3379] = 42785;
  35538. t[3393] = 1159;
  35539. t[3416] = 8377;
  35540. });
  35541. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35542. t[227] = 322;
  35543. t[264] = 261;
  35544. t[291] = 346;
  35545. });
  35546. exports.getStdFontMap = getStdFontMap;
  35547. exports.getNonStdFontMap = getNonStdFontMap;
  35548. exports.getSerifFonts = getSerifFonts;
  35549. exports.getSymbolsFonts = getSymbolsFonts;
  35550. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35551. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35552. /***/ }),
  35553. /* 22 */
  35554. /***/ (function(module, exports, __w_pdfjs_require__) {
  35555. "use strict";
  35556. var sharedUtil = __w_pdfjs_require__(0);
  35557. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35558. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35559. t[63721] = 0x00A9;
  35560. t[63193] = 0x00A9;
  35561. t[63720] = 0x00AE;
  35562. t[63194] = 0x00AE;
  35563. t[63722] = 0x2122;
  35564. t[63195] = 0x2122;
  35565. t[63729] = 0x23A7;
  35566. t[63730] = 0x23A8;
  35567. t[63731] = 0x23A9;
  35568. t[63740] = 0x23AB;
  35569. t[63741] = 0x23AC;
  35570. t[63742] = 0x23AD;
  35571. t[63726] = 0x23A1;
  35572. t[63727] = 0x23A2;
  35573. t[63728] = 0x23A3;
  35574. t[63737] = 0x23A4;
  35575. t[63738] = 0x23A5;
  35576. t[63739] = 0x23A6;
  35577. t[63723] = 0x239B;
  35578. t[63724] = 0x239C;
  35579. t[63725] = 0x239D;
  35580. t[63734] = 0x239E;
  35581. t[63735] = 0x239F;
  35582. t[63736] = 0x23A0;
  35583. });
  35584. function mapSpecialUnicodeValues(code) {
  35585. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35586. return 0;
  35587. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35588. return getSpecialPUASymbols()[code] || code;
  35589. }
  35590. return code;
  35591. }
  35592. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35593. var unicode = glyphsUnicodeMap[name];
  35594. if (unicode !== undefined) {
  35595. return unicode;
  35596. }
  35597. if (!name) {
  35598. return -1;
  35599. }
  35600. if (name[0] === 'u') {
  35601. var nameLen = name.length, hexStr;
  35602. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35603. hexStr = name.substr(3);
  35604. } else if (nameLen >= 5 && nameLen <= 7) {
  35605. hexStr = name.substr(1);
  35606. } else {
  35607. return -1;
  35608. }
  35609. if (hexStr === hexStr.toUpperCase()) {
  35610. unicode = parseInt(hexStr, 16);
  35611. if (unicode >= 0) {
  35612. return unicode;
  35613. }
  35614. }
  35615. }
  35616. return -1;
  35617. }
  35618. var UnicodeRanges = [
  35619. {
  35620. 'begin': 0x0000,
  35621. 'end': 0x007F
  35622. },
  35623. {
  35624. 'begin': 0x0080,
  35625. 'end': 0x00FF
  35626. },
  35627. {
  35628. 'begin': 0x0100,
  35629. 'end': 0x017F
  35630. },
  35631. {
  35632. 'begin': 0x0180,
  35633. 'end': 0x024F
  35634. },
  35635. {
  35636. 'begin': 0x0250,
  35637. 'end': 0x02AF
  35638. },
  35639. {
  35640. 'begin': 0x02B0,
  35641. 'end': 0x02FF
  35642. },
  35643. {
  35644. 'begin': 0x0300,
  35645. 'end': 0x036F
  35646. },
  35647. {
  35648. 'begin': 0x0370,
  35649. 'end': 0x03FF
  35650. },
  35651. {
  35652. 'begin': 0x2C80,
  35653. 'end': 0x2CFF
  35654. },
  35655. {
  35656. 'begin': 0x0400,
  35657. 'end': 0x04FF
  35658. },
  35659. {
  35660. 'begin': 0x0530,
  35661. 'end': 0x058F
  35662. },
  35663. {
  35664. 'begin': 0x0590,
  35665. 'end': 0x05FF
  35666. },
  35667. {
  35668. 'begin': 0xA500,
  35669. 'end': 0xA63F
  35670. },
  35671. {
  35672. 'begin': 0x0600,
  35673. 'end': 0x06FF
  35674. },
  35675. {
  35676. 'begin': 0x07C0,
  35677. 'end': 0x07FF
  35678. },
  35679. {
  35680. 'begin': 0x0900,
  35681. 'end': 0x097F
  35682. },
  35683. {
  35684. 'begin': 0x0980,
  35685. 'end': 0x09FF
  35686. },
  35687. {
  35688. 'begin': 0x0A00,
  35689. 'end': 0x0A7F
  35690. },
  35691. {
  35692. 'begin': 0x0A80,
  35693. 'end': 0x0AFF
  35694. },
  35695. {
  35696. 'begin': 0x0B00,
  35697. 'end': 0x0B7F
  35698. },
  35699. {
  35700. 'begin': 0x0B80,
  35701. 'end': 0x0BFF
  35702. },
  35703. {
  35704. 'begin': 0x0C00,
  35705. 'end': 0x0C7F
  35706. },
  35707. {
  35708. 'begin': 0x0C80,
  35709. 'end': 0x0CFF
  35710. },
  35711. {
  35712. 'begin': 0x0D00,
  35713. 'end': 0x0D7F
  35714. },
  35715. {
  35716. 'begin': 0x0E00,
  35717. 'end': 0x0E7F
  35718. },
  35719. {
  35720. 'begin': 0x0E80,
  35721. 'end': 0x0EFF
  35722. },
  35723. {
  35724. 'begin': 0x10A0,
  35725. 'end': 0x10FF
  35726. },
  35727. {
  35728. 'begin': 0x1B00,
  35729. 'end': 0x1B7F
  35730. },
  35731. {
  35732. 'begin': 0x1100,
  35733. 'end': 0x11FF
  35734. },
  35735. {
  35736. 'begin': 0x1E00,
  35737. 'end': 0x1EFF
  35738. },
  35739. {
  35740. 'begin': 0x1F00,
  35741. 'end': 0x1FFF
  35742. },
  35743. {
  35744. 'begin': 0x2000,
  35745. 'end': 0x206F
  35746. },
  35747. {
  35748. 'begin': 0x2070,
  35749. 'end': 0x209F
  35750. },
  35751. {
  35752. 'begin': 0x20A0,
  35753. 'end': 0x20CF
  35754. },
  35755. {
  35756. 'begin': 0x20D0,
  35757. 'end': 0x20FF
  35758. },
  35759. {
  35760. 'begin': 0x2100,
  35761. 'end': 0x214F
  35762. },
  35763. {
  35764. 'begin': 0x2150,
  35765. 'end': 0x218F
  35766. },
  35767. {
  35768. 'begin': 0x2190,
  35769. 'end': 0x21FF
  35770. },
  35771. {
  35772. 'begin': 0x2200,
  35773. 'end': 0x22FF
  35774. },
  35775. {
  35776. 'begin': 0x2300,
  35777. 'end': 0x23FF
  35778. },
  35779. {
  35780. 'begin': 0x2400,
  35781. 'end': 0x243F
  35782. },
  35783. {
  35784. 'begin': 0x2440,
  35785. 'end': 0x245F
  35786. },
  35787. {
  35788. 'begin': 0x2460,
  35789. 'end': 0x24FF
  35790. },
  35791. {
  35792. 'begin': 0x2500,
  35793. 'end': 0x257F
  35794. },
  35795. {
  35796. 'begin': 0x2580,
  35797. 'end': 0x259F
  35798. },
  35799. {
  35800. 'begin': 0x25A0,
  35801. 'end': 0x25FF
  35802. },
  35803. {
  35804. 'begin': 0x2600,
  35805. 'end': 0x26FF
  35806. },
  35807. {
  35808. 'begin': 0x2700,
  35809. 'end': 0x27BF
  35810. },
  35811. {
  35812. 'begin': 0x3000,
  35813. 'end': 0x303F
  35814. },
  35815. {
  35816. 'begin': 0x3040,
  35817. 'end': 0x309F
  35818. },
  35819. {
  35820. 'begin': 0x30A0,
  35821. 'end': 0x30FF
  35822. },
  35823. {
  35824. 'begin': 0x3100,
  35825. 'end': 0x312F
  35826. },
  35827. {
  35828. 'begin': 0x3130,
  35829. 'end': 0x318F
  35830. },
  35831. {
  35832. 'begin': 0xA840,
  35833. 'end': 0xA87F
  35834. },
  35835. {
  35836. 'begin': 0x3200,
  35837. 'end': 0x32FF
  35838. },
  35839. {
  35840. 'begin': 0x3300,
  35841. 'end': 0x33FF
  35842. },
  35843. {
  35844. 'begin': 0xAC00,
  35845. 'end': 0xD7AF
  35846. },
  35847. {
  35848. 'begin': 0xD800,
  35849. 'end': 0xDFFF
  35850. },
  35851. {
  35852. 'begin': 0x10900,
  35853. 'end': 0x1091F
  35854. },
  35855. {
  35856. 'begin': 0x4E00,
  35857. 'end': 0x9FFF
  35858. },
  35859. {
  35860. 'begin': 0xE000,
  35861. 'end': 0xF8FF
  35862. },
  35863. {
  35864. 'begin': 0x31C0,
  35865. 'end': 0x31EF
  35866. },
  35867. {
  35868. 'begin': 0xFB00,
  35869. 'end': 0xFB4F
  35870. },
  35871. {
  35872. 'begin': 0xFB50,
  35873. 'end': 0xFDFF
  35874. },
  35875. {
  35876. 'begin': 0xFE20,
  35877. 'end': 0xFE2F
  35878. },
  35879. {
  35880. 'begin': 0xFE10,
  35881. 'end': 0xFE1F
  35882. },
  35883. {
  35884. 'begin': 0xFE50,
  35885. 'end': 0xFE6F
  35886. },
  35887. {
  35888. 'begin': 0xFE70,
  35889. 'end': 0xFEFF
  35890. },
  35891. {
  35892. 'begin': 0xFF00,
  35893. 'end': 0xFFEF
  35894. },
  35895. {
  35896. 'begin': 0xFFF0,
  35897. 'end': 0xFFFF
  35898. },
  35899. {
  35900. 'begin': 0x0F00,
  35901. 'end': 0x0FFF
  35902. },
  35903. {
  35904. 'begin': 0x0700,
  35905. 'end': 0x074F
  35906. },
  35907. {
  35908. 'begin': 0x0780,
  35909. 'end': 0x07BF
  35910. },
  35911. {
  35912. 'begin': 0x0D80,
  35913. 'end': 0x0DFF
  35914. },
  35915. {
  35916. 'begin': 0x1000,
  35917. 'end': 0x109F
  35918. },
  35919. {
  35920. 'begin': 0x1200,
  35921. 'end': 0x137F
  35922. },
  35923. {
  35924. 'begin': 0x13A0,
  35925. 'end': 0x13FF
  35926. },
  35927. {
  35928. 'begin': 0x1400,
  35929. 'end': 0x167F
  35930. },
  35931. {
  35932. 'begin': 0x1680,
  35933. 'end': 0x169F
  35934. },
  35935. {
  35936. 'begin': 0x16A0,
  35937. 'end': 0x16FF
  35938. },
  35939. {
  35940. 'begin': 0x1780,
  35941. 'end': 0x17FF
  35942. },
  35943. {
  35944. 'begin': 0x1800,
  35945. 'end': 0x18AF
  35946. },
  35947. {
  35948. 'begin': 0x2800,
  35949. 'end': 0x28FF
  35950. },
  35951. {
  35952. 'begin': 0xA000,
  35953. 'end': 0xA48F
  35954. },
  35955. {
  35956. 'begin': 0x1700,
  35957. 'end': 0x171F
  35958. },
  35959. {
  35960. 'begin': 0x10300,
  35961. 'end': 0x1032F
  35962. },
  35963. {
  35964. 'begin': 0x10330,
  35965. 'end': 0x1034F
  35966. },
  35967. {
  35968. 'begin': 0x10400,
  35969. 'end': 0x1044F
  35970. },
  35971. {
  35972. 'begin': 0x1D000,
  35973. 'end': 0x1D0FF
  35974. },
  35975. {
  35976. 'begin': 0x1D400,
  35977. 'end': 0x1D7FF
  35978. },
  35979. {
  35980. 'begin': 0xFF000,
  35981. 'end': 0xFFFFD
  35982. },
  35983. {
  35984. 'begin': 0xFE00,
  35985. 'end': 0xFE0F
  35986. },
  35987. {
  35988. 'begin': 0xE0000,
  35989. 'end': 0xE007F
  35990. },
  35991. {
  35992. 'begin': 0x1900,
  35993. 'end': 0x194F
  35994. },
  35995. {
  35996. 'begin': 0x1950,
  35997. 'end': 0x197F
  35998. },
  35999. {
  36000. 'begin': 0x1980,
  36001. 'end': 0x19DF
  36002. },
  36003. {
  36004. 'begin': 0x1A00,
  36005. 'end': 0x1A1F
  36006. },
  36007. {
  36008. 'begin': 0x2C00,
  36009. 'end': 0x2C5F
  36010. },
  36011. {
  36012. 'begin': 0x2D30,
  36013. 'end': 0x2D7F
  36014. },
  36015. {
  36016. 'begin': 0x4DC0,
  36017. 'end': 0x4DFF
  36018. },
  36019. {
  36020. 'begin': 0xA800,
  36021. 'end': 0xA82F
  36022. },
  36023. {
  36024. 'begin': 0x10000,
  36025. 'end': 0x1007F
  36026. },
  36027. {
  36028. 'begin': 0x10140,
  36029. 'end': 0x1018F
  36030. },
  36031. {
  36032. 'begin': 0x10380,
  36033. 'end': 0x1039F
  36034. },
  36035. {
  36036. 'begin': 0x103A0,
  36037. 'end': 0x103DF
  36038. },
  36039. {
  36040. 'begin': 0x10450,
  36041. 'end': 0x1047F
  36042. },
  36043. {
  36044. 'begin': 0x10480,
  36045. 'end': 0x104AF
  36046. },
  36047. {
  36048. 'begin': 0x10800,
  36049. 'end': 0x1083F
  36050. },
  36051. {
  36052. 'begin': 0x10A00,
  36053. 'end': 0x10A5F
  36054. },
  36055. {
  36056. 'begin': 0x1D300,
  36057. 'end': 0x1D35F
  36058. },
  36059. {
  36060. 'begin': 0x12000,
  36061. 'end': 0x123FF
  36062. },
  36063. {
  36064. 'begin': 0x1D360,
  36065. 'end': 0x1D37F
  36066. },
  36067. {
  36068. 'begin': 0x1B80,
  36069. 'end': 0x1BBF
  36070. },
  36071. {
  36072. 'begin': 0x1C00,
  36073. 'end': 0x1C4F
  36074. },
  36075. {
  36076. 'begin': 0x1C50,
  36077. 'end': 0x1C7F
  36078. },
  36079. {
  36080. 'begin': 0xA880,
  36081. 'end': 0xA8DF
  36082. },
  36083. {
  36084. 'begin': 0xA900,
  36085. 'end': 0xA92F
  36086. },
  36087. {
  36088. 'begin': 0xA930,
  36089. 'end': 0xA95F
  36090. },
  36091. {
  36092. 'begin': 0xAA00,
  36093. 'end': 0xAA5F
  36094. },
  36095. {
  36096. 'begin': 0x10190,
  36097. 'end': 0x101CF
  36098. },
  36099. {
  36100. 'begin': 0x101D0,
  36101. 'end': 0x101FF
  36102. },
  36103. {
  36104. 'begin': 0x102A0,
  36105. 'end': 0x102DF
  36106. },
  36107. {
  36108. 'begin': 0x1F030,
  36109. 'end': 0x1F09F
  36110. }
  36111. ];
  36112. function getUnicodeRangeFor(value) {
  36113. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36114. var range = UnicodeRanges[i];
  36115. if (value >= range.begin && value < range.end) {
  36116. return i;
  36117. }
  36118. }
  36119. return -1;
  36120. }
  36121. function isRTLRangeFor(value) {
  36122. var range = UnicodeRanges[13];
  36123. if (value >= range.begin && value < range.end) {
  36124. return true;
  36125. }
  36126. range = UnicodeRanges[11];
  36127. if (value >= range.begin && value < range.end) {
  36128. return true;
  36129. }
  36130. return false;
  36131. }
  36132. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36133. t['\u00A8'] = '\u0020\u0308';
  36134. t['\u00AF'] = '\u0020\u0304';
  36135. t['\u00B4'] = '\u0020\u0301';
  36136. t['\u00B5'] = '\u03BC';
  36137. t['\u00B8'] = '\u0020\u0327';
  36138. t['\u0132'] = '\u0049\u004A';
  36139. t['\u0133'] = '\u0069\u006A';
  36140. t['\u013F'] = '\u004C\u00B7';
  36141. t['\u0140'] = '\u006C\u00B7';
  36142. t['\u0149'] = '\u02BC\u006E';
  36143. t['\u017F'] = '\u0073';
  36144. t['\u01C4'] = '\u0044\u017D';
  36145. t['\u01C5'] = '\u0044\u017E';
  36146. t['\u01C6'] = '\u0064\u017E';
  36147. t['\u01C7'] = '\u004C\u004A';
  36148. t['\u01C8'] = '\u004C\u006A';
  36149. t['\u01C9'] = '\u006C\u006A';
  36150. t['\u01CA'] = '\u004E\u004A';
  36151. t['\u01CB'] = '\u004E\u006A';
  36152. t['\u01CC'] = '\u006E\u006A';
  36153. t['\u01F1'] = '\u0044\u005A';
  36154. t['\u01F2'] = '\u0044\u007A';
  36155. t['\u01F3'] = '\u0064\u007A';
  36156. t['\u02D8'] = '\u0020\u0306';
  36157. t['\u02D9'] = '\u0020\u0307';
  36158. t['\u02DA'] = '\u0020\u030A';
  36159. t['\u02DB'] = '\u0020\u0328';
  36160. t['\u02DC'] = '\u0020\u0303';
  36161. t['\u02DD'] = '\u0020\u030B';
  36162. t['\u037A'] = '\u0020\u0345';
  36163. t['\u0384'] = '\u0020\u0301';
  36164. t['\u03D0'] = '\u03B2';
  36165. t['\u03D1'] = '\u03B8';
  36166. t['\u03D2'] = '\u03A5';
  36167. t['\u03D5'] = '\u03C6';
  36168. t['\u03D6'] = '\u03C0';
  36169. t['\u03F0'] = '\u03BA';
  36170. t['\u03F1'] = '\u03C1';
  36171. t['\u03F2'] = '\u03C2';
  36172. t['\u03F4'] = '\u0398';
  36173. t['\u03F5'] = '\u03B5';
  36174. t['\u03F9'] = '\u03A3';
  36175. t['\u0587'] = '\u0565\u0582';
  36176. t['\u0675'] = '\u0627\u0674';
  36177. t['\u0676'] = '\u0648\u0674';
  36178. t['\u0677'] = '\u06C7\u0674';
  36179. t['\u0678'] = '\u064A\u0674';
  36180. t['\u0E33'] = '\u0E4D\u0E32';
  36181. t['\u0EB3'] = '\u0ECD\u0EB2';
  36182. t['\u0EDC'] = '\u0EAB\u0E99';
  36183. t['\u0EDD'] = '\u0EAB\u0EA1';
  36184. t['\u0F77'] = '\u0FB2\u0F81';
  36185. t['\u0F79'] = '\u0FB3\u0F81';
  36186. t['\u1E9A'] = '\u0061\u02BE';
  36187. t['\u1FBD'] = '\u0020\u0313';
  36188. t['\u1FBF'] = '\u0020\u0313';
  36189. t['\u1FC0'] = '\u0020\u0342';
  36190. t['\u1FFE'] = '\u0020\u0314';
  36191. t['\u2002'] = '\u0020';
  36192. t['\u2003'] = '\u0020';
  36193. t['\u2004'] = '\u0020';
  36194. t['\u2005'] = '\u0020';
  36195. t['\u2006'] = '\u0020';
  36196. t['\u2008'] = '\u0020';
  36197. t['\u2009'] = '\u0020';
  36198. t['\u200A'] = '\u0020';
  36199. t['\u2017'] = '\u0020\u0333';
  36200. t['\u2024'] = '\u002E';
  36201. t['\u2025'] = '\u002E\u002E';
  36202. t['\u2026'] = '\u002E\u002E\u002E';
  36203. t['\u2033'] = '\u2032\u2032';
  36204. t['\u2034'] = '\u2032\u2032\u2032';
  36205. t['\u2036'] = '\u2035\u2035';
  36206. t['\u2037'] = '\u2035\u2035\u2035';
  36207. t['\u203C'] = '\u0021\u0021';
  36208. t['\u203E'] = '\u0020\u0305';
  36209. t['\u2047'] = '\u003F\u003F';
  36210. t['\u2048'] = '\u003F\u0021';
  36211. t['\u2049'] = '\u0021\u003F';
  36212. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36213. t['\u205F'] = '\u0020';
  36214. t['\u20A8'] = '\u0052\u0073';
  36215. t['\u2100'] = '\u0061\u002F\u0063';
  36216. t['\u2101'] = '\u0061\u002F\u0073';
  36217. t['\u2103'] = '\u00B0\u0043';
  36218. t['\u2105'] = '\u0063\u002F\u006F';
  36219. t['\u2106'] = '\u0063\u002F\u0075';
  36220. t['\u2107'] = '\u0190';
  36221. t['\u2109'] = '\u00B0\u0046';
  36222. t['\u2116'] = '\u004E\u006F';
  36223. t['\u2121'] = '\u0054\u0045\u004C';
  36224. t['\u2135'] = '\u05D0';
  36225. t['\u2136'] = '\u05D1';
  36226. t['\u2137'] = '\u05D2';
  36227. t['\u2138'] = '\u05D3';
  36228. t['\u213B'] = '\u0046\u0041\u0058';
  36229. t['\u2160'] = '\u0049';
  36230. t['\u2161'] = '\u0049\u0049';
  36231. t['\u2162'] = '\u0049\u0049\u0049';
  36232. t['\u2163'] = '\u0049\u0056';
  36233. t['\u2164'] = '\u0056';
  36234. t['\u2165'] = '\u0056\u0049';
  36235. t['\u2166'] = '\u0056\u0049\u0049';
  36236. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36237. t['\u2168'] = '\u0049\u0058';
  36238. t['\u2169'] = '\u0058';
  36239. t['\u216A'] = '\u0058\u0049';
  36240. t['\u216B'] = '\u0058\u0049\u0049';
  36241. t['\u216C'] = '\u004C';
  36242. t['\u216D'] = '\u0043';
  36243. t['\u216E'] = '\u0044';
  36244. t['\u216F'] = '\u004D';
  36245. t['\u2170'] = '\u0069';
  36246. t['\u2171'] = '\u0069\u0069';
  36247. t['\u2172'] = '\u0069\u0069\u0069';
  36248. t['\u2173'] = '\u0069\u0076';
  36249. t['\u2174'] = '\u0076';
  36250. t['\u2175'] = '\u0076\u0069';
  36251. t['\u2176'] = '\u0076\u0069\u0069';
  36252. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36253. t['\u2178'] = '\u0069\u0078';
  36254. t['\u2179'] = '\u0078';
  36255. t['\u217A'] = '\u0078\u0069';
  36256. t['\u217B'] = '\u0078\u0069\u0069';
  36257. t['\u217C'] = '\u006C';
  36258. t['\u217D'] = '\u0063';
  36259. t['\u217E'] = '\u0064';
  36260. t['\u217F'] = '\u006D';
  36261. t['\u222C'] = '\u222B\u222B';
  36262. t['\u222D'] = '\u222B\u222B\u222B';
  36263. t['\u222F'] = '\u222E\u222E';
  36264. t['\u2230'] = '\u222E\u222E\u222E';
  36265. t['\u2474'] = '\u0028\u0031\u0029';
  36266. t['\u2475'] = '\u0028\u0032\u0029';
  36267. t['\u2476'] = '\u0028\u0033\u0029';
  36268. t['\u2477'] = '\u0028\u0034\u0029';
  36269. t['\u2478'] = '\u0028\u0035\u0029';
  36270. t['\u2479'] = '\u0028\u0036\u0029';
  36271. t['\u247A'] = '\u0028\u0037\u0029';
  36272. t['\u247B'] = '\u0028\u0038\u0029';
  36273. t['\u247C'] = '\u0028\u0039\u0029';
  36274. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36275. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36276. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36277. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36278. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36279. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36280. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36281. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36282. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36283. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36284. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36285. t['\u2488'] = '\u0031\u002E';
  36286. t['\u2489'] = '\u0032\u002E';
  36287. t['\u248A'] = '\u0033\u002E';
  36288. t['\u248B'] = '\u0034\u002E';
  36289. t['\u248C'] = '\u0035\u002E';
  36290. t['\u248D'] = '\u0036\u002E';
  36291. t['\u248E'] = '\u0037\u002E';
  36292. t['\u248F'] = '\u0038\u002E';
  36293. t['\u2490'] = '\u0039\u002E';
  36294. t['\u2491'] = '\u0031\u0030\u002E';
  36295. t['\u2492'] = '\u0031\u0031\u002E';
  36296. t['\u2493'] = '\u0031\u0032\u002E';
  36297. t['\u2494'] = '\u0031\u0033\u002E';
  36298. t['\u2495'] = '\u0031\u0034\u002E';
  36299. t['\u2496'] = '\u0031\u0035\u002E';
  36300. t['\u2497'] = '\u0031\u0036\u002E';
  36301. t['\u2498'] = '\u0031\u0037\u002E';
  36302. t['\u2499'] = '\u0031\u0038\u002E';
  36303. t['\u249A'] = '\u0031\u0039\u002E';
  36304. t['\u249B'] = '\u0032\u0030\u002E';
  36305. t['\u249C'] = '\u0028\u0061\u0029';
  36306. t['\u249D'] = '\u0028\u0062\u0029';
  36307. t['\u249E'] = '\u0028\u0063\u0029';
  36308. t['\u249F'] = '\u0028\u0064\u0029';
  36309. t['\u24A0'] = '\u0028\u0065\u0029';
  36310. t['\u24A1'] = '\u0028\u0066\u0029';
  36311. t['\u24A2'] = '\u0028\u0067\u0029';
  36312. t['\u24A3'] = '\u0028\u0068\u0029';
  36313. t['\u24A4'] = '\u0028\u0069\u0029';
  36314. t['\u24A5'] = '\u0028\u006A\u0029';
  36315. t['\u24A6'] = '\u0028\u006B\u0029';
  36316. t['\u24A7'] = '\u0028\u006C\u0029';
  36317. t['\u24A8'] = '\u0028\u006D\u0029';
  36318. t['\u24A9'] = '\u0028\u006E\u0029';
  36319. t['\u24AA'] = '\u0028\u006F\u0029';
  36320. t['\u24AB'] = '\u0028\u0070\u0029';
  36321. t['\u24AC'] = '\u0028\u0071\u0029';
  36322. t['\u24AD'] = '\u0028\u0072\u0029';
  36323. t['\u24AE'] = '\u0028\u0073\u0029';
  36324. t['\u24AF'] = '\u0028\u0074\u0029';
  36325. t['\u24B0'] = '\u0028\u0075\u0029';
  36326. t['\u24B1'] = '\u0028\u0076\u0029';
  36327. t['\u24B2'] = '\u0028\u0077\u0029';
  36328. t['\u24B3'] = '\u0028\u0078\u0029';
  36329. t['\u24B4'] = '\u0028\u0079\u0029';
  36330. t['\u24B5'] = '\u0028\u007A\u0029';
  36331. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36332. t['\u2A74'] = '\u003A\u003A\u003D';
  36333. t['\u2A75'] = '\u003D\u003D';
  36334. t['\u2A76'] = '\u003D\u003D\u003D';
  36335. t['\u2E9F'] = '\u6BCD';
  36336. t['\u2EF3'] = '\u9F9F';
  36337. t['\u2F00'] = '\u4E00';
  36338. t['\u2F01'] = '\u4E28';
  36339. t['\u2F02'] = '\u4E36';
  36340. t['\u2F03'] = '\u4E3F';
  36341. t['\u2F04'] = '\u4E59';
  36342. t['\u2F05'] = '\u4E85';
  36343. t['\u2F06'] = '\u4E8C';
  36344. t['\u2F07'] = '\u4EA0';
  36345. t['\u2F08'] = '\u4EBA';
  36346. t['\u2F09'] = '\u513F';
  36347. t['\u2F0A'] = '\u5165';
  36348. t['\u2F0B'] = '\u516B';
  36349. t['\u2F0C'] = '\u5182';
  36350. t['\u2F0D'] = '\u5196';
  36351. t['\u2F0E'] = '\u51AB';
  36352. t['\u2F0F'] = '\u51E0';
  36353. t['\u2F10'] = '\u51F5';
  36354. t['\u2F11'] = '\u5200';
  36355. t['\u2F12'] = '\u529B';
  36356. t['\u2F13'] = '\u52F9';
  36357. t['\u2F14'] = '\u5315';
  36358. t['\u2F15'] = '\u531A';
  36359. t['\u2F16'] = '\u5338';
  36360. t['\u2F17'] = '\u5341';
  36361. t['\u2F18'] = '\u535C';
  36362. t['\u2F19'] = '\u5369';
  36363. t['\u2F1A'] = '\u5382';
  36364. t['\u2F1B'] = '\u53B6';
  36365. t['\u2F1C'] = '\u53C8';
  36366. t['\u2F1D'] = '\u53E3';
  36367. t['\u2F1E'] = '\u56D7';
  36368. t['\u2F1F'] = '\u571F';
  36369. t['\u2F20'] = '\u58EB';
  36370. t['\u2F21'] = '\u5902';
  36371. t['\u2F22'] = '\u590A';
  36372. t['\u2F23'] = '\u5915';
  36373. t['\u2F24'] = '\u5927';
  36374. t['\u2F25'] = '\u5973';
  36375. t['\u2F26'] = '\u5B50';
  36376. t['\u2F27'] = '\u5B80';
  36377. t['\u2F28'] = '\u5BF8';
  36378. t['\u2F29'] = '\u5C0F';
  36379. t['\u2F2A'] = '\u5C22';
  36380. t['\u2F2B'] = '\u5C38';
  36381. t['\u2F2C'] = '\u5C6E';
  36382. t['\u2F2D'] = '\u5C71';
  36383. t['\u2F2E'] = '\u5DDB';
  36384. t['\u2F2F'] = '\u5DE5';
  36385. t['\u2F30'] = '\u5DF1';
  36386. t['\u2F31'] = '\u5DFE';
  36387. t['\u2F32'] = '\u5E72';
  36388. t['\u2F33'] = '\u5E7A';
  36389. t['\u2F34'] = '\u5E7F';
  36390. t['\u2F35'] = '\u5EF4';
  36391. t['\u2F36'] = '\u5EFE';
  36392. t['\u2F37'] = '\u5F0B';
  36393. t['\u2F38'] = '\u5F13';
  36394. t['\u2F39'] = '\u5F50';
  36395. t['\u2F3A'] = '\u5F61';
  36396. t['\u2F3B'] = '\u5F73';
  36397. t['\u2F3C'] = '\u5FC3';
  36398. t['\u2F3D'] = '\u6208';
  36399. t['\u2F3E'] = '\u6236';
  36400. t['\u2F3F'] = '\u624B';
  36401. t['\u2F40'] = '\u652F';
  36402. t['\u2F41'] = '\u6534';
  36403. t['\u2F42'] = '\u6587';
  36404. t['\u2F43'] = '\u6597';
  36405. t['\u2F44'] = '\u65A4';
  36406. t['\u2F45'] = '\u65B9';
  36407. t['\u2F46'] = '\u65E0';
  36408. t['\u2F47'] = '\u65E5';
  36409. t['\u2F48'] = '\u66F0';
  36410. t['\u2F49'] = '\u6708';
  36411. t['\u2F4A'] = '\u6728';
  36412. t['\u2F4B'] = '\u6B20';
  36413. t['\u2F4C'] = '\u6B62';
  36414. t['\u2F4D'] = '\u6B79';
  36415. t['\u2F4E'] = '\u6BB3';
  36416. t['\u2F4F'] = '\u6BCB';
  36417. t['\u2F50'] = '\u6BD4';
  36418. t['\u2F51'] = '\u6BDB';
  36419. t['\u2F52'] = '\u6C0F';
  36420. t['\u2F53'] = '\u6C14';
  36421. t['\u2F54'] = '\u6C34';
  36422. t['\u2F55'] = '\u706B';
  36423. t['\u2F56'] = '\u722A';
  36424. t['\u2F57'] = '\u7236';
  36425. t['\u2F58'] = '\u723B';
  36426. t['\u2F59'] = '\u723F';
  36427. t['\u2F5A'] = '\u7247';
  36428. t['\u2F5B'] = '\u7259';
  36429. t['\u2F5C'] = '\u725B';
  36430. t['\u2F5D'] = '\u72AC';
  36431. t['\u2F5E'] = '\u7384';
  36432. t['\u2F5F'] = '\u7389';
  36433. t['\u2F60'] = '\u74DC';
  36434. t['\u2F61'] = '\u74E6';
  36435. t['\u2F62'] = '\u7518';
  36436. t['\u2F63'] = '\u751F';
  36437. t['\u2F64'] = '\u7528';
  36438. t['\u2F65'] = '\u7530';
  36439. t['\u2F66'] = '\u758B';
  36440. t['\u2F67'] = '\u7592';
  36441. t['\u2F68'] = '\u7676';
  36442. t['\u2F69'] = '\u767D';
  36443. t['\u2F6A'] = '\u76AE';
  36444. t['\u2F6B'] = '\u76BF';
  36445. t['\u2F6C'] = '\u76EE';
  36446. t['\u2F6D'] = '\u77DB';
  36447. t['\u2F6E'] = '\u77E2';
  36448. t['\u2F6F'] = '\u77F3';
  36449. t['\u2F70'] = '\u793A';
  36450. t['\u2F71'] = '\u79B8';
  36451. t['\u2F72'] = '\u79BE';
  36452. t['\u2F73'] = '\u7A74';
  36453. t['\u2F74'] = '\u7ACB';
  36454. t['\u2F75'] = '\u7AF9';
  36455. t['\u2F76'] = '\u7C73';
  36456. t['\u2F77'] = '\u7CF8';
  36457. t['\u2F78'] = '\u7F36';
  36458. t['\u2F79'] = '\u7F51';
  36459. t['\u2F7A'] = '\u7F8A';
  36460. t['\u2F7B'] = '\u7FBD';
  36461. t['\u2F7C'] = '\u8001';
  36462. t['\u2F7D'] = '\u800C';
  36463. t['\u2F7E'] = '\u8012';
  36464. t['\u2F7F'] = '\u8033';
  36465. t['\u2F80'] = '\u807F';
  36466. t['\u2F81'] = '\u8089';
  36467. t['\u2F82'] = '\u81E3';
  36468. t['\u2F83'] = '\u81EA';
  36469. t['\u2F84'] = '\u81F3';
  36470. t['\u2F85'] = '\u81FC';
  36471. t['\u2F86'] = '\u820C';
  36472. t['\u2F87'] = '\u821B';
  36473. t['\u2F88'] = '\u821F';
  36474. t['\u2F89'] = '\u826E';
  36475. t['\u2F8A'] = '\u8272';
  36476. t['\u2F8B'] = '\u8278';
  36477. t['\u2F8C'] = '\u864D';
  36478. t['\u2F8D'] = '\u866B';
  36479. t['\u2F8E'] = '\u8840';
  36480. t['\u2F8F'] = '\u884C';
  36481. t['\u2F90'] = '\u8863';
  36482. t['\u2F91'] = '\u897E';
  36483. t['\u2F92'] = '\u898B';
  36484. t['\u2F93'] = '\u89D2';
  36485. t['\u2F94'] = '\u8A00';
  36486. t['\u2F95'] = '\u8C37';
  36487. t['\u2F96'] = '\u8C46';
  36488. t['\u2F97'] = '\u8C55';
  36489. t['\u2F98'] = '\u8C78';
  36490. t['\u2F99'] = '\u8C9D';
  36491. t['\u2F9A'] = '\u8D64';
  36492. t['\u2F9B'] = '\u8D70';
  36493. t['\u2F9C'] = '\u8DB3';
  36494. t['\u2F9D'] = '\u8EAB';
  36495. t['\u2F9E'] = '\u8ECA';
  36496. t['\u2F9F'] = '\u8F9B';
  36497. t['\u2FA0'] = '\u8FB0';
  36498. t['\u2FA1'] = '\u8FB5';
  36499. t['\u2FA2'] = '\u9091';
  36500. t['\u2FA3'] = '\u9149';
  36501. t['\u2FA4'] = '\u91C6';
  36502. t['\u2FA5'] = '\u91CC';
  36503. t['\u2FA6'] = '\u91D1';
  36504. t['\u2FA7'] = '\u9577';
  36505. t['\u2FA8'] = '\u9580';
  36506. t['\u2FA9'] = '\u961C';
  36507. t['\u2FAA'] = '\u96B6';
  36508. t['\u2FAB'] = '\u96B9';
  36509. t['\u2FAC'] = '\u96E8';
  36510. t['\u2FAD'] = '\u9751';
  36511. t['\u2FAE'] = '\u975E';
  36512. t['\u2FAF'] = '\u9762';
  36513. t['\u2FB0'] = '\u9769';
  36514. t['\u2FB1'] = '\u97CB';
  36515. t['\u2FB2'] = '\u97ED';
  36516. t['\u2FB3'] = '\u97F3';
  36517. t['\u2FB4'] = '\u9801';
  36518. t['\u2FB5'] = '\u98A8';
  36519. t['\u2FB6'] = '\u98DB';
  36520. t['\u2FB7'] = '\u98DF';
  36521. t['\u2FB8'] = '\u9996';
  36522. t['\u2FB9'] = '\u9999';
  36523. t['\u2FBA'] = '\u99AC';
  36524. t['\u2FBB'] = '\u9AA8';
  36525. t['\u2FBC'] = '\u9AD8';
  36526. t['\u2FBD'] = '\u9ADF';
  36527. t['\u2FBE'] = '\u9B25';
  36528. t['\u2FBF'] = '\u9B2F';
  36529. t['\u2FC0'] = '\u9B32';
  36530. t['\u2FC1'] = '\u9B3C';
  36531. t['\u2FC2'] = '\u9B5A';
  36532. t['\u2FC3'] = '\u9CE5';
  36533. t['\u2FC4'] = '\u9E75';
  36534. t['\u2FC5'] = '\u9E7F';
  36535. t['\u2FC6'] = '\u9EA5';
  36536. t['\u2FC7'] = '\u9EBB';
  36537. t['\u2FC8'] = '\u9EC3';
  36538. t['\u2FC9'] = '\u9ECD';
  36539. t['\u2FCA'] = '\u9ED1';
  36540. t['\u2FCB'] = '\u9EF9';
  36541. t['\u2FCC'] = '\u9EFD';
  36542. t['\u2FCD'] = '\u9F0E';
  36543. t['\u2FCE'] = '\u9F13';
  36544. t['\u2FCF'] = '\u9F20';
  36545. t['\u2FD0'] = '\u9F3B';
  36546. t['\u2FD1'] = '\u9F4A';
  36547. t['\u2FD2'] = '\u9F52';
  36548. t['\u2FD3'] = '\u9F8D';
  36549. t['\u2FD4'] = '\u9F9C';
  36550. t['\u2FD5'] = '\u9FA0';
  36551. t['\u3036'] = '\u3012';
  36552. t['\u3038'] = '\u5341';
  36553. t['\u3039'] = '\u5344';
  36554. t['\u303A'] = '\u5345';
  36555. t['\u309B'] = '\u0020\u3099';
  36556. t['\u309C'] = '\u0020\u309A';
  36557. t['\u3131'] = '\u1100';
  36558. t['\u3132'] = '\u1101';
  36559. t['\u3133'] = '\u11AA';
  36560. t['\u3134'] = '\u1102';
  36561. t['\u3135'] = '\u11AC';
  36562. t['\u3136'] = '\u11AD';
  36563. t['\u3137'] = '\u1103';
  36564. t['\u3138'] = '\u1104';
  36565. t['\u3139'] = '\u1105';
  36566. t['\u313A'] = '\u11B0';
  36567. t['\u313B'] = '\u11B1';
  36568. t['\u313C'] = '\u11B2';
  36569. t['\u313D'] = '\u11B3';
  36570. t['\u313E'] = '\u11B4';
  36571. t['\u313F'] = '\u11B5';
  36572. t['\u3140'] = '\u111A';
  36573. t['\u3141'] = '\u1106';
  36574. t['\u3142'] = '\u1107';
  36575. t['\u3143'] = '\u1108';
  36576. t['\u3144'] = '\u1121';
  36577. t['\u3145'] = '\u1109';
  36578. t['\u3146'] = '\u110A';
  36579. t['\u3147'] = '\u110B';
  36580. t['\u3148'] = '\u110C';
  36581. t['\u3149'] = '\u110D';
  36582. t['\u314A'] = '\u110E';
  36583. t['\u314B'] = '\u110F';
  36584. t['\u314C'] = '\u1110';
  36585. t['\u314D'] = '\u1111';
  36586. t['\u314E'] = '\u1112';
  36587. t['\u314F'] = '\u1161';
  36588. t['\u3150'] = '\u1162';
  36589. t['\u3151'] = '\u1163';
  36590. t['\u3152'] = '\u1164';
  36591. t['\u3153'] = '\u1165';
  36592. t['\u3154'] = '\u1166';
  36593. t['\u3155'] = '\u1167';
  36594. t['\u3156'] = '\u1168';
  36595. t['\u3157'] = '\u1169';
  36596. t['\u3158'] = '\u116A';
  36597. t['\u3159'] = '\u116B';
  36598. t['\u315A'] = '\u116C';
  36599. t['\u315B'] = '\u116D';
  36600. t['\u315C'] = '\u116E';
  36601. t['\u315D'] = '\u116F';
  36602. t['\u315E'] = '\u1170';
  36603. t['\u315F'] = '\u1171';
  36604. t['\u3160'] = '\u1172';
  36605. t['\u3161'] = '\u1173';
  36606. t['\u3162'] = '\u1174';
  36607. t['\u3163'] = '\u1175';
  36608. t['\u3164'] = '\u1160';
  36609. t['\u3165'] = '\u1114';
  36610. t['\u3166'] = '\u1115';
  36611. t['\u3167'] = '\u11C7';
  36612. t['\u3168'] = '\u11C8';
  36613. t['\u3169'] = '\u11CC';
  36614. t['\u316A'] = '\u11CE';
  36615. t['\u316B'] = '\u11D3';
  36616. t['\u316C'] = '\u11D7';
  36617. t['\u316D'] = '\u11D9';
  36618. t['\u316E'] = '\u111C';
  36619. t['\u316F'] = '\u11DD';
  36620. t['\u3170'] = '\u11DF';
  36621. t['\u3171'] = '\u111D';
  36622. t['\u3172'] = '\u111E';
  36623. t['\u3173'] = '\u1120';
  36624. t['\u3174'] = '\u1122';
  36625. t['\u3175'] = '\u1123';
  36626. t['\u3176'] = '\u1127';
  36627. t['\u3177'] = '\u1129';
  36628. t['\u3178'] = '\u112B';
  36629. t['\u3179'] = '\u112C';
  36630. t['\u317A'] = '\u112D';
  36631. t['\u317B'] = '\u112E';
  36632. t['\u317C'] = '\u112F';
  36633. t['\u317D'] = '\u1132';
  36634. t['\u317E'] = '\u1136';
  36635. t['\u317F'] = '\u1140';
  36636. t['\u3180'] = '\u1147';
  36637. t['\u3181'] = '\u114C';
  36638. t['\u3182'] = '\u11F1';
  36639. t['\u3183'] = '\u11F2';
  36640. t['\u3184'] = '\u1157';
  36641. t['\u3185'] = '\u1158';
  36642. t['\u3186'] = '\u1159';
  36643. t['\u3187'] = '\u1184';
  36644. t['\u3188'] = '\u1185';
  36645. t['\u3189'] = '\u1188';
  36646. t['\u318A'] = '\u1191';
  36647. t['\u318B'] = '\u1192';
  36648. t['\u318C'] = '\u1194';
  36649. t['\u318D'] = '\u119E';
  36650. t['\u318E'] = '\u11A1';
  36651. t['\u3200'] = '\u0028\u1100\u0029';
  36652. t['\u3201'] = '\u0028\u1102\u0029';
  36653. t['\u3202'] = '\u0028\u1103\u0029';
  36654. t['\u3203'] = '\u0028\u1105\u0029';
  36655. t['\u3204'] = '\u0028\u1106\u0029';
  36656. t['\u3205'] = '\u0028\u1107\u0029';
  36657. t['\u3206'] = '\u0028\u1109\u0029';
  36658. t['\u3207'] = '\u0028\u110B\u0029';
  36659. t['\u3208'] = '\u0028\u110C\u0029';
  36660. t['\u3209'] = '\u0028\u110E\u0029';
  36661. t['\u320A'] = '\u0028\u110F\u0029';
  36662. t['\u320B'] = '\u0028\u1110\u0029';
  36663. t['\u320C'] = '\u0028\u1111\u0029';
  36664. t['\u320D'] = '\u0028\u1112\u0029';
  36665. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36666. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36667. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36668. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36669. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36670. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36671. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36672. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36673. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36674. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36675. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36676. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36677. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36678. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36679. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36680. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36681. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36682. t['\u3220'] = '\u0028\u4E00\u0029';
  36683. t['\u3221'] = '\u0028\u4E8C\u0029';
  36684. t['\u3222'] = '\u0028\u4E09\u0029';
  36685. t['\u3223'] = '\u0028\u56DB\u0029';
  36686. t['\u3224'] = '\u0028\u4E94\u0029';
  36687. t['\u3225'] = '\u0028\u516D\u0029';
  36688. t['\u3226'] = '\u0028\u4E03\u0029';
  36689. t['\u3227'] = '\u0028\u516B\u0029';
  36690. t['\u3228'] = '\u0028\u4E5D\u0029';
  36691. t['\u3229'] = '\u0028\u5341\u0029';
  36692. t['\u322A'] = '\u0028\u6708\u0029';
  36693. t['\u322B'] = '\u0028\u706B\u0029';
  36694. t['\u322C'] = '\u0028\u6C34\u0029';
  36695. t['\u322D'] = '\u0028\u6728\u0029';
  36696. t['\u322E'] = '\u0028\u91D1\u0029';
  36697. t['\u322F'] = '\u0028\u571F\u0029';
  36698. t['\u3230'] = '\u0028\u65E5\u0029';
  36699. t['\u3231'] = '\u0028\u682A\u0029';
  36700. t['\u3232'] = '\u0028\u6709\u0029';
  36701. t['\u3233'] = '\u0028\u793E\u0029';
  36702. t['\u3234'] = '\u0028\u540D\u0029';
  36703. t['\u3235'] = '\u0028\u7279\u0029';
  36704. t['\u3236'] = '\u0028\u8CA1\u0029';
  36705. t['\u3237'] = '\u0028\u795D\u0029';
  36706. t['\u3238'] = '\u0028\u52B4\u0029';
  36707. t['\u3239'] = '\u0028\u4EE3\u0029';
  36708. t['\u323A'] = '\u0028\u547C\u0029';
  36709. t['\u323B'] = '\u0028\u5B66\u0029';
  36710. t['\u323C'] = '\u0028\u76E3\u0029';
  36711. t['\u323D'] = '\u0028\u4F01\u0029';
  36712. t['\u323E'] = '\u0028\u8CC7\u0029';
  36713. t['\u323F'] = '\u0028\u5354\u0029';
  36714. t['\u3240'] = '\u0028\u796D\u0029';
  36715. t['\u3241'] = '\u0028\u4F11\u0029';
  36716. t['\u3242'] = '\u0028\u81EA\u0029';
  36717. t['\u3243'] = '\u0028\u81F3\u0029';
  36718. t['\u32C0'] = '\u0031\u6708';
  36719. t['\u32C1'] = '\u0032\u6708';
  36720. t['\u32C2'] = '\u0033\u6708';
  36721. t['\u32C3'] = '\u0034\u6708';
  36722. t['\u32C4'] = '\u0035\u6708';
  36723. t['\u32C5'] = '\u0036\u6708';
  36724. t['\u32C6'] = '\u0037\u6708';
  36725. t['\u32C7'] = '\u0038\u6708';
  36726. t['\u32C8'] = '\u0039\u6708';
  36727. t['\u32C9'] = '\u0031\u0030\u6708';
  36728. t['\u32CA'] = '\u0031\u0031\u6708';
  36729. t['\u32CB'] = '\u0031\u0032\u6708';
  36730. t['\u3358'] = '\u0030\u70B9';
  36731. t['\u3359'] = '\u0031\u70B9';
  36732. t['\u335A'] = '\u0032\u70B9';
  36733. t['\u335B'] = '\u0033\u70B9';
  36734. t['\u335C'] = '\u0034\u70B9';
  36735. t['\u335D'] = '\u0035\u70B9';
  36736. t['\u335E'] = '\u0036\u70B9';
  36737. t['\u335F'] = '\u0037\u70B9';
  36738. t['\u3360'] = '\u0038\u70B9';
  36739. t['\u3361'] = '\u0039\u70B9';
  36740. t['\u3362'] = '\u0031\u0030\u70B9';
  36741. t['\u3363'] = '\u0031\u0031\u70B9';
  36742. t['\u3364'] = '\u0031\u0032\u70B9';
  36743. t['\u3365'] = '\u0031\u0033\u70B9';
  36744. t['\u3366'] = '\u0031\u0034\u70B9';
  36745. t['\u3367'] = '\u0031\u0035\u70B9';
  36746. t['\u3368'] = '\u0031\u0036\u70B9';
  36747. t['\u3369'] = '\u0031\u0037\u70B9';
  36748. t['\u336A'] = '\u0031\u0038\u70B9';
  36749. t['\u336B'] = '\u0031\u0039\u70B9';
  36750. t['\u336C'] = '\u0032\u0030\u70B9';
  36751. t['\u336D'] = '\u0032\u0031\u70B9';
  36752. t['\u336E'] = '\u0032\u0032\u70B9';
  36753. t['\u336F'] = '\u0032\u0033\u70B9';
  36754. t['\u3370'] = '\u0032\u0034\u70B9';
  36755. t['\u33E0'] = '\u0031\u65E5';
  36756. t['\u33E1'] = '\u0032\u65E5';
  36757. t['\u33E2'] = '\u0033\u65E5';
  36758. t['\u33E3'] = '\u0034\u65E5';
  36759. t['\u33E4'] = '\u0035\u65E5';
  36760. t['\u33E5'] = '\u0036\u65E5';
  36761. t['\u33E6'] = '\u0037\u65E5';
  36762. t['\u33E7'] = '\u0038\u65E5';
  36763. t['\u33E8'] = '\u0039\u65E5';
  36764. t['\u33E9'] = '\u0031\u0030\u65E5';
  36765. t['\u33EA'] = '\u0031\u0031\u65E5';
  36766. t['\u33EB'] = '\u0031\u0032\u65E5';
  36767. t['\u33EC'] = '\u0031\u0033\u65E5';
  36768. t['\u33ED'] = '\u0031\u0034\u65E5';
  36769. t['\u33EE'] = '\u0031\u0035\u65E5';
  36770. t['\u33EF'] = '\u0031\u0036\u65E5';
  36771. t['\u33F0'] = '\u0031\u0037\u65E5';
  36772. t['\u33F1'] = '\u0031\u0038\u65E5';
  36773. t['\u33F2'] = '\u0031\u0039\u65E5';
  36774. t['\u33F3'] = '\u0032\u0030\u65E5';
  36775. t['\u33F4'] = '\u0032\u0031\u65E5';
  36776. t['\u33F5'] = '\u0032\u0032\u65E5';
  36777. t['\u33F6'] = '\u0032\u0033\u65E5';
  36778. t['\u33F7'] = '\u0032\u0034\u65E5';
  36779. t['\u33F8'] = '\u0032\u0035\u65E5';
  36780. t['\u33F9'] = '\u0032\u0036\u65E5';
  36781. t['\u33FA'] = '\u0032\u0037\u65E5';
  36782. t['\u33FB'] = '\u0032\u0038\u65E5';
  36783. t['\u33FC'] = '\u0032\u0039\u65E5';
  36784. t['\u33FD'] = '\u0033\u0030\u65E5';
  36785. t['\u33FE'] = '\u0033\u0031\u65E5';
  36786. t['\uFB00'] = '\u0066\u0066';
  36787. t['\uFB01'] = '\u0066\u0069';
  36788. t['\uFB02'] = '\u0066\u006C';
  36789. t['\uFB03'] = '\u0066\u0066\u0069';
  36790. t['\uFB04'] = '\u0066\u0066\u006C';
  36791. t['\uFB05'] = '\u017F\u0074';
  36792. t['\uFB06'] = '\u0073\u0074';
  36793. t['\uFB13'] = '\u0574\u0576';
  36794. t['\uFB14'] = '\u0574\u0565';
  36795. t['\uFB15'] = '\u0574\u056B';
  36796. t['\uFB16'] = '\u057E\u0576';
  36797. t['\uFB17'] = '\u0574\u056D';
  36798. t['\uFB4F'] = '\u05D0\u05DC';
  36799. t['\uFB50'] = '\u0671';
  36800. t['\uFB51'] = '\u0671';
  36801. t['\uFB52'] = '\u067B';
  36802. t['\uFB53'] = '\u067B';
  36803. t['\uFB54'] = '\u067B';
  36804. t['\uFB55'] = '\u067B';
  36805. t['\uFB56'] = '\u067E';
  36806. t['\uFB57'] = '\u067E';
  36807. t['\uFB58'] = '\u067E';
  36808. t['\uFB59'] = '\u067E';
  36809. t['\uFB5A'] = '\u0680';
  36810. t['\uFB5B'] = '\u0680';
  36811. t['\uFB5C'] = '\u0680';
  36812. t['\uFB5D'] = '\u0680';
  36813. t['\uFB5E'] = '\u067A';
  36814. t['\uFB5F'] = '\u067A';
  36815. t['\uFB60'] = '\u067A';
  36816. t['\uFB61'] = '\u067A';
  36817. t['\uFB62'] = '\u067F';
  36818. t['\uFB63'] = '\u067F';
  36819. t['\uFB64'] = '\u067F';
  36820. t['\uFB65'] = '\u067F';
  36821. t['\uFB66'] = '\u0679';
  36822. t['\uFB67'] = '\u0679';
  36823. t['\uFB68'] = '\u0679';
  36824. t['\uFB69'] = '\u0679';
  36825. t['\uFB6A'] = '\u06A4';
  36826. t['\uFB6B'] = '\u06A4';
  36827. t['\uFB6C'] = '\u06A4';
  36828. t['\uFB6D'] = '\u06A4';
  36829. t['\uFB6E'] = '\u06A6';
  36830. t['\uFB6F'] = '\u06A6';
  36831. t['\uFB70'] = '\u06A6';
  36832. t['\uFB71'] = '\u06A6';
  36833. t['\uFB72'] = '\u0684';
  36834. t['\uFB73'] = '\u0684';
  36835. t['\uFB74'] = '\u0684';
  36836. t['\uFB75'] = '\u0684';
  36837. t['\uFB76'] = '\u0683';
  36838. t['\uFB77'] = '\u0683';
  36839. t['\uFB78'] = '\u0683';
  36840. t['\uFB79'] = '\u0683';
  36841. t['\uFB7A'] = '\u0686';
  36842. t['\uFB7B'] = '\u0686';
  36843. t['\uFB7C'] = '\u0686';
  36844. t['\uFB7D'] = '\u0686';
  36845. t['\uFB7E'] = '\u0687';
  36846. t['\uFB7F'] = '\u0687';
  36847. t['\uFB80'] = '\u0687';
  36848. t['\uFB81'] = '\u0687';
  36849. t['\uFB82'] = '\u068D';
  36850. t['\uFB83'] = '\u068D';
  36851. t['\uFB84'] = '\u068C';
  36852. t['\uFB85'] = '\u068C';
  36853. t['\uFB86'] = '\u068E';
  36854. t['\uFB87'] = '\u068E';
  36855. t['\uFB88'] = '\u0688';
  36856. t['\uFB89'] = '\u0688';
  36857. t['\uFB8A'] = '\u0698';
  36858. t['\uFB8B'] = '\u0698';
  36859. t['\uFB8C'] = '\u0691';
  36860. t['\uFB8D'] = '\u0691';
  36861. t['\uFB8E'] = '\u06A9';
  36862. t['\uFB8F'] = '\u06A9';
  36863. t['\uFB90'] = '\u06A9';
  36864. t['\uFB91'] = '\u06A9';
  36865. t['\uFB92'] = '\u06AF';
  36866. t['\uFB93'] = '\u06AF';
  36867. t['\uFB94'] = '\u06AF';
  36868. t['\uFB95'] = '\u06AF';
  36869. t['\uFB96'] = '\u06B3';
  36870. t['\uFB97'] = '\u06B3';
  36871. t['\uFB98'] = '\u06B3';
  36872. t['\uFB99'] = '\u06B3';
  36873. t['\uFB9A'] = '\u06B1';
  36874. t['\uFB9B'] = '\u06B1';
  36875. t['\uFB9C'] = '\u06B1';
  36876. t['\uFB9D'] = '\u06B1';
  36877. t['\uFB9E'] = '\u06BA';
  36878. t['\uFB9F'] = '\u06BA';
  36879. t['\uFBA0'] = '\u06BB';
  36880. t['\uFBA1'] = '\u06BB';
  36881. t['\uFBA2'] = '\u06BB';
  36882. t['\uFBA3'] = '\u06BB';
  36883. t['\uFBA4'] = '\u06C0';
  36884. t['\uFBA5'] = '\u06C0';
  36885. t['\uFBA6'] = '\u06C1';
  36886. t['\uFBA7'] = '\u06C1';
  36887. t['\uFBA8'] = '\u06C1';
  36888. t['\uFBA9'] = '\u06C1';
  36889. t['\uFBAA'] = '\u06BE';
  36890. t['\uFBAB'] = '\u06BE';
  36891. t['\uFBAC'] = '\u06BE';
  36892. t['\uFBAD'] = '\u06BE';
  36893. t['\uFBAE'] = '\u06D2';
  36894. t['\uFBAF'] = '\u06D2';
  36895. t['\uFBB0'] = '\u06D3';
  36896. t['\uFBB1'] = '\u06D3';
  36897. t['\uFBD3'] = '\u06AD';
  36898. t['\uFBD4'] = '\u06AD';
  36899. t['\uFBD5'] = '\u06AD';
  36900. t['\uFBD6'] = '\u06AD';
  36901. t['\uFBD7'] = '\u06C7';
  36902. t['\uFBD8'] = '\u06C7';
  36903. t['\uFBD9'] = '\u06C6';
  36904. t['\uFBDA'] = '\u06C6';
  36905. t['\uFBDB'] = '\u06C8';
  36906. t['\uFBDC'] = '\u06C8';
  36907. t['\uFBDD'] = '\u0677';
  36908. t['\uFBDE'] = '\u06CB';
  36909. t['\uFBDF'] = '\u06CB';
  36910. t['\uFBE0'] = '\u06C5';
  36911. t['\uFBE1'] = '\u06C5';
  36912. t['\uFBE2'] = '\u06C9';
  36913. t['\uFBE3'] = '\u06C9';
  36914. t['\uFBE4'] = '\u06D0';
  36915. t['\uFBE5'] = '\u06D0';
  36916. t['\uFBE6'] = '\u06D0';
  36917. t['\uFBE7'] = '\u06D0';
  36918. t['\uFBE8'] = '\u0649';
  36919. t['\uFBE9'] = '\u0649';
  36920. t['\uFBEA'] = '\u0626\u0627';
  36921. t['\uFBEB'] = '\u0626\u0627';
  36922. t['\uFBEC'] = '\u0626\u06D5';
  36923. t['\uFBED'] = '\u0626\u06D5';
  36924. t['\uFBEE'] = '\u0626\u0648';
  36925. t['\uFBEF'] = '\u0626\u0648';
  36926. t['\uFBF0'] = '\u0626\u06C7';
  36927. t['\uFBF1'] = '\u0626\u06C7';
  36928. t['\uFBF2'] = '\u0626\u06C6';
  36929. t['\uFBF3'] = '\u0626\u06C6';
  36930. t['\uFBF4'] = '\u0626\u06C8';
  36931. t['\uFBF5'] = '\u0626\u06C8';
  36932. t['\uFBF6'] = '\u0626\u06D0';
  36933. t['\uFBF7'] = '\u0626\u06D0';
  36934. t['\uFBF8'] = '\u0626\u06D0';
  36935. t['\uFBF9'] = '\u0626\u0649';
  36936. t['\uFBFA'] = '\u0626\u0649';
  36937. t['\uFBFB'] = '\u0626\u0649';
  36938. t['\uFBFC'] = '\u06CC';
  36939. t['\uFBFD'] = '\u06CC';
  36940. t['\uFBFE'] = '\u06CC';
  36941. t['\uFBFF'] = '\u06CC';
  36942. t['\uFC00'] = '\u0626\u062C';
  36943. t['\uFC01'] = '\u0626\u062D';
  36944. t['\uFC02'] = '\u0626\u0645';
  36945. t['\uFC03'] = '\u0626\u0649';
  36946. t['\uFC04'] = '\u0626\u064A';
  36947. t['\uFC05'] = '\u0628\u062C';
  36948. t['\uFC06'] = '\u0628\u062D';
  36949. t['\uFC07'] = '\u0628\u062E';
  36950. t['\uFC08'] = '\u0628\u0645';
  36951. t['\uFC09'] = '\u0628\u0649';
  36952. t['\uFC0A'] = '\u0628\u064A';
  36953. t['\uFC0B'] = '\u062A\u062C';
  36954. t['\uFC0C'] = '\u062A\u062D';
  36955. t['\uFC0D'] = '\u062A\u062E';
  36956. t['\uFC0E'] = '\u062A\u0645';
  36957. t['\uFC0F'] = '\u062A\u0649';
  36958. t['\uFC10'] = '\u062A\u064A';
  36959. t['\uFC11'] = '\u062B\u062C';
  36960. t['\uFC12'] = '\u062B\u0645';
  36961. t['\uFC13'] = '\u062B\u0649';
  36962. t['\uFC14'] = '\u062B\u064A';
  36963. t['\uFC15'] = '\u062C\u062D';
  36964. t['\uFC16'] = '\u062C\u0645';
  36965. t['\uFC17'] = '\u062D\u062C';
  36966. t['\uFC18'] = '\u062D\u0645';
  36967. t['\uFC19'] = '\u062E\u062C';
  36968. t['\uFC1A'] = '\u062E\u062D';
  36969. t['\uFC1B'] = '\u062E\u0645';
  36970. t['\uFC1C'] = '\u0633\u062C';
  36971. t['\uFC1D'] = '\u0633\u062D';
  36972. t['\uFC1E'] = '\u0633\u062E';
  36973. t['\uFC1F'] = '\u0633\u0645';
  36974. t['\uFC20'] = '\u0635\u062D';
  36975. t['\uFC21'] = '\u0635\u0645';
  36976. t['\uFC22'] = '\u0636\u062C';
  36977. t['\uFC23'] = '\u0636\u062D';
  36978. t['\uFC24'] = '\u0636\u062E';
  36979. t['\uFC25'] = '\u0636\u0645';
  36980. t['\uFC26'] = '\u0637\u062D';
  36981. t['\uFC27'] = '\u0637\u0645';
  36982. t['\uFC28'] = '\u0638\u0645';
  36983. t['\uFC29'] = '\u0639\u062C';
  36984. t['\uFC2A'] = '\u0639\u0645';
  36985. t['\uFC2B'] = '\u063A\u062C';
  36986. t['\uFC2C'] = '\u063A\u0645';
  36987. t['\uFC2D'] = '\u0641\u062C';
  36988. t['\uFC2E'] = '\u0641\u062D';
  36989. t['\uFC2F'] = '\u0641\u062E';
  36990. t['\uFC30'] = '\u0641\u0645';
  36991. t['\uFC31'] = '\u0641\u0649';
  36992. t['\uFC32'] = '\u0641\u064A';
  36993. t['\uFC33'] = '\u0642\u062D';
  36994. t['\uFC34'] = '\u0642\u0645';
  36995. t['\uFC35'] = '\u0642\u0649';
  36996. t['\uFC36'] = '\u0642\u064A';
  36997. t['\uFC37'] = '\u0643\u0627';
  36998. t['\uFC38'] = '\u0643\u062C';
  36999. t['\uFC39'] = '\u0643\u062D';
  37000. t['\uFC3A'] = '\u0643\u062E';
  37001. t['\uFC3B'] = '\u0643\u0644';
  37002. t['\uFC3C'] = '\u0643\u0645';
  37003. t['\uFC3D'] = '\u0643\u0649';
  37004. t['\uFC3E'] = '\u0643\u064A';
  37005. t['\uFC3F'] = '\u0644\u062C';
  37006. t['\uFC40'] = '\u0644\u062D';
  37007. t['\uFC41'] = '\u0644\u062E';
  37008. t['\uFC42'] = '\u0644\u0645';
  37009. t['\uFC43'] = '\u0644\u0649';
  37010. t['\uFC44'] = '\u0644\u064A';
  37011. t['\uFC45'] = '\u0645\u062C';
  37012. t['\uFC46'] = '\u0645\u062D';
  37013. t['\uFC47'] = '\u0645\u062E';
  37014. t['\uFC48'] = '\u0645\u0645';
  37015. t['\uFC49'] = '\u0645\u0649';
  37016. t['\uFC4A'] = '\u0645\u064A';
  37017. t['\uFC4B'] = '\u0646\u062C';
  37018. t['\uFC4C'] = '\u0646\u062D';
  37019. t['\uFC4D'] = '\u0646\u062E';
  37020. t['\uFC4E'] = '\u0646\u0645';
  37021. t['\uFC4F'] = '\u0646\u0649';
  37022. t['\uFC50'] = '\u0646\u064A';
  37023. t['\uFC51'] = '\u0647\u062C';
  37024. t['\uFC52'] = '\u0647\u0645';
  37025. t['\uFC53'] = '\u0647\u0649';
  37026. t['\uFC54'] = '\u0647\u064A';
  37027. t['\uFC55'] = '\u064A\u062C';
  37028. t['\uFC56'] = '\u064A\u062D';
  37029. t['\uFC57'] = '\u064A\u062E';
  37030. t['\uFC58'] = '\u064A\u0645';
  37031. t['\uFC59'] = '\u064A\u0649';
  37032. t['\uFC5A'] = '\u064A\u064A';
  37033. t['\uFC5B'] = '\u0630\u0670';
  37034. t['\uFC5C'] = '\u0631\u0670';
  37035. t['\uFC5D'] = '\u0649\u0670';
  37036. t['\uFC5E'] = '\u0020\u064C\u0651';
  37037. t['\uFC5F'] = '\u0020\u064D\u0651';
  37038. t['\uFC60'] = '\u0020\u064E\u0651';
  37039. t['\uFC61'] = '\u0020\u064F\u0651';
  37040. t['\uFC62'] = '\u0020\u0650\u0651';
  37041. t['\uFC63'] = '\u0020\u0651\u0670';
  37042. t['\uFC64'] = '\u0626\u0631';
  37043. t['\uFC65'] = '\u0626\u0632';
  37044. t['\uFC66'] = '\u0626\u0645';
  37045. t['\uFC67'] = '\u0626\u0646';
  37046. t['\uFC68'] = '\u0626\u0649';
  37047. t['\uFC69'] = '\u0626\u064A';
  37048. t['\uFC6A'] = '\u0628\u0631';
  37049. t['\uFC6B'] = '\u0628\u0632';
  37050. t['\uFC6C'] = '\u0628\u0645';
  37051. t['\uFC6D'] = '\u0628\u0646';
  37052. t['\uFC6E'] = '\u0628\u0649';
  37053. t['\uFC6F'] = '\u0628\u064A';
  37054. t['\uFC70'] = '\u062A\u0631';
  37055. t['\uFC71'] = '\u062A\u0632';
  37056. t['\uFC72'] = '\u062A\u0645';
  37057. t['\uFC73'] = '\u062A\u0646';
  37058. t['\uFC74'] = '\u062A\u0649';
  37059. t['\uFC75'] = '\u062A\u064A';
  37060. t['\uFC76'] = '\u062B\u0631';
  37061. t['\uFC77'] = '\u062B\u0632';
  37062. t['\uFC78'] = '\u062B\u0645';
  37063. t['\uFC79'] = '\u062B\u0646';
  37064. t['\uFC7A'] = '\u062B\u0649';
  37065. t['\uFC7B'] = '\u062B\u064A';
  37066. t['\uFC7C'] = '\u0641\u0649';
  37067. t['\uFC7D'] = '\u0641\u064A';
  37068. t['\uFC7E'] = '\u0642\u0649';
  37069. t['\uFC7F'] = '\u0642\u064A';
  37070. t['\uFC80'] = '\u0643\u0627';
  37071. t['\uFC81'] = '\u0643\u0644';
  37072. t['\uFC82'] = '\u0643\u0645';
  37073. t['\uFC83'] = '\u0643\u0649';
  37074. t['\uFC84'] = '\u0643\u064A';
  37075. t['\uFC85'] = '\u0644\u0645';
  37076. t['\uFC86'] = '\u0644\u0649';
  37077. t['\uFC87'] = '\u0644\u064A';
  37078. t['\uFC88'] = '\u0645\u0627';
  37079. t['\uFC89'] = '\u0645\u0645';
  37080. t['\uFC8A'] = '\u0646\u0631';
  37081. t['\uFC8B'] = '\u0646\u0632';
  37082. t['\uFC8C'] = '\u0646\u0645';
  37083. t['\uFC8D'] = '\u0646\u0646';
  37084. t['\uFC8E'] = '\u0646\u0649';
  37085. t['\uFC8F'] = '\u0646\u064A';
  37086. t['\uFC90'] = '\u0649\u0670';
  37087. t['\uFC91'] = '\u064A\u0631';
  37088. t['\uFC92'] = '\u064A\u0632';
  37089. t['\uFC93'] = '\u064A\u0645';
  37090. t['\uFC94'] = '\u064A\u0646';
  37091. t['\uFC95'] = '\u064A\u0649';
  37092. t['\uFC96'] = '\u064A\u064A';
  37093. t['\uFC97'] = '\u0626\u062C';
  37094. t['\uFC98'] = '\u0626\u062D';
  37095. t['\uFC99'] = '\u0626\u062E';
  37096. t['\uFC9A'] = '\u0626\u0645';
  37097. t['\uFC9B'] = '\u0626\u0647';
  37098. t['\uFC9C'] = '\u0628\u062C';
  37099. t['\uFC9D'] = '\u0628\u062D';
  37100. t['\uFC9E'] = '\u0628\u062E';
  37101. t['\uFC9F'] = '\u0628\u0645';
  37102. t['\uFCA0'] = '\u0628\u0647';
  37103. t['\uFCA1'] = '\u062A\u062C';
  37104. t['\uFCA2'] = '\u062A\u062D';
  37105. t['\uFCA3'] = '\u062A\u062E';
  37106. t['\uFCA4'] = '\u062A\u0645';
  37107. t['\uFCA5'] = '\u062A\u0647';
  37108. t['\uFCA6'] = '\u062B\u0645';
  37109. t['\uFCA7'] = '\u062C\u062D';
  37110. t['\uFCA8'] = '\u062C\u0645';
  37111. t['\uFCA9'] = '\u062D\u062C';
  37112. t['\uFCAA'] = '\u062D\u0645';
  37113. t['\uFCAB'] = '\u062E\u062C';
  37114. t['\uFCAC'] = '\u062E\u0645';
  37115. t['\uFCAD'] = '\u0633\u062C';
  37116. t['\uFCAE'] = '\u0633\u062D';
  37117. t['\uFCAF'] = '\u0633\u062E';
  37118. t['\uFCB0'] = '\u0633\u0645';
  37119. t['\uFCB1'] = '\u0635\u062D';
  37120. t['\uFCB2'] = '\u0635\u062E';
  37121. t['\uFCB3'] = '\u0635\u0645';
  37122. t['\uFCB4'] = '\u0636\u062C';
  37123. t['\uFCB5'] = '\u0636\u062D';
  37124. t['\uFCB6'] = '\u0636\u062E';
  37125. t['\uFCB7'] = '\u0636\u0645';
  37126. t['\uFCB8'] = '\u0637\u062D';
  37127. t['\uFCB9'] = '\u0638\u0645';
  37128. t['\uFCBA'] = '\u0639\u062C';
  37129. t['\uFCBB'] = '\u0639\u0645';
  37130. t['\uFCBC'] = '\u063A\u062C';
  37131. t['\uFCBD'] = '\u063A\u0645';
  37132. t['\uFCBE'] = '\u0641\u062C';
  37133. t['\uFCBF'] = '\u0641\u062D';
  37134. t['\uFCC0'] = '\u0641\u062E';
  37135. t['\uFCC1'] = '\u0641\u0645';
  37136. t['\uFCC2'] = '\u0642\u062D';
  37137. t['\uFCC3'] = '\u0642\u0645';
  37138. t['\uFCC4'] = '\u0643\u062C';
  37139. t['\uFCC5'] = '\u0643\u062D';
  37140. t['\uFCC6'] = '\u0643\u062E';
  37141. t['\uFCC7'] = '\u0643\u0644';
  37142. t['\uFCC8'] = '\u0643\u0645';
  37143. t['\uFCC9'] = '\u0644\u062C';
  37144. t['\uFCCA'] = '\u0644\u062D';
  37145. t['\uFCCB'] = '\u0644\u062E';
  37146. t['\uFCCC'] = '\u0644\u0645';
  37147. t['\uFCCD'] = '\u0644\u0647';
  37148. t['\uFCCE'] = '\u0645\u062C';
  37149. t['\uFCCF'] = '\u0645\u062D';
  37150. t['\uFCD0'] = '\u0645\u062E';
  37151. t['\uFCD1'] = '\u0645\u0645';
  37152. t['\uFCD2'] = '\u0646\u062C';
  37153. t['\uFCD3'] = '\u0646\u062D';
  37154. t['\uFCD4'] = '\u0646\u062E';
  37155. t['\uFCD5'] = '\u0646\u0645';
  37156. t['\uFCD6'] = '\u0646\u0647';
  37157. t['\uFCD7'] = '\u0647\u062C';
  37158. t['\uFCD8'] = '\u0647\u0645';
  37159. t['\uFCD9'] = '\u0647\u0670';
  37160. t['\uFCDA'] = '\u064A\u062C';
  37161. t['\uFCDB'] = '\u064A\u062D';
  37162. t['\uFCDC'] = '\u064A\u062E';
  37163. t['\uFCDD'] = '\u064A\u0645';
  37164. t['\uFCDE'] = '\u064A\u0647';
  37165. t['\uFCDF'] = '\u0626\u0645';
  37166. t['\uFCE0'] = '\u0626\u0647';
  37167. t['\uFCE1'] = '\u0628\u0645';
  37168. t['\uFCE2'] = '\u0628\u0647';
  37169. t['\uFCE3'] = '\u062A\u0645';
  37170. t['\uFCE4'] = '\u062A\u0647';
  37171. t['\uFCE5'] = '\u062B\u0645';
  37172. t['\uFCE6'] = '\u062B\u0647';
  37173. t['\uFCE7'] = '\u0633\u0645';
  37174. t['\uFCE8'] = '\u0633\u0647';
  37175. t['\uFCE9'] = '\u0634\u0645';
  37176. t['\uFCEA'] = '\u0634\u0647';
  37177. t['\uFCEB'] = '\u0643\u0644';
  37178. t['\uFCEC'] = '\u0643\u0645';
  37179. t['\uFCED'] = '\u0644\u0645';
  37180. t['\uFCEE'] = '\u0646\u0645';
  37181. t['\uFCEF'] = '\u0646\u0647';
  37182. t['\uFCF0'] = '\u064A\u0645';
  37183. t['\uFCF1'] = '\u064A\u0647';
  37184. t['\uFCF2'] = '\u0640\u064E\u0651';
  37185. t['\uFCF3'] = '\u0640\u064F\u0651';
  37186. t['\uFCF4'] = '\u0640\u0650\u0651';
  37187. t['\uFCF5'] = '\u0637\u0649';
  37188. t['\uFCF6'] = '\u0637\u064A';
  37189. t['\uFCF7'] = '\u0639\u0649';
  37190. t['\uFCF8'] = '\u0639\u064A';
  37191. t['\uFCF9'] = '\u063A\u0649';
  37192. t['\uFCFA'] = '\u063A\u064A';
  37193. t['\uFCFB'] = '\u0633\u0649';
  37194. t['\uFCFC'] = '\u0633\u064A';
  37195. t['\uFCFD'] = '\u0634\u0649';
  37196. t['\uFCFE'] = '\u0634\u064A';
  37197. t['\uFCFF'] = '\u062D\u0649';
  37198. t['\uFD00'] = '\u062D\u064A';
  37199. t['\uFD01'] = '\u062C\u0649';
  37200. t['\uFD02'] = '\u062C\u064A';
  37201. t['\uFD03'] = '\u062E\u0649';
  37202. t['\uFD04'] = '\u062E\u064A';
  37203. t['\uFD05'] = '\u0635\u0649';
  37204. t['\uFD06'] = '\u0635\u064A';
  37205. t['\uFD07'] = '\u0636\u0649';
  37206. t['\uFD08'] = '\u0636\u064A';
  37207. t['\uFD09'] = '\u0634\u062C';
  37208. t['\uFD0A'] = '\u0634\u062D';
  37209. t['\uFD0B'] = '\u0634\u062E';
  37210. t['\uFD0C'] = '\u0634\u0645';
  37211. t['\uFD0D'] = '\u0634\u0631';
  37212. t['\uFD0E'] = '\u0633\u0631';
  37213. t['\uFD0F'] = '\u0635\u0631';
  37214. t['\uFD10'] = '\u0636\u0631';
  37215. t['\uFD11'] = '\u0637\u0649';
  37216. t['\uFD12'] = '\u0637\u064A';
  37217. t['\uFD13'] = '\u0639\u0649';
  37218. t['\uFD14'] = '\u0639\u064A';
  37219. t['\uFD15'] = '\u063A\u0649';
  37220. t['\uFD16'] = '\u063A\u064A';
  37221. t['\uFD17'] = '\u0633\u0649';
  37222. t['\uFD18'] = '\u0633\u064A';
  37223. t['\uFD19'] = '\u0634\u0649';
  37224. t['\uFD1A'] = '\u0634\u064A';
  37225. t['\uFD1B'] = '\u062D\u0649';
  37226. t['\uFD1C'] = '\u062D\u064A';
  37227. t['\uFD1D'] = '\u062C\u0649';
  37228. t['\uFD1E'] = '\u062C\u064A';
  37229. t['\uFD1F'] = '\u062E\u0649';
  37230. t['\uFD20'] = '\u062E\u064A';
  37231. t['\uFD21'] = '\u0635\u0649';
  37232. t['\uFD22'] = '\u0635\u064A';
  37233. t['\uFD23'] = '\u0636\u0649';
  37234. t['\uFD24'] = '\u0636\u064A';
  37235. t['\uFD25'] = '\u0634\u062C';
  37236. t['\uFD26'] = '\u0634\u062D';
  37237. t['\uFD27'] = '\u0634\u062E';
  37238. t['\uFD28'] = '\u0634\u0645';
  37239. t['\uFD29'] = '\u0634\u0631';
  37240. t['\uFD2A'] = '\u0633\u0631';
  37241. t['\uFD2B'] = '\u0635\u0631';
  37242. t['\uFD2C'] = '\u0636\u0631';
  37243. t['\uFD2D'] = '\u0634\u062C';
  37244. t['\uFD2E'] = '\u0634\u062D';
  37245. t['\uFD2F'] = '\u0634\u062E';
  37246. t['\uFD30'] = '\u0634\u0645';
  37247. t['\uFD31'] = '\u0633\u0647';
  37248. t['\uFD32'] = '\u0634\u0647';
  37249. t['\uFD33'] = '\u0637\u0645';
  37250. t['\uFD34'] = '\u0633\u062C';
  37251. t['\uFD35'] = '\u0633\u062D';
  37252. t['\uFD36'] = '\u0633\u062E';
  37253. t['\uFD37'] = '\u0634\u062C';
  37254. t['\uFD38'] = '\u0634\u062D';
  37255. t['\uFD39'] = '\u0634\u062E';
  37256. t['\uFD3A'] = '\u0637\u0645';
  37257. t['\uFD3B'] = '\u0638\u0645';
  37258. t['\uFD3C'] = '\u0627\u064B';
  37259. t['\uFD3D'] = '\u0627\u064B';
  37260. t['\uFD50'] = '\u062A\u062C\u0645';
  37261. t['\uFD51'] = '\u062A\u062D\u062C';
  37262. t['\uFD52'] = '\u062A\u062D\u062C';
  37263. t['\uFD53'] = '\u062A\u062D\u0645';
  37264. t['\uFD54'] = '\u062A\u062E\u0645';
  37265. t['\uFD55'] = '\u062A\u0645\u062C';
  37266. t['\uFD56'] = '\u062A\u0645\u062D';
  37267. t['\uFD57'] = '\u062A\u0645\u062E';
  37268. t['\uFD58'] = '\u062C\u0645\u062D';
  37269. t['\uFD59'] = '\u062C\u0645\u062D';
  37270. t['\uFD5A'] = '\u062D\u0645\u064A';
  37271. t['\uFD5B'] = '\u062D\u0645\u0649';
  37272. t['\uFD5C'] = '\u0633\u062D\u062C';
  37273. t['\uFD5D'] = '\u0633\u062C\u062D';
  37274. t['\uFD5E'] = '\u0633\u062C\u0649';
  37275. t['\uFD5F'] = '\u0633\u0645\u062D';
  37276. t['\uFD60'] = '\u0633\u0645\u062D';
  37277. t['\uFD61'] = '\u0633\u0645\u062C';
  37278. t['\uFD62'] = '\u0633\u0645\u0645';
  37279. t['\uFD63'] = '\u0633\u0645\u0645';
  37280. t['\uFD64'] = '\u0635\u062D\u062D';
  37281. t['\uFD65'] = '\u0635\u062D\u062D';
  37282. t['\uFD66'] = '\u0635\u0645\u0645';
  37283. t['\uFD67'] = '\u0634\u062D\u0645';
  37284. t['\uFD68'] = '\u0634\u062D\u0645';
  37285. t['\uFD69'] = '\u0634\u062C\u064A';
  37286. t['\uFD6A'] = '\u0634\u0645\u062E';
  37287. t['\uFD6B'] = '\u0634\u0645\u062E';
  37288. t['\uFD6C'] = '\u0634\u0645\u0645';
  37289. t['\uFD6D'] = '\u0634\u0645\u0645';
  37290. t['\uFD6E'] = '\u0636\u062D\u0649';
  37291. t['\uFD6F'] = '\u0636\u062E\u0645';
  37292. t['\uFD70'] = '\u0636\u062E\u0645';
  37293. t['\uFD71'] = '\u0637\u0645\u062D';
  37294. t['\uFD72'] = '\u0637\u0645\u062D';
  37295. t['\uFD73'] = '\u0637\u0645\u0645';
  37296. t['\uFD74'] = '\u0637\u0645\u064A';
  37297. t['\uFD75'] = '\u0639\u062C\u0645';
  37298. t['\uFD76'] = '\u0639\u0645\u0645';
  37299. t['\uFD77'] = '\u0639\u0645\u0645';
  37300. t['\uFD78'] = '\u0639\u0645\u0649';
  37301. t['\uFD79'] = '\u063A\u0645\u0645';
  37302. t['\uFD7A'] = '\u063A\u0645\u064A';
  37303. t['\uFD7B'] = '\u063A\u0645\u0649';
  37304. t['\uFD7C'] = '\u0641\u062E\u0645';
  37305. t['\uFD7D'] = '\u0641\u062E\u0645';
  37306. t['\uFD7E'] = '\u0642\u0645\u062D';
  37307. t['\uFD7F'] = '\u0642\u0645\u0645';
  37308. t['\uFD80'] = '\u0644\u062D\u0645';
  37309. t['\uFD81'] = '\u0644\u062D\u064A';
  37310. t['\uFD82'] = '\u0644\u062D\u0649';
  37311. t['\uFD83'] = '\u0644\u062C\u062C';
  37312. t['\uFD84'] = '\u0644\u062C\u062C';
  37313. t['\uFD85'] = '\u0644\u062E\u0645';
  37314. t['\uFD86'] = '\u0644\u062E\u0645';
  37315. t['\uFD87'] = '\u0644\u0645\u062D';
  37316. t['\uFD88'] = '\u0644\u0645\u062D';
  37317. t['\uFD89'] = '\u0645\u062D\u062C';
  37318. t['\uFD8A'] = '\u0645\u062D\u0645';
  37319. t['\uFD8B'] = '\u0645\u062D\u064A';
  37320. t['\uFD8C'] = '\u0645\u062C\u062D';
  37321. t['\uFD8D'] = '\u0645\u062C\u0645';
  37322. t['\uFD8E'] = '\u0645\u062E\u062C';
  37323. t['\uFD8F'] = '\u0645\u062E\u0645';
  37324. t['\uFD92'] = '\u0645\u062C\u062E';
  37325. t['\uFD93'] = '\u0647\u0645\u062C';
  37326. t['\uFD94'] = '\u0647\u0645\u0645';
  37327. t['\uFD95'] = '\u0646\u062D\u0645';
  37328. t['\uFD96'] = '\u0646\u062D\u0649';
  37329. t['\uFD97'] = '\u0646\u062C\u0645';
  37330. t['\uFD98'] = '\u0646\u062C\u0645';
  37331. t['\uFD99'] = '\u0646\u062C\u0649';
  37332. t['\uFD9A'] = '\u0646\u0645\u064A';
  37333. t['\uFD9B'] = '\u0646\u0645\u0649';
  37334. t['\uFD9C'] = '\u064A\u0645\u0645';
  37335. t['\uFD9D'] = '\u064A\u0645\u0645';
  37336. t['\uFD9E'] = '\u0628\u062E\u064A';
  37337. t['\uFD9F'] = '\u062A\u062C\u064A';
  37338. t['\uFDA0'] = '\u062A\u062C\u0649';
  37339. t['\uFDA1'] = '\u062A\u062E\u064A';
  37340. t['\uFDA2'] = '\u062A\u062E\u0649';
  37341. t['\uFDA3'] = '\u062A\u0645\u064A';
  37342. t['\uFDA4'] = '\u062A\u0645\u0649';
  37343. t['\uFDA5'] = '\u062C\u0645\u064A';
  37344. t['\uFDA6'] = '\u062C\u062D\u0649';
  37345. t['\uFDA7'] = '\u062C\u0645\u0649';
  37346. t['\uFDA8'] = '\u0633\u062E\u0649';
  37347. t['\uFDA9'] = '\u0635\u062D\u064A';
  37348. t['\uFDAA'] = '\u0634\u062D\u064A';
  37349. t['\uFDAB'] = '\u0636\u062D\u064A';
  37350. t['\uFDAC'] = '\u0644\u062C\u064A';
  37351. t['\uFDAD'] = '\u0644\u0645\u064A';
  37352. t['\uFDAE'] = '\u064A\u062D\u064A';
  37353. t['\uFDAF'] = '\u064A\u062C\u064A';
  37354. t['\uFDB0'] = '\u064A\u0645\u064A';
  37355. t['\uFDB1'] = '\u0645\u0645\u064A';
  37356. t['\uFDB2'] = '\u0642\u0645\u064A';
  37357. t['\uFDB3'] = '\u0646\u062D\u064A';
  37358. t['\uFDB4'] = '\u0642\u0645\u062D';
  37359. t['\uFDB5'] = '\u0644\u062D\u0645';
  37360. t['\uFDB6'] = '\u0639\u0645\u064A';
  37361. t['\uFDB7'] = '\u0643\u0645\u064A';
  37362. t['\uFDB8'] = '\u0646\u062C\u062D';
  37363. t['\uFDB9'] = '\u0645\u062E\u064A';
  37364. t['\uFDBA'] = '\u0644\u062C\u0645';
  37365. t['\uFDBB'] = '\u0643\u0645\u0645';
  37366. t['\uFDBC'] = '\u0644\u062C\u0645';
  37367. t['\uFDBD'] = '\u0646\u062C\u062D';
  37368. t['\uFDBE'] = '\u062C\u062D\u064A';
  37369. t['\uFDBF'] = '\u062D\u062C\u064A';
  37370. t['\uFDC0'] = '\u0645\u062C\u064A';
  37371. t['\uFDC1'] = '\u0641\u0645\u064A';
  37372. t['\uFDC2'] = '\u0628\u062D\u064A';
  37373. t['\uFDC3'] = '\u0643\u0645\u0645';
  37374. t['\uFDC4'] = '\u0639\u062C\u0645';
  37375. t['\uFDC5'] = '\u0635\u0645\u0645';
  37376. t['\uFDC6'] = '\u0633\u062E\u064A';
  37377. t['\uFDC7'] = '\u0646\u062C\u064A';
  37378. t['\uFE49'] = '\u203E';
  37379. t['\uFE4A'] = '\u203E';
  37380. t['\uFE4B'] = '\u203E';
  37381. t['\uFE4C'] = '\u203E';
  37382. t['\uFE4D'] = '\u005F';
  37383. t['\uFE4E'] = '\u005F';
  37384. t['\uFE4F'] = '\u005F';
  37385. t['\uFE80'] = '\u0621';
  37386. t['\uFE81'] = '\u0622';
  37387. t['\uFE82'] = '\u0622';
  37388. t['\uFE83'] = '\u0623';
  37389. t['\uFE84'] = '\u0623';
  37390. t['\uFE85'] = '\u0624';
  37391. t['\uFE86'] = '\u0624';
  37392. t['\uFE87'] = '\u0625';
  37393. t['\uFE88'] = '\u0625';
  37394. t['\uFE89'] = '\u0626';
  37395. t['\uFE8A'] = '\u0626';
  37396. t['\uFE8B'] = '\u0626';
  37397. t['\uFE8C'] = '\u0626';
  37398. t['\uFE8D'] = '\u0627';
  37399. t['\uFE8E'] = '\u0627';
  37400. t['\uFE8F'] = '\u0628';
  37401. t['\uFE90'] = '\u0628';
  37402. t['\uFE91'] = '\u0628';
  37403. t['\uFE92'] = '\u0628';
  37404. t['\uFE93'] = '\u0629';
  37405. t['\uFE94'] = '\u0629';
  37406. t['\uFE95'] = '\u062A';
  37407. t['\uFE96'] = '\u062A';
  37408. t['\uFE97'] = '\u062A';
  37409. t['\uFE98'] = '\u062A';
  37410. t['\uFE99'] = '\u062B';
  37411. t['\uFE9A'] = '\u062B';
  37412. t['\uFE9B'] = '\u062B';
  37413. t['\uFE9C'] = '\u062B';
  37414. t['\uFE9D'] = '\u062C';
  37415. t['\uFE9E'] = '\u062C';
  37416. t['\uFE9F'] = '\u062C';
  37417. t['\uFEA0'] = '\u062C';
  37418. t['\uFEA1'] = '\u062D';
  37419. t['\uFEA2'] = '\u062D';
  37420. t['\uFEA3'] = '\u062D';
  37421. t['\uFEA4'] = '\u062D';
  37422. t['\uFEA5'] = '\u062E';
  37423. t['\uFEA6'] = '\u062E';
  37424. t['\uFEA7'] = '\u062E';
  37425. t['\uFEA8'] = '\u062E';
  37426. t['\uFEA9'] = '\u062F';
  37427. t['\uFEAA'] = '\u062F';
  37428. t['\uFEAB'] = '\u0630';
  37429. t['\uFEAC'] = '\u0630';
  37430. t['\uFEAD'] = '\u0631';
  37431. t['\uFEAE'] = '\u0631';
  37432. t['\uFEAF'] = '\u0632';
  37433. t['\uFEB0'] = '\u0632';
  37434. t['\uFEB1'] = '\u0633';
  37435. t['\uFEB2'] = '\u0633';
  37436. t['\uFEB3'] = '\u0633';
  37437. t['\uFEB4'] = '\u0633';
  37438. t['\uFEB5'] = '\u0634';
  37439. t['\uFEB6'] = '\u0634';
  37440. t['\uFEB7'] = '\u0634';
  37441. t['\uFEB8'] = '\u0634';
  37442. t['\uFEB9'] = '\u0635';
  37443. t['\uFEBA'] = '\u0635';
  37444. t['\uFEBB'] = '\u0635';
  37445. t['\uFEBC'] = '\u0635';
  37446. t['\uFEBD'] = '\u0636';
  37447. t['\uFEBE'] = '\u0636';
  37448. t['\uFEBF'] = '\u0636';
  37449. t['\uFEC0'] = '\u0636';
  37450. t['\uFEC1'] = '\u0637';
  37451. t['\uFEC2'] = '\u0637';
  37452. t['\uFEC3'] = '\u0637';
  37453. t['\uFEC4'] = '\u0637';
  37454. t['\uFEC5'] = '\u0638';
  37455. t['\uFEC6'] = '\u0638';
  37456. t['\uFEC7'] = '\u0638';
  37457. t['\uFEC8'] = '\u0638';
  37458. t['\uFEC9'] = '\u0639';
  37459. t['\uFECA'] = '\u0639';
  37460. t['\uFECB'] = '\u0639';
  37461. t['\uFECC'] = '\u0639';
  37462. t['\uFECD'] = '\u063A';
  37463. t['\uFECE'] = '\u063A';
  37464. t['\uFECF'] = '\u063A';
  37465. t['\uFED0'] = '\u063A';
  37466. t['\uFED1'] = '\u0641';
  37467. t['\uFED2'] = '\u0641';
  37468. t['\uFED3'] = '\u0641';
  37469. t['\uFED4'] = '\u0641';
  37470. t['\uFED5'] = '\u0642';
  37471. t['\uFED6'] = '\u0642';
  37472. t['\uFED7'] = '\u0642';
  37473. t['\uFED8'] = '\u0642';
  37474. t['\uFED9'] = '\u0643';
  37475. t['\uFEDA'] = '\u0643';
  37476. t['\uFEDB'] = '\u0643';
  37477. t['\uFEDC'] = '\u0643';
  37478. t['\uFEDD'] = '\u0644';
  37479. t['\uFEDE'] = '\u0644';
  37480. t['\uFEDF'] = '\u0644';
  37481. t['\uFEE0'] = '\u0644';
  37482. t['\uFEE1'] = '\u0645';
  37483. t['\uFEE2'] = '\u0645';
  37484. t['\uFEE3'] = '\u0645';
  37485. t['\uFEE4'] = '\u0645';
  37486. t['\uFEE5'] = '\u0646';
  37487. t['\uFEE6'] = '\u0646';
  37488. t['\uFEE7'] = '\u0646';
  37489. t['\uFEE8'] = '\u0646';
  37490. t['\uFEE9'] = '\u0647';
  37491. t['\uFEEA'] = '\u0647';
  37492. t['\uFEEB'] = '\u0647';
  37493. t['\uFEEC'] = '\u0647';
  37494. t['\uFEED'] = '\u0648';
  37495. t['\uFEEE'] = '\u0648';
  37496. t['\uFEEF'] = '\u0649';
  37497. t['\uFEF0'] = '\u0649';
  37498. t['\uFEF1'] = '\u064A';
  37499. t['\uFEF2'] = '\u064A';
  37500. t['\uFEF3'] = '\u064A';
  37501. t['\uFEF4'] = '\u064A';
  37502. t['\uFEF5'] = '\u0644\u0622';
  37503. t['\uFEF6'] = '\u0644\u0622';
  37504. t['\uFEF7'] = '\u0644\u0623';
  37505. t['\uFEF8'] = '\u0644\u0623';
  37506. t['\uFEF9'] = '\u0644\u0625';
  37507. t['\uFEFA'] = '\u0644\u0625';
  37508. t['\uFEFB'] = '\u0644\u0627';
  37509. t['\uFEFC'] = '\u0644\u0627';
  37510. });
  37511. function reverseIfRtl(chars) {
  37512. var charsLength = chars.length;
  37513. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37514. return chars;
  37515. }
  37516. var s = '';
  37517. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37518. s += chars[ii];
  37519. }
  37520. return s;
  37521. }
  37522. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37523. exports.reverseIfRtl = reverseIfRtl;
  37524. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37525. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37526. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37527. /***/ }),
  37528. /* 23 */
  37529. /***/ (function(module, exports, __w_pdfjs_require__) {
  37530. "use strict";
  37531. var sharedUtil = __w_pdfjs_require__(0);
  37532. var corePrimitives = __w_pdfjs_require__(1);
  37533. var corePdfManager = __w_pdfjs_require__(41);
  37534. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37535. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37536. var MessageHandler = sharedUtil.MessageHandler;
  37537. var MissingPDFException = sharedUtil.MissingPDFException;
  37538. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37539. var PasswordException = sharedUtil.PasswordException;
  37540. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37541. var XRefParseException = sharedUtil.XRefParseException;
  37542. var arrayByteLength = sharedUtil.arrayByteLength;
  37543. var arraysToBytes = sharedUtil.arraysToBytes;
  37544. var assert = sharedUtil.assert;
  37545. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37546. var info = sharedUtil.info;
  37547. var warn = sharedUtil.warn;
  37548. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37549. var isNodeJS = sharedUtil.isNodeJS;
  37550. var Ref = corePrimitives.Ref;
  37551. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37552. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37553. var WorkerTask = function WorkerTaskClosure() {
  37554. function WorkerTask(name) {
  37555. this.name = name;
  37556. this.terminated = false;
  37557. this._capability = createPromiseCapability();
  37558. }
  37559. WorkerTask.prototype = {
  37560. get finished() {
  37561. return this._capability.promise;
  37562. },
  37563. finish: function () {
  37564. this._capability.resolve();
  37565. },
  37566. terminate: function () {
  37567. this.terminated = true;
  37568. },
  37569. ensureNotTerminated: function () {
  37570. if (this.terminated) {
  37571. throw new Error('Worker task was terminated');
  37572. }
  37573. }
  37574. };
  37575. return WorkerTask;
  37576. }();
  37577. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37578. function PDFWorkerStream(params, msgHandler) {
  37579. this._queuedChunks = [];
  37580. var initialData = params.initialData;
  37581. if (initialData && initialData.length > 0) {
  37582. this._queuedChunks.push(initialData);
  37583. }
  37584. this._msgHandler = msgHandler;
  37585. this._isRangeSupported = !params.disableRange;
  37586. this._isStreamingSupported = !params.disableStream;
  37587. this._contentLength = params.length;
  37588. this._fullRequestReader = null;
  37589. this._rangeReaders = [];
  37590. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37591. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37592. }
  37593. PDFWorkerStream.prototype = {
  37594. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37595. if (args.begin === undefined) {
  37596. if (this._fullRequestReader) {
  37597. this._fullRequestReader._enqueue(args.chunk);
  37598. } else {
  37599. this._queuedChunks.push(args.chunk);
  37600. }
  37601. } else {
  37602. var found = this._rangeReaders.some(function (rangeReader) {
  37603. if (rangeReader._begin !== args.begin) {
  37604. return false;
  37605. }
  37606. rangeReader._enqueue(args.chunk);
  37607. return true;
  37608. });
  37609. assert(found);
  37610. }
  37611. },
  37612. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37613. if (this._rangeReaders.length > 0) {
  37614. var firstReader = this._rangeReaders[0];
  37615. if (firstReader.onProgress) {
  37616. firstReader.onProgress({ loaded: evt.loaded });
  37617. }
  37618. }
  37619. },
  37620. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37621. var i = this._rangeReaders.indexOf(reader);
  37622. if (i >= 0) {
  37623. this._rangeReaders.splice(i, 1);
  37624. }
  37625. },
  37626. getFullReader: function PDFWorkerStream_getFullReader() {
  37627. assert(!this._fullRequestReader);
  37628. var queuedChunks = this._queuedChunks;
  37629. this._queuedChunks = null;
  37630. return new PDFWorkerStreamReader(this, queuedChunks);
  37631. },
  37632. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37633. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37634. this._msgHandler.send('RequestDataRange', {
  37635. begin: begin,
  37636. end: end
  37637. });
  37638. this._rangeReaders.push(reader);
  37639. return reader;
  37640. },
  37641. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37642. if (this._fullRequestReader) {
  37643. this._fullRequestReader.cancel(reason);
  37644. }
  37645. var readers = this._rangeReaders.slice(0);
  37646. readers.forEach(function (rangeReader) {
  37647. rangeReader.cancel(reason);
  37648. });
  37649. }
  37650. };
  37651. function PDFWorkerStreamReader(stream, queuedChunks) {
  37652. this._stream = stream;
  37653. this._done = false;
  37654. this._queuedChunks = queuedChunks || [];
  37655. this._requests = [];
  37656. this._headersReady = Promise.resolve();
  37657. stream._fullRequestReader = this;
  37658. this.onProgress = null;
  37659. }
  37660. PDFWorkerStreamReader.prototype = {
  37661. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37662. if (this._done) {
  37663. return;
  37664. }
  37665. if (this._requests.length > 0) {
  37666. var requestCapability = this._requests.shift();
  37667. requestCapability.resolve({
  37668. value: chunk,
  37669. done: false
  37670. });
  37671. return;
  37672. }
  37673. this._queuedChunks.push(chunk);
  37674. },
  37675. get headersReady() {
  37676. return this._headersReady;
  37677. },
  37678. get isRangeSupported() {
  37679. return this._stream._isRangeSupported;
  37680. },
  37681. get isStreamingSupported() {
  37682. return this._stream._isStreamingSupported;
  37683. },
  37684. get contentLength() {
  37685. return this._stream._contentLength;
  37686. },
  37687. read: function PDFWorkerStreamReader_read() {
  37688. if (this._queuedChunks.length > 0) {
  37689. var chunk = this._queuedChunks.shift();
  37690. return Promise.resolve({
  37691. value: chunk,
  37692. done: false
  37693. });
  37694. }
  37695. if (this._done) {
  37696. return Promise.resolve({
  37697. value: undefined,
  37698. done: true
  37699. });
  37700. }
  37701. var requestCapability = createPromiseCapability();
  37702. this._requests.push(requestCapability);
  37703. return requestCapability.promise;
  37704. },
  37705. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37706. this._done = true;
  37707. this._requests.forEach(function (requestCapability) {
  37708. requestCapability.resolve({
  37709. value: undefined,
  37710. done: true
  37711. });
  37712. });
  37713. this._requests = [];
  37714. }
  37715. };
  37716. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37717. this._stream = stream;
  37718. this._begin = begin;
  37719. this._end = end;
  37720. this._queuedChunk = null;
  37721. this._requests = [];
  37722. this._done = false;
  37723. this.onProgress = null;
  37724. }
  37725. PDFWorkerStreamRangeReader.prototype = {
  37726. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37727. if (this._done) {
  37728. return;
  37729. }
  37730. if (this._requests.length === 0) {
  37731. this._queuedChunk = chunk;
  37732. } else {
  37733. var requestsCapability = this._requests.shift();
  37734. requestsCapability.resolve({
  37735. value: chunk,
  37736. done: false
  37737. });
  37738. this._requests.forEach(function (requestCapability) {
  37739. requestCapability.resolve({
  37740. value: undefined,
  37741. done: true
  37742. });
  37743. });
  37744. this._requests = [];
  37745. }
  37746. this._done = true;
  37747. this._stream._removeRangeReader(this);
  37748. },
  37749. get isStreamingSupported() {
  37750. return false;
  37751. },
  37752. read: function PDFWorkerStreamRangeReader_read() {
  37753. if (this._queuedChunk) {
  37754. return Promise.resolve({
  37755. value: this._queuedChunk,
  37756. done: false
  37757. });
  37758. }
  37759. if (this._done) {
  37760. return Promise.resolve({
  37761. value: undefined,
  37762. done: true
  37763. });
  37764. }
  37765. var requestCapability = createPromiseCapability();
  37766. this._requests.push(requestCapability);
  37767. return requestCapability.promise;
  37768. },
  37769. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37770. this._done = true;
  37771. this._requests.forEach(function (requestCapability) {
  37772. requestCapability.resolve({
  37773. value: undefined,
  37774. done: true
  37775. });
  37776. });
  37777. this._requests = [];
  37778. this._stream._removeRangeReader(this);
  37779. }
  37780. };
  37781. return PDFWorkerStream;
  37782. }();
  37783. var PDFNetworkStream;
  37784. function setPDFNetworkStreamClass(cls) {
  37785. PDFNetworkStream = cls;
  37786. }
  37787. var WorkerMessageHandler = {
  37788. setup: function wphSetup(handler, port) {
  37789. var testMessageProcessed = false;
  37790. handler.on('test', function wphSetupTest(data) {
  37791. if (testMessageProcessed) {
  37792. return;
  37793. }
  37794. testMessageProcessed = true;
  37795. if (!(data instanceof Uint8Array)) {
  37796. handler.send('test', 'main', false);
  37797. return;
  37798. }
  37799. var supportTransfers = data[0] === 255;
  37800. handler.postMessageTransfers = supportTransfers;
  37801. var xhr = new XMLHttpRequest();
  37802. var responseExists = 'response' in xhr;
  37803. try {
  37804. xhr.responseType;
  37805. } catch (e) {
  37806. responseExists = false;
  37807. }
  37808. if (!responseExists) {
  37809. handler.send('test', false);
  37810. return;
  37811. }
  37812. handler.send('test', {
  37813. supportTypedArray: true,
  37814. supportTransfers: supportTransfers
  37815. });
  37816. });
  37817. handler.on('configure', function wphConfigure(data) {
  37818. setVerbosityLevel(data.verbosity);
  37819. });
  37820. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37821. return WorkerMessageHandler.createDocumentHandler(data, port);
  37822. });
  37823. },
  37824. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37825. var pdfManager;
  37826. var terminated = false;
  37827. var cancelXHRs = null;
  37828. var WorkerTasks = [];
  37829. var docId = docParams.docId;
  37830. var docBaseUrl = docParams.docBaseUrl;
  37831. var workerHandlerName = docParams.docId + '_worker';
  37832. var handler = new MessageHandler(workerHandlerName, docId, port);
  37833. handler.postMessageTransfers = docParams.postMessageTransfers;
  37834. function ensureNotTerminated() {
  37835. if (terminated) {
  37836. throw new Error('Worker was terminated');
  37837. }
  37838. }
  37839. function startWorkerTask(task) {
  37840. WorkerTasks.push(task);
  37841. }
  37842. function finishWorkerTask(task) {
  37843. task.finish();
  37844. var i = WorkerTasks.indexOf(task);
  37845. WorkerTasks.splice(i, 1);
  37846. }
  37847. function loadDocument(recoveryMode) {
  37848. var loadDocumentCapability = createPromiseCapability();
  37849. var parseSuccess = function parseSuccess() {
  37850. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37851. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37852. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37853. Promise.all([
  37854. numPagesPromise,
  37855. fingerprintPromise,
  37856. encryptedPromise
  37857. ]).then(function onDocReady(results) {
  37858. var doc = {
  37859. numPages: results[0],
  37860. fingerprint: results[1],
  37861. encrypted: !!results[2]
  37862. };
  37863. loadDocumentCapability.resolve(doc);
  37864. }, parseFailure);
  37865. };
  37866. var parseFailure = function parseFailure(e) {
  37867. loadDocumentCapability.reject(e);
  37868. };
  37869. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37870. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37871. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37872. }, parseFailure);
  37873. }, parseFailure);
  37874. return loadDocumentCapability.promise;
  37875. }
  37876. function getPdfManager(data, evaluatorOptions) {
  37877. var pdfManagerCapability = createPromiseCapability();
  37878. var pdfManager;
  37879. var source = data.source;
  37880. if (source.data) {
  37881. try {
  37882. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37883. pdfManagerCapability.resolve(pdfManager);
  37884. } catch (ex) {
  37885. pdfManagerCapability.reject(ex);
  37886. }
  37887. return pdfManagerCapability.promise;
  37888. }
  37889. var pdfStream;
  37890. try {
  37891. if (source.chunkedViewerLoading) {
  37892. pdfStream = new PDFWorkerStream(source, handler);
  37893. } else {
  37894. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37895. pdfStream = new PDFNetworkStream(data);
  37896. }
  37897. } catch (ex) {
  37898. pdfManagerCapability.reject(ex);
  37899. return pdfManagerCapability.promise;
  37900. }
  37901. var fullRequest = pdfStream.getFullReader();
  37902. fullRequest.headersReady.then(function () {
  37903. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37904. fullRequest.onProgress = function (evt) {
  37905. handler.send('DocProgress', {
  37906. loaded: evt.loaded,
  37907. total: evt.total
  37908. });
  37909. };
  37910. }
  37911. if (!fullRequest.isRangeSupported) {
  37912. return;
  37913. }
  37914. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37915. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37916. msgHandler: handler,
  37917. url: source.url,
  37918. password: source.password,
  37919. length: fullRequest.contentLength,
  37920. disableAutoFetch: disableAutoFetch,
  37921. rangeChunkSize: source.rangeChunkSize
  37922. }, evaluatorOptions, docBaseUrl);
  37923. pdfManagerCapability.resolve(pdfManager);
  37924. cancelXHRs = null;
  37925. }).catch(function (reason) {
  37926. pdfManagerCapability.reject(reason);
  37927. cancelXHRs = null;
  37928. });
  37929. var cachedChunks = [], loaded = 0;
  37930. var flushChunks = function () {
  37931. var pdfFile = arraysToBytes(cachedChunks);
  37932. if (source.length && pdfFile.length !== source.length) {
  37933. warn('reported HTTP length is different from actual');
  37934. }
  37935. try {
  37936. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37937. pdfManagerCapability.resolve(pdfManager);
  37938. } catch (ex) {
  37939. pdfManagerCapability.reject(ex);
  37940. }
  37941. cachedChunks = [];
  37942. };
  37943. var readPromise = new Promise(function (resolve, reject) {
  37944. var readChunk = function (chunk) {
  37945. try {
  37946. ensureNotTerminated();
  37947. if (chunk.done) {
  37948. if (!pdfManager) {
  37949. flushChunks();
  37950. }
  37951. cancelXHRs = null;
  37952. return;
  37953. }
  37954. var data = chunk.value;
  37955. loaded += arrayByteLength(data);
  37956. if (!fullRequest.isStreamingSupported) {
  37957. handler.send('DocProgress', {
  37958. loaded: loaded,
  37959. total: Math.max(loaded, fullRequest.contentLength || 0)
  37960. });
  37961. }
  37962. if (pdfManager) {
  37963. pdfManager.sendProgressiveData(data);
  37964. } else {
  37965. cachedChunks.push(data);
  37966. }
  37967. fullRequest.read().then(readChunk, reject);
  37968. } catch (e) {
  37969. reject(e);
  37970. }
  37971. };
  37972. fullRequest.read().then(readChunk, reject);
  37973. });
  37974. readPromise.catch(function (e) {
  37975. pdfManagerCapability.reject(e);
  37976. cancelXHRs = null;
  37977. });
  37978. cancelXHRs = function () {
  37979. pdfStream.cancelAllRequests('abort');
  37980. };
  37981. return pdfManagerCapability.promise;
  37982. }
  37983. function setupDoc(data) {
  37984. function onSuccess(doc) {
  37985. ensureNotTerminated();
  37986. handler.send('GetDoc', { pdfInfo: doc });
  37987. }
  37988. function onFailure(e) {
  37989. if (e instanceof PasswordException) {
  37990. var task = new WorkerTask('PasswordException: response ' + e.code);
  37991. startWorkerTask(task);
  37992. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  37993. finishWorkerTask(task);
  37994. pdfManager.updatePassword(data.password);
  37995. pdfManagerReady();
  37996. }).catch(function (ex) {
  37997. finishWorkerTask(task);
  37998. handler.send('PasswordException', ex);
  37999. }.bind(null, e));
  38000. } else if (e instanceof InvalidPDFException) {
  38001. handler.send('InvalidPDF', e);
  38002. } else if (e instanceof MissingPDFException) {
  38003. handler.send('MissingPDF', e);
  38004. } else if (e instanceof UnexpectedResponseException) {
  38005. handler.send('UnexpectedResponse', e);
  38006. } else {
  38007. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38008. }
  38009. }
  38010. function pdfManagerReady() {
  38011. ensureNotTerminated();
  38012. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38013. ensureNotTerminated();
  38014. if (!(ex instanceof XRefParseException)) {
  38015. onFailure(ex);
  38016. return;
  38017. }
  38018. pdfManager.requestLoadedStream();
  38019. pdfManager.onLoadedStream().then(function () {
  38020. ensureNotTerminated();
  38021. loadDocument(true).then(onSuccess, onFailure);
  38022. });
  38023. }, onFailure);
  38024. }
  38025. ensureNotTerminated();
  38026. var evaluatorOptions = {
  38027. forceDataSchema: data.disableCreateObjectURL,
  38028. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38029. disableFontFace: data.disableFontFace,
  38030. disableNativeImageDecoder: data.disableNativeImageDecoder
  38031. };
  38032. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38033. if (terminated) {
  38034. newPdfManager.terminate();
  38035. throw new Error('Worker was terminated');
  38036. }
  38037. pdfManager = newPdfManager;
  38038. handler.send('PDFManagerReady', null);
  38039. pdfManager.onLoadedStream().then(function (stream) {
  38040. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38041. });
  38042. }).then(pdfManagerReady, onFailure);
  38043. }
  38044. handler.on('GetPage', function wphSetupGetPage(data) {
  38045. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38046. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38047. var refPromise = pdfManager.ensure(page, 'ref');
  38048. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38049. var viewPromise = pdfManager.ensure(page, 'view');
  38050. return Promise.all([
  38051. rotatePromise,
  38052. refPromise,
  38053. userUnitPromise,
  38054. viewPromise
  38055. ]).then(function (results) {
  38056. return {
  38057. rotate: results[0],
  38058. ref: results[1],
  38059. userUnit: results[2],
  38060. view: results[3]
  38061. };
  38062. });
  38063. });
  38064. });
  38065. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38066. var ref = new Ref(data.ref.num, data.ref.gen);
  38067. var catalog = pdfManager.pdfDocument.catalog;
  38068. return catalog.getPageIndex(ref);
  38069. });
  38070. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38071. return pdfManager.ensureCatalog('destinations');
  38072. });
  38073. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38074. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38075. });
  38076. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38077. return pdfManager.ensureCatalog('pageLabels');
  38078. });
  38079. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38080. return pdfManager.ensureCatalog('attachments');
  38081. });
  38082. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38083. return pdfManager.ensureCatalog('javaScript');
  38084. });
  38085. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38086. return pdfManager.ensureCatalog('documentOutline');
  38087. });
  38088. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38089. return Promise.all([
  38090. pdfManager.ensureDoc('documentInfo'),
  38091. pdfManager.ensureCatalog('metadata')
  38092. ]);
  38093. });
  38094. handler.on('GetData', function wphSetupGetData(data) {
  38095. pdfManager.requestLoadedStream();
  38096. return pdfManager.onLoadedStream().then(function (stream) {
  38097. return stream.bytes;
  38098. });
  38099. });
  38100. handler.on('GetStats', function wphSetupGetStats(data) {
  38101. return pdfManager.pdfDocument.xref.stats;
  38102. });
  38103. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38104. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38105. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38106. });
  38107. });
  38108. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38109. var pageIndex = data.pageIndex;
  38110. pdfManager.getPage(pageIndex).then(function (page) {
  38111. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38112. startWorkerTask(task);
  38113. var pageNum = pageIndex + 1;
  38114. var start = Date.now();
  38115. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38116. finishWorkerTask(task);
  38117. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38118. }, function (e) {
  38119. finishWorkerTask(task);
  38120. if (task.terminated) {
  38121. return;
  38122. }
  38123. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38124. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38125. var wrappedException;
  38126. if (typeof e === 'string') {
  38127. wrappedException = {
  38128. message: e,
  38129. stack: minimumStackMessage
  38130. };
  38131. } else if (typeof e === 'object') {
  38132. wrappedException = {
  38133. message: e.message || e.toString(),
  38134. stack: e.stack || minimumStackMessage
  38135. };
  38136. } else {
  38137. wrappedException = {
  38138. message: 'Unknown exception type: ' + typeof e,
  38139. stack: minimumStackMessage
  38140. };
  38141. }
  38142. handler.send('PageError', {
  38143. pageNum: pageNum,
  38144. error: wrappedException,
  38145. intent: data.intent
  38146. });
  38147. });
  38148. });
  38149. }, this);
  38150. handler.on('GetTextContent', function wphExtractText(data) {
  38151. var pageIndex = data.pageIndex;
  38152. var normalizeWhitespace = data.normalizeWhitespace;
  38153. var combineTextItems = data.combineTextItems;
  38154. return pdfManager.getPage(pageIndex).then(function (page) {
  38155. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38156. startWorkerTask(task);
  38157. var pageNum = pageIndex + 1;
  38158. var start = Date.now();
  38159. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38160. finishWorkerTask(task);
  38161. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38162. return textContent;
  38163. }, function (reason) {
  38164. finishWorkerTask(task);
  38165. if (task.terminated) {
  38166. return;
  38167. }
  38168. throw reason;
  38169. });
  38170. });
  38171. });
  38172. handler.on('Cleanup', function wphCleanup(data) {
  38173. return pdfManager.cleanup();
  38174. });
  38175. handler.on('Terminate', function wphTerminate(data) {
  38176. terminated = true;
  38177. if (pdfManager) {
  38178. pdfManager.terminate();
  38179. pdfManager = null;
  38180. }
  38181. if (cancelXHRs) {
  38182. cancelXHRs();
  38183. }
  38184. var waitOn = [];
  38185. WorkerTasks.forEach(function (task) {
  38186. waitOn.push(task.finished);
  38187. task.terminate();
  38188. });
  38189. return Promise.all(waitOn).then(function () {
  38190. handler.destroy();
  38191. handler = null;
  38192. });
  38193. });
  38194. handler.on('Ready', function wphReady(data) {
  38195. setupDoc(docParams);
  38196. docParams = null;
  38197. });
  38198. return workerHandlerName;
  38199. }
  38200. };
  38201. function initializeWorker() {
  38202. var handler = new MessageHandler('worker', 'main', self);
  38203. WorkerMessageHandler.setup(handler, self);
  38204. handler.send('ready', null);
  38205. }
  38206. if (typeof window === 'undefined' && !isNodeJS()) {
  38207. initializeWorker();
  38208. }
  38209. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38210. exports.WorkerTask = WorkerTask;
  38211. exports.WorkerMessageHandler = WorkerMessageHandler;
  38212. /***/ }),
  38213. /* 24 */
  38214. /***/ (function(module, exports, __w_pdfjs_require__) {
  38215. "use strict";
  38216. var sharedUtil = __w_pdfjs_require__(0);
  38217. var error = sharedUtil.error;
  38218. function fixMetadata(meta) {
  38219. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38220. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38221. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38222. });
  38223. var chars = '';
  38224. for (var i = 0; i < bytes.length; i += 2) {
  38225. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38226. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38227. }
  38228. return '>' + chars;
  38229. });
  38230. }
  38231. function Metadata(meta) {
  38232. if (typeof meta === 'string') {
  38233. meta = fixMetadata(meta);
  38234. var parser = new DOMParser();
  38235. meta = parser.parseFromString(meta, 'application/xml');
  38236. } else if (!(meta instanceof Document)) {
  38237. error('Metadata: Invalid metadata object');
  38238. }
  38239. this.metaDocument = meta;
  38240. this.metadata = Object.create(null);
  38241. this.parse();
  38242. }
  38243. Metadata.prototype = {
  38244. parse: function Metadata_parse() {
  38245. var doc = this.metaDocument;
  38246. var rdf = doc.documentElement;
  38247. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38248. rdf = rdf.firstChild;
  38249. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38250. rdf = rdf.nextSibling;
  38251. }
  38252. }
  38253. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38254. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38255. return;
  38256. }
  38257. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38258. for (i = 0, length = children.length; i < length; i++) {
  38259. desc = children[i];
  38260. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38261. continue;
  38262. }
  38263. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38264. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38265. entry = desc.childNodes[ii];
  38266. name = entry.nodeName.toLowerCase();
  38267. this.metadata[name] = entry.textContent.trim();
  38268. }
  38269. }
  38270. }
  38271. },
  38272. get: function Metadata_get(name) {
  38273. return this.metadata[name] || null;
  38274. },
  38275. has: function Metadata_has(name) {
  38276. return typeof this.metadata[name] !== 'undefined';
  38277. }
  38278. };
  38279. exports.Metadata = Metadata;
  38280. /***/ }),
  38281. /* 25 */
  38282. /***/ (function(module, exports, __w_pdfjs_require__) {
  38283. "use strict";
  38284. var sharedUtil = __w_pdfjs_require__(0);
  38285. var displayDOMUtils = __w_pdfjs_require__(3);
  38286. var shadow = sharedUtil.shadow;
  38287. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38288. var WebGLUtils = function WebGLUtilsClosure() {
  38289. function loadShader(gl, code, shaderType) {
  38290. var shader = gl.createShader(shaderType);
  38291. gl.shaderSource(shader, code);
  38292. gl.compileShader(shader);
  38293. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38294. if (!compiled) {
  38295. var errorMsg = gl.getShaderInfoLog(shader);
  38296. throw new Error('Error during shader compilation: ' + errorMsg);
  38297. }
  38298. return shader;
  38299. }
  38300. function createVertexShader(gl, code) {
  38301. return loadShader(gl, code, gl.VERTEX_SHADER);
  38302. }
  38303. function createFragmentShader(gl, code) {
  38304. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38305. }
  38306. function createProgram(gl, shaders) {
  38307. var program = gl.createProgram();
  38308. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38309. gl.attachShader(program, shaders[i]);
  38310. }
  38311. gl.linkProgram(program);
  38312. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38313. if (!linked) {
  38314. var errorMsg = gl.getProgramInfoLog(program);
  38315. throw new Error('Error during program linking: ' + errorMsg);
  38316. }
  38317. return program;
  38318. }
  38319. function createTexture(gl, image, textureId) {
  38320. gl.activeTexture(textureId);
  38321. var texture = gl.createTexture();
  38322. gl.bindTexture(gl.TEXTURE_2D, texture);
  38323. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38324. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38325. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38326. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38327. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38328. return texture;
  38329. }
  38330. var currentGL, currentCanvas;
  38331. function generateGL() {
  38332. if (currentGL) {
  38333. return;
  38334. }
  38335. currentCanvas = document.createElement('canvas');
  38336. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38337. }
  38338. var smaskVertexShaderCode = '\
  38339. attribute vec2 a_position; \
  38340. attribute vec2 a_texCoord; \
  38341. \
  38342. uniform vec2 u_resolution; \
  38343. \
  38344. varying vec2 v_texCoord; \
  38345. \
  38346. void main() { \
  38347. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38348. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38349. \
  38350. v_texCoord = a_texCoord; \
  38351. } ';
  38352. var smaskFragmentShaderCode = '\
  38353. precision mediump float; \
  38354. \
  38355. uniform vec4 u_backdrop; \
  38356. uniform int u_subtype; \
  38357. uniform sampler2D u_image; \
  38358. uniform sampler2D u_mask; \
  38359. \
  38360. varying vec2 v_texCoord; \
  38361. \
  38362. void main() { \
  38363. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38364. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38365. if (u_backdrop.a > 0.0) { \
  38366. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38367. u_backdrop.rgb * (1.0 - maskColor.a); \
  38368. } \
  38369. float lum; \
  38370. if (u_subtype == 0) { \
  38371. lum = maskColor.a; \
  38372. } else { \
  38373. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38374. maskColor.b * 0.11; \
  38375. } \
  38376. imageColor.a *= lum; \
  38377. imageColor.rgb *= imageColor.a; \
  38378. gl_FragColor = imageColor; \
  38379. } ';
  38380. var smaskCache = null;
  38381. function initSmaskGL() {
  38382. var canvas, gl;
  38383. generateGL();
  38384. canvas = currentCanvas;
  38385. currentCanvas = null;
  38386. gl = currentGL;
  38387. currentGL = null;
  38388. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38389. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38390. var program = createProgram(gl, [
  38391. vertexShader,
  38392. fragmentShader
  38393. ]);
  38394. gl.useProgram(program);
  38395. var cache = {};
  38396. cache.gl = gl;
  38397. cache.canvas = canvas;
  38398. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38399. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38400. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38401. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38402. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38403. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38404. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38405. var texCoordBuffer = gl.createBuffer();
  38406. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38407. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38408. 0.0,
  38409. 0.0,
  38410. 1.0,
  38411. 0.0,
  38412. 0.0,
  38413. 1.0,
  38414. 0.0,
  38415. 1.0,
  38416. 1.0,
  38417. 0.0,
  38418. 1.0,
  38419. 1.0
  38420. ]), gl.STATIC_DRAW);
  38421. gl.enableVertexAttribArray(texCoordLocation);
  38422. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38423. gl.uniform1i(texLayerLocation, 0);
  38424. gl.uniform1i(texMaskLocation, 1);
  38425. smaskCache = cache;
  38426. }
  38427. function composeSMask(layer, mask, properties) {
  38428. var width = layer.width, height = layer.height;
  38429. if (!smaskCache) {
  38430. initSmaskGL();
  38431. }
  38432. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38433. canvas.width = width;
  38434. canvas.height = height;
  38435. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38436. gl.uniform2f(cache.resolutionLocation, width, height);
  38437. if (properties.backdrop) {
  38438. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38439. } else {
  38440. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38441. }
  38442. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38443. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38444. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38445. var buffer = gl.createBuffer();
  38446. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38447. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38448. 0,
  38449. 0,
  38450. width,
  38451. 0,
  38452. 0,
  38453. height,
  38454. 0,
  38455. height,
  38456. width,
  38457. 0,
  38458. width,
  38459. height
  38460. ]), gl.STATIC_DRAW);
  38461. gl.enableVertexAttribArray(cache.positionLocation);
  38462. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38463. gl.clearColor(0, 0, 0, 0);
  38464. gl.enable(gl.BLEND);
  38465. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38466. gl.clear(gl.COLOR_BUFFER_BIT);
  38467. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38468. gl.flush();
  38469. gl.deleteTexture(texture);
  38470. gl.deleteTexture(maskTexture);
  38471. gl.deleteBuffer(buffer);
  38472. return canvas;
  38473. }
  38474. var figuresVertexShaderCode = '\
  38475. attribute vec2 a_position; \
  38476. attribute vec3 a_color; \
  38477. \
  38478. uniform vec2 u_resolution; \
  38479. uniform vec2 u_scale; \
  38480. uniform vec2 u_offset; \
  38481. \
  38482. varying vec4 v_color; \
  38483. \
  38484. void main() { \
  38485. vec2 position = (a_position + u_offset) * u_scale; \
  38486. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38487. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38488. \
  38489. v_color = vec4(a_color / 255.0, 1.0); \
  38490. } ';
  38491. var figuresFragmentShaderCode = '\
  38492. precision mediump float; \
  38493. \
  38494. varying vec4 v_color; \
  38495. \
  38496. void main() { \
  38497. gl_FragColor = v_color; \
  38498. } ';
  38499. var figuresCache = null;
  38500. function initFiguresGL() {
  38501. var canvas, gl;
  38502. generateGL();
  38503. canvas = currentCanvas;
  38504. currentCanvas = null;
  38505. gl = currentGL;
  38506. currentGL = null;
  38507. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38508. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38509. var program = createProgram(gl, [
  38510. vertexShader,
  38511. fragmentShader
  38512. ]);
  38513. gl.useProgram(program);
  38514. var cache = {};
  38515. cache.gl = gl;
  38516. cache.canvas = canvas;
  38517. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38518. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38519. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38520. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38521. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38522. figuresCache = cache;
  38523. }
  38524. function drawFigures(width, height, backgroundColor, figures, context) {
  38525. if (!figuresCache) {
  38526. initFiguresGL();
  38527. }
  38528. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38529. canvas.width = width;
  38530. canvas.height = height;
  38531. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38532. gl.uniform2f(cache.resolutionLocation, width, height);
  38533. var count = 0;
  38534. var i, ii, rows;
  38535. for (i = 0, ii = figures.length; i < ii; i++) {
  38536. switch (figures[i].type) {
  38537. case 'lattice':
  38538. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38539. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38540. break;
  38541. case 'triangles':
  38542. count += figures[i].coords.length;
  38543. break;
  38544. }
  38545. }
  38546. var coords = new Float32Array(count * 2);
  38547. var colors = new Uint8Array(count * 3);
  38548. var coordsMap = context.coords, colorsMap = context.colors;
  38549. var pIndex = 0, cIndex = 0;
  38550. for (i = 0, ii = figures.length; i < ii; i++) {
  38551. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38552. switch (figure.type) {
  38553. case 'lattice':
  38554. var cols = figure.verticesPerRow;
  38555. rows = ps.length / cols | 0;
  38556. for (var row = 1; row < rows; row++) {
  38557. var offset = row * cols + 1;
  38558. for (var col = 1; col < cols; col++, offset++) {
  38559. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38560. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38561. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38562. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38563. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38564. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38565. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38566. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38567. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38568. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38569. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38570. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38571. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38572. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38573. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38574. coords[pIndex + 6] = coords[pIndex + 2];
  38575. coords[pIndex + 7] = coords[pIndex + 3];
  38576. coords[pIndex + 8] = coords[pIndex + 4];
  38577. coords[pIndex + 9] = coords[pIndex + 5];
  38578. coords[pIndex + 10] = coordsMap[ps[offset]];
  38579. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38580. colors[cIndex + 9] = colors[cIndex + 3];
  38581. colors[cIndex + 10] = colors[cIndex + 4];
  38582. colors[cIndex + 11] = colors[cIndex + 5];
  38583. colors[cIndex + 12] = colors[cIndex + 6];
  38584. colors[cIndex + 13] = colors[cIndex + 7];
  38585. colors[cIndex + 14] = colors[cIndex + 8];
  38586. colors[cIndex + 15] = colorsMap[cs[offset]];
  38587. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38588. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38589. pIndex += 12;
  38590. cIndex += 18;
  38591. }
  38592. }
  38593. break;
  38594. case 'triangles':
  38595. for (var j = 0, jj = ps.length; j < jj; j++) {
  38596. coords[pIndex] = coordsMap[ps[j]];
  38597. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38598. colors[cIndex] = colorsMap[cs[j]];
  38599. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38600. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38601. pIndex += 2;
  38602. cIndex += 3;
  38603. }
  38604. break;
  38605. }
  38606. }
  38607. if (backgroundColor) {
  38608. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38609. } else {
  38610. gl.clearColor(0, 0, 0, 0);
  38611. }
  38612. gl.clear(gl.COLOR_BUFFER_BIT);
  38613. var coordsBuffer = gl.createBuffer();
  38614. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38615. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38616. gl.enableVertexAttribArray(cache.positionLocation);
  38617. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38618. var colorsBuffer = gl.createBuffer();
  38619. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38620. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38621. gl.enableVertexAttribArray(cache.colorLocation);
  38622. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38623. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38624. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38625. gl.drawArrays(gl.TRIANGLES, 0, count);
  38626. gl.flush();
  38627. gl.deleteBuffer(coordsBuffer);
  38628. gl.deleteBuffer(colorsBuffer);
  38629. return canvas;
  38630. }
  38631. function cleanup() {
  38632. if (smaskCache && smaskCache.canvas) {
  38633. smaskCache.canvas.width = 0;
  38634. smaskCache.canvas.height = 0;
  38635. }
  38636. if (figuresCache && figuresCache.canvas) {
  38637. figuresCache.canvas.width = 0;
  38638. figuresCache.canvas.height = 0;
  38639. }
  38640. smaskCache = null;
  38641. figuresCache = null;
  38642. }
  38643. return {
  38644. get isEnabled() {
  38645. if (getDefaultSetting('disableWebGL')) {
  38646. return false;
  38647. }
  38648. var enabled = false;
  38649. try {
  38650. generateGL();
  38651. enabled = !!currentGL;
  38652. } catch (e) {
  38653. }
  38654. return shadow(this, 'isEnabled', enabled);
  38655. },
  38656. composeSMask: composeSMask,
  38657. drawFigures: drawFigures,
  38658. clear: cleanup
  38659. };
  38660. }();
  38661. exports.WebGLUtils = WebGLUtils;
  38662. /***/ }),
  38663. /* 26 */
  38664. /***/ (function(module, exports, __w_pdfjs_require__) {
  38665. "use strict";
  38666. var sharedUtil = __w_pdfjs_require__(0);
  38667. var displayDOMUtils = __w_pdfjs_require__(3);
  38668. var displayAPI = __w_pdfjs_require__(10);
  38669. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38670. var displayTextLayer = __w_pdfjs_require__(12);
  38671. var displayMetadata = __w_pdfjs_require__(24);
  38672. var displaySVG = __w_pdfjs_require__(11);
  38673. var globalScope = sharedUtil.globalScope;
  38674. var deprecated = sharedUtil.deprecated;
  38675. var warn = sharedUtil.warn;
  38676. var LinkTarget = displayDOMUtils.LinkTarget;
  38677. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38678. var isWorker = typeof window === 'undefined';
  38679. if (!globalScope.PDFJS) {
  38680. globalScope.PDFJS = {};
  38681. }
  38682. var PDFJS = globalScope.PDFJS;
  38683. PDFJS.version = '1.7.331';
  38684. PDFJS.build = 'b75d53a7';
  38685. PDFJS.pdfBug = false;
  38686. if (PDFJS.verbosity !== undefined) {
  38687. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38688. }
  38689. delete PDFJS.verbosity;
  38690. Object.defineProperty(PDFJS, 'verbosity', {
  38691. get: function () {
  38692. return sharedUtil.getVerbosityLevel();
  38693. },
  38694. set: function (level) {
  38695. sharedUtil.setVerbosityLevel(level);
  38696. },
  38697. enumerable: true,
  38698. configurable: true
  38699. });
  38700. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38701. PDFJS.OPS = sharedUtil.OPS;
  38702. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38703. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38704. PDFJS.shadow = sharedUtil.shadow;
  38705. PDFJS.createBlob = sharedUtil.createBlob;
  38706. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38707. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38708. };
  38709. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38710. configurable: true,
  38711. get: function PDFJS_isLittleEndian() {
  38712. var value = sharedUtil.isLittleEndian();
  38713. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38714. }
  38715. });
  38716. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38717. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38718. PDFJS.PasswordException = sharedUtil.PasswordException;
  38719. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38720. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38721. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38722. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38723. PDFJS.Util = sharedUtil.Util;
  38724. PDFJS.PageViewport = sharedUtil.PageViewport;
  38725. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38726. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38727. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38728. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38729. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38730. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38731. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38732. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38733. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  38734. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38735. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38736. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38737. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38738. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38739. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38740. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38741. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38742. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38743. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38744. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38745. delete PDFJS.openExternalLinksInNewWindow;
  38746. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38747. get: function () {
  38748. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38749. },
  38750. set: function (value) {
  38751. if (value) {
  38752. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38753. }
  38754. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38755. warn('PDFJS.externalLinkTarget is already initialized');
  38756. return;
  38757. }
  38758. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38759. },
  38760. enumerable: true,
  38761. configurable: true
  38762. });
  38763. if (savedOpenExternalLinksInNewWindow) {
  38764. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38765. }
  38766. PDFJS.getDocument = displayAPI.getDocument;
  38767. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38768. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38769. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38770. configurable: true,
  38771. get: function PDFJS_hasCanvasTypedArrays() {
  38772. var value = displayDOMUtils.hasCanvasTypedArrays();
  38773. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38774. }
  38775. });
  38776. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38777. PDFJS.LinkTarget = LinkTarget;
  38778. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38779. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38780. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38781. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38782. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38783. PDFJS.Metadata = displayMetadata.Metadata;
  38784. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38785. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38786. exports.globalScope = globalScope;
  38787. exports.isWorker = isWorker;
  38788. exports.PDFJS = globalScope.PDFJS;
  38789. /***/ }),
  38790. /* 27 */
  38791. /***/ (function(module, exports, __w_pdfjs_require__) {
  38792. "use strict";
  38793. var sharedUtil = __w_pdfjs_require__(0);
  38794. var corePrimitives = __w_pdfjs_require__(1);
  38795. var coreStream = __w_pdfjs_require__(2);
  38796. var coreColorSpace = __w_pdfjs_require__(4);
  38797. var coreObj = __w_pdfjs_require__(20);
  38798. var coreEvaluator = __w_pdfjs_require__(18);
  38799. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38800. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38801. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38802. var AnnotationType = sharedUtil.AnnotationType;
  38803. var OPS = sharedUtil.OPS;
  38804. var Util = sharedUtil.Util;
  38805. var isArray = sharedUtil.isArray;
  38806. var isInt = sharedUtil.isInt;
  38807. var stringToBytes = sharedUtil.stringToBytes;
  38808. var stringToPDFString = sharedUtil.stringToPDFString;
  38809. var warn = sharedUtil.warn;
  38810. var Dict = corePrimitives.Dict;
  38811. var isDict = corePrimitives.isDict;
  38812. var isName = corePrimitives.isName;
  38813. var isRef = corePrimitives.isRef;
  38814. var isStream = corePrimitives.isStream;
  38815. var Stream = coreStream.Stream;
  38816. var ColorSpace = coreColorSpace.ColorSpace;
  38817. var Catalog = coreObj.Catalog;
  38818. var ObjectLoader = coreObj.ObjectLoader;
  38819. var FileSpec = coreObj.FileSpec;
  38820. var OperatorList = coreEvaluator.OperatorList;
  38821. function AnnotationFactory() {
  38822. }
  38823. AnnotationFactory.prototype = {
  38824. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38825. var dict = xref.fetchIfRef(ref);
  38826. if (!isDict(dict)) {
  38827. return;
  38828. }
  38829. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38830. var subtype = dict.get('Subtype');
  38831. subtype = isName(subtype) ? subtype.name : null;
  38832. var parameters = {
  38833. xref: xref,
  38834. dict: dict,
  38835. ref: isRef(ref) ? ref : null,
  38836. subtype: subtype,
  38837. id: id,
  38838. pdfManager: pdfManager
  38839. };
  38840. switch (subtype) {
  38841. case 'Link':
  38842. return new LinkAnnotation(parameters);
  38843. case 'Text':
  38844. return new TextAnnotation(parameters);
  38845. case 'Widget':
  38846. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38847. fieldType = isName(fieldType) ? fieldType.name : null;
  38848. switch (fieldType) {
  38849. case 'Tx':
  38850. return new TextWidgetAnnotation(parameters);
  38851. case 'Btn':
  38852. return new ButtonWidgetAnnotation(parameters);
  38853. case 'Ch':
  38854. return new ChoiceWidgetAnnotation(parameters);
  38855. }
  38856. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38857. return new WidgetAnnotation(parameters);
  38858. case 'Popup':
  38859. return new PopupAnnotation(parameters);
  38860. case 'Highlight':
  38861. return new HighlightAnnotation(parameters);
  38862. case 'Underline':
  38863. return new UnderlineAnnotation(parameters);
  38864. case 'Squiggly':
  38865. return new SquigglyAnnotation(parameters);
  38866. case 'StrikeOut':
  38867. return new StrikeOutAnnotation(parameters);
  38868. case 'FileAttachment':
  38869. return new FileAttachmentAnnotation(parameters);
  38870. default:
  38871. if (!subtype) {
  38872. warn('Annotation is missing the required /Subtype.');
  38873. } else {
  38874. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38875. }
  38876. return new Annotation(parameters);
  38877. }
  38878. }
  38879. };
  38880. var Annotation = function AnnotationClosure() {
  38881. function getTransformMatrix(rect, bbox, matrix) {
  38882. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38883. var minX = bounds[0];
  38884. var minY = bounds[1];
  38885. var maxX = bounds[2];
  38886. var maxY = bounds[3];
  38887. if (minX === maxX || minY === maxY) {
  38888. return [
  38889. 1,
  38890. 0,
  38891. 0,
  38892. 1,
  38893. rect[0],
  38894. rect[1]
  38895. ];
  38896. }
  38897. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38898. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38899. return [
  38900. xRatio,
  38901. 0,
  38902. 0,
  38903. yRatio,
  38904. rect[0] - minX * xRatio,
  38905. rect[1] - minY * yRatio
  38906. ];
  38907. }
  38908. function Annotation(params) {
  38909. var dict = params.dict;
  38910. this.setFlags(dict.get('F'));
  38911. this.setRectangle(dict.getArray('Rect'));
  38912. this.setColor(dict.getArray('C'));
  38913. this.setBorderStyle(dict);
  38914. this.setAppearance(dict);
  38915. this.data = {};
  38916. this.data.id = params.id;
  38917. this.data.subtype = params.subtype;
  38918. this.data.annotationFlags = this.flags;
  38919. this.data.rect = this.rectangle;
  38920. this.data.color = this.color;
  38921. this.data.borderStyle = this.borderStyle;
  38922. this.data.hasAppearance = !!this.appearance;
  38923. }
  38924. Annotation.prototype = {
  38925. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38926. return !!(flags & flag);
  38927. },
  38928. _isViewable: function Annotation_isViewable(flags) {
  38929. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38930. },
  38931. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38932. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38933. },
  38934. get viewable() {
  38935. if (this.flags === 0) {
  38936. return true;
  38937. }
  38938. return this._isViewable(this.flags);
  38939. },
  38940. get printable() {
  38941. if (this.flags === 0) {
  38942. return false;
  38943. }
  38944. return this._isPrintable(this.flags);
  38945. },
  38946. setFlags: function Annotation_setFlags(flags) {
  38947. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38948. },
  38949. hasFlag: function Annotation_hasFlag(flag) {
  38950. return this._hasFlag(this.flags, flag);
  38951. },
  38952. setRectangle: function Annotation_setRectangle(rectangle) {
  38953. if (isArray(rectangle) && rectangle.length === 4) {
  38954. this.rectangle = Util.normalizeRect(rectangle);
  38955. } else {
  38956. this.rectangle = [
  38957. 0,
  38958. 0,
  38959. 0,
  38960. 0
  38961. ];
  38962. }
  38963. },
  38964. setColor: function Annotation_setColor(color) {
  38965. var rgbColor = new Uint8Array(3);
  38966. if (!isArray(color)) {
  38967. this.color = rgbColor;
  38968. return;
  38969. }
  38970. switch (color.length) {
  38971. case 0:
  38972. this.color = null;
  38973. break;
  38974. case 1:
  38975. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38976. this.color = rgbColor;
  38977. break;
  38978. case 3:
  38979. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38980. this.color = rgbColor;
  38981. break;
  38982. case 4:
  38983. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  38984. this.color = rgbColor;
  38985. break;
  38986. default:
  38987. this.color = rgbColor;
  38988. break;
  38989. }
  38990. },
  38991. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  38992. this.borderStyle = new AnnotationBorderStyle();
  38993. if (!isDict(borderStyle)) {
  38994. return;
  38995. }
  38996. if (borderStyle.has('BS')) {
  38997. var dict = borderStyle.get('BS');
  38998. var dictType = dict.get('Type');
  38999. if (!dictType || isName(dictType, 'Border')) {
  39000. this.borderStyle.setWidth(dict.get('W'));
  39001. this.borderStyle.setStyle(dict.get('S'));
  39002. this.borderStyle.setDashArray(dict.getArray('D'));
  39003. }
  39004. } else if (borderStyle.has('Border')) {
  39005. var array = borderStyle.getArray('Border');
  39006. if (isArray(array) && array.length >= 3) {
  39007. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39008. this.borderStyle.setVerticalCornerRadius(array[1]);
  39009. this.borderStyle.setWidth(array[2]);
  39010. if (array.length === 4) {
  39011. this.borderStyle.setDashArray(array[3]);
  39012. }
  39013. }
  39014. } else {
  39015. this.borderStyle.setWidth(0);
  39016. }
  39017. },
  39018. setAppearance: function Annotation_setAppearance(dict) {
  39019. this.appearance = null;
  39020. var appearanceStates = dict.get('AP');
  39021. if (!isDict(appearanceStates)) {
  39022. return;
  39023. }
  39024. var normalAppearanceState = appearanceStates.get('N');
  39025. if (isStream(normalAppearanceState)) {
  39026. this.appearance = normalAppearanceState;
  39027. return;
  39028. }
  39029. if (!isDict(normalAppearanceState)) {
  39030. return;
  39031. }
  39032. var as = dict.get('AS');
  39033. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39034. return;
  39035. }
  39036. this.appearance = normalAppearanceState.get(as.name);
  39037. },
  39038. _preparePopup: function Annotation_preparePopup(dict) {
  39039. if (!dict.has('C')) {
  39040. this.data.color = null;
  39041. }
  39042. this.data.hasPopup = dict.has('Popup');
  39043. this.data.title = stringToPDFString(dict.get('T') || '');
  39044. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39045. },
  39046. loadResources: function Annotation_loadResources(keys) {
  39047. return new Promise(function (resolve, reject) {
  39048. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39049. if (!resources) {
  39050. resolve();
  39051. return;
  39052. }
  39053. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39054. objectLoader.load().then(function () {
  39055. resolve(resources);
  39056. }, reject);
  39057. }, reject);
  39058. }.bind(this));
  39059. },
  39060. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39061. if (!this.appearance) {
  39062. return Promise.resolve(new OperatorList());
  39063. }
  39064. var data = this.data;
  39065. var appearanceDict = this.appearance.dict;
  39066. var resourcesPromise = this.loadResources([
  39067. 'ExtGState',
  39068. 'ColorSpace',
  39069. 'Pattern',
  39070. 'Shading',
  39071. 'XObject',
  39072. 'Font'
  39073. ]);
  39074. var bbox = appearanceDict.getArray('BBox') || [
  39075. 0,
  39076. 0,
  39077. 1,
  39078. 1
  39079. ];
  39080. var matrix = appearanceDict.getArray('Matrix') || [
  39081. 1,
  39082. 0,
  39083. 0,
  39084. 1,
  39085. 0,
  39086. 0
  39087. ];
  39088. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39089. var self = this;
  39090. return resourcesPromise.then(function (resources) {
  39091. var opList = new OperatorList();
  39092. opList.addOp(OPS.beginAnnotation, [
  39093. data.rect,
  39094. transform,
  39095. matrix
  39096. ]);
  39097. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39098. opList.addOp(OPS.endAnnotation, []);
  39099. self.appearance.reset();
  39100. return opList;
  39101. });
  39102. });
  39103. }
  39104. };
  39105. return Annotation;
  39106. }();
  39107. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39108. function AnnotationBorderStyle() {
  39109. this.width = 1;
  39110. this.style = AnnotationBorderStyleType.SOLID;
  39111. this.dashArray = [3];
  39112. this.horizontalCornerRadius = 0;
  39113. this.verticalCornerRadius = 0;
  39114. }
  39115. AnnotationBorderStyle.prototype = {
  39116. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39117. if (width === (width | 0)) {
  39118. this.width = width;
  39119. }
  39120. },
  39121. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39122. if (!style) {
  39123. return;
  39124. }
  39125. switch (style.name) {
  39126. case 'S':
  39127. this.style = AnnotationBorderStyleType.SOLID;
  39128. break;
  39129. case 'D':
  39130. this.style = AnnotationBorderStyleType.DASHED;
  39131. break;
  39132. case 'B':
  39133. this.style = AnnotationBorderStyleType.BEVELED;
  39134. break;
  39135. case 'I':
  39136. this.style = AnnotationBorderStyleType.INSET;
  39137. break;
  39138. case 'U':
  39139. this.style = AnnotationBorderStyleType.UNDERLINE;
  39140. break;
  39141. default:
  39142. break;
  39143. }
  39144. },
  39145. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39146. if (isArray(dashArray) && dashArray.length > 0) {
  39147. var isValid = true;
  39148. var allZeros = true;
  39149. for (var i = 0, len = dashArray.length; i < len; i++) {
  39150. var element = dashArray[i];
  39151. var validNumber = +element >= 0;
  39152. if (!validNumber) {
  39153. isValid = false;
  39154. break;
  39155. } else if (element > 0) {
  39156. allZeros = false;
  39157. }
  39158. }
  39159. if (isValid && !allZeros) {
  39160. this.dashArray = dashArray;
  39161. } else {
  39162. this.width = 0;
  39163. }
  39164. } else if (dashArray) {
  39165. this.width = 0;
  39166. }
  39167. },
  39168. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39169. if (radius === (radius | 0)) {
  39170. this.horizontalCornerRadius = radius;
  39171. }
  39172. },
  39173. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39174. if (radius === (radius | 0)) {
  39175. this.verticalCornerRadius = radius;
  39176. }
  39177. }
  39178. };
  39179. return AnnotationBorderStyle;
  39180. }();
  39181. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39182. function WidgetAnnotation(params) {
  39183. Annotation.call(this, params);
  39184. var dict = params.dict;
  39185. var data = this.data;
  39186. data.annotationType = AnnotationType.WIDGET;
  39187. data.fieldName = this._constructFieldName(dict);
  39188. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39189. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39190. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39191. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39192. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39193. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39194. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39195. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39196. data.fieldFlags = 0;
  39197. }
  39198. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39199. if (data.fieldType === 'Sig') {
  39200. this.setFlags(AnnotationFlag.HIDDEN);
  39201. }
  39202. }
  39203. Util.inherit(WidgetAnnotation, Annotation, {
  39204. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39205. if (!dict.has('T') && !dict.has('Parent')) {
  39206. warn('Unknown field name, falling back to empty field name.');
  39207. return '';
  39208. }
  39209. if (!dict.has('Parent')) {
  39210. return stringToPDFString(dict.get('T'));
  39211. }
  39212. var fieldName = [];
  39213. if (dict.has('T')) {
  39214. fieldName.unshift(stringToPDFString(dict.get('T')));
  39215. }
  39216. var loopDict = dict;
  39217. while (loopDict.has('Parent')) {
  39218. loopDict = loopDict.get('Parent');
  39219. if (loopDict.has('T')) {
  39220. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39221. }
  39222. }
  39223. return fieldName.join('.');
  39224. },
  39225. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39226. return !!(this.data.fieldFlags & flag);
  39227. }
  39228. });
  39229. return WidgetAnnotation;
  39230. }();
  39231. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39232. function TextWidgetAnnotation(params) {
  39233. WidgetAnnotation.call(this, params);
  39234. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39235. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39236. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39237. alignment = null;
  39238. }
  39239. this.data.textAlignment = alignment;
  39240. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39241. if (!isInt(maximumLength) || maximumLength < 0) {
  39242. maximumLength = null;
  39243. }
  39244. this.data.maxLen = maximumLength;
  39245. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39246. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39247. }
  39248. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39249. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39250. var operatorList = new OperatorList();
  39251. if (renderForms) {
  39252. return Promise.resolve(operatorList);
  39253. }
  39254. if (this.appearance) {
  39255. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39256. }
  39257. if (!this.data.defaultAppearance) {
  39258. return Promise.resolve(operatorList);
  39259. }
  39260. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39261. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39262. return operatorList;
  39263. });
  39264. }
  39265. });
  39266. return TextWidgetAnnotation;
  39267. }();
  39268. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39269. function ButtonWidgetAnnotation(params) {
  39270. WidgetAnnotation.call(this, params);
  39271. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39272. if (this.data.checkBox) {
  39273. if (!isName(this.data.fieldValue)) {
  39274. return;
  39275. }
  39276. this.data.fieldValue = this.data.fieldValue.name;
  39277. }
  39278. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39279. if (this.data.radioButton) {
  39280. this.data.fieldValue = this.data.buttonValue = null;
  39281. var fieldParent = params.dict.get('Parent');
  39282. if (isDict(fieldParent) && fieldParent.has('V')) {
  39283. var fieldParentValue = fieldParent.get('V');
  39284. if (isName(fieldParentValue)) {
  39285. this.data.fieldValue = fieldParentValue.name;
  39286. }
  39287. }
  39288. var appearanceStates = params.dict.get('AP');
  39289. if (!isDict(appearanceStates)) {
  39290. return;
  39291. }
  39292. var normalAppearanceState = appearanceStates.get('N');
  39293. if (!isDict(normalAppearanceState)) {
  39294. return;
  39295. }
  39296. var keys = normalAppearanceState.getKeys();
  39297. for (var i = 0, ii = keys.length; i < ii; i++) {
  39298. if (keys[i] !== 'Off') {
  39299. this.data.buttonValue = keys[i];
  39300. break;
  39301. }
  39302. }
  39303. }
  39304. }
  39305. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39306. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39307. var operatorList = new OperatorList();
  39308. if (renderForms) {
  39309. return Promise.resolve(operatorList);
  39310. }
  39311. if (this.appearance) {
  39312. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39313. }
  39314. return Promise.resolve(operatorList);
  39315. }
  39316. });
  39317. return ButtonWidgetAnnotation;
  39318. }();
  39319. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39320. function ChoiceWidgetAnnotation(params) {
  39321. WidgetAnnotation.call(this, params);
  39322. this.data.options = [];
  39323. var options = Util.getInheritableProperty(params.dict, 'Opt');
  39324. if (isArray(options)) {
  39325. var xref = params.xref;
  39326. for (var i = 0, ii = options.length; i < ii; i++) {
  39327. var option = xref.fetchIfRef(options[i]);
  39328. var isOptionArray = isArray(option);
  39329. this.data.options[i] = {
  39330. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39331. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39332. };
  39333. }
  39334. }
  39335. if (!isArray(this.data.fieldValue)) {
  39336. this.data.fieldValue = [this.data.fieldValue];
  39337. }
  39338. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39339. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39340. }
  39341. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39342. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39343. var operatorList = new OperatorList();
  39344. if (renderForms) {
  39345. return Promise.resolve(operatorList);
  39346. }
  39347. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39348. }
  39349. });
  39350. return ChoiceWidgetAnnotation;
  39351. }();
  39352. var TextAnnotation = function TextAnnotationClosure() {
  39353. var DEFAULT_ICON_SIZE = 22;
  39354. function TextAnnotation(parameters) {
  39355. Annotation.call(this, parameters);
  39356. this.data.annotationType = AnnotationType.TEXT;
  39357. if (this.data.hasAppearance) {
  39358. this.data.name = 'NoIcon';
  39359. } else {
  39360. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39361. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39362. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39363. }
  39364. this._preparePopup(parameters.dict);
  39365. }
  39366. Util.inherit(TextAnnotation, Annotation, {});
  39367. return TextAnnotation;
  39368. }();
  39369. var LinkAnnotation = function LinkAnnotationClosure() {
  39370. function LinkAnnotation(params) {
  39371. Annotation.call(this, params);
  39372. var data = this.data;
  39373. data.annotationType = AnnotationType.LINK;
  39374. Catalog.parseDestDictionary({
  39375. destDict: params.dict,
  39376. resultObj: data,
  39377. docBaseUrl: params.pdfManager.docBaseUrl
  39378. });
  39379. }
  39380. Util.inherit(LinkAnnotation, Annotation, {});
  39381. return LinkAnnotation;
  39382. }();
  39383. var PopupAnnotation = function PopupAnnotationClosure() {
  39384. function PopupAnnotation(parameters) {
  39385. Annotation.call(this, parameters);
  39386. this.data.annotationType = AnnotationType.POPUP;
  39387. var dict = parameters.dict;
  39388. var parentItem = dict.get('Parent');
  39389. if (!parentItem) {
  39390. warn('Popup annotation has a missing or invalid parent annotation.');
  39391. return;
  39392. }
  39393. this.data.parentId = dict.getRaw('Parent').toString();
  39394. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39395. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39396. if (!parentItem.has('C')) {
  39397. this.data.color = null;
  39398. } else {
  39399. this.setColor(parentItem.getArray('C'));
  39400. this.data.color = this.color;
  39401. }
  39402. if (!this.viewable) {
  39403. var parentFlags = parentItem.get('F');
  39404. if (this._isViewable(parentFlags)) {
  39405. this.setFlags(parentFlags);
  39406. }
  39407. }
  39408. }
  39409. Util.inherit(PopupAnnotation, Annotation, {});
  39410. return PopupAnnotation;
  39411. }();
  39412. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39413. function HighlightAnnotation(parameters) {
  39414. Annotation.call(this, parameters);
  39415. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39416. this._preparePopup(parameters.dict);
  39417. this.data.borderStyle.setWidth(0);
  39418. }
  39419. Util.inherit(HighlightAnnotation, Annotation, {});
  39420. return HighlightAnnotation;
  39421. }();
  39422. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39423. function UnderlineAnnotation(parameters) {
  39424. Annotation.call(this, parameters);
  39425. this.data.annotationType = AnnotationType.UNDERLINE;
  39426. this._preparePopup(parameters.dict);
  39427. this.data.borderStyle.setWidth(0);
  39428. }
  39429. Util.inherit(UnderlineAnnotation, Annotation, {});
  39430. return UnderlineAnnotation;
  39431. }();
  39432. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39433. function SquigglyAnnotation(parameters) {
  39434. Annotation.call(this, parameters);
  39435. this.data.annotationType = AnnotationType.SQUIGGLY;
  39436. this._preparePopup(parameters.dict);
  39437. this.data.borderStyle.setWidth(0);
  39438. }
  39439. Util.inherit(SquigglyAnnotation, Annotation, {});
  39440. return SquigglyAnnotation;
  39441. }();
  39442. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39443. function StrikeOutAnnotation(parameters) {
  39444. Annotation.call(this, parameters);
  39445. this.data.annotationType = AnnotationType.STRIKEOUT;
  39446. this._preparePopup(parameters.dict);
  39447. this.data.borderStyle.setWidth(0);
  39448. }
  39449. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39450. return StrikeOutAnnotation;
  39451. }();
  39452. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39453. function FileAttachmentAnnotation(parameters) {
  39454. Annotation.call(this, parameters);
  39455. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39456. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39457. this.data.file = file.serializable;
  39458. this._preparePopup(parameters.dict);
  39459. }
  39460. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39461. return FileAttachmentAnnotation;
  39462. }();
  39463. exports.Annotation = Annotation;
  39464. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39465. exports.AnnotationFactory = AnnotationFactory;
  39466. /***/ }),
  39467. /* 28 */
  39468. /***/ (function(module, exports, __w_pdfjs_require__) {
  39469. "use strict";
  39470. var sharedUtil = __w_pdfjs_require__(0);
  39471. var warn = sharedUtil.warn;
  39472. var baseTypes = [
  39473. 'BN',
  39474. 'BN',
  39475. 'BN',
  39476. 'BN',
  39477. 'BN',
  39478. 'BN',
  39479. 'BN',
  39480. 'BN',
  39481. 'BN',
  39482. 'S',
  39483. 'B',
  39484. 'S',
  39485. 'WS',
  39486. 'B',
  39487. 'BN',
  39488. 'BN',
  39489. 'BN',
  39490. 'BN',
  39491. 'BN',
  39492. 'BN',
  39493. 'BN',
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'BN',
  39499. 'BN',
  39500. 'BN',
  39501. 'B',
  39502. 'B',
  39503. 'B',
  39504. 'S',
  39505. 'WS',
  39506. 'ON',
  39507. 'ON',
  39508. 'ET',
  39509. 'ET',
  39510. 'ET',
  39511. 'ON',
  39512. 'ON',
  39513. 'ON',
  39514. 'ON',
  39515. 'ON',
  39516. 'ES',
  39517. 'CS',
  39518. 'ES',
  39519. 'CS',
  39520. 'CS',
  39521. 'EN',
  39522. 'EN',
  39523. 'EN',
  39524. 'EN',
  39525. 'EN',
  39526. 'EN',
  39527. 'EN',
  39528. 'EN',
  39529. 'EN',
  39530. 'EN',
  39531. 'CS',
  39532. 'ON',
  39533. 'ON',
  39534. 'ON',
  39535. 'ON',
  39536. 'ON',
  39537. 'ON',
  39538. 'L',
  39539. 'L',
  39540. 'L',
  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. 'ON',
  39565. 'ON',
  39566. 'ON',
  39567. 'ON',
  39568. 'ON',
  39569. 'ON',
  39570. 'L',
  39571. 'L',
  39572. 'L',
  39573. 'L',
  39574. 'L',
  39575. 'L',
  39576. 'L',
  39577. 'L',
  39578. 'L',
  39579. 'L',
  39580. 'L',
  39581. 'L',
  39582. '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. 'ON',
  39597. 'ON',
  39598. 'ON',
  39599. 'ON',
  39600. 'BN',
  39601. 'BN',
  39602. 'BN',
  39603. 'BN',
  39604. 'BN',
  39605. 'BN',
  39606. 'B',
  39607. 'BN',
  39608. 'BN',
  39609. 'BN',
  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. 'CS',
  39634. 'ON',
  39635. 'ET',
  39636. 'ET',
  39637. 'ET',
  39638. 'ET',
  39639. 'ON',
  39640. 'ON',
  39641. 'ON',
  39642. 'ON',
  39643. 'L',
  39644. 'ON',
  39645. 'ON',
  39646. 'BN',
  39647. 'ON',
  39648. 'ON',
  39649. 'ET',
  39650. 'ET',
  39651. 'EN',
  39652. 'EN',
  39653. 'ON',
  39654. 'L',
  39655. 'ON',
  39656. 'ON',
  39657. 'ON',
  39658. 'EN',
  39659. 'L',
  39660. 'ON',
  39661. 'ON',
  39662. 'ON',
  39663. 'ON',
  39664. 'ON',
  39665. 'L',
  39666. 'L',
  39667. 'L',
  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. 'ON',
  39689. 'L',
  39690. 'L',
  39691. 'L',
  39692. 'L',
  39693. 'L',
  39694. 'L',
  39695. 'L',
  39696. 'L',
  39697. 'L',
  39698. 'L',
  39699. 'L',
  39700. 'L',
  39701. 'L',
  39702. 'L',
  39703. 'L',
  39704. 'L',
  39705. 'L',
  39706. '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. 'ON',
  39721. 'L',
  39722. 'L',
  39723. 'L',
  39724. 'L',
  39725. 'L',
  39726. 'L',
  39727. 'L',
  39728. 'L'
  39729. ];
  39730. var arabicTypes = [
  39731. 'AN',
  39732. 'AN',
  39733. 'AN',
  39734. 'AN',
  39735. 'AN',
  39736. 'AN',
  39737. 'ON',
  39738. 'ON',
  39739. 'AL',
  39740. 'ET',
  39741. 'ET',
  39742. 'AL',
  39743. 'CS',
  39744. 'AL',
  39745. 'ON',
  39746. 'ON',
  39747. 'NSM',
  39748. 'NSM',
  39749. 'NSM',
  39750. 'NSM',
  39751. 'NSM',
  39752. 'NSM',
  39753. 'NSM',
  39754. 'NSM',
  39755. 'NSM',
  39756. 'NSM',
  39757. 'NSM',
  39758. 'AL',
  39759. 'AL',
  39760. '',
  39761. 'AL',
  39762. 'AL',
  39763. 'AL',
  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. 'NSM',
  39807. 'NSM',
  39808. 'NSM',
  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. 'AN',
  39828. 'AN',
  39829. 'AN',
  39830. 'AN',
  39831. 'AN',
  39832. 'AN',
  39833. 'AN',
  39834. 'AN',
  39835. 'AN',
  39836. 'AN',
  39837. 'ET',
  39838. 'AN',
  39839. 'AN',
  39840. 'AL',
  39841. 'AL',
  39842. 'AL',
  39843. 'NSM',
  39844. 'AL',
  39845. 'AL',
  39846. 'AL',
  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. 'NSM',
  39946. 'NSM',
  39947. 'NSM',
  39948. 'NSM',
  39949. 'NSM',
  39950. 'NSM',
  39951. 'NSM',
  39952. 'AN',
  39953. 'ON',
  39954. 'NSM',
  39955. 'NSM',
  39956. 'NSM',
  39957. 'NSM',
  39958. 'NSM',
  39959. 'NSM',
  39960. 'AL',
  39961. 'AL',
  39962. 'NSM',
  39963. 'NSM',
  39964. 'ON',
  39965. 'NSM',
  39966. 'NSM',
  39967. 'NSM',
  39968. 'NSM',
  39969. 'AL',
  39970. 'AL',
  39971. 'EN',
  39972. 'EN',
  39973. 'EN',
  39974. 'EN',
  39975. 'EN',
  39976. 'EN',
  39977. 'EN',
  39978. 'EN',
  39979. 'EN',
  39980. 'EN',
  39981. 'AL',
  39982. 'AL',
  39983. 'AL',
  39984. 'AL',
  39985. 'AL',
  39986. 'AL'
  39987. ];
  39988. function isOdd(i) {
  39989. return (i & 1) !== 0;
  39990. }
  39991. function isEven(i) {
  39992. return (i & 1) === 0;
  39993. }
  39994. function findUnequal(arr, start, value) {
  39995. for (var j = start, jj = arr.length; j < jj; ++j) {
  39996. if (arr[j] !== value) {
  39997. return j;
  39998. }
  39999. }
  40000. return j;
  40001. }
  40002. function setValues(arr, start, end, value) {
  40003. for (var j = start; j < end; ++j) {
  40004. arr[j] = value;
  40005. }
  40006. }
  40007. function reverseValues(arr, start, end) {
  40008. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40009. var temp = arr[i];
  40010. arr[i] = arr[j];
  40011. arr[j] = temp;
  40012. }
  40013. }
  40014. function createBidiText(str, isLTR, vertical) {
  40015. return {
  40016. str: str,
  40017. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40018. };
  40019. }
  40020. var chars = [];
  40021. var types = [];
  40022. function bidi(str, startLevel, vertical) {
  40023. var isLTR = true;
  40024. var strLength = str.length;
  40025. if (strLength === 0 || vertical) {
  40026. return createBidiText(str, isLTR, vertical);
  40027. }
  40028. chars.length = strLength;
  40029. types.length = strLength;
  40030. var numBidi = 0;
  40031. var i, ii;
  40032. for (i = 0; i < strLength; ++i) {
  40033. chars[i] = str.charAt(i);
  40034. var charCode = str.charCodeAt(i);
  40035. var charType = 'L';
  40036. if (charCode <= 0x00ff) {
  40037. charType = baseTypes[charCode];
  40038. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40039. charType = 'R';
  40040. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40041. charType = arabicTypes[charCode & 0xff];
  40042. if (!charType) {
  40043. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40044. }
  40045. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40046. charType = 'AL';
  40047. }
  40048. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40049. numBidi++;
  40050. }
  40051. types[i] = charType;
  40052. }
  40053. if (numBidi === 0) {
  40054. isLTR = true;
  40055. return createBidiText(str, isLTR);
  40056. }
  40057. if (startLevel === -1) {
  40058. if (numBidi / strLength < 0.3) {
  40059. isLTR = true;
  40060. startLevel = 0;
  40061. } else {
  40062. isLTR = false;
  40063. startLevel = 1;
  40064. }
  40065. }
  40066. var levels = [];
  40067. for (i = 0; i < strLength; ++i) {
  40068. levels[i] = startLevel;
  40069. }
  40070. var e = isOdd(startLevel) ? 'R' : 'L';
  40071. var sor = e;
  40072. var eor = sor;
  40073. var lastType = sor;
  40074. for (i = 0; i < strLength; ++i) {
  40075. if (types[i] === 'NSM') {
  40076. types[i] = lastType;
  40077. } else {
  40078. lastType = types[i];
  40079. }
  40080. }
  40081. lastType = sor;
  40082. var t;
  40083. for (i = 0; i < strLength; ++i) {
  40084. t = types[i];
  40085. if (t === 'EN') {
  40086. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40087. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40088. lastType = t;
  40089. }
  40090. }
  40091. for (i = 0; i < strLength; ++i) {
  40092. t = types[i];
  40093. if (t === 'AL') {
  40094. types[i] = 'R';
  40095. }
  40096. }
  40097. for (i = 1; i < strLength - 1; ++i) {
  40098. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40099. types[i] = 'EN';
  40100. }
  40101. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40102. types[i] = types[i - 1];
  40103. }
  40104. }
  40105. for (i = 0; i < strLength; ++i) {
  40106. if (types[i] === 'EN') {
  40107. var j;
  40108. for (j = i - 1; j >= 0; --j) {
  40109. if (types[j] !== 'ET') {
  40110. break;
  40111. }
  40112. types[j] = 'EN';
  40113. }
  40114. for (j = i + 1; j < strLength; ++j) {
  40115. if (types[j] !== 'ET') {
  40116. break;
  40117. }
  40118. types[j] = 'EN';
  40119. }
  40120. }
  40121. }
  40122. for (i = 0; i < strLength; ++i) {
  40123. t = types[i];
  40124. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40125. types[i] = 'ON';
  40126. }
  40127. }
  40128. lastType = sor;
  40129. for (i = 0; i < strLength; ++i) {
  40130. t = types[i];
  40131. if (t === 'EN') {
  40132. types[i] = lastType === 'L' ? 'L' : 'EN';
  40133. } else if (t === 'R' || t === 'L') {
  40134. lastType = t;
  40135. }
  40136. }
  40137. for (i = 0; i < strLength; ++i) {
  40138. if (types[i] === 'ON') {
  40139. var end = findUnequal(types, i + 1, 'ON');
  40140. var before = sor;
  40141. if (i > 0) {
  40142. before = types[i - 1];
  40143. }
  40144. var after = eor;
  40145. if (end + 1 < strLength) {
  40146. after = types[end + 1];
  40147. }
  40148. if (before !== 'L') {
  40149. before = 'R';
  40150. }
  40151. if (after !== 'L') {
  40152. after = 'R';
  40153. }
  40154. if (before === after) {
  40155. setValues(types, i, end, before);
  40156. }
  40157. i = end - 1;
  40158. }
  40159. }
  40160. for (i = 0; i < strLength; ++i) {
  40161. if (types[i] === 'ON') {
  40162. types[i] = e;
  40163. }
  40164. }
  40165. for (i = 0; i < strLength; ++i) {
  40166. t = types[i];
  40167. if (isEven(levels[i])) {
  40168. if (t === 'R') {
  40169. levels[i] += 1;
  40170. } else if (t === 'AN' || t === 'EN') {
  40171. levels[i] += 2;
  40172. }
  40173. } else {
  40174. if (t === 'L' || t === 'AN' || t === 'EN') {
  40175. levels[i] += 1;
  40176. }
  40177. }
  40178. }
  40179. var highestLevel = -1;
  40180. var lowestOddLevel = 99;
  40181. var level;
  40182. for (i = 0, ii = levels.length; i < ii; ++i) {
  40183. level = levels[i];
  40184. if (highestLevel < level) {
  40185. highestLevel = level;
  40186. }
  40187. if (lowestOddLevel > level && isOdd(level)) {
  40188. lowestOddLevel = level;
  40189. }
  40190. }
  40191. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40192. var start = -1;
  40193. for (i = 0, ii = levels.length; i < ii; ++i) {
  40194. if (levels[i] < level) {
  40195. if (start >= 0) {
  40196. reverseValues(chars, start, i);
  40197. start = -1;
  40198. }
  40199. } else if (start < 0) {
  40200. start = i;
  40201. }
  40202. }
  40203. if (start >= 0) {
  40204. reverseValues(chars, start, levels.length);
  40205. }
  40206. }
  40207. for (i = 0, ii = chars.length; i < ii; ++i) {
  40208. var ch = chars[i];
  40209. if (ch === '<' || ch === '>') {
  40210. chars[i] = '';
  40211. }
  40212. }
  40213. return createBidiText(chars.join(''), isLTR);
  40214. }
  40215. exports.bidi = bidi;
  40216. /***/ }),
  40217. /* 29 */
  40218. /***/ (function(module, exports, __w_pdfjs_require__) {
  40219. "use strict";
  40220. var ISOAdobeCharset = [
  40221. '.notdef',
  40222. 'space',
  40223. 'exclam',
  40224. 'quotedbl',
  40225. 'numbersign',
  40226. 'dollar',
  40227. 'percent',
  40228. 'ampersand',
  40229. 'quoteright',
  40230. 'parenleft',
  40231. 'parenright',
  40232. 'asterisk',
  40233. 'plus',
  40234. 'comma',
  40235. 'hyphen',
  40236. 'period',
  40237. 'slash',
  40238. 'zero',
  40239. 'one',
  40240. 'two',
  40241. 'three',
  40242. 'four',
  40243. 'five',
  40244. 'six',
  40245. 'seven',
  40246. 'eight',
  40247. 'nine',
  40248. 'colon',
  40249. 'semicolon',
  40250. 'less',
  40251. 'equal',
  40252. 'greater',
  40253. 'question',
  40254. 'at',
  40255. 'A',
  40256. 'B',
  40257. 'C',
  40258. 'D',
  40259. 'E',
  40260. 'F',
  40261. 'G',
  40262. 'H',
  40263. 'I',
  40264. 'J',
  40265. 'K',
  40266. 'L',
  40267. 'M',
  40268. 'N',
  40269. 'O',
  40270. 'P',
  40271. 'Q',
  40272. 'R',
  40273. 'S',
  40274. 'T',
  40275. 'U',
  40276. 'V',
  40277. 'W',
  40278. 'X',
  40279. 'Y',
  40280. 'Z',
  40281. 'bracketleft',
  40282. 'backslash',
  40283. 'bracketright',
  40284. 'asciicircum',
  40285. 'underscore',
  40286. 'quoteleft',
  40287. 'a',
  40288. 'b',
  40289. 'c',
  40290. 'd',
  40291. 'e',
  40292. 'f',
  40293. 'g',
  40294. 'h',
  40295. 'i',
  40296. 'j',
  40297. 'k',
  40298. 'l',
  40299. 'm',
  40300. 'n',
  40301. 'o',
  40302. 'p',
  40303. 'q',
  40304. 'r',
  40305. 's',
  40306. 't',
  40307. 'u',
  40308. 'v',
  40309. 'w',
  40310. 'x',
  40311. 'y',
  40312. 'z',
  40313. 'braceleft',
  40314. 'bar',
  40315. 'braceright',
  40316. 'asciitilde',
  40317. 'exclamdown',
  40318. 'cent',
  40319. 'sterling',
  40320. 'fraction',
  40321. 'yen',
  40322. 'florin',
  40323. 'section',
  40324. 'currency',
  40325. 'quotesingle',
  40326. 'quotedblleft',
  40327. 'guillemotleft',
  40328. 'guilsinglleft',
  40329. 'guilsinglright',
  40330. 'fi',
  40331. 'fl',
  40332. 'endash',
  40333. 'dagger',
  40334. 'daggerdbl',
  40335. 'periodcentered',
  40336. 'paragraph',
  40337. 'bullet',
  40338. 'quotesinglbase',
  40339. 'quotedblbase',
  40340. 'quotedblright',
  40341. 'guillemotright',
  40342. 'ellipsis',
  40343. 'perthousand',
  40344. 'questiondown',
  40345. 'grave',
  40346. 'acute',
  40347. 'circumflex',
  40348. 'tilde',
  40349. 'macron',
  40350. 'breve',
  40351. 'dotaccent',
  40352. 'dieresis',
  40353. 'ring',
  40354. 'cedilla',
  40355. 'hungarumlaut',
  40356. 'ogonek',
  40357. 'caron',
  40358. 'emdash',
  40359. 'AE',
  40360. 'ordfeminine',
  40361. 'Lslash',
  40362. 'Oslash',
  40363. 'OE',
  40364. 'ordmasculine',
  40365. 'ae',
  40366. 'dotlessi',
  40367. 'lslash',
  40368. 'oslash',
  40369. 'oe',
  40370. 'germandbls',
  40371. 'onesuperior',
  40372. 'logicalnot',
  40373. 'mu',
  40374. 'trademark',
  40375. 'Eth',
  40376. 'onehalf',
  40377. 'plusminus',
  40378. 'Thorn',
  40379. 'onequarter',
  40380. 'divide',
  40381. 'brokenbar',
  40382. 'degree',
  40383. 'thorn',
  40384. 'threequarters',
  40385. 'twosuperior',
  40386. 'registered',
  40387. 'minus',
  40388. 'eth',
  40389. 'multiply',
  40390. 'threesuperior',
  40391. 'copyright',
  40392. 'Aacute',
  40393. 'Acircumflex',
  40394. 'Adieresis',
  40395. 'Agrave',
  40396. 'Aring',
  40397. 'Atilde',
  40398. 'Ccedilla',
  40399. 'Eacute',
  40400. 'Ecircumflex',
  40401. 'Edieresis',
  40402. 'Egrave',
  40403. 'Iacute',
  40404. 'Icircumflex',
  40405. 'Idieresis',
  40406. 'Igrave',
  40407. 'Ntilde',
  40408. 'Oacute',
  40409. 'Ocircumflex',
  40410. 'Odieresis',
  40411. 'Ograve',
  40412. 'Otilde',
  40413. 'Scaron',
  40414. 'Uacute',
  40415. 'Ucircumflex',
  40416. 'Udieresis',
  40417. 'Ugrave',
  40418. 'Yacute',
  40419. 'Ydieresis',
  40420. 'Zcaron',
  40421. 'aacute',
  40422. 'acircumflex',
  40423. 'adieresis',
  40424. 'agrave',
  40425. 'aring',
  40426. 'atilde',
  40427. 'ccedilla',
  40428. 'eacute',
  40429. 'ecircumflex',
  40430. 'edieresis',
  40431. 'egrave',
  40432. 'iacute',
  40433. 'icircumflex',
  40434. 'idieresis',
  40435. 'igrave',
  40436. 'ntilde',
  40437. 'oacute',
  40438. 'ocircumflex',
  40439. 'odieresis',
  40440. 'ograve',
  40441. 'otilde',
  40442. 'scaron',
  40443. 'uacute',
  40444. 'ucircumflex',
  40445. 'udieresis',
  40446. 'ugrave',
  40447. 'yacute',
  40448. 'ydieresis',
  40449. 'zcaron'
  40450. ];
  40451. var ExpertCharset = [
  40452. '.notdef',
  40453. 'space',
  40454. 'exclamsmall',
  40455. 'Hungarumlautsmall',
  40456. 'dollaroldstyle',
  40457. 'dollarsuperior',
  40458. 'ampersandsmall',
  40459. 'Acutesmall',
  40460. 'parenleftsuperior',
  40461. 'parenrightsuperior',
  40462. 'twodotenleader',
  40463. 'onedotenleader',
  40464. 'comma',
  40465. 'hyphen',
  40466. 'period',
  40467. 'fraction',
  40468. 'zerooldstyle',
  40469. 'oneoldstyle',
  40470. 'twooldstyle',
  40471. 'threeoldstyle',
  40472. 'fouroldstyle',
  40473. 'fiveoldstyle',
  40474. 'sixoldstyle',
  40475. 'sevenoldstyle',
  40476. 'eightoldstyle',
  40477. 'nineoldstyle',
  40478. 'colon',
  40479. 'semicolon',
  40480. 'commasuperior',
  40481. 'threequartersemdash',
  40482. 'periodsuperior',
  40483. 'questionsmall',
  40484. 'asuperior',
  40485. 'bsuperior',
  40486. 'centsuperior',
  40487. 'dsuperior',
  40488. 'esuperior',
  40489. 'isuperior',
  40490. 'lsuperior',
  40491. 'msuperior',
  40492. 'nsuperior',
  40493. 'osuperior',
  40494. 'rsuperior',
  40495. 'ssuperior',
  40496. 'tsuperior',
  40497. 'ff',
  40498. 'fi',
  40499. 'fl',
  40500. 'ffi',
  40501. 'ffl',
  40502. 'parenleftinferior',
  40503. 'parenrightinferior',
  40504. 'Circumflexsmall',
  40505. 'hyphensuperior',
  40506. 'Gravesmall',
  40507. 'Asmall',
  40508. 'Bsmall',
  40509. 'Csmall',
  40510. 'Dsmall',
  40511. 'Esmall',
  40512. 'Fsmall',
  40513. 'Gsmall',
  40514. 'Hsmall',
  40515. 'Ismall',
  40516. 'Jsmall',
  40517. 'Ksmall',
  40518. 'Lsmall',
  40519. 'Msmall',
  40520. 'Nsmall',
  40521. 'Osmall',
  40522. 'Psmall',
  40523. 'Qsmall',
  40524. 'Rsmall',
  40525. 'Ssmall',
  40526. 'Tsmall',
  40527. 'Usmall',
  40528. 'Vsmall',
  40529. 'Wsmall',
  40530. 'Xsmall',
  40531. 'Ysmall',
  40532. 'Zsmall',
  40533. 'colonmonetary',
  40534. 'onefitted',
  40535. 'rupiah',
  40536. 'Tildesmall',
  40537. 'exclamdownsmall',
  40538. 'centoldstyle',
  40539. 'Lslashsmall',
  40540. 'Scaronsmall',
  40541. 'Zcaronsmall',
  40542. 'Dieresissmall',
  40543. 'Brevesmall',
  40544. 'Caronsmall',
  40545. 'Dotaccentsmall',
  40546. 'Macronsmall',
  40547. 'figuredash',
  40548. 'hypheninferior',
  40549. 'Ogoneksmall',
  40550. 'Ringsmall',
  40551. 'Cedillasmall',
  40552. 'onequarter',
  40553. 'onehalf',
  40554. 'threequarters',
  40555. 'questiondownsmall',
  40556. 'oneeighth',
  40557. 'threeeighths',
  40558. 'fiveeighths',
  40559. 'seveneighths',
  40560. 'onethird',
  40561. 'twothirds',
  40562. 'zerosuperior',
  40563. 'onesuperior',
  40564. 'twosuperior',
  40565. 'threesuperior',
  40566. 'foursuperior',
  40567. 'fivesuperior',
  40568. 'sixsuperior',
  40569. 'sevensuperior',
  40570. 'eightsuperior',
  40571. 'ninesuperior',
  40572. 'zeroinferior',
  40573. 'oneinferior',
  40574. 'twoinferior',
  40575. 'threeinferior',
  40576. 'fourinferior',
  40577. 'fiveinferior',
  40578. 'sixinferior',
  40579. 'seveninferior',
  40580. 'eightinferior',
  40581. 'nineinferior',
  40582. 'centinferior',
  40583. 'dollarinferior',
  40584. 'periodinferior',
  40585. 'commainferior',
  40586. 'Agravesmall',
  40587. 'Aacutesmall',
  40588. 'Acircumflexsmall',
  40589. 'Atildesmall',
  40590. 'Adieresissmall',
  40591. 'Aringsmall',
  40592. 'AEsmall',
  40593. 'Ccedillasmall',
  40594. 'Egravesmall',
  40595. 'Eacutesmall',
  40596. 'Ecircumflexsmall',
  40597. 'Edieresissmall',
  40598. 'Igravesmall',
  40599. 'Iacutesmall',
  40600. 'Icircumflexsmall',
  40601. 'Idieresissmall',
  40602. 'Ethsmall',
  40603. 'Ntildesmall',
  40604. 'Ogravesmall',
  40605. 'Oacutesmall',
  40606. 'Ocircumflexsmall',
  40607. 'Otildesmall',
  40608. 'Odieresissmall',
  40609. 'OEsmall',
  40610. 'Oslashsmall',
  40611. 'Ugravesmall',
  40612. 'Uacutesmall',
  40613. 'Ucircumflexsmall',
  40614. 'Udieresissmall',
  40615. 'Yacutesmall',
  40616. 'Thornsmall',
  40617. 'Ydieresissmall'
  40618. ];
  40619. var ExpertSubsetCharset = [
  40620. '.notdef',
  40621. 'space',
  40622. 'dollaroldstyle',
  40623. 'dollarsuperior',
  40624. 'parenleftsuperior',
  40625. 'parenrightsuperior',
  40626. 'twodotenleader',
  40627. 'onedotenleader',
  40628. 'comma',
  40629. 'hyphen',
  40630. 'period',
  40631. 'fraction',
  40632. 'zerooldstyle',
  40633. 'oneoldstyle',
  40634. 'twooldstyle',
  40635. 'threeoldstyle',
  40636. 'fouroldstyle',
  40637. 'fiveoldstyle',
  40638. 'sixoldstyle',
  40639. 'sevenoldstyle',
  40640. 'eightoldstyle',
  40641. 'nineoldstyle',
  40642. 'colon',
  40643. 'semicolon',
  40644. 'commasuperior',
  40645. 'threequartersemdash',
  40646. 'periodsuperior',
  40647. 'asuperior',
  40648. 'bsuperior',
  40649. 'centsuperior',
  40650. 'dsuperior',
  40651. 'esuperior',
  40652. 'isuperior',
  40653. 'lsuperior',
  40654. 'msuperior',
  40655. 'nsuperior',
  40656. 'osuperior',
  40657. 'rsuperior',
  40658. 'ssuperior',
  40659. 'tsuperior',
  40660. 'ff',
  40661. 'fi',
  40662. 'fl',
  40663. 'ffi',
  40664. 'ffl',
  40665. 'parenleftinferior',
  40666. 'parenrightinferior',
  40667. 'hyphensuperior',
  40668. 'colonmonetary',
  40669. 'onefitted',
  40670. 'rupiah',
  40671. 'centoldstyle',
  40672. 'figuredash',
  40673. 'hypheninferior',
  40674. 'onequarter',
  40675. 'onehalf',
  40676. 'threequarters',
  40677. 'oneeighth',
  40678. 'threeeighths',
  40679. 'fiveeighths',
  40680. 'seveneighths',
  40681. 'onethird',
  40682. 'twothirds',
  40683. 'zerosuperior',
  40684. 'onesuperior',
  40685. 'twosuperior',
  40686. 'threesuperior',
  40687. 'foursuperior',
  40688. 'fivesuperior',
  40689. 'sixsuperior',
  40690. 'sevensuperior',
  40691. 'eightsuperior',
  40692. 'ninesuperior',
  40693. 'zeroinferior',
  40694. 'oneinferior',
  40695. 'twoinferior',
  40696. 'threeinferior',
  40697. 'fourinferior',
  40698. 'fiveinferior',
  40699. 'sixinferior',
  40700. 'seveninferior',
  40701. 'eightinferior',
  40702. 'nineinferior',
  40703. 'centinferior',
  40704. 'dollarinferior',
  40705. 'periodinferior',
  40706. 'commainferior'
  40707. ];
  40708. exports.ISOAdobeCharset = ISOAdobeCharset;
  40709. exports.ExpertCharset = ExpertCharset;
  40710. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40711. /***/ }),
  40712. /* 30 */
  40713. /***/ (function(module, exports, __w_pdfjs_require__) {
  40714. "use strict";
  40715. var sharedUtil = __w_pdfjs_require__(0);
  40716. var corePrimitives = __w_pdfjs_require__(1);
  40717. var coreStream = __w_pdfjs_require__(2);
  40718. var coreParser = __w_pdfjs_require__(6);
  40719. var Util = sharedUtil.Util;
  40720. var assert = sharedUtil.assert;
  40721. var warn = sharedUtil.warn;
  40722. var error = sharedUtil.error;
  40723. var isInt = sharedUtil.isInt;
  40724. var isString = sharedUtil.isString;
  40725. var MissingDataException = sharedUtil.MissingDataException;
  40726. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40727. var isEOF = corePrimitives.isEOF;
  40728. var isName = corePrimitives.isName;
  40729. var isCmd = corePrimitives.isCmd;
  40730. var isStream = corePrimitives.isStream;
  40731. var Stream = coreStream.Stream;
  40732. var Lexer = coreParser.Lexer;
  40733. var BUILT_IN_CMAPS = [
  40734. 'Adobe-GB1-UCS2',
  40735. 'Adobe-CNS1-UCS2',
  40736. 'Adobe-Japan1-UCS2',
  40737. 'Adobe-Korea1-UCS2',
  40738. '78-EUC-H',
  40739. '78-EUC-V',
  40740. '78-H',
  40741. '78-RKSJ-H',
  40742. '78-RKSJ-V',
  40743. '78-V',
  40744. '78ms-RKSJ-H',
  40745. '78ms-RKSJ-V',
  40746. '83pv-RKSJ-H',
  40747. '90ms-RKSJ-H',
  40748. '90ms-RKSJ-V',
  40749. '90msp-RKSJ-H',
  40750. '90msp-RKSJ-V',
  40751. '90pv-RKSJ-H',
  40752. '90pv-RKSJ-V',
  40753. 'Add-H',
  40754. 'Add-RKSJ-H',
  40755. 'Add-RKSJ-V',
  40756. 'Add-V',
  40757. 'Adobe-CNS1-0',
  40758. 'Adobe-CNS1-1',
  40759. 'Adobe-CNS1-2',
  40760. 'Adobe-CNS1-3',
  40761. 'Adobe-CNS1-4',
  40762. 'Adobe-CNS1-5',
  40763. 'Adobe-CNS1-6',
  40764. 'Adobe-GB1-0',
  40765. 'Adobe-GB1-1',
  40766. 'Adobe-GB1-2',
  40767. 'Adobe-GB1-3',
  40768. 'Adobe-GB1-4',
  40769. 'Adobe-GB1-5',
  40770. 'Adobe-Japan1-0',
  40771. 'Adobe-Japan1-1',
  40772. 'Adobe-Japan1-2',
  40773. 'Adobe-Japan1-3',
  40774. 'Adobe-Japan1-4',
  40775. 'Adobe-Japan1-5',
  40776. 'Adobe-Japan1-6',
  40777. 'Adobe-Korea1-0',
  40778. 'Adobe-Korea1-1',
  40779. 'Adobe-Korea1-2',
  40780. 'B5-H',
  40781. 'B5-V',
  40782. 'B5pc-H',
  40783. 'B5pc-V',
  40784. 'CNS-EUC-H',
  40785. 'CNS-EUC-V',
  40786. 'CNS1-H',
  40787. 'CNS1-V',
  40788. 'CNS2-H',
  40789. 'CNS2-V',
  40790. 'ETHK-B5-H',
  40791. 'ETHK-B5-V',
  40792. 'ETen-B5-H',
  40793. 'ETen-B5-V',
  40794. 'ETenms-B5-H',
  40795. 'ETenms-B5-V',
  40796. 'EUC-H',
  40797. 'EUC-V',
  40798. 'Ext-H',
  40799. 'Ext-RKSJ-H',
  40800. 'Ext-RKSJ-V',
  40801. 'Ext-V',
  40802. 'GB-EUC-H',
  40803. 'GB-EUC-V',
  40804. 'GB-H',
  40805. 'GB-V',
  40806. 'GBK-EUC-H',
  40807. 'GBK-EUC-V',
  40808. 'GBK2K-H',
  40809. 'GBK2K-V',
  40810. 'GBKp-EUC-H',
  40811. 'GBKp-EUC-V',
  40812. 'GBT-EUC-H',
  40813. 'GBT-EUC-V',
  40814. 'GBT-H',
  40815. 'GBT-V',
  40816. 'GBTpc-EUC-H',
  40817. 'GBTpc-EUC-V',
  40818. 'GBpc-EUC-H',
  40819. 'GBpc-EUC-V',
  40820. 'H',
  40821. 'HKdla-B5-H',
  40822. 'HKdla-B5-V',
  40823. 'HKdlb-B5-H',
  40824. 'HKdlb-B5-V',
  40825. 'HKgccs-B5-H',
  40826. 'HKgccs-B5-V',
  40827. 'HKm314-B5-H',
  40828. 'HKm314-B5-V',
  40829. 'HKm471-B5-H',
  40830. 'HKm471-B5-V',
  40831. 'HKscs-B5-H',
  40832. 'HKscs-B5-V',
  40833. 'Hankaku',
  40834. 'Hiragana',
  40835. 'KSC-EUC-H',
  40836. 'KSC-EUC-V',
  40837. 'KSC-H',
  40838. 'KSC-Johab-H',
  40839. 'KSC-Johab-V',
  40840. 'KSC-V',
  40841. 'KSCms-UHC-H',
  40842. 'KSCms-UHC-HW-H',
  40843. 'KSCms-UHC-HW-V',
  40844. 'KSCms-UHC-V',
  40845. 'KSCpc-EUC-H',
  40846. 'KSCpc-EUC-V',
  40847. 'Katakana',
  40848. 'NWP-H',
  40849. 'NWP-V',
  40850. 'RKSJ-H',
  40851. 'RKSJ-V',
  40852. 'Roman',
  40853. 'UniCNS-UCS2-H',
  40854. 'UniCNS-UCS2-V',
  40855. 'UniCNS-UTF16-H',
  40856. 'UniCNS-UTF16-V',
  40857. 'UniCNS-UTF32-H',
  40858. 'UniCNS-UTF32-V',
  40859. 'UniCNS-UTF8-H',
  40860. 'UniCNS-UTF8-V',
  40861. 'UniGB-UCS2-H',
  40862. 'UniGB-UCS2-V',
  40863. 'UniGB-UTF16-H',
  40864. 'UniGB-UTF16-V',
  40865. 'UniGB-UTF32-H',
  40866. 'UniGB-UTF32-V',
  40867. 'UniGB-UTF8-H',
  40868. 'UniGB-UTF8-V',
  40869. 'UniJIS-UCS2-H',
  40870. 'UniJIS-UCS2-HW-H',
  40871. 'UniJIS-UCS2-HW-V',
  40872. 'UniJIS-UCS2-V',
  40873. 'UniJIS-UTF16-H',
  40874. 'UniJIS-UTF16-V',
  40875. 'UniJIS-UTF32-H',
  40876. 'UniJIS-UTF32-V',
  40877. 'UniJIS-UTF8-H',
  40878. 'UniJIS-UTF8-V',
  40879. 'UniJIS2004-UTF16-H',
  40880. 'UniJIS2004-UTF16-V',
  40881. 'UniJIS2004-UTF32-H',
  40882. 'UniJIS2004-UTF32-V',
  40883. 'UniJIS2004-UTF8-H',
  40884. 'UniJIS2004-UTF8-V',
  40885. 'UniJISPro-UCS2-HW-V',
  40886. 'UniJISPro-UCS2-V',
  40887. 'UniJISPro-UTF8-V',
  40888. 'UniJISX0213-UTF32-H',
  40889. 'UniJISX0213-UTF32-V',
  40890. 'UniJISX02132004-UTF32-H',
  40891. 'UniJISX02132004-UTF32-V',
  40892. 'UniKS-UCS2-H',
  40893. 'UniKS-UCS2-V',
  40894. 'UniKS-UTF16-H',
  40895. 'UniKS-UTF16-V',
  40896. 'UniKS-UTF32-H',
  40897. 'UniKS-UTF32-V',
  40898. 'UniKS-UTF8-H',
  40899. 'UniKS-UTF8-V',
  40900. 'V',
  40901. 'WP-Symbol'
  40902. ];
  40903. var CMap = function CMapClosure() {
  40904. function CMap(builtInCMap) {
  40905. this.codespaceRanges = [
  40906. [],
  40907. [],
  40908. [],
  40909. []
  40910. ];
  40911. this.numCodespaceRanges = 0;
  40912. this._map = [];
  40913. this.name = '';
  40914. this.vertical = false;
  40915. this.useCMap = null;
  40916. this.builtInCMap = builtInCMap;
  40917. }
  40918. CMap.prototype = {
  40919. addCodespaceRange: function (n, low, high) {
  40920. this.codespaceRanges[n - 1].push(low, high);
  40921. this.numCodespaceRanges++;
  40922. },
  40923. mapCidRange: function (low, high, dstLow) {
  40924. while (low <= high) {
  40925. this._map[low++] = dstLow++;
  40926. }
  40927. },
  40928. mapBfRange: function (low, high, dstLow) {
  40929. var lastByte = dstLow.length - 1;
  40930. while (low <= high) {
  40931. this._map[low++] = dstLow;
  40932. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40933. }
  40934. },
  40935. mapBfRangeToArray: function (low, high, array) {
  40936. var i = 0, ii = array.length;
  40937. while (low <= high && i < ii) {
  40938. this._map[low] = array[i++];
  40939. ++low;
  40940. }
  40941. },
  40942. mapOne: function (src, dst) {
  40943. this._map[src] = dst;
  40944. },
  40945. lookup: function (code) {
  40946. return this._map[code];
  40947. },
  40948. contains: function (code) {
  40949. return this._map[code] !== undefined;
  40950. },
  40951. forEach: function (callback) {
  40952. var map = this._map;
  40953. var length = map.length;
  40954. var i;
  40955. if (length <= 0x10000) {
  40956. for (i = 0; i < length; i++) {
  40957. if (map[i] !== undefined) {
  40958. callback(i, map[i]);
  40959. }
  40960. }
  40961. } else {
  40962. for (i in this._map) {
  40963. callback(i, map[i]);
  40964. }
  40965. }
  40966. },
  40967. charCodeOf: function (value) {
  40968. return this._map.indexOf(value);
  40969. },
  40970. getMap: function () {
  40971. return this._map;
  40972. },
  40973. readCharCode: function (str, offset, out) {
  40974. var c = 0;
  40975. var codespaceRanges = this.codespaceRanges;
  40976. var codespaceRangesLen = this.codespaceRanges.length;
  40977. for (var n = 0; n < codespaceRangesLen; n++) {
  40978. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  40979. var codespaceRange = codespaceRanges[n];
  40980. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  40981. var low = codespaceRange[k++];
  40982. var high = codespaceRange[k++];
  40983. if (c >= low && c <= high) {
  40984. out.charcode = c;
  40985. out.length = n + 1;
  40986. return;
  40987. }
  40988. }
  40989. }
  40990. out.charcode = 0;
  40991. out.length = 1;
  40992. },
  40993. get length() {
  40994. return this._map.length;
  40995. },
  40996. get isIdentityCMap() {
  40997. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  40998. return false;
  40999. }
  41000. if (this._map.length !== 0x10000) {
  41001. return false;
  41002. }
  41003. for (var i = 0; i < 0x10000; i++) {
  41004. if (this._map[i] !== i) {
  41005. return false;
  41006. }
  41007. }
  41008. return true;
  41009. }
  41010. };
  41011. return CMap;
  41012. }();
  41013. var IdentityCMap = function IdentityCMapClosure() {
  41014. function IdentityCMap(vertical, n) {
  41015. CMap.call(this);
  41016. this.vertical = vertical;
  41017. this.addCodespaceRange(n, 0, 0xffff);
  41018. }
  41019. Util.inherit(IdentityCMap, CMap, {});
  41020. IdentityCMap.prototype = {
  41021. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41022. mapCidRange: function (low, high, dstLow) {
  41023. error('should not call mapCidRange');
  41024. },
  41025. mapBfRange: function (low, high, dstLow) {
  41026. error('should not call mapBfRange');
  41027. },
  41028. mapBfRangeToArray: function (low, high, array) {
  41029. error('should not call mapBfRangeToArray');
  41030. },
  41031. mapOne: function (src, dst) {
  41032. error('should not call mapCidOne');
  41033. },
  41034. lookup: function (code) {
  41035. return isInt(code) && code <= 0xffff ? code : undefined;
  41036. },
  41037. contains: function (code) {
  41038. return isInt(code) && code <= 0xffff;
  41039. },
  41040. forEach: function (callback) {
  41041. for (var i = 0; i <= 0xffff; i++) {
  41042. callback(i, i);
  41043. }
  41044. },
  41045. charCodeOf: function (value) {
  41046. return isInt(value) && value <= 0xffff ? value : -1;
  41047. },
  41048. getMap: function () {
  41049. var map = new Array(0x10000);
  41050. for (var i = 0; i <= 0xffff; i++) {
  41051. map[i] = i;
  41052. }
  41053. return map;
  41054. },
  41055. readCharCode: CMap.prototype.readCharCode,
  41056. get length() {
  41057. return 0x10000;
  41058. },
  41059. get isIdentityCMap() {
  41060. error('should not access .isIdentityCMap');
  41061. }
  41062. };
  41063. return IdentityCMap;
  41064. }();
  41065. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41066. function hexToInt(a, size) {
  41067. var n = 0;
  41068. for (var i = 0; i <= size; i++) {
  41069. n = n << 8 | a[i];
  41070. }
  41071. return n >>> 0;
  41072. }
  41073. function hexToStr(a, size) {
  41074. if (size === 1) {
  41075. return String.fromCharCode(a[0], a[1]);
  41076. }
  41077. if (size === 3) {
  41078. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41079. }
  41080. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41081. }
  41082. function addHex(a, b, size) {
  41083. var c = 0;
  41084. for (var i = size; i >= 0; i--) {
  41085. c += a[i] + b[i];
  41086. a[i] = c & 255;
  41087. c >>= 8;
  41088. }
  41089. }
  41090. function incHex(a, size) {
  41091. var c = 1;
  41092. for (var i = size; i >= 0 && c > 0; i--) {
  41093. c += a[i];
  41094. a[i] = c & 255;
  41095. c >>= 8;
  41096. }
  41097. }
  41098. var MAX_NUM_SIZE = 16;
  41099. var MAX_ENCODED_NUM_SIZE = 19;
  41100. function BinaryCMapStream(data) {
  41101. this.buffer = data;
  41102. this.pos = 0;
  41103. this.end = data.length;
  41104. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41105. }
  41106. BinaryCMapStream.prototype = {
  41107. readByte: function () {
  41108. if (this.pos >= this.end) {
  41109. return -1;
  41110. }
  41111. return this.buffer[this.pos++];
  41112. },
  41113. readNumber: function () {
  41114. var n = 0;
  41115. var last;
  41116. do {
  41117. var b = this.readByte();
  41118. if (b < 0) {
  41119. error('unexpected EOF in bcmap');
  41120. }
  41121. last = !(b & 0x80);
  41122. n = n << 7 | b & 0x7F;
  41123. } while (!last);
  41124. return n;
  41125. },
  41126. readSigned: function () {
  41127. var n = this.readNumber();
  41128. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41129. },
  41130. readHex: function (num, size) {
  41131. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41132. this.pos += size + 1;
  41133. },
  41134. readHexNumber: function (num, size) {
  41135. var last;
  41136. var stack = this.tmpBuf, sp = 0;
  41137. do {
  41138. var b = this.readByte();
  41139. if (b < 0) {
  41140. error('unexpected EOF in bcmap');
  41141. }
  41142. last = !(b & 0x80);
  41143. stack[sp++] = b & 0x7F;
  41144. } while (!last);
  41145. var i = size, buffer = 0, bufferSize = 0;
  41146. while (i >= 0) {
  41147. while (bufferSize < 8 && stack.length > 0) {
  41148. buffer = stack[--sp] << bufferSize | buffer;
  41149. bufferSize += 7;
  41150. }
  41151. num[i] = buffer & 255;
  41152. i--;
  41153. buffer >>= 8;
  41154. bufferSize -= 8;
  41155. }
  41156. },
  41157. readHexSigned: function (num, size) {
  41158. this.readHexNumber(num, size);
  41159. var sign = num[size] & 1 ? 255 : 0;
  41160. var c = 0;
  41161. for (var i = 0; i <= size; i++) {
  41162. c = (c & 1) << 8 | num[i];
  41163. num[i] = c >> 1 ^ sign;
  41164. }
  41165. },
  41166. readString: function () {
  41167. var len = this.readNumber();
  41168. var s = '';
  41169. for (var i = 0; i < len; i++) {
  41170. s += String.fromCharCode(this.readNumber());
  41171. }
  41172. return s;
  41173. }
  41174. };
  41175. function processBinaryCMap(data, cMap, extend) {
  41176. return new Promise(function (resolve, reject) {
  41177. var stream = new BinaryCMapStream(data);
  41178. var header = stream.readByte();
  41179. cMap.vertical = !!(header & 1);
  41180. var useCMap = null;
  41181. var start = new Uint8Array(MAX_NUM_SIZE);
  41182. var end = new Uint8Array(MAX_NUM_SIZE);
  41183. var char = new Uint8Array(MAX_NUM_SIZE);
  41184. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41185. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41186. var code;
  41187. var b;
  41188. while ((b = stream.readByte()) >= 0) {
  41189. var type = b >> 5;
  41190. if (type === 7) {
  41191. switch (b & 0x1F) {
  41192. case 0:
  41193. stream.readString();
  41194. break;
  41195. case 1:
  41196. useCMap = stream.readString();
  41197. break;
  41198. }
  41199. continue;
  41200. }
  41201. var sequence = !!(b & 0x10);
  41202. var dataSize = b & 15;
  41203. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41204. var ucs2DataSize = 1;
  41205. var subitemsCount = stream.readNumber();
  41206. var i;
  41207. switch (type) {
  41208. case 0:
  41209. stream.readHex(start, dataSize);
  41210. stream.readHexNumber(end, dataSize);
  41211. addHex(end, start, dataSize);
  41212. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41213. for (i = 1; i < subitemsCount; i++) {
  41214. incHex(end, dataSize);
  41215. stream.readHexNumber(start, dataSize);
  41216. addHex(start, end, dataSize);
  41217. stream.readHexNumber(end, dataSize);
  41218. addHex(end, start, dataSize);
  41219. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41220. }
  41221. break;
  41222. case 1:
  41223. stream.readHex(start, dataSize);
  41224. stream.readHexNumber(end, dataSize);
  41225. addHex(end, start, dataSize);
  41226. code = stream.readNumber();
  41227. for (i = 1; i < subitemsCount; i++) {
  41228. incHex(end, dataSize);
  41229. stream.readHexNumber(start, dataSize);
  41230. addHex(start, end, dataSize);
  41231. stream.readHexNumber(end, dataSize);
  41232. addHex(end, start, dataSize);
  41233. code = stream.readNumber();
  41234. }
  41235. break;
  41236. case 2:
  41237. stream.readHex(char, dataSize);
  41238. code = stream.readNumber();
  41239. cMap.mapOne(hexToInt(char, dataSize), code);
  41240. for (i = 1; i < subitemsCount; i++) {
  41241. incHex(char, dataSize);
  41242. if (!sequence) {
  41243. stream.readHexNumber(tmp, dataSize);
  41244. addHex(char, tmp, dataSize);
  41245. }
  41246. code = stream.readSigned() + (code + 1);
  41247. cMap.mapOne(hexToInt(char, dataSize), code);
  41248. }
  41249. break;
  41250. case 3:
  41251. stream.readHex(start, dataSize);
  41252. stream.readHexNumber(end, dataSize);
  41253. addHex(end, start, dataSize);
  41254. code = stream.readNumber();
  41255. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41256. for (i = 1; i < subitemsCount; i++) {
  41257. incHex(end, dataSize);
  41258. if (!sequence) {
  41259. stream.readHexNumber(start, dataSize);
  41260. addHex(start, end, dataSize);
  41261. } else {
  41262. start.set(end);
  41263. }
  41264. stream.readHexNumber(end, dataSize);
  41265. addHex(end, start, dataSize);
  41266. code = stream.readNumber();
  41267. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41268. }
  41269. break;
  41270. case 4:
  41271. stream.readHex(char, ucs2DataSize);
  41272. stream.readHex(charCode, dataSize);
  41273. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41274. for (i = 1; i < subitemsCount; i++) {
  41275. incHex(char, ucs2DataSize);
  41276. if (!sequence) {
  41277. stream.readHexNumber(tmp, ucs2DataSize);
  41278. addHex(char, tmp, ucs2DataSize);
  41279. }
  41280. incHex(charCode, dataSize);
  41281. stream.readHexSigned(tmp, dataSize);
  41282. addHex(charCode, tmp, dataSize);
  41283. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41284. }
  41285. break;
  41286. case 5:
  41287. stream.readHex(start, ucs2DataSize);
  41288. stream.readHexNumber(end, ucs2DataSize);
  41289. addHex(end, start, ucs2DataSize);
  41290. stream.readHex(charCode, dataSize);
  41291. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41292. for (i = 1; i < subitemsCount; i++) {
  41293. incHex(end, ucs2DataSize);
  41294. if (!sequence) {
  41295. stream.readHexNumber(start, ucs2DataSize);
  41296. addHex(start, end, ucs2DataSize);
  41297. } else {
  41298. start.set(end);
  41299. }
  41300. stream.readHexNumber(end, ucs2DataSize);
  41301. addHex(end, start, ucs2DataSize);
  41302. stream.readHex(charCode, dataSize);
  41303. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41304. }
  41305. break;
  41306. default:
  41307. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41308. return;
  41309. }
  41310. }
  41311. if (useCMap) {
  41312. resolve(extend(useCMap));
  41313. return;
  41314. }
  41315. resolve(cMap);
  41316. });
  41317. }
  41318. function BinaryCMapReader() {
  41319. }
  41320. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41321. return BinaryCMapReader;
  41322. }();
  41323. var CMapFactory = function CMapFactoryClosure() {
  41324. function strToInt(str) {
  41325. var a = 0;
  41326. for (var i = 0; i < str.length; i++) {
  41327. a = a << 8 | str.charCodeAt(i);
  41328. }
  41329. return a >>> 0;
  41330. }
  41331. function expectString(obj) {
  41332. if (!isString(obj)) {
  41333. error('Malformed CMap: expected string.');
  41334. }
  41335. }
  41336. function expectInt(obj) {
  41337. if (!isInt(obj)) {
  41338. error('Malformed CMap: expected int.');
  41339. }
  41340. }
  41341. function parseBfChar(cMap, lexer) {
  41342. while (true) {
  41343. var obj = lexer.getObj();
  41344. if (isEOF(obj)) {
  41345. break;
  41346. }
  41347. if (isCmd(obj, 'endbfchar')) {
  41348. return;
  41349. }
  41350. expectString(obj);
  41351. var src = strToInt(obj);
  41352. obj = lexer.getObj();
  41353. expectString(obj);
  41354. var dst = obj;
  41355. cMap.mapOne(src, dst);
  41356. }
  41357. }
  41358. function parseBfRange(cMap, lexer) {
  41359. while (true) {
  41360. var obj = lexer.getObj();
  41361. if (isEOF(obj)) {
  41362. break;
  41363. }
  41364. if (isCmd(obj, 'endbfrange')) {
  41365. return;
  41366. }
  41367. expectString(obj);
  41368. var low = strToInt(obj);
  41369. obj = lexer.getObj();
  41370. expectString(obj);
  41371. var high = strToInt(obj);
  41372. obj = lexer.getObj();
  41373. if (isInt(obj) || isString(obj)) {
  41374. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41375. cMap.mapBfRange(low, high, dstLow);
  41376. } else if (isCmd(obj, '[')) {
  41377. obj = lexer.getObj();
  41378. var array = [];
  41379. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41380. array.push(obj);
  41381. obj = lexer.getObj();
  41382. }
  41383. cMap.mapBfRangeToArray(low, high, array);
  41384. } else {
  41385. break;
  41386. }
  41387. }
  41388. error('Invalid bf range.');
  41389. }
  41390. function parseCidChar(cMap, lexer) {
  41391. while (true) {
  41392. var obj = lexer.getObj();
  41393. if (isEOF(obj)) {
  41394. break;
  41395. }
  41396. if (isCmd(obj, 'endcidchar')) {
  41397. return;
  41398. }
  41399. expectString(obj);
  41400. var src = strToInt(obj);
  41401. obj = lexer.getObj();
  41402. expectInt(obj);
  41403. var dst = obj;
  41404. cMap.mapOne(src, dst);
  41405. }
  41406. }
  41407. function parseCidRange(cMap, lexer) {
  41408. while (true) {
  41409. var obj = lexer.getObj();
  41410. if (isEOF(obj)) {
  41411. break;
  41412. }
  41413. if (isCmd(obj, 'endcidrange')) {
  41414. return;
  41415. }
  41416. expectString(obj);
  41417. var low = strToInt(obj);
  41418. obj = lexer.getObj();
  41419. expectString(obj);
  41420. var high = strToInt(obj);
  41421. obj = lexer.getObj();
  41422. expectInt(obj);
  41423. var dstLow = obj;
  41424. cMap.mapCidRange(low, high, dstLow);
  41425. }
  41426. }
  41427. function parseCodespaceRange(cMap, lexer) {
  41428. while (true) {
  41429. var obj = lexer.getObj();
  41430. if (isEOF(obj)) {
  41431. break;
  41432. }
  41433. if (isCmd(obj, 'endcodespacerange')) {
  41434. return;
  41435. }
  41436. if (!isString(obj)) {
  41437. break;
  41438. }
  41439. var low = strToInt(obj);
  41440. obj = lexer.getObj();
  41441. if (!isString(obj)) {
  41442. break;
  41443. }
  41444. var high = strToInt(obj);
  41445. cMap.addCodespaceRange(obj.length, low, high);
  41446. }
  41447. error('Invalid codespace range.');
  41448. }
  41449. function parseWMode(cMap, lexer) {
  41450. var obj = lexer.getObj();
  41451. if (isInt(obj)) {
  41452. cMap.vertical = !!obj;
  41453. }
  41454. }
  41455. function parseCMapName(cMap, lexer) {
  41456. var obj = lexer.getObj();
  41457. if (isName(obj) && isString(obj.name)) {
  41458. cMap.name = obj.name;
  41459. }
  41460. }
  41461. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41462. var previous;
  41463. var embededUseCMap;
  41464. objLoop:
  41465. while (true) {
  41466. try {
  41467. var obj = lexer.getObj();
  41468. if (isEOF(obj)) {
  41469. break;
  41470. } else if (isName(obj)) {
  41471. if (obj.name === 'WMode') {
  41472. parseWMode(cMap, lexer);
  41473. } else if (obj.name === 'CMapName') {
  41474. parseCMapName(cMap, lexer);
  41475. }
  41476. previous = obj;
  41477. } else if (isCmd(obj)) {
  41478. switch (obj.cmd) {
  41479. case 'endcmap':
  41480. break objLoop;
  41481. case 'usecmap':
  41482. if (isName(previous)) {
  41483. embededUseCMap = previous.name;
  41484. }
  41485. break;
  41486. case 'begincodespacerange':
  41487. parseCodespaceRange(cMap, lexer);
  41488. break;
  41489. case 'beginbfchar':
  41490. parseBfChar(cMap, lexer);
  41491. break;
  41492. case 'begincidchar':
  41493. parseCidChar(cMap, lexer);
  41494. break;
  41495. case 'beginbfrange':
  41496. parseBfRange(cMap, lexer);
  41497. break;
  41498. case 'begincidrange':
  41499. parseCidRange(cMap, lexer);
  41500. break;
  41501. }
  41502. }
  41503. } catch (ex) {
  41504. if (ex instanceof MissingDataException) {
  41505. throw ex;
  41506. }
  41507. warn('Invalid cMap data: ' + ex);
  41508. continue;
  41509. }
  41510. }
  41511. if (!useCMap && embededUseCMap) {
  41512. useCMap = embededUseCMap;
  41513. }
  41514. if (useCMap) {
  41515. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41516. }
  41517. return Promise.resolve(cMap);
  41518. }
  41519. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41520. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41521. cMap.useCMap = newCMap;
  41522. if (cMap.numCodespaceRanges === 0) {
  41523. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41524. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41525. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41526. }
  41527. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41528. }
  41529. cMap.useCMap.forEach(function (key, value) {
  41530. if (!cMap.contains(key)) {
  41531. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41532. }
  41533. });
  41534. return cMap;
  41535. });
  41536. }
  41537. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41538. if (name === 'Identity-H') {
  41539. return Promise.resolve(new IdentityCMap(false, 2));
  41540. } else if (name === 'Identity-V') {
  41541. return Promise.resolve(new IdentityCMap(true, 2));
  41542. }
  41543. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41544. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41545. }
  41546. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41547. return fetchBuiltInCMap(name).then(function (data) {
  41548. var cMapData = data.cMapData, compressionType = data.compressionType;
  41549. var cMap = new CMap(true);
  41550. if (compressionType === CMapCompressionType.BINARY) {
  41551. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41552. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41553. });
  41554. }
  41555. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41556. var lexer = new Lexer(new Stream(cMapData));
  41557. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41558. });
  41559. }
  41560. return {
  41561. create: function (params) {
  41562. var encoding = params.encoding;
  41563. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41564. var useCMap = params.useCMap;
  41565. if (isName(encoding)) {
  41566. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41567. } else if (isStream(encoding)) {
  41568. var cMap = new CMap();
  41569. var lexer = new Lexer(encoding);
  41570. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41571. if (parsedCMap.isIdentityCMap) {
  41572. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41573. }
  41574. return parsedCMap;
  41575. });
  41576. }
  41577. return Promise.reject(new Error('Encoding required.'));
  41578. }
  41579. };
  41580. }();
  41581. exports.CMap = CMap;
  41582. exports.CMapFactory = CMapFactory;
  41583. exports.IdentityCMap = IdentityCMap;
  41584. /***/ }),
  41585. /* 31 */
  41586. /***/ (function(module, exports, __w_pdfjs_require__) {
  41587. "use strict";
  41588. var sharedUtil = __w_pdfjs_require__(0);
  41589. var corePrimitives = __w_pdfjs_require__(1);
  41590. var coreStream = __w_pdfjs_require__(2);
  41591. var coreObj = __w_pdfjs_require__(20);
  41592. var coreParser = __w_pdfjs_require__(6);
  41593. var coreCrypto = __w_pdfjs_require__(17);
  41594. var coreEvaluator = __w_pdfjs_require__(18);
  41595. var coreAnnotation = __w_pdfjs_require__(27);
  41596. var OPS = sharedUtil.OPS;
  41597. var MissingDataException = sharedUtil.MissingDataException;
  41598. var Util = sharedUtil.Util;
  41599. var assert = sharedUtil.assert;
  41600. var error = sharedUtil.error;
  41601. var info = sharedUtil.info;
  41602. var isArray = sharedUtil.isArray;
  41603. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41604. var isNum = sharedUtil.isNum;
  41605. var isString = sharedUtil.isString;
  41606. var shadow = sharedUtil.shadow;
  41607. var stringToBytes = sharedUtil.stringToBytes;
  41608. var stringToPDFString = sharedUtil.stringToPDFString;
  41609. var warn = sharedUtil.warn;
  41610. var isSpace = sharedUtil.isSpace;
  41611. var Dict = corePrimitives.Dict;
  41612. var isDict = corePrimitives.isDict;
  41613. var isName = corePrimitives.isName;
  41614. var isStream = corePrimitives.isStream;
  41615. var NullStream = coreStream.NullStream;
  41616. var Stream = coreStream.Stream;
  41617. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41618. var Catalog = coreObj.Catalog;
  41619. var ObjectLoader = coreObj.ObjectLoader;
  41620. var XRef = coreObj.XRef;
  41621. var Linearization = coreParser.Linearization;
  41622. var calculateMD5 = coreCrypto.calculateMD5;
  41623. var OperatorList = coreEvaluator.OperatorList;
  41624. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41625. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41626. var Page = function PageClosure() {
  41627. var DEFAULT_USER_UNIT = 1.0;
  41628. var LETTER_SIZE_MEDIABOX = [
  41629. 0,
  41630. 0,
  41631. 612,
  41632. 792
  41633. ];
  41634. function isAnnotationRenderable(annotation, intent) {
  41635. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  41636. }
  41637. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41638. this.pdfManager = pdfManager;
  41639. this.pageIndex = pageIndex;
  41640. this.pageDict = pageDict;
  41641. this.xref = xref;
  41642. this.ref = ref;
  41643. this.fontCache = fontCache;
  41644. this.builtInCMapCache = builtInCMapCache;
  41645. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41646. this.resourcesPromise = null;
  41647. var uniquePrefix = 'p' + this.pageIndex + '_';
  41648. var idCounters = { obj: 0 };
  41649. this.idFactory = {
  41650. createObjId: function () {
  41651. return uniquePrefix + ++idCounters.obj;
  41652. }
  41653. };
  41654. }
  41655. Page.prototype = {
  41656. getPageProp: function Page_getPageProp(key) {
  41657. return this.pageDict.get(key);
  41658. },
  41659. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41660. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41661. var MAX_LOOP_COUNT = 100;
  41662. getArray = getArray || false;
  41663. while (dict) {
  41664. var value = getArray ? dict.getArray(key) : dict.get(key);
  41665. if (value) {
  41666. if (!valueArray) {
  41667. valueArray = [];
  41668. }
  41669. valueArray.push(value);
  41670. }
  41671. if (++loopCount > MAX_LOOP_COUNT) {
  41672. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  41673. break;
  41674. }
  41675. dict = dict.get('Parent');
  41676. }
  41677. if (!valueArray) {
  41678. return Dict.empty;
  41679. }
  41680. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  41681. return valueArray[0];
  41682. }
  41683. return Dict.merge(this.xref, valueArray);
  41684. },
  41685. get content() {
  41686. return this.getPageProp('Contents');
  41687. },
  41688. get resources() {
  41689. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  41690. },
  41691. get mediaBox() {
  41692. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41693. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41694. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41695. }
  41696. return shadow(this, 'mediaBox', mediaBox);
  41697. },
  41698. get cropBox() {
  41699. var cropBox = this.getInheritedPageProp('CropBox', true);
  41700. if (!isArray(cropBox) || cropBox.length !== 4) {
  41701. return shadow(this, 'cropBox', this.mediaBox);
  41702. }
  41703. return shadow(this, 'cropBox', cropBox);
  41704. },
  41705. get userUnit() {
  41706. var obj = this.getPageProp('UserUnit');
  41707. if (!isNum(obj) || obj <= 0) {
  41708. obj = DEFAULT_USER_UNIT;
  41709. }
  41710. return shadow(this, 'userUnit', obj);
  41711. },
  41712. get view() {
  41713. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41714. if (mediaBox === cropBox) {
  41715. return shadow(this, 'view', mediaBox);
  41716. }
  41717. var intersection = Util.intersect(cropBox, mediaBox);
  41718. return shadow(this, 'view', intersection || mediaBox);
  41719. },
  41720. get rotate() {
  41721. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41722. if (rotate % 90 !== 0) {
  41723. rotate = 0;
  41724. } else if (rotate >= 360) {
  41725. rotate = rotate % 360;
  41726. } else if (rotate < 0) {
  41727. rotate = (rotate % 360 + 360) % 360;
  41728. }
  41729. return shadow(this, 'rotate', rotate);
  41730. },
  41731. getContentStream: function Page_getContentStream() {
  41732. var content = this.content;
  41733. var stream;
  41734. if (isArray(content)) {
  41735. var xref = this.xref;
  41736. var i, n = content.length;
  41737. var streams = [];
  41738. for (i = 0; i < n; ++i) {
  41739. streams.push(xref.fetchIfRef(content[i]));
  41740. }
  41741. stream = new StreamsSequenceStream(streams);
  41742. } else if (isStream(content)) {
  41743. stream = content;
  41744. } else {
  41745. stream = new NullStream();
  41746. }
  41747. return stream;
  41748. },
  41749. loadResources: function Page_loadResources(keys) {
  41750. if (!this.resourcesPromise) {
  41751. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41752. }
  41753. return this.resourcesPromise.then(function resourceSuccess() {
  41754. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41755. return objectLoader.load();
  41756. }.bind(this));
  41757. },
  41758. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41759. var self = this;
  41760. var pdfManager = this.pdfManager;
  41761. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41762. var resourcesPromise = this.loadResources([
  41763. 'ExtGState',
  41764. 'ColorSpace',
  41765. 'Pattern',
  41766. 'Shading',
  41767. 'XObject',
  41768. 'Font'
  41769. ]);
  41770. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41771. var dataPromises = Promise.all([
  41772. contentStreamPromise,
  41773. resourcesPromise
  41774. ]);
  41775. var pageListPromise = dataPromises.then(function (data) {
  41776. var contentStream = data[0];
  41777. var opList = new OperatorList(intent, handler, self.pageIndex);
  41778. handler.send('StartRenderPage', {
  41779. transparency: partialEvaluator.hasBlendModes(self.resources),
  41780. pageIndex: self.pageIndex,
  41781. intent: intent
  41782. });
  41783. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41784. return opList;
  41785. });
  41786. });
  41787. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41788. return Promise.all([
  41789. pageListPromise,
  41790. annotationsPromise
  41791. ]).then(function (datas) {
  41792. var pageOpList = datas[0];
  41793. var annotations = datas[1];
  41794. if (annotations.length === 0) {
  41795. pageOpList.flush(true);
  41796. return pageOpList;
  41797. }
  41798. var i, ii, opListPromises = [];
  41799. for (i = 0, ii = annotations.length; i < ii; i++) {
  41800. if (isAnnotationRenderable(annotations[i], intent)) {
  41801. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  41802. }
  41803. }
  41804. return Promise.all(opListPromises).then(function (opLists) {
  41805. pageOpList.addOp(OPS.beginAnnotations, []);
  41806. for (i = 0, ii = opLists.length; i < ii; i++) {
  41807. pageOpList.addOpList(opLists[i]);
  41808. }
  41809. pageOpList.addOp(OPS.endAnnotations, []);
  41810. pageOpList.flush(true);
  41811. return pageOpList;
  41812. });
  41813. });
  41814. },
  41815. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  41816. var handler = {
  41817. on: function nullHandlerOn() {
  41818. },
  41819. send: function nullHandlerSend() {
  41820. }
  41821. };
  41822. var self = this;
  41823. var pdfManager = this.pdfManager;
  41824. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41825. var resourcesPromise = this.loadResources([
  41826. 'ExtGState',
  41827. 'XObject',
  41828. 'Font'
  41829. ]);
  41830. var dataPromises = Promise.all([
  41831. contentStreamPromise,
  41832. resourcesPromise
  41833. ]);
  41834. return dataPromises.then(function (data) {
  41835. var contentStream = data[0];
  41836. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41837. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41838. });
  41839. },
  41840. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41841. var annotations = this.annotations;
  41842. var annotationsData = [];
  41843. for (var i = 0, n = annotations.length; i < n; ++i) {
  41844. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  41845. annotationsData.push(annotations[i].data);
  41846. }
  41847. }
  41848. return annotationsData;
  41849. },
  41850. get annotations() {
  41851. var annotations = [];
  41852. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41853. var annotationFactory = new AnnotationFactory();
  41854. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41855. var annotationRef = annotationRefs[i];
  41856. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41857. if (annotation) {
  41858. annotations.push(annotation);
  41859. }
  41860. }
  41861. return shadow(this, 'annotations', annotations);
  41862. }
  41863. };
  41864. return Page;
  41865. }();
  41866. var PDFDocument = function PDFDocumentClosure() {
  41867. var FINGERPRINT_FIRST_BYTES = 1024;
  41868. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41869. function PDFDocument(pdfManager, arg) {
  41870. var stream;
  41871. if (isStream(arg)) {
  41872. stream = arg;
  41873. } else if (isArrayBuffer(arg)) {
  41874. stream = new Stream(arg);
  41875. } else {
  41876. error('PDFDocument: Unknown argument type');
  41877. }
  41878. assert(stream.length > 0, 'stream must have data');
  41879. this.pdfManager = pdfManager;
  41880. this.stream = stream;
  41881. this.xref = new XRef(stream, pdfManager);
  41882. }
  41883. function find(stream, needle, limit, backwards) {
  41884. var pos = stream.pos;
  41885. var end = stream.end;
  41886. var strBuf = [];
  41887. if (pos + limit > end) {
  41888. limit = end - pos;
  41889. }
  41890. for (var n = 0; n < limit; ++n) {
  41891. strBuf.push(String.fromCharCode(stream.getByte()));
  41892. }
  41893. var str = strBuf.join('');
  41894. stream.pos = pos;
  41895. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41896. if (index === -1) {
  41897. return false;
  41898. }
  41899. stream.pos += index;
  41900. return true;
  41901. }
  41902. var DocumentInfoValidators = {
  41903. get entries() {
  41904. return shadow(this, 'entries', {
  41905. Title: isString,
  41906. Author: isString,
  41907. Subject: isString,
  41908. Keywords: isString,
  41909. Creator: isString,
  41910. Producer: isString,
  41911. CreationDate: isString,
  41912. ModDate: isString,
  41913. Trapped: isName
  41914. });
  41915. }
  41916. };
  41917. PDFDocument.prototype = {
  41918. parse: function PDFDocument_parse(recoveryMode) {
  41919. this.setup(recoveryMode);
  41920. var version = this.catalog.catDict.get('Version');
  41921. if (isName(version)) {
  41922. this.pdfFormatVersion = version.name;
  41923. }
  41924. try {
  41925. this.acroForm = this.catalog.catDict.get('AcroForm');
  41926. if (this.acroForm) {
  41927. this.xfa = this.acroForm.get('XFA');
  41928. var fields = this.acroForm.get('Fields');
  41929. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41930. this.acroForm = null;
  41931. }
  41932. }
  41933. } catch (ex) {
  41934. info('Something wrong with AcroForm entry');
  41935. this.acroForm = null;
  41936. }
  41937. },
  41938. get linearization() {
  41939. var linearization = null;
  41940. if (this.stream.length) {
  41941. try {
  41942. linearization = Linearization.create(this.stream);
  41943. } catch (err) {
  41944. if (err instanceof MissingDataException) {
  41945. throw err;
  41946. }
  41947. info(err);
  41948. }
  41949. }
  41950. return shadow(this, 'linearization', linearization);
  41951. },
  41952. get startXRef() {
  41953. var stream = this.stream;
  41954. var startXRef = 0;
  41955. var linearization = this.linearization;
  41956. if (linearization) {
  41957. stream.reset();
  41958. if (find(stream, 'endobj', 1024)) {
  41959. startXRef = stream.pos + 6;
  41960. }
  41961. } else {
  41962. var step = 1024;
  41963. var found = false, pos = stream.end;
  41964. while (!found && pos > 0) {
  41965. pos -= step - 'startxref'.length;
  41966. if (pos < 0) {
  41967. pos = 0;
  41968. }
  41969. stream.pos = pos;
  41970. found = find(stream, 'startxref', step, true);
  41971. }
  41972. if (found) {
  41973. stream.skip(9);
  41974. var ch;
  41975. do {
  41976. ch = stream.getByte();
  41977. } while (isSpace(ch));
  41978. var str = '';
  41979. while (ch >= 0x20 && ch <= 0x39) {
  41980. str += String.fromCharCode(ch);
  41981. ch = stream.getByte();
  41982. }
  41983. startXRef = parseInt(str, 10);
  41984. if (isNaN(startXRef)) {
  41985. startXRef = 0;
  41986. }
  41987. }
  41988. }
  41989. return shadow(this, 'startXRef', startXRef);
  41990. },
  41991. get mainXRefEntriesOffset() {
  41992. var mainXRefEntriesOffset = 0;
  41993. var linearization = this.linearization;
  41994. if (linearization) {
  41995. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  41996. }
  41997. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  41998. },
  41999. checkHeader: function PDFDocument_checkHeader() {
  42000. var stream = this.stream;
  42001. stream.reset();
  42002. if (find(stream, '%PDF-', 1024)) {
  42003. stream.moveStart();
  42004. var MAX_VERSION_LENGTH = 12;
  42005. var version = '', ch;
  42006. while ((ch = stream.getByte()) > 0x20) {
  42007. if (version.length >= MAX_VERSION_LENGTH) {
  42008. break;
  42009. }
  42010. version += String.fromCharCode(ch);
  42011. }
  42012. if (!this.pdfFormatVersion) {
  42013. this.pdfFormatVersion = version.substring(5);
  42014. }
  42015. return;
  42016. }
  42017. },
  42018. parseStartXRef: function PDFDocument_parseStartXRef() {
  42019. var startXRef = this.startXRef;
  42020. this.xref.setStartXRef(startXRef);
  42021. },
  42022. setup: function PDFDocument_setup(recoveryMode) {
  42023. this.xref.parse(recoveryMode);
  42024. var self = this;
  42025. var pageFactory = {
  42026. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42027. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42028. }
  42029. };
  42030. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42031. },
  42032. get numPages() {
  42033. var linearization = this.linearization;
  42034. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42035. return shadow(this, 'numPages', num);
  42036. },
  42037. get documentInfo() {
  42038. var docInfo = {
  42039. PDFFormatVersion: this.pdfFormatVersion,
  42040. IsAcroFormPresent: !!this.acroForm,
  42041. IsXFAPresent: !!this.xfa
  42042. };
  42043. var infoDict;
  42044. try {
  42045. infoDict = this.xref.trailer.get('Info');
  42046. } catch (err) {
  42047. info('The document information dictionary is invalid.');
  42048. }
  42049. if (infoDict) {
  42050. var validEntries = DocumentInfoValidators.entries;
  42051. for (var key in validEntries) {
  42052. if (infoDict.has(key)) {
  42053. var value = infoDict.get(key);
  42054. if (validEntries[key](value)) {
  42055. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42056. } else {
  42057. info('Bad value in document info for "' + key + '"');
  42058. }
  42059. }
  42060. }
  42061. }
  42062. return shadow(this, 'documentInfo', docInfo);
  42063. },
  42064. get fingerprint() {
  42065. var xref = this.xref, hash, fileID = '';
  42066. var idArray = xref.trailer.get('ID');
  42067. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42068. hash = stringToBytes(idArray[0]);
  42069. } else {
  42070. if (this.stream.ensureRange) {
  42071. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42072. }
  42073. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42074. }
  42075. for (var i = 0, n = hash.length; i < n; i++) {
  42076. var hex = hash[i].toString(16);
  42077. fileID += hex.length === 1 ? '0' + hex : hex;
  42078. }
  42079. return shadow(this, 'fingerprint', fileID);
  42080. },
  42081. getPage: function PDFDocument_getPage(pageIndex) {
  42082. return this.catalog.getPage(pageIndex);
  42083. },
  42084. cleanup: function PDFDocument_cleanup() {
  42085. return this.catalog.cleanup();
  42086. }
  42087. };
  42088. return PDFDocument;
  42089. }();
  42090. exports.Page = Page;
  42091. exports.PDFDocument = PDFDocument;
  42092. /***/ }),
  42093. /* 32 */
  42094. /***/ (function(module, exports, __w_pdfjs_require__) {
  42095. "use strict";
  42096. var sharedUtil = __w_pdfjs_require__(0);
  42097. var coreStream = __w_pdfjs_require__(2);
  42098. var coreGlyphList = __w_pdfjs_require__(8);
  42099. var coreEncodings = __w_pdfjs_require__(5);
  42100. var coreCFFParser = __w_pdfjs_require__(15);
  42101. var Util = sharedUtil.Util;
  42102. var bytesToString = sharedUtil.bytesToString;
  42103. var error = sharedUtil.error;
  42104. var Stream = coreStream.Stream;
  42105. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42106. var StandardEncoding = coreEncodings.StandardEncoding;
  42107. var CFFParser = coreCFFParser.CFFParser;
  42108. var FontRendererFactory = function FontRendererFactoryClosure() {
  42109. function getLong(data, offset) {
  42110. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42111. }
  42112. function getUshort(data, offset) {
  42113. return data[offset] << 8 | data[offset + 1];
  42114. }
  42115. function parseCmap(data, start, end) {
  42116. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42117. var format = getUshort(data, start + offset);
  42118. var ranges, p, i;
  42119. if (format === 4) {
  42120. getUshort(data, start + offset + 2);
  42121. var segCount = getUshort(data, start + offset + 6) >> 1;
  42122. p = start + offset + 14;
  42123. ranges = [];
  42124. for (i = 0; i < segCount; i++, p += 2) {
  42125. ranges[i] = { end: getUshort(data, p) };
  42126. }
  42127. p += 2;
  42128. for (i = 0; i < segCount; i++, p += 2) {
  42129. ranges[i].start = getUshort(data, p);
  42130. }
  42131. for (i = 0; i < segCount; i++, p += 2) {
  42132. ranges[i].idDelta = getUshort(data, p);
  42133. }
  42134. for (i = 0; i < segCount; i++, p += 2) {
  42135. var idOffset = getUshort(data, p);
  42136. if (idOffset === 0) {
  42137. continue;
  42138. }
  42139. ranges[i].ids = [];
  42140. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42141. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42142. idOffset += 2;
  42143. }
  42144. }
  42145. return ranges;
  42146. } else if (format === 12) {
  42147. getLong(data, start + offset + 4);
  42148. var groups = getLong(data, start + offset + 12);
  42149. p = start + offset + 16;
  42150. ranges = [];
  42151. for (i = 0; i < groups; i++) {
  42152. ranges.push({
  42153. start: getLong(data, p),
  42154. end: getLong(data, p + 4),
  42155. idDelta: getLong(data, p + 8) - getLong(data, p)
  42156. });
  42157. p += 12;
  42158. }
  42159. return ranges;
  42160. }
  42161. error('not supported cmap: ' + format);
  42162. }
  42163. function parseCff(data, start, end, seacAnalysisEnabled) {
  42164. var properties = {};
  42165. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42166. var cff = parser.parse();
  42167. return {
  42168. glyphs: cff.charStrings.objects,
  42169. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42170. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42171. };
  42172. }
  42173. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42174. var itemSize, itemDecode;
  42175. if (isGlyphLocationsLong) {
  42176. itemSize = 4;
  42177. itemDecode = function fontItemDecodeLong(data, offset) {
  42178. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42179. };
  42180. } else {
  42181. itemSize = 2;
  42182. itemDecode = function fontItemDecode(data, offset) {
  42183. return data[offset] << 9 | data[offset + 1] << 1;
  42184. };
  42185. }
  42186. var glyphs = [];
  42187. var startOffset = itemDecode(loca, 0);
  42188. for (var j = itemSize; j < loca.length; j += itemSize) {
  42189. var endOffset = itemDecode(loca, j);
  42190. glyphs.push(glyf.subarray(startOffset, endOffset));
  42191. startOffset = endOffset;
  42192. }
  42193. return glyphs;
  42194. }
  42195. function lookupCmap(ranges, unicode) {
  42196. var code = unicode.charCodeAt(0), gid = 0;
  42197. var l = 0, r = ranges.length - 1;
  42198. while (l < r) {
  42199. var c = l + r + 1 >> 1;
  42200. if (code < ranges[c].start) {
  42201. r = c - 1;
  42202. } else {
  42203. l = c;
  42204. }
  42205. }
  42206. if (ranges[l].start <= code && code <= ranges[l].end) {
  42207. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42208. }
  42209. return {
  42210. charCode: code,
  42211. glyphId: gid
  42212. };
  42213. }
  42214. function compileGlyf(code, cmds, font) {
  42215. function moveTo(x, y) {
  42216. cmds.push({
  42217. cmd: 'moveTo',
  42218. args: [
  42219. x,
  42220. y
  42221. ]
  42222. });
  42223. }
  42224. function lineTo(x, y) {
  42225. cmds.push({
  42226. cmd: 'lineTo',
  42227. args: [
  42228. x,
  42229. y
  42230. ]
  42231. });
  42232. }
  42233. function quadraticCurveTo(xa, ya, x, y) {
  42234. cmds.push({
  42235. cmd: 'quadraticCurveTo',
  42236. args: [
  42237. xa,
  42238. ya,
  42239. x,
  42240. y
  42241. ]
  42242. });
  42243. }
  42244. var i = 0;
  42245. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42246. var flags;
  42247. var x = 0, y = 0;
  42248. i += 10;
  42249. if (numberOfContours < 0) {
  42250. do {
  42251. flags = code[i] << 8 | code[i + 1];
  42252. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42253. i += 4;
  42254. var arg1, arg2;
  42255. if (flags & 0x01) {
  42256. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42257. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42258. i += 4;
  42259. } else {
  42260. arg1 = code[i++];
  42261. arg2 = code[i++];
  42262. }
  42263. if (flags & 0x02) {
  42264. x = arg1;
  42265. y = arg2;
  42266. } else {
  42267. x = 0;
  42268. y = 0;
  42269. }
  42270. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42271. if (flags & 0x08) {
  42272. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42273. i += 2;
  42274. } else if (flags & 0x40) {
  42275. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42276. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42277. i += 4;
  42278. } else if (flags & 0x80) {
  42279. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42280. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42281. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42282. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42283. i += 8;
  42284. }
  42285. var subglyph = font.glyphs[glyphIndex];
  42286. if (subglyph) {
  42287. cmds.push({ cmd: 'save' });
  42288. cmds.push({
  42289. cmd: 'transform',
  42290. args: [
  42291. scaleX,
  42292. scale01,
  42293. scale10,
  42294. scaleY,
  42295. x,
  42296. y
  42297. ]
  42298. });
  42299. compileGlyf(subglyph, cmds, font);
  42300. cmds.push({ cmd: 'restore' });
  42301. }
  42302. } while (flags & 0x20);
  42303. } else {
  42304. var endPtsOfContours = [];
  42305. var j, jj;
  42306. for (j = 0; j < numberOfContours; j++) {
  42307. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42308. i += 2;
  42309. }
  42310. var instructionLength = code[i] << 8 | code[i + 1];
  42311. i += 2 + instructionLength;
  42312. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42313. var points = [];
  42314. while (points.length < numberOfPoints) {
  42315. flags = code[i++];
  42316. var repeat = 1;
  42317. if (flags & 0x08) {
  42318. repeat += code[i++];
  42319. }
  42320. while (repeat-- > 0) {
  42321. points.push({ flags: flags });
  42322. }
  42323. }
  42324. for (j = 0; j < numberOfPoints; j++) {
  42325. switch (points[j].flags & 0x12) {
  42326. case 0x00:
  42327. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42328. i += 2;
  42329. break;
  42330. case 0x02:
  42331. x -= code[i++];
  42332. break;
  42333. case 0x12:
  42334. x += code[i++];
  42335. break;
  42336. }
  42337. points[j].x = x;
  42338. }
  42339. for (j = 0; j < numberOfPoints; j++) {
  42340. switch (points[j].flags & 0x24) {
  42341. case 0x00:
  42342. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42343. i += 2;
  42344. break;
  42345. case 0x04:
  42346. y -= code[i++];
  42347. break;
  42348. case 0x24:
  42349. y += code[i++];
  42350. break;
  42351. }
  42352. points[j].y = y;
  42353. }
  42354. var startPoint = 0;
  42355. for (i = 0; i < numberOfContours; i++) {
  42356. var endPoint = endPtsOfContours[i];
  42357. var contour = points.slice(startPoint, endPoint + 1);
  42358. if (contour[0].flags & 1) {
  42359. contour.push(contour[0]);
  42360. } else if (contour[contour.length - 1].flags & 1) {
  42361. contour.unshift(contour[contour.length - 1]);
  42362. } else {
  42363. var p = {
  42364. flags: 1,
  42365. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42366. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42367. };
  42368. contour.unshift(p);
  42369. contour.push(p);
  42370. }
  42371. moveTo(contour[0].x, contour[0].y);
  42372. for (j = 1, jj = contour.length; j < jj; j++) {
  42373. if (contour[j].flags & 1) {
  42374. lineTo(contour[j].x, contour[j].y);
  42375. } else if (contour[j + 1].flags & 1) {
  42376. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42377. j++;
  42378. } else {
  42379. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42380. }
  42381. }
  42382. startPoint = endPoint + 1;
  42383. }
  42384. }
  42385. }
  42386. function compileCharString(code, cmds, font) {
  42387. var stack = [];
  42388. var x = 0, y = 0;
  42389. var stems = 0;
  42390. function moveTo(x, y) {
  42391. cmds.push({
  42392. cmd: 'moveTo',
  42393. args: [
  42394. x,
  42395. y
  42396. ]
  42397. });
  42398. }
  42399. function lineTo(x, y) {
  42400. cmds.push({
  42401. cmd: 'lineTo',
  42402. args: [
  42403. x,
  42404. y
  42405. ]
  42406. });
  42407. }
  42408. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42409. cmds.push({
  42410. cmd: 'bezierCurveTo',
  42411. args: [
  42412. x1,
  42413. y1,
  42414. x2,
  42415. y2,
  42416. x,
  42417. y
  42418. ]
  42419. });
  42420. }
  42421. function parse(code) {
  42422. var i = 0;
  42423. while (i < code.length) {
  42424. var stackClean = false;
  42425. var v = code[i++];
  42426. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42427. switch (v) {
  42428. case 1:
  42429. stems += stack.length >> 1;
  42430. stackClean = true;
  42431. break;
  42432. case 3:
  42433. stems += stack.length >> 1;
  42434. stackClean = true;
  42435. break;
  42436. case 4:
  42437. y += stack.pop();
  42438. moveTo(x, y);
  42439. stackClean = true;
  42440. break;
  42441. case 5:
  42442. while (stack.length > 0) {
  42443. x += stack.shift();
  42444. y += stack.shift();
  42445. lineTo(x, y);
  42446. }
  42447. break;
  42448. case 6:
  42449. while (stack.length > 0) {
  42450. x += stack.shift();
  42451. lineTo(x, y);
  42452. if (stack.length === 0) {
  42453. break;
  42454. }
  42455. y += stack.shift();
  42456. lineTo(x, y);
  42457. }
  42458. break;
  42459. case 7:
  42460. while (stack.length > 0) {
  42461. y += stack.shift();
  42462. lineTo(x, y);
  42463. if (stack.length === 0) {
  42464. break;
  42465. }
  42466. x += stack.shift();
  42467. lineTo(x, y);
  42468. }
  42469. break;
  42470. case 8:
  42471. while (stack.length > 0) {
  42472. xa = x + stack.shift();
  42473. ya = y + stack.shift();
  42474. xb = xa + stack.shift();
  42475. yb = ya + stack.shift();
  42476. x = xb + stack.shift();
  42477. y = yb + stack.shift();
  42478. bezierCurveTo(xa, ya, xb, yb, x, y);
  42479. }
  42480. break;
  42481. case 10:
  42482. n = stack.pop() + font.subrsBias;
  42483. subrCode = font.subrs[n];
  42484. if (subrCode) {
  42485. parse(subrCode);
  42486. }
  42487. break;
  42488. case 11:
  42489. return;
  42490. case 12:
  42491. v = code[i++];
  42492. switch (v) {
  42493. case 34:
  42494. xa = x + stack.shift();
  42495. xb = xa + stack.shift();
  42496. y1 = y + stack.shift();
  42497. x = xb + stack.shift();
  42498. bezierCurveTo(xa, y, xb, y1, x, y1);
  42499. xa = x + stack.shift();
  42500. xb = xa + stack.shift();
  42501. x = xb + stack.shift();
  42502. bezierCurveTo(xa, y1, xb, y, x, y);
  42503. break;
  42504. case 35:
  42505. xa = x + stack.shift();
  42506. ya = y + stack.shift();
  42507. xb = xa + stack.shift();
  42508. yb = ya + stack.shift();
  42509. x = xb + stack.shift();
  42510. y = yb + stack.shift();
  42511. bezierCurveTo(xa, ya, xb, yb, x, y);
  42512. xa = x + stack.shift();
  42513. ya = y + stack.shift();
  42514. xb = xa + stack.shift();
  42515. yb = ya + stack.shift();
  42516. x = xb + stack.shift();
  42517. y = yb + stack.shift();
  42518. bezierCurveTo(xa, ya, xb, yb, x, y);
  42519. stack.pop();
  42520. break;
  42521. case 36:
  42522. xa = x + stack.shift();
  42523. y1 = y + stack.shift();
  42524. xb = xa + stack.shift();
  42525. y2 = y1 + stack.shift();
  42526. x = xb + stack.shift();
  42527. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42528. xa = x + stack.shift();
  42529. xb = xa + stack.shift();
  42530. y3 = y2 + stack.shift();
  42531. x = xb + stack.shift();
  42532. bezierCurveTo(xa, y2, xb, y3, x, y);
  42533. break;
  42534. case 37:
  42535. var x0 = x, y0 = y;
  42536. xa = x + stack.shift();
  42537. ya = y + stack.shift();
  42538. xb = xa + stack.shift();
  42539. yb = ya + stack.shift();
  42540. x = xb + stack.shift();
  42541. y = yb + stack.shift();
  42542. bezierCurveTo(xa, ya, xb, yb, x, y);
  42543. xa = x + stack.shift();
  42544. ya = y + stack.shift();
  42545. xb = xa + stack.shift();
  42546. yb = ya + stack.shift();
  42547. x = xb;
  42548. y = yb;
  42549. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42550. x += stack.shift();
  42551. } else {
  42552. y += stack.shift();
  42553. }
  42554. bezierCurveTo(xa, ya, xb, yb, x, y);
  42555. break;
  42556. default:
  42557. error('unknown operator: 12 ' + v);
  42558. }
  42559. break;
  42560. case 14:
  42561. if (stack.length >= 4) {
  42562. var achar = stack.pop();
  42563. var bchar = stack.pop();
  42564. y = stack.pop();
  42565. x = stack.pop();
  42566. cmds.push({ cmd: 'save' });
  42567. cmds.push({
  42568. cmd: 'translate',
  42569. args: [
  42570. x,
  42571. y
  42572. ]
  42573. });
  42574. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42575. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42576. cmds.push({ cmd: 'restore' });
  42577. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42578. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42579. }
  42580. return;
  42581. case 18:
  42582. stems += stack.length >> 1;
  42583. stackClean = true;
  42584. break;
  42585. case 19:
  42586. stems += stack.length >> 1;
  42587. i += stems + 7 >> 3;
  42588. stackClean = true;
  42589. break;
  42590. case 20:
  42591. stems += stack.length >> 1;
  42592. i += stems + 7 >> 3;
  42593. stackClean = true;
  42594. break;
  42595. case 21:
  42596. y += stack.pop();
  42597. x += stack.pop();
  42598. moveTo(x, y);
  42599. stackClean = true;
  42600. break;
  42601. case 22:
  42602. x += stack.pop();
  42603. moveTo(x, y);
  42604. stackClean = true;
  42605. break;
  42606. case 23:
  42607. stems += stack.length >> 1;
  42608. stackClean = true;
  42609. break;
  42610. case 24:
  42611. while (stack.length > 2) {
  42612. xa = x + stack.shift();
  42613. ya = y + stack.shift();
  42614. xb = xa + stack.shift();
  42615. yb = ya + stack.shift();
  42616. x = xb + stack.shift();
  42617. y = yb + stack.shift();
  42618. bezierCurveTo(xa, ya, xb, yb, x, y);
  42619. }
  42620. x += stack.shift();
  42621. y += stack.shift();
  42622. lineTo(x, y);
  42623. break;
  42624. case 25:
  42625. while (stack.length > 6) {
  42626. x += stack.shift();
  42627. y += stack.shift();
  42628. lineTo(x, y);
  42629. }
  42630. xa = x + stack.shift();
  42631. ya = y + stack.shift();
  42632. xb = xa + stack.shift();
  42633. yb = ya + stack.shift();
  42634. x = xb + stack.shift();
  42635. y = yb + stack.shift();
  42636. bezierCurveTo(xa, ya, xb, yb, x, y);
  42637. break;
  42638. case 26:
  42639. if (stack.length % 2) {
  42640. x += stack.shift();
  42641. }
  42642. while (stack.length > 0) {
  42643. xa = x;
  42644. ya = y + stack.shift();
  42645. xb = xa + stack.shift();
  42646. yb = ya + stack.shift();
  42647. x = xb;
  42648. y = yb + stack.shift();
  42649. bezierCurveTo(xa, ya, xb, yb, x, y);
  42650. }
  42651. break;
  42652. case 27:
  42653. if (stack.length % 2) {
  42654. y += stack.shift();
  42655. }
  42656. while (stack.length > 0) {
  42657. xa = x + stack.shift();
  42658. ya = y;
  42659. xb = xa + stack.shift();
  42660. yb = ya + stack.shift();
  42661. x = xb + stack.shift();
  42662. y = yb;
  42663. bezierCurveTo(xa, ya, xb, yb, x, y);
  42664. }
  42665. break;
  42666. case 28:
  42667. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42668. i += 2;
  42669. break;
  42670. case 29:
  42671. n = stack.pop() + font.gsubrsBias;
  42672. subrCode = font.gsubrs[n];
  42673. if (subrCode) {
  42674. parse(subrCode);
  42675. }
  42676. break;
  42677. case 30:
  42678. while (stack.length > 0) {
  42679. xa = x;
  42680. ya = y + stack.shift();
  42681. xb = xa + stack.shift();
  42682. yb = ya + stack.shift();
  42683. x = xb + stack.shift();
  42684. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42685. bezierCurveTo(xa, ya, xb, yb, x, y);
  42686. if (stack.length === 0) {
  42687. break;
  42688. }
  42689. xa = x + stack.shift();
  42690. ya = y;
  42691. xb = xa + stack.shift();
  42692. yb = ya + stack.shift();
  42693. y = yb + stack.shift();
  42694. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42695. bezierCurveTo(xa, ya, xb, yb, x, y);
  42696. }
  42697. break;
  42698. case 31:
  42699. while (stack.length > 0) {
  42700. xa = x + stack.shift();
  42701. ya = y;
  42702. xb = xa + stack.shift();
  42703. yb = ya + stack.shift();
  42704. y = yb + stack.shift();
  42705. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42706. bezierCurveTo(xa, ya, xb, yb, x, y);
  42707. if (stack.length === 0) {
  42708. break;
  42709. }
  42710. xa = x;
  42711. ya = y + stack.shift();
  42712. xb = xa + stack.shift();
  42713. yb = ya + stack.shift();
  42714. x = xb + stack.shift();
  42715. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42716. bezierCurveTo(xa, ya, xb, yb, x, y);
  42717. }
  42718. break;
  42719. default:
  42720. if (v < 32) {
  42721. error('unknown operator: ' + v);
  42722. }
  42723. if (v < 247) {
  42724. stack.push(v - 139);
  42725. } else if (v < 251) {
  42726. stack.push((v - 247) * 256 + code[i++] + 108);
  42727. } else if (v < 255) {
  42728. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42729. } else {
  42730. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42731. i += 4;
  42732. }
  42733. break;
  42734. }
  42735. if (stackClean) {
  42736. stack.length = 0;
  42737. }
  42738. }
  42739. }
  42740. parse(code);
  42741. }
  42742. var noop = '';
  42743. function CompiledFont(fontMatrix) {
  42744. this.compiledGlyphs = Object.create(null);
  42745. this.compiledCharCodeToGlyphId = Object.create(null);
  42746. this.fontMatrix = fontMatrix;
  42747. }
  42748. CompiledFont.prototype = {
  42749. getPathJs: function (unicode) {
  42750. var cmap = lookupCmap(this.cmap, unicode);
  42751. var fn = this.compiledGlyphs[cmap.glyphId];
  42752. if (!fn) {
  42753. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42754. this.compiledGlyphs[cmap.glyphId] = fn;
  42755. }
  42756. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42757. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42758. }
  42759. return fn;
  42760. },
  42761. compileGlyph: function (code) {
  42762. if (!code || code.length === 0 || code[0] === 14) {
  42763. return noop;
  42764. }
  42765. var cmds = [];
  42766. cmds.push({ cmd: 'save' });
  42767. cmds.push({
  42768. cmd: 'transform',
  42769. args: this.fontMatrix.slice()
  42770. });
  42771. cmds.push({
  42772. cmd: 'scale',
  42773. args: [
  42774. 'size',
  42775. '-size'
  42776. ]
  42777. });
  42778. this.compileGlyphImpl(code, cmds);
  42779. cmds.push({ cmd: 'restore' });
  42780. return cmds;
  42781. },
  42782. compileGlyphImpl: function () {
  42783. error('Children classes should implement this.');
  42784. },
  42785. hasBuiltPath: function (unicode) {
  42786. var cmap = lookupCmap(this.cmap, unicode);
  42787. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42788. }
  42789. };
  42790. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42791. fontMatrix = fontMatrix || [
  42792. 0.000488,
  42793. 0,
  42794. 0,
  42795. 0.000488,
  42796. 0,
  42797. 0
  42798. ];
  42799. CompiledFont.call(this, fontMatrix);
  42800. this.glyphs = glyphs;
  42801. this.cmap = cmap;
  42802. }
  42803. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42804. compileGlyphImpl: function (code, cmds) {
  42805. compileGlyf(code, cmds, this);
  42806. }
  42807. });
  42808. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42809. fontMatrix = fontMatrix || [
  42810. 0.001,
  42811. 0,
  42812. 0,
  42813. 0.001,
  42814. 0,
  42815. 0
  42816. ];
  42817. CompiledFont.call(this, fontMatrix);
  42818. this.glyphs = cffInfo.glyphs;
  42819. this.gsubrs = cffInfo.gsubrs || [];
  42820. this.subrs = cffInfo.subrs || [];
  42821. this.cmap = cmap;
  42822. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42823. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42824. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42825. }
  42826. Util.inherit(Type2Compiled, CompiledFont, {
  42827. compileGlyphImpl: function (code, cmds) {
  42828. compileCharString(code, cmds, this);
  42829. }
  42830. });
  42831. return {
  42832. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42833. var data = new Uint8Array(font.data);
  42834. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42835. var numTables = getUshort(data, 4);
  42836. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42837. var tag = bytesToString(data.subarray(p, p + 4));
  42838. var offset = getLong(data, p + 8);
  42839. var length = getLong(data, p + 12);
  42840. switch (tag) {
  42841. case 'cmap':
  42842. cmap = parseCmap(data, offset, offset + length);
  42843. break;
  42844. case 'glyf':
  42845. glyf = data.subarray(offset, offset + length);
  42846. break;
  42847. case 'loca':
  42848. loca = data.subarray(offset, offset + length);
  42849. break;
  42850. case 'head':
  42851. unitsPerEm = getUshort(data, offset + 18);
  42852. indexToLocFormat = getUshort(data, offset + 50);
  42853. break;
  42854. case 'CFF ':
  42855. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42856. break;
  42857. }
  42858. }
  42859. if (glyf) {
  42860. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42861. 1 / unitsPerEm,
  42862. 0,
  42863. 0,
  42864. 1 / unitsPerEm,
  42865. 0,
  42866. 0
  42867. ];
  42868. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42869. }
  42870. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42871. }
  42872. };
  42873. }();
  42874. exports.FontRendererFactory = FontRendererFactory;
  42875. /***/ }),
  42876. /* 33 */
  42877. /***/ (function(module, exports, __w_pdfjs_require__) {
  42878. "use strict";
  42879. var sharedUtil = __w_pdfjs_require__(0);
  42880. var corePrimitives = __w_pdfjs_require__(1);
  42881. var coreStream = __w_pdfjs_require__(2);
  42882. var coreGlyphList = __w_pdfjs_require__(8);
  42883. var coreFontRenderer = __w_pdfjs_require__(32);
  42884. var coreEncodings = __w_pdfjs_require__(5);
  42885. var coreStandardFonts = __w_pdfjs_require__(21);
  42886. var coreUnicode = __w_pdfjs_require__(22);
  42887. var coreType1Parser = __w_pdfjs_require__(43);
  42888. var coreCFFParser = __w_pdfjs_require__(15);
  42889. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42890. var FontType = sharedUtil.FontType;
  42891. var assert = sharedUtil.assert;
  42892. var bytesToString = sharedUtil.bytesToString;
  42893. var error = sharedUtil.error;
  42894. var info = sharedUtil.info;
  42895. var isArray = sharedUtil.isArray;
  42896. var isInt = sharedUtil.isInt;
  42897. var isNum = sharedUtil.isNum;
  42898. var readUint32 = sharedUtil.readUint32;
  42899. var shadow = sharedUtil.shadow;
  42900. var string32 = sharedUtil.string32;
  42901. var warn = sharedUtil.warn;
  42902. var MissingDataException = sharedUtil.MissingDataException;
  42903. var isSpace = sharedUtil.isSpace;
  42904. var Stream = coreStream.Stream;
  42905. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42906. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42907. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42908. var StandardEncoding = coreEncodings.StandardEncoding;
  42909. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42910. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42911. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42912. var getEncoding = coreEncodings.getEncoding;
  42913. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42914. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42915. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42916. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42917. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42918. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42919. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42920. var Type1Parser = coreType1Parser.Type1Parser;
  42921. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42922. var CFFParser = coreCFFParser.CFFParser;
  42923. var CFFCompiler = coreCFFParser.CFFCompiler;
  42924. var CFF = coreCFFParser.CFF;
  42925. var CFFHeader = coreCFFParser.CFFHeader;
  42926. var CFFTopDict = coreCFFParser.CFFTopDict;
  42927. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42928. var CFFStrings = coreCFFParser.CFFStrings;
  42929. var CFFIndex = coreCFFParser.CFFIndex;
  42930. var CFFCharset = coreCFFParser.CFFCharset;
  42931. var PRIVATE_USE_OFFSET_START = 0xE000;
  42932. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42933. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42934. var PDF_GLYPH_SPACE_UNITS = 1000;
  42935. var SEAC_ANALYSIS_ENABLED = false;
  42936. var FontFlags = {
  42937. FixedPitch: 1,
  42938. Serif: 2,
  42939. Symbolic: 4,
  42940. Script: 8,
  42941. Nonsymbolic: 32,
  42942. Italic: 64,
  42943. AllCap: 65536,
  42944. SmallCap: 131072,
  42945. ForceBold: 262144
  42946. };
  42947. var MacStandardGlyphOrdering = [
  42948. '.notdef',
  42949. '.null',
  42950. 'nonmarkingreturn',
  42951. 'space',
  42952. 'exclam',
  42953. 'quotedbl',
  42954. 'numbersign',
  42955. 'dollar',
  42956. 'percent',
  42957. 'ampersand',
  42958. 'quotesingle',
  42959. 'parenleft',
  42960. 'parenright',
  42961. 'asterisk',
  42962. 'plus',
  42963. 'comma',
  42964. 'hyphen',
  42965. 'period',
  42966. 'slash',
  42967. 'zero',
  42968. 'one',
  42969. 'two',
  42970. 'three',
  42971. 'four',
  42972. 'five',
  42973. 'six',
  42974. 'seven',
  42975. 'eight',
  42976. 'nine',
  42977. 'colon',
  42978. 'semicolon',
  42979. 'less',
  42980. 'equal',
  42981. 'greater',
  42982. 'question',
  42983. 'at',
  42984. 'A',
  42985. 'B',
  42986. 'C',
  42987. 'D',
  42988. 'E',
  42989. 'F',
  42990. 'G',
  42991. 'H',
  42992. 'I',
  42993. 'J',
  42994. 'K',
  42995. 'L',
  42996. 'M',
  42997. 'N',
  42998. 'O',
  42999. 'P',
  43000. 'Q',
  43001. 'R',
  43002. 'S',
  43003. 'T',
  43004. 'U',
  43005. 'V',
  43006. 'W',
  43007. 'X',
  43008. 'Y',
  43009. 'Z',
  43010. 'bracketleft',
  43011. 'backslash',
  43012. 'bracketright',
  43013. 'asciicircum',
  43014. 'underscore',
  43015. 'grave',
  43016. 'a',
  43017. 'b',
  43018. 'c',
  43019. 'd',
  43020. 'e',
  43021. 'f',
  43022. 'g',
  43023. 'h',
  43024. 'i',
  43025. 'j',
  43026. 'k',
  43027. 'l',
  43028. 'm',
  43029. 'n',
  43030. 'o',
  43031. 'p',
  43032. 'q',
  43033. 'r',
  43034. 's',
  43035. 't',
  43036. 'u',
  43037. 'v',
  43038. 'w',
  43039. 'x',
  43040. 'y',
  43041. 'z',
  43042. 'braceleft',
  43043. 'bar',
  43044. 'braceright',
  43045. 'asciitilde',
  43046. 'Adieresis',
  43047. 'Aring',
  43048. 'Ccedilla',
  43049. 'Eacute',
  43050. 'Ntilde',
  43051. 'Odieresis',
  43052. 'Udieresis',
  43053. 'aacute',
  43054. 'agrave',
  43055. 'acircumflex',
  43056. 'adieresis',
  43057. 'atilde',
  43058. 'aring',
  43059. 'ccedilla',
  43060. 'eacute',
  43061. 'egrave',
  43062. 'ecircumflex',
  43063. 'edieresis',
  43064. 'iacute',
  43065. 'igrave',
  43066. 'icircumflex',
  43067. 'idieresis',
  43068. 'ntilde',
  43069. 'oacute',
  43070. 'ograve',
  43071. 'ocircumflex',
  43072. 'odieresis',
  43073. 'otilde',
  43074. 'uacute',
  43075. 'ugrave',
  43076. 'ucircumflex',
  43077. 'udieresis',
  43078. 'dagger',
  43079. 'degree',
  43080. 'cent',
  43081. 'sterling',
  43082. 'section',
  43083. 'bullet',
  43084. 'paragraph',
  43085. 'germandbls',
  43086. 'registered',
  43087. 'copyright',
  43088. 'trademark',
  43089. 'acute',
  43090. 'dieresis',
  43091. 'notequal',
  43092. 'AE',
  43093. 'Oslash',
  43094. 'infinity',
  43095. 'plusminus',
  43096. 'lessequal',
  43097. 'greaterequal',
  43098. 'yen',
  43099. 'mu',
  43100. 'partialdiff',
  43101. 'summation',
  43102. 'product',
  43103. 'pi',
  43104. 'integral',
  43105. 'ordfeminine',
  43106. 'ordmasculine',
  43107. 'Omega',
  43108. 'ae',
  43109. 'oslash',
  43110. 'questiondown',
  43111. 'exclamdown',
  43112. 'logicalnot',
  43113. 'radical',
  43114. 'florin',
  43115. 'approxequal',
  43116. 'Delta',
  43117. 'guillemotleft',
  43118. 'guillemotright',
  43119. 'ellipsis',
  43120. 'nonbreakingspace',
  43121. 'Agrave',
  43122. 'Atilde',
  43123. 'Otilde',
  43124. 'OE',
  43125. 'oe',
  43126. 'endash',
  43127. 'emdash',
  43128. 'quotedblleft',
  43129. 'quotedblright',
  43130. 'quoteleft',
  43131. 'quoteright',
  43132. 'divide',
  43133. 'lozenge',
  43134. 'ydieresis',
  43135. 'Ydieresis',
  43136. 'fraction',
  43137. 'currency',
  43138. 'guilsinglleft',
  43139. 'guilsinglright',
  43140. 'fi',
  43141. 'fl',
  43142. 'daggerdbl',
  43143. 'periodcentered',
  43144. 'quotesinglbase',
  43145. 'quotedblbase',
  43146. 'perthousand',
  43147. 'Acircumflex',
  43148. 'Ecircumflex',
  43149. 'Aacute',
  43150. 'Edieresis',
  43151. 'Egrave',
  43152. 'Iacute',
  43153. 'Icircumflex',
  43154. 'Idieresis',
  43155. 'Igrave',
  43156. 'Oacute',
  43157. 'Ocircumflex',
  43158. 'apple',
  43159. 'Ograve',
  43160. 'Uacute',
  43161. 'Ucircumflex',
  43162. 'Ugrave',
  43163. 'dotlessi',
  43164. 'circumflex',
  43165. 'tilde',
  43166. 'macron',
  43167. 'breve',
  43168. 'dotaccent',
  43169. 'ring',
  43170. 'cedilla',
  43171. 'hungarumlaut',
  43172. 'ogonek',
  43173. 'caron',
  43174. 'Lslash',
  43175. 'lslash',
  43176. 'Scaron',
  43177. 'scaron',
  43178. 'Zcaron',
  43179. 'zcaron',
  43180. 'brokenbar',
  43181. 'Eth',
  43182. 'eth',
  43183. 'Yacute',
  43184. 'yacute',
  43185. 'Thorn',
  43186. 'thorn',
  43187. 'minus',
  43188. 'multiply',
  43189. 'onesuperior',
  43190. 'twosuperior',
  43191. 'threesuperior',
  43192. 'onehalf',
  43193. 'onequarter',
  43194. 'threequarters',
  43195. 'franc',
  43196. 'Gbreve',
  43197. 'gbreve',
  43198. 'Idotaccent',
  43199. 'Scedilla',
  43200. 'scedilla',
  43201. 'Cacute',
  43202. 'cacute',
  43203. 'Ccaron',
  43204. 'ccaron',
  43205. 'dcroat'
  43206. ];
  43207. function adjustWidths(properties) {
  43208. if (!properties.fontMatrix) {
  43209. return;
  43210. }
  43211. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43212. return;
  43213. }
  43214. var scale = 0.001 / properties.fontMatrix[0];
  43215. var glyphsWidths = properties.widths;
  43216. for (var glyph in glyphsWidths) {
  43217. glyphsWidths[glyph] *= scale;
  43218. }
  43219. properties.defaultWidth *= scale;
  43220. }
  43221. function adjustToUnicode(properties, builtInEncoding) {
  43222. if (properties.hasIncludedToUnicodeMap) {
  43223. return;
  43224. }
  43225. if (properties.hasEncoding) {
  43226. return;
  43227. }
  43228. if (builtInEncoding === properties.defaultEncoding) {
  43229. return;
  43230. }
  43231. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43232. return;
  43233. }
  43234. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43235. for (var charCode in builtInEncoding) {
  43236. var glyphName = builtInEncoding[charCode];
  43237. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43238. if (unicode !== -1) {
  43239. toUnicode[charCode] = String.fromCharCode(unicode);
  43240. }
  43241. }
  43242. properties.toUnicode.amend(toUnicode);
  43243. }
  43244. function getFontType(type, subtype) {
  43245. switch (type) {
  43246. case 'Type1':
  43247. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43248. case 'CIDFontType0':
  43249. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43250. case 'OpenType':
  43251. return FontType.OPENTYPE;
  43252. case 'TrueType':
  43253. return FontType.TRUETYPE;
  43254. case 'CIDFontType2':
  43255. return FontType.CIDFONTTYPE2;
  43256. case 'MMType1':
  43257. return FontType.MMTYPE1;
  43258. case 'Type0':
  43259. return FontType.TYPE0;
  43260. default:
  43261. return FontType.UNKNOWN;
  43262. }
  43263. }
  43264. function recoverGlyphName(name, glyphsUnicodeMap) {
  43265. if (glyphsUnicodeMap[name] !== undefined) {
  43266. return name;
  43267. }
  43268. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43269. if (unicode !== -1) {
  43270. for (var key in glyphsUnicodeMap) {
  43271. if (glyphsUnicodeMap[key] === unicode) {
  43272. return key;
  43273. }
  43274. }
  43275. }
  43276. info('Unable to recover a standard glyph name for: ' + name);
  43277. return name;
  43278. }
  43279. var Glyph = function GlyphClosure() {
  43280. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43281. this.fontChar = fontChar;
  43282. this.unicode = unicode;
  43283. this.accent = accent;
  43284. this.width = width;
  43285. this.vmetric = vmetric;
  43286. this.operatorListId = operatorListId;
  43287. this.isSpace = isSpace;
  43288. this.isInFont = isInFont;
  43289. }
  43290. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43291. 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;
  43292. };
  43293. return Glyph;
  43294. }();
  43295. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43296. function ToUnicodeMap(cmap) {
  43297. this._map = cmap;
  43298. }
  43299. ToUnicodeMap.prototype = {
  43300. get length() {
  43301. return this._map.length;
  43302. },
  43303. forEach: function (callback) {
  43304. for (var charCode in this._map) {
  43305. callback(charCode, this._map[charCode].charCodeAt(0));
  43306. }
  43307. },
  43308. has: function (i) {
  43309. return this._map[i] !== undefined;
  43310. },
  43311. get: function (i) {
  43312. return this._map[i];
  43313. },
  43314. charCodeOf: function (v) {
  43315. return this._map.indexOf(v);
  43316. },
  43317. amend: function (map) {
  43318. for (var charCode in map) {
  43319. this._map[charCode] = map[charCode];
  43320. }
  43321. }
  43322. };
  43323. return ToUnicodeMap;
  43324. }();
  43325. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43326. function IdentityToUnicodeMap(firstChar, lastChar) {
  43327. this.firstChar = firstChar;
  43328. this.lastChar = lastChar;
  43329. }
  43330. IdentityToUnicodeMap.prototype = {
  43331. get length() {
  43332. return this.lastChar + 1 - this.firstChar;
  43333. },
  43334. forEach: function (callback) {
  43335. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43336. callback(i, i);
  43337. }
  43338. },
  43339. has: function (i) {
  43340. return this.firstChar <= i && i <= this.lastChar;
  43341. },
  43342. get: function (i) {
  43343. if (this.firstChar <= i && i <= this.lastChar) {
  43344. return String.fromCharCode(i);
  43345. }
  43346. return undefined;
  43347. },
  43348. charCodeOf: function (v) {
  43349. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43350. },
  43351. amend: function (map) {
  43352. error('Should not call amend()');
  43353. }
  43354. };
  43355. return IdentityToUnicodeMap;
  43356. }();
  43357. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43358. function writeInt16(dest, offset, num) {
  43359. dest[offset] = num >> 8 & 0xFF;
  43360. dest[offset + 1] = num & 0xFF;
  43361. }
  43362. function writeInt32(dest, offset, num) {
  43363. dest[offset] = num >> 24 & 0xFF;
  43364. dest[offset + 1] = num >> 16 & 0xFF;
  43365. dest[offset + 2] = num >> 8 & 0xFF;
  43366. dest[offset + 3] = num & 0xFF;
  43367. }
  43368. function writeData(dest, offset, data) {
  43369. var i, ii;
  43370. if (data instanceof Uint8Array) {
  43371. dest.set(data, offset);
  43372. } else if (typeof data === 'string') {
  43373. for (i = 0, ii = data.length; i < ii; i++) {
  43374. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43375. }
  43376. } else {
  43377. for (i = 0, ii = data.length; i < ii; i++) {
  43378. dest[offset++] = data[i] & 0xFF;
  43379. }
  43380. }
  43381. }
  43382. function OpenTypeFileBuilder(sfnt) {
  43383. this.sfnt = sfnt;
  43384. this.tables = Object.create(null);
  43385. }
  43386. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43387. var maxPower2 = 1, log2 = 0;
  43388. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43389. maxPower2 <<= 1;
  43390. log2++;
  43391. }
  43392. var searchRange = maxPower2 * entrySize;
  43393. return {
  43394. range: searchRange,
  43395. entry: log2,
  43396. rangeShift: entrySize * entriesCount - searchRange
  43397. };
  43398. };
  43399. var OTF_HEADER_SIZE = 12;
  43400. var OTF_TABLE_ENTRY_SIZE = 16;
  43401. OpenTypeFileBuilder.prototype = {
  43402. toArray: function OpenTypeFileBuilder_toArray() {
  43403. var sfnt = this.sfnt;
  43404. var tables = this.tables;
  43405. var tablesNames = Object.keys(tables);
  43406. tablesNames.sort();
  43407. var numTables = tablesNames.length;
  43408. var i, j, jj, table, tableName;
  43409. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43410. var tableOffsets = [offset];
  43411. for (i = 0; i < numTables; i++) {
  43412. table = tables[tablesNames[i]];
  43413. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43414. offset += paddedLength;
  43415. tableOffsets.push(offset);
  43416. }
  43417. var file = new Uint8Array(offset);
  43418. for (i = 0; i < numTables; i++) {
  43419. table = tables[tablesNames[i]];
  43420. writeData(file, tableOffsets[i], table);
  43421. }
  43422. if (sfnt === 'true') {
  43423. sfnt = string32(0x00010000);
  43424. }
  43425. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43426. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43427. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43428. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43429. writeInt16(file, 4, numTables);
  43430. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43431. writeInt16(file, 6, searchParams.range);
  43432. writeInt16(file, 8, searchParams.entry);
  43433. writeInt16(file, 10, searchParams.rangeShift);
  43434. offset = OTF_HEADER_SIZE;
  43435. for (i = 0; i < numTables; i++) {
  43436. tableName = tablesNames[i];
  43437. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43438. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43439. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43440. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43441. var checksum = 0;
  43442. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43443. var quad = readUint32(file, j);
  43444. checksum = checksum + quad >>> 0;
  43445. }
  43446. writeInt32(file, offset + 4, checksum);
  43447. writeInt32(file, offset + 8, tableOffsets[i]);
  43448. writeInt32(file, offset + 12, tables[tableName].length);
  43449. offset += OTF_TABLE_ENTRY_SIZE;
  43450. }
  43451. return file;
  43452. },
  43453. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43454. if (tag in this.tables) {
  43455. throw new Error('Table ' + tag + ' already exists');
  43456. }
  43457. this.tables[tag] = data;
  43458. }
  43459. };
  43460. return OpenTypeFileBuilder;
  43461. }();
  43462. var ProblematicCharRanges = new Int32Array([
  43463. 0x0000,
  43464. 0x0020,
  43465. 0x007F,
  43466. 0x00A1,
  43467. 0x00AD,
  43468. 0x00AE,
  43469. 0x0600,
  43470. 0x0780,
  43471. 0x08A0,
  43472. 0x10A0,
  43473. 0x1780,
  43474. 0x1800,
  43475. 0x1C00,
  43476. 0x1C50,
  43477. 0x2000,
  43478. 0x2010,
  43479. 0x2011,
  43480. 0x2012,
  43481. 0x2028,
  43482. 0x2030,
  43483. 0x205F,
  43484. 0x2070,
  43485. 0x25CC,
  43486. 0x25CD,
  43487. 0x3000,
  43488. 0x3001,
  43489. 0xAA60,
  43490. 0xAA80,
  43491. 0xFFF0,
  43492. 0x10000
  43493. ]);
  43494. var Font = function FontClosure() {
  43495. function Font(name, file, properties) {
  43496. var charCode, glyphName, unicode;
  43497. this.name = name;
  43498. this.loadedName = properties.loadedName;
  43499. this.isType3Font = properties.isType3Font;
  43500. this.sizes = [];
  43501. this.missingFile = false;
  43502. this.glyphCache = Object.create(null);
  43503. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43504. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43505. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43506. var type = properties.type;
  43507. var subtype = properties.subtype;
  43508. this.type = type;
  43509. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43510. this.differences = properties.differences;
  43511. this.widths = properties.widths;
  43512. this.defaultWidth = properties.defaultWidth;
  43513. this.composite = properties.composite;
  43514. this.wideChars = properties.wideChars;
  43515. this.cMap = properties.cMap;
  43516. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43517. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43518. this.fontMatrix = properties.fontMatrix;
  43519. this.bbox = properties.bbox;
  43520. this.toUnicode = properties.toUnicode;
  43521. this.toFontChar = [];
  43522. if (properties.type === 'Type3') {
  43523. for (charCode = 0; charCode < 256; charCode++) {
  43524. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43525. }
  43526. this.fontType = FontType.TYPE3;
  43527. return;
  43528. }
  43529. this.cidEncoding = properties.cidEncoding;
  43530. this.vertical = properties.vertical;
  43531. if (this.vertical) {
  43532. this.vmetrics = properties.vmetrics;
  43533. this.defaultVMetrics = properties.defaultVMetrics;
  43534. }
  43535. var glyphsUnicodeMap;
  43536. if (!file || file.isEmpty) {
  43537. if (file) {
  43538. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43539. }
  43540. this.missingFile = true;
  43541. var fontName = name.replace(/[,_]/g, '-');
  43542. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43543. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43544. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43545. this.bold = fontName.search(/bold/gi) !== -1;
  43546. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43547. this.black = name.search(/Black/g) !== -1;
  43548. this.remeasure = Object.keys(this.widths).length > 0;
  43549. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43550. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43551. var map = [];
  43552. for (charCode in GlyphMapForStandardFonts) {
  43553. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43554. }
  43555. if (/Arial-?Black/i.test(name)) {
  43556. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43557. for (charCode in SupplementalGlyphMapForArialBlack) {
  43558. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43559. }
  43560. }
  43561. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43562. if (!isIdentityUnicode) {
  43563. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43564. map[+charCode] = unicodeCharCode;
  43565. });
  43566. }
  43567. this.toFontChar = map;
  43568. this.toUnicode = new ToUnicodeMap(map);
  43569. } else if (/Symbol/i.test(fontName)) {
  43570. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43571. } else if (/Dingbats/i.test(fontName)) {
  43572. if (/Wingdings/i.test(name)) {
  43573. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43574. }
  43575. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43576. } else if (isStandardFont) {
  43577. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43578. } else {
  43579. glyphsUnicodeMap = getGlyphsUnicode();
  43580. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43581. if (!this.composite) {
  43582. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43583. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43584. if (unicode !== -1) {
  43585. unicodeCharCode = unicode;
  43586. }
  43587. }
  43588. this.toFontChar[charCode] = unicodeCharCode;
  43589. }.bind(this));
  43590. }
  43591. this.loadedName = fontName.split('-')[0];
  43592. this.loading = false;
  43593. this.fontType = getFontType(type, subtype);
  43594. return;
  43595. }
  43596. if (subtype === 'Type1C') {
  43597. if (type !== 'Type1' && type !== 'MMType1') {
  43598. if (isTrueTypeFile(file)) {
  43599. subtype = 'TrueType';
  43600. } else {
  43601. type = 'Type1';
  43602. }
  43603. } else if (isOpenTypeFile(file)) {
  43604. type = subtype = 'OpenType';
  43605. }
  43606. }
  43607. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43608. type = 'CIDFontType0';
  43609. }
  43610. if (subtype === 'OpenType') {
  43611. type = 'OpenType';
  43612. }
  43613. if (type === 'CIDFontType0') {
  43614. if (isType1File(file)) {
  43615. subtype = 'CIDFontType0';
  43616. } else if (isOpenTypeFile(file)) {
  43617. type = subtype = 'OpenType';
  43618. } else {
  43619. subtype = 'CIDFontType0C';
  43620. }
  43621. }
  43622. var data;
  43623. switch (type) {
  43624. case 'MMType1':
  43625. info('MMType1 font (' + name + '), falling back to Type1.');
  43626. case 'Type1':
  43627. case 'CIDFontType0':
  43628. this.mimetype = 'font/opentype';
  43629. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43630. adjustWidths(properties);
  43631. data = this.convert(name, cff, properties);
  43632. break;
  43633. case 'OpenType':
  43634. case 'TrueType':
  43635. case 'CIDFontType2':
  43636. this.mimetype = 'font/opentype';
  43637. data = this.checkAndRepair(name, file, properties);
  43638. if (this.isOpenType) {
  43639. adjustWidths(properties);
  43640. type = 'OpenType';
  43641. }
  43642. break;
  43643. default:
  43644. error('Font ' + type + ' is not supported');
  43645. break;
  43646. }
  43647. this.data = data;
  43648. this.fontType = getFontType(type, subtype);
  43649. this.fontMatrix = properties.fontMatrix;
  43650. this.widths = properties.widths;
  43651. this.defaultWidth = properties.defaultWidth;
  43652. this.toUnicode = properties.toUnicode;
  43653. this.encoding = properties.baseEncoding;
  43654. this.seacMap = properties.seacMap;
  43655. this.loading = true;
  43656. }
  43657. Font.getFontID = function () {
  43658. var ID = 1;
  43659. return function Font_getFontID() {
  43660. return String(ID++);
  43661. };
  43662. }();
  43663. function int16(b0, b1) {
  43664. return (b0 << 8) + b1;
  43665. }
  43666. function signedInt16(b0, b1) {
  43667. var value = (b0 << 8) + b1;
  43668. return value & 1 << 15 ? value - 0x10000 : value;
  43669. }
  43670. function int32(b0, b1, b2, b3) {
  43671. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43672. }
  43673. function string16(value) {
  43674. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43675. }
  43676. function safeString16(value) {
  43677. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43678. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43679. }
  43680. function isTrueTypeFile(file) {
  43681. var header = file.peekBytes(4);
  43682. return readUint32(header, 0) === 0x00010000;
  43683. }
  43684. function isOpenTypeFile(file) {
  43685. var header = file.peekBytes(4);
  43686. return bytesToString(header) === 'OTTO';
  43687. }
  43688. function isType1File(file) {
  43689. var header = file.peekBytes(2);
  43690. if (header[0] === 0x25 && header[1] === 0x21) {
  43691. return true;
  43692. }
  43693. if (header[0] === 0x80 && header[1] === 0x01) {
  43694. return true;
  43695. }
  43696. return false;
  43697. }
  43698. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43699. var toFontChar = [], unicode;
  43700. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43701. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43702. if (unicode !== -1) {
  43703. toFontChar[i] = unicode;
  43704. }
  43705. }
  43706. for (var charCode in differences) {
  43707. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43708. if (unicode !== -1) {
  43709. toFontChar[+charCode] = unicode;
  43710. }
  43711. }
  43712. return toFontChar;
  43713. }
  43714. function isProblematicUnicodeLocation(code) {
  43715. var i = 0, j = ProblematicCharRanges.length - 1;
  43716. while (i < j) {
  43717. var c = i + j + 1 >> 1;
  43718. if (code < ProblematicCharRanges[c]) {
  43719. j = c - 1;
  43720. } else {
  43721. i = c;
  43722. }
  43723. }
  43724. return !(i & 1);
  43725. }
  43726. function adjustMapping(charCodeToGlyphId, properties) {
  43727. var toUnicode = properties.toUnicode;
  43728. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43729. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43730. var newMap = Object.create(null);
  43731. var toFontChar = [];
  43732. var usedFontCharCodes = [];
  43733. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43734. for (var originalCharCode in charCodeToGlyphId) {
  43735. originalCharCode |= 0;
  43736. var glyphId = charCodeToGlyphId[originalCharCode];
  43737. var fontCharCode = originalCharCode;
  43738. var hasUnicodeValue = false;
  43739. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43740. hasUnicodeValue = true;
  43741. var unicode = toUnicode.get(fontCharCode);
  43742. if (unicode.length === 1) {
  43743. fontCharCode = unicode.charCodeAt(0);
  43744. }
  43745. }
  43746. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43747. do {
  43748. fontCharCode = nextAvailableFontCharCode++;
  43749. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43750. fontCharCode = 0xF020;
  43751. nextAvailableFontCharCode = fontCharCode + 1;
  43752. }
  43753. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43754. }
  43755. newMap[fontCharCode] = glyphId;
  43756. toFontChar[originalCharCode] = fontCharCode;
  43757. usedFontCharCodes[fontCharCode] = true;
  43758. }
  43759. return {
  43760. toFontChar: toFontChar,
  43761. charCodeToGlyphId: newMap,
  43762. nextAvailableFontCharCode: nextAvailableFontCharCode
  43763. };
  43764. }
  43765. function getRanges(glyphs, numGlyphs) {
  43766. var codes = [];
  43767. for (var charCode in glyphs) {
  43768. if (glyphs[charCode] >= numGlyphs) {
  43769. continue;
  43770. }
  43771. codes.push({
  43772. fontCharCode: charCode | 0,
  43773. glyphId: glyphs[charCode]
  43774. });
  43775. }
  43776. codes.sort(function fontGetRangesSort(a, b) {
  43777. return a.fontCharCode - b.fontCharCode;
  43778. });
  43779. var ranges = [];
  43780. var length = codes.length;
  43781. for (var n = 0; n < length;) {
  43782. var start = codes[n].fontCharCode;
  43783. var codeIndices = [codes[n].glyphId];
  43784. ++n;
  43785. var end = start;
  43786. while (n < length && end + 1 === codes[n].fontCharCode) {
  43787. codeIndices.push(codes[n].glyphId);
  43788. ++end;
  43789. ++n;
  43790. if (end === 0xFFFF) {
  43791. break;
  43792. }
  43793. }
  43794. ranges.push([
  43795. start,
  43796. end,
  43797. codeIndices
  43798. ]);
  43799. }
  43800. return ranges;
  43801. }
  43802. function createCmapTable(glyphs, numGlyphs) {
  43803. var ranges = getRanges(glyphs, numGlyphs);
  43804. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43805. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43806. var i, ii, j, jj;
  43807. for (i = ranges.length - 1; i >= 0; --i) {
  43808. if (ranges[i][0] <= 0xFFFF) {
  43809. break;
  43810. }
  43811. }
  43812. var bmpLength = i + 1;
  43813. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43814. ranges[i][1] = 0xFFFE;
  43815. }
  43816. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43817. var segCount = bmpLength + trailingRangesCount;
  43818. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43819. var startCount = '';
  43820. var endCount = '';
  43821. var idDeltas = '';
  43822. var idRangeOffsets = '';
  43823. var glyphsIds = '';
  43824. var bias = 0;
  43825. var range, start, end, codes;
  43826. for (i = 0, ii = bmpLength; i < ii; i++) {
  43827. range = ranges[i];
  43828. start = range[0];
  43829. end = range[1];
  43830. startCount += string16(start);
  43831. endCount += string16(end);
  43832. codes = range[2];
  43833. var contiguous = true;
  43834. for (j = 1, jj = codes.length; j < jj; ++j) {
  43835. if (codes[j] !== codes[j - 1] + 1) {
  43836. contiguous = false;
  43837. break;
  43838. }
  43839. }
  43840. if (!contiguous) {
  43841. var offset = (segCount - i) * 2 + bias * 2;
  43842. bias += end - start + 1;
  43843. idDeltas += string16(0);
  43844. idRangeOffsets += string16(offset);
  43845. for (j = 0, jj = codes.length; j < jj; ++j) {
  43846. glyphsIds += string16(codes[j]);
  43847. }
  43848. } else {
  43849. var startCode = codes[0];
  43850. idDeltas += string16(startCode - start & 0xFFFF);
  43851. idRangeOffsets += string16(0);
  43852. }
  43853. }
  43854. if (trailingRangesCount > 0) {
  43855. endCount += '\xFF\xFF';
  43856. startCount += '\xFF\xFF';
  43857. idDeltas += '\x00\x01';
  43858. idRangeOffsets += '\x00\x00';
  43859. }
  43860. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43861. var format31012 = '';
  43862. var header31012 = '';
  43863. if (numTables > 1) {
  43864. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43865. format31012 = '';
  43866. for (i = 0, ii = ranges.length; i < ii; i++) {
  43867. range = ranges[i];
  43868. start = range[0];
  43869. codes = range[2];
  43870. var code = codes[0];
  43871. for (j = 1, jj = codes.length; j < jj; ++j) {
  43872. if (codes[j] !== codes[j - 1] + 1) {
  43873. end = range[0] + j - 1;
  43874. format31012 += string32(start) + string32(end) + string32(code);
  43875. start = end + 1;
  43876. code = codes[j];
  43877. }
  43878. }
  43879. format31012 += string32(start) + string32(range[1]) + string32(code);
  43880. }
  43881. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43882. }
  43883. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43884. }
  43885. function validateOS2Table(os2) {
  43886. var stream = new Stream(os2.data);
  43887. var version = stream.getUint16();
  43888. stream.getBytes(60);
  43889. var selection = stream.getUint16();
  43890. if (version < 4 && selection & 0x0300) {
  43891. return false;
  43892. }
  43893. var firstChar = stream.getUint16();
  43894. var lastChar = stream.getUint16();
  43895. if (firstChar > lastChar) {
  43896. return false;
  43897. }
  43898. stream.getBytes(6);
  43899. var usWinAscent = stream.getUint16();
  43900. if (usWinAscent === 0) {
  43901. return false;
  43902. }
  43903. os2.data[8] = os2.data[9] = 0;
  43904. return true;
  43905. }
  43906. function createOS2Table(properties, charstrings, override) {
  43907. override = override || {
  43908. unitsPerEm: 0,
  43909. yMax: 0,
  43910. yMin: 0,
  43911. ascent: 0,
  43912. descent: 0
  43913. };
  43914. var ulUnicodeRange1 = 0;
  43915. var ulUnicodeRange2 = 0;
  43916. var ulUnicodeRange3 = 0;
  43917. var ulUnicodeRange4 = 0;
  43918. var firstCharIndex = null;
  43919. var lastCharIndex = 0;
  43920. if (charstrings) {
  43921. for (var code in charstrings) {
  43922. code |= 0;
  43923. if (firstCharIndex > code || !firstCharIndex) {
  43924. firstCharIndex = code;
  43925. }
  43926. if (lastCharIndex < code) {
  43927. lastCharIndex = code;
  43928. }
  43929. var position = getUnicodeRangeFor(code);
  43930. if (position < 32) {
  43931. ulUnicodeRange1 |= 1 << position;
  43932. } else if (position < 64) {
  43933. ulUnicodeRange2 |= 1 << position - 32;
  43934. } else if (position < 96) {
  43935. ulUnicodeRange3 |= 1 << position - 64;
  43936. } else if (position < 123) {
  43937. ulUnicodeRange4 |= 1 << position - 96;
  43938. } else {
  43939. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43940. }
  43941. }
  43942. } else {
  43943. firstCharIndex = 0;
  43944. lastCharIndex = 255;
  43945. }
  43946. var bbox = properties.bbox || [
  43947. 0,
  43948. 0,
  43949. 0,
  43950. 0
  43951. ];
  43952. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43953. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43954. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43955. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43956. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43957. typoDescent = -typoDescent;
  43958. }
  43959. var winAscent = override.yMax || typoAscent;
  43960. var winDescent = -override.yMin || -typoDescent;
  43961. 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';
  43962. }
  43963. function createPostTable(properties) {
  43964. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43965. 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';
  43966. }
  43967. function createNameTable(name, proto) {
  43968. if (!proto) {
  43969. proto = [
  43970. [],
  43971. []
  43972. ];
  43973. }
  43974. var strings = [
  43975. proto[0][0] || 'Original licence',
  43976. proto[0][1] || name,
  43977. proto[0][2] || 'Unknown',
  43978. proto[0][3] || 'uniqueID',
  43979. proto[0][4] || name,
  43980. proto[0][5] || 'Version 0.11',
  43981. proto[0][6] || '',
  43982. proto[0][7] || 'Unknown',
  43983. proto[0][8] || 'Unknown',
  43984. proto[0][9] || 'Unknown'
  43985. ];
  43986. var stringsUnicode = [];
  43987. var i, ii, j, jj, str;
  43988. for (i = 0, ii = strings.length; i < ii; i++) {
  43989. str = proto[1][i] || strings[i];
  43990. var strBufUnicode = [];
  43991. for (j = 0, jj = str.length; j < jj; j++) {
  43992. strBufUnicode.push(string16(str.charCodeAt(j)));
  43993. }
  43994. stringsUnicode.push(strBufUnicode.join(''));
  43995. }
  43996. var names = [
  43997. strings,
  43998. stringsUnicode
  43999. ];
  44000. var platforms = [
  44001. '\x00\x01',
  44002. '\x00\x03'
  44003. ];
  44004. var encodings = [
  44005. '\x00\x00',
  44006. '\x00\x01'
  44007. ];
  44008. var languages = [
  44009. '\x00\x00',
  44010. '\x04\x09'
  44011. ];
  44012. var namesRecordCount = strings.length * platforms.length;
  44013. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44014. var strOffset = 0;
  44015. for (i = 0, ii = platforms.length; i < ii; i++) {
  44016. var strs = names[i];
  44017. for (j = 0, jj = strs.length; j < jj; j++) {
  44018. str = strs[j];
  44019. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44020. nameTable += nameRecord;
  44021. strOffset += str.length;
  44022. }
  44023. }
  44024. nameTable += strings.join('') + stringsUnicode.join('');
  44025. return nameTable;
  44026. }
  44027. Font.prototype = {
  44028. name: null,
  44029. font: null,
  44030. mimetype: null,
  44031. encoding: null,
  44032. get renderer() {
  44033. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44034. return shadow(this, 'renderer', renderer);
  44035. },
  44036. exportData: function Font_exportData() {
  44037. var data = {};
  44038. for (var i in this) {
  44039. if (this.hasOwnProperty(i)) {
  44040. data[i] = this[i];
  44041. }
  44042. }
  44043. return data;
  44044. },
  44045. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44046. function readTableEntry(file) {
  44047. var tag = bytesToString(file.getBytes(4));
  44048. var checksum = file.getInt32() >>> 0;
  44049. var offset = file.getInt32() >>> 0;
  44050. var length = file.getInt32() >>> 0;
  44051. var previousPosition = file.pos;
  44052. file.pos = file.start ? file.start : 0;
  44053. file.skip(offset);
  44054. var data = file.getBytes(length);
  44055. file.pos = previousPosition;
  44056. if (tag === 'head') {
  44057. data[8] = data[9] = data[10] = data[11] = 0;
  44058. data[17] |= 0x20;
  44059. }
  44060. return {
  44061. tag: tag,
  44062. checksum: checksum,
  44063. length: length,
  44064. offset: offset,
  44065. data: data
  44066. };
  44067. }
  44068. function readOpenTypeHeader(ttf) {
  44069. return {
  44070. version: bytesToString(ttf.getBytes(4)),
  44071. numTables: ttf.getUint16(),
  44072. searchRange: ttf.getUint16(),
  44073. entrySelector: ttf.getUint16(),
  44074. rangeShift: ttf.getUint16()
  44075. };
  44076. }
  44077. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44078. if (!cmap) {
  44079. warn('No cmap table available.');
  44080. return {
  44081. platformId: -1,
  44082. encodingId: -1,
  44083. mappings: [],
  44084. hasShortCmap: false
  44085. };
  44086. }
  44087. var segment;
  44088. var start = (font.start ? font.start : 0) + cmap.offset;
  44089. font.pos = start;
  44090. font.getUint16();
  44091. var numTables = font.getUint16();
  44092. var potentialTable;
  44093. var canBreak = false;
  44094. for (var i = 0; i < numTables; i++) {
  44095. var platformId = font.getUint16();
  44096. var encodingId = font.getUint16();
  44097. var offset = font.getInt32() >>> 0;
  44098. var useTable = false;
  44099. if (platformId === 0 && encodingId === 0) {
  44100. useTable = true;
  44101. } else if (platformId === 1 && encodingId === 0) {
  44102. useTable = true;
  44103. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44104. useTable = true;
  44105. if (!isSymbolicFont) {
  44106. canBreak = true;
  44107. }
  44108. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44109. useTable = true;
  44110. canBreak = true;
  44111. }
  44112. if (useTable) {
  44113. potentialTable = {
  44114. platformId: platformId,
  44115. encodingId: encodingId,
  44116. offset: offset
  44117. };
  44118. }
  44119. if (canBreak) {
  44120. break;
  44121. }
  44122. }
  44123. if (potentialTable) {
  44124. font.pos = start + potentialTable.offset;
  44125. }
  44126. if (!potentialTable || font.peekByte() === -1) {
  44127. warn('Could not find a preferred cmap table.');
  44128. return {
  44129. platformId: -1,
  44130. encodingId: -1,
  44131. mappings: [],
  44132. hasShortCmap: false
  44133. };
  44134. }
  44135. var format = font.getUint16();
  44136. font.getUint16();
  44137. font.getUint16();
  44138. var hasShortCmap = false;
  44139. var mappings = [];
  44140. var j, glyphId;
  44141. if (format === 0) {
  44142. for (j = 0; j < 256; j++) {
  44143. var index = font.getByte();
  44144. if (!index) {
  44145. continue;
  44146. }
  44147. mappings.push({
  44148. charCode: j,
  44149. glyphId: index
  44150. });
  44151. }
  44152. hasShortCmap = true;
  44153. } else if (format === 4) {
  44154. var segCount = font.getUint16() >> 1;
  44155. font.getBytes(6);
  44156. var segIndex, segments = [];
  44157. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44158. segments.push({ end: font.getUint16() });
  44159. }
  44160. font.getUint16();
  44161. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44162. segments[segIndex].start = font.getUint16();
  44163. }
  44164. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44165. segments[segIndex].delta = font.getUint16();
  44166. }
  44167. var offsetsCount = 0;
  44168. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44169. segment = segments[segIndex];
  44170. var rangeOffset = font.getUint16();
  44171. if (!rangeOffset) {
  44172. segment.offsetIndex = -1;
  44173. continue;
  44174. }
  44175. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44176. segment.offsetIndex = offsetIndex;
  44177. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44178. }
  44179. var offsets = [];
  44180. for (j = 0; j < offsetsCount; j++) {
  44181. offsets.push(font.getUint16());
  44182. }
  44183. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44184. segment = segments[segIndex];
  44185. start = segment.start;
  44186. var end = segment.end;
  44187. var delta = segment.delta;
  44188. offsetIndex = segment.offsetIndex;
  44189. for (j = start; j <= end; j++) {
  44190. if (j === 0xFFFF) {
  44191. continue;
  44192. }
  44193. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44194. glyphId = glyphId + delta & 0xFFFF;
  44195. if (glyphId === 0) {
  44196. continue;
  44197. }
  44198. mappings.push({
  44199. charCode: j,
  44200. glyphId: glyphId
  44201. });
  44202. }
  44203. }
  44204. } else if (format === 6) {
  44205. var firstCode = font.getUint16();
  44206. var entryCount = font.getUint16();
  44207. for (j = 0; j < entryCount; j++) {
  44208. glyphId = font.getUint16();
  44209. var charCode = firstCode + j;
  44210. mappings.push({
  44211. charCode: charCode,
  44212. glyphId: glyphId
  44213. });
  44214. }
  44215. } else {
  44216. warn('cmap table has unsupported format: ' + format);
  44217. return {
  44218. platformId: -1,
  44219. encodingId: -1,
  44220. mappings: [],
  44221. hasShortCmap: false
  44222. };
  44223. }
  44224. mappings.sort(function (a, b) {
  44225. return a.charCode - b.charCode;
  44226. });
  44227. for (i = 1; i < mappings.length; i++) {
  44228. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44229. mappings.splice(i, 1);
  44230. i--;
  44231. }
  44232. }
  44233. return {
  44234. platformId: potentialTable.platformId,
  44235. encodingId: potentialTable.encodingId,
  44236. mappings: mappings,
  44237. hasShortCmap: hasShortCmap
  44238. };
  44239. }
  44240. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44241. if (!header) {
  44242. if (metrics) {
  44243. metrics.data = null;
  44244. }
  44245. return;
  44246. }
  44247. font.pos = (font.start ? font.start : 0) + header.offset;
  44248. font.pos += header.length - 2;
  44249. var numOfMetrics = font.getUint16();
  44250. if (numOfMetrics > numGlyphs) {
  44251. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44252. numOfMetrics = numGlyphs;
  44253. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44254. header.data[35] = numOfMetrics & 0x00ff;
  44255. }
  44256. var numOfSidebearings = numGlyphs - numOfMetrics;
  44257. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44258. if (numMissing > 0) {
  44259. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44260. entries.set(metrics.data);
  44261. metrics.data = entries;
  44262. }
  44263. }
  44264. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44265. if (sourceEnd - sourceStart <= 12) {
  44266. return 0;
  44267. }
  44268. var glyf = source.subarray(sourceStart, sourceEnd);
  44269. var contoursCount = glyf[0] << 8 | glyf[1];
  44270. if (contoursCount & 0x8000) {
  44271. dest.set(glyf, destStart);
  44272. return glyf.length;
  44273. }
  44274. var i, j = 10, flagsCount = 0;
  44275. for (i = 0; i < contoursCount; i++) {
  44276. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44277. flagsCount = endPoint + 1;
  44278. j += 2;
  44279. }
  44280. var instructionsStart = j;
  44281. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44282. j += 2 + instructionsLength;
  44283. var instructionsEnd = j;
  44284. var coordinatesLength = 0;
  44285. for (i = 0; i < flagsCount; i++) {
  44286. var flag = glyf[j++];
  44287. if (flag & 0xC0) {
  44288. glyf[j - 1] = flag & 0x3F;
  44289. }
  44290. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44291. coordinatesLength += xyLength;
  44292. if (flag & 8) {
  44293. var repeat = glyf[j++];
  44294. i += repeat;
  44295. coordinatesLength += repeat * xyLength;
  44296. }
  44297. }
  44298. if (coordinatesLength === 0) {
  44299. return 0;
  44300. }
  44301. var glyphDataLength = j + coordinatesLength;
  44302. if (glyphDataLength > glyf.length) {
  44303. return 0;
  44304. }
  44305. if (!hintsValid && instructionsLength > 0) {
  44306. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44307. dest.set([
  44308. 0,
  44309. 0
  44310. ], destStart + instructionsStart);
  44311. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44312. glyphDataLength -= instructionsLength;
  44313. if (glyf.length - glyphDataLength > 3) {
  44314. glyphDataLength = glyphDataLength + 3 & ~3;
  44315. }
  44316. return glyphDataLength;
  44317. }
  44318. if (glyf.length - glyphDataLength > 3) {
  44319. glyphDataLength = glyphDataLength + 3 & ~3;
  44320. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44321. return glyphDataLength;
  44322. }
  44323. dest.set(glyf, destStart);
  44324. return glyf.length;
  44325. }
  44326. function sanitizeHead(head, numGlyphs, locaLength) {
  44327. var data = head.data;
  44328. var version = int32(data[0], data[1], data[2], data[3]);
  44329. if (version >> 16 !== 1) {
  44330. info('Attempting to fix invalid version in head table: ' + version);
  44331. data[0] = 0;
  44332. data[1] = 1;
  44333. data[2] = 0;
  44334. data[3] = 0;
  44335. }
  44336. var indexToLocFormat = int16(data[50], data[51]);
  44337. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44338. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44339. var numGlyphsPlusOne = numGlyphs + 1;
  44340. if (locaLength === numGlyphsPlusOne << 1) {
  44341. data[50] = 0;
  44342. data[51] = 0;
  44343. } else if (locaLength === numGlyphsPlusOne << 2) {
  44344. data[50] = 0;
  44345. data[51] = 1;
  44346. } else {
  44347. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44348. }
  44349. }
  44350. }
  44351. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44352. var itemSize, itemDecode, itemEncode;
  44353. if (isGlyphLocationsLong) {
  44354. itemSize = 4;
  44355. itemDecode = function fontItemDecodeLong(data, offset) {
  44356. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44357. };
  44358. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44359. data[offset] = value >>> 24 & 0xFF;
  44360. data[offset + 1] = value >> 16 & 0xFF;
  44361. data[offset + 2] = value >> 8 & 0xFF;
  44362. data[offset + 3] = value & 0xFF;
  44363. };
  44364. } else {
  44365. itemSize = 2;
  44366. itemDecode = function fontItemDecode(data, offset) {
  44367. return data[offset] << 9 | data[offset + 1] << 1;
  44368. };
  44369. itemEncode = function fontItemEncode(data, offset, value) {
  44370. data[offset] = value >> 9 & 0xFF;
  44371. data[offset + 1] = value >> 1 & 0xFF;
  44372. };
  44373. }
  44374. var locaData = loca.data;
  44375. var locaDataSize = itemSize * (1 + numGlyphs);
  44376. if (locaData.length !== locaDataSize) {
  44377. locaData = new Uint8Array(locaDataSize);
  44378. locaData.set(loca.data.subarray(0, locaDataSize));
  44379. loca.data = locaData;
  44380. }
  44381. var oldGlyfData = glyf.data;
  44382. var oldGlyfDataLength = oldGlyfData.length;
  44383. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44384. var startOffset = itemDecode(locaData, 0);
  44385. var writeOffset = 0;
  44386. var missingGlyphData = Object.create(null);
  44387. itemEncode(locaData, 0, writeOffset);
  44388. var i, j;
  44389. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44390. var endOffset = itemDecode(locaData, j);
  44391. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44392. endOffset = oldGlyfDataLength;
  44393. }
  44394. if (endOffset > oldGlyfDataLength) {
  44395. itemEncode(locaData, j, writeOffset);
  44396. startOffset = endOffset;
  44397. continue;
  44398. }
  44399. if (startOffset === endOffset) {
  44400. missingGlyphData[i] = true;
  44401. }
  44402. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44403. writeOffset += newLength;
  44404. itemEncode(locaData, j, writeOffset);
  44405. startOffset = endOffset;
  44406. }
  44407. if (writeOffset === 0) {
  44408. var simpleGlyph = new Uint8Array([
  44409. 0,
  44410. 1,
  44411. 0,
  44412. 0,
  44413. 0,
  44414. 0,
  44415. 0,
  44416. 0,
  44417. 0,
  44418. 0,
  44419. 0,
  44420. 0,
  44421. 0,
  44422. 0,
  44423. 49,
  44424. 0
  44425. ]);
  44426. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44427. itemEncode(locaData, j, simpleGlyph.length);
  44428. }
  44429. glyf.data = simpleGlyph;
  44430. return missingGlyphData;
  44431. }
  44432. if (dupFirstEntry) {
  44433. var firstEntryLength = itemDecode(locaData, itemSize);
  44434. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44435. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44436. } else {
  44437. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44438. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44439. }
  44440. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44441. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44442. } else {
  44443. glyf.data = newGlyfData.subarray(0, writeOffset);
  44444. }
  44445. return missingGlyphData;
  44446. }
  44447. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44448. var start = (font.start ? font.start : 0) + post.offset;
  44449. font.pos = start;
  44450. var length = post.length, end = start + length;
  44451. var version = font.getInt32();
  44452. font.getBytes(28);
  44453. var glyphNames;
  44454. var valid = true;
  44455. var i;
  44456. switch (version) {
  44457. case 0x00010000:
  44458. glyphNames = MacStandardGlyphOrdering;
  44459. break;
  44460. case 0x00020000:
  44461. var numGlyphs = font.getUint16();
  44462. if (numGlyphs !== maxpNumGlyphs) {
  44463. valid = false;
  44464. break;
  44465. }
  44466. var glyphNameIndexes = [];
  44467. for (i = 0; i < numGlyphs; ++i) {
  44468. var index = font.getUint16();
  44469. if (index >= 32768) {
  44470. valid = false;
  44471. break;
  44472. }
  44473. glyphNameIndexes.push(index);
  44474. }
  44475. if (!valid) {
  44476. break;
  44477. }
  44478. var customNames = [];
  44479. var strBuf = [];
  44480. while (font.pos < end) {
  44481. var stringLength = font.getByte();
  44482. strBuf.length = stringLength;
  44483. for (i = 0; i < stringLength; ++i) {
  44484. strBuf[i] = String.fromCharCode(font.getByte());
  44485. }
  44486. customNames.push(strBuf.join(''));
  44487. }
  44488. glyphNames = [];
  44489. for (i = 0; i < numGlyphs; ++i) {
  44490. var j = glyphNameIndexes[i];
  44491. if (j < 258) {
  44492. glyphNames.push(MacStandardGlyphOrdering[j]);
  44493. continue;
  44494. }
  44495. glyphNames.push(customNames[j - 258]);
  44496. }
  44497. break;
  44498. case 0x00030000:
  44499. break;
  44500. default:
  44501. warn('Unknown/unsupported post table version ' + version);
  44502. valid = false;
  44503. if (properties.defaultEncoding) {
  44504. glyphNames = properties.defaultEncoding;
  44505. }
  44506. break;
  44507. }
  44508. properties.glyphNames = glyphNames;
  44509. return valid;
  44510. }
  44511. function readNameTable(nameTable) {
  44512. var start = (font.start ? font.start : 0) + nameTable.offset;
  44513. font.pos = start;
  44514. var names = [
  44515. [],
  44516. []
  44517. ];
  44518. var length = nameTable.length, end = start + length;
  44519. var format = font.getUint16();
  44520. var FORMAT_0_HEADER_LENGTH = 6;
  44521. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44522. return names;
  44523. }
  44524. var numRecords = font.getUint16();
  44525. var stringsStart = font.getUint16();
  44526. var records = [];
  44527. var NAME_RECORD_LENGTH = 12;
  44528. var i, ii;
  44529. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44530. var r = {
  44531. platform: font.getUint16(),
  44532. encoding: font.getUint16(),
  44533. language: font.getUint16(),
  44534. name: font.getUint16(),
  44535. length: font.getUint16(),
  44536. offset: font.getUint16()
  44537. };
  44538. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44539. records.push(r);
  44540. }
  44541. }
  44542. for (i = 0, ii = records.length; i < ii; i++) {
  44543. var record = records[i];
  44544. if (record.length <= 0) {
  44545. continue;
  44546. }
  44547. var pos = start + stringsStart + record.offset;
  44548. if (pos + record.length > end) {
  44549. continue;
  44550. }
  44551. font.pos = pos;
  44552. var nameIndex = record.name;
  44553. if (record.encoding) {
  44554. var str = '';
  44555. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44556. str += String.fromCharCode(font.getUint16());
  44557. }
  44558. names[1][nameIndex] = str;
  44559. } else {
  44560. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44561. }
  44562. }
  44563. return names;
  44564. }
  44565. var TTOpsStackDeltas = [
  44566. 0,
  44567. 0,
  44568. 0,
  44569. 0,
  44570. 0,
  44571. 0,
  44572. 0,
  44573. 0,
  44574. -2,
  44575. -2,
  44576. -2,
  44577. -2,
  44578. 0,
  44579. 0,
  44580. -2,
  44581. -5,
  44582. -1,
  44583. -1,
  44584. -1,
  44585. -1,
  44586. -1,
  44587. -1,
  44588. -1,
  44589. -1,
  44590. 0,
  44591. 0,
  44592. -1,
  44593. 0,
  44594. -1,
  44595. -1,
  44596. -1,
  44597. -1,
  44598. 1,
  44599. -1,
  44600. -999,
  44601. 0,
  44602. 1,
  44603. 0,
  44604. -1,
  44605. -2,
  44606. 0,
  44607. -1,
  44608. -2,
  44609. -1,
  44610. -1,
  44611. 0,
  44612. -1,
  44613. -1,
  44614. 0,
  44615. 0,
  44616. -999,
  44617. -999,
  44618. -1,
  44619. -1,
  44620. -1,
  44621. -1,
  44622. -2,
  44623. -999,
  44624. -2,
  44625. -2,
  44626. -999,
  44627. 0,
  44628. -2,
  44629. -2,
  44630. 0,
  44631. 0,
  44632. -2,
  44633. 0,
  44634. -2,
  44635. 0,
  44636. 0,
  44637. 0,
  44638. -2,
  44639. -1,
  44640. -1,
  44641. 1,
  44642. 1,
  44643. 0,
  44644. 0,
  44645. -1,
  44646. -1,
  44647. -1,
  44648. -1,
  44649. -1,
  44650. -1,
  44651. -1,
  44652. 0,
  44653. 0,
  44654. -1,
  44655. 0,
  44656. -1,
  44657. -1,
  44658. 0,
  44659. -999,
  44660. -1,
  44661. -1,
  44662. -1,
  44663. -1,
  44664. -1,
  44665. -1,
  44666. 0,
  44667. 0,
  44668. 0,
  44669. 0,
  44670. 0,
  44671. 0,
  44672. 0,
  44673. 0,
  44674. 0,
  44675. 0,
  44676. 0,
  44677. 0,
  44678. -2,
  44679. -999,
  44680. -999,
  44681. -999,
  44682. -999,
  44683. -999,
  44684. -1,
  44685. -1,
  44686. -2,
  44687. -2,
  44688. 0,
  44689. 0,
  44690. 0,
  44691. 0,
  44692. -1,
  44693. -1,
  44694. -999,
  44695. -2,
  44696. -2,
  44697. 0,
  44698. 0,
  44699. -1,
  44700. -2,
  44701. -2,
  44702. 0,
  44703. 0,
  44704. 0,
  44705. -1,
  44706. -1,
  44707. -1,
  44708. -2
  44709. ];
  44710. function sanitizeTTProgram(table, ttContext) {
  44711. var data = table.data;
  44712. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44713. var stack = [];
  44714. var callstack = [];
  44715. var functionsCalled = [];
  44716. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44717. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44718. for (var ii = data.length; i < ii;) {
  44719. var op = data[i++];
  44720. if (op === 0x40) {
  44721. n = data[i++];
  44722. if (inFDEF || inELSE) {
  44723. i += n;
  44724. } else {
  44725. for (j = 0; j < n; j++) {
  44726. stack.push(data[i++]);
  44727. }
  44728. }
  44729. } else if (op === 0x41) {
  44730. n = data[i++];
  44731. if (inFDEF || inELSE) {
  44732. i += n * 2;
  44733. } else {
  44734. for (j = 0; j < n; j++) {
  44735. b = data[i++];
  44736. stack.push(b << 8 | data[i++]);
  44737. }
  44738. }
  44739. } else if ((op & 0xF8) === 0xB0) {
  44740. n = op - 0xB0 + 1;
  44741. if (inFDEF || inELSE) {
  44742. i += n;
  44743. } else {
  44744. for (j = 0; j < n; j++) {
  44745. stack.push(data[i++]);
  44746. }
  44747. }
  44748. } else if ((op & 0xF8) === 0xB8) {
  44749. n = op - 0xB8 + 1;
  44750. if (inFDEF || inELSE) {
  44751. i += n * 2;
  44752. } else {
  44753. for (j = 0; j < n; j++) {
  44754. b = data[i++];
  44755. stack.push(b << 8 | data[i++]);
  44756. }
  44757. }
  44758. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44759. if (!inFDEF && !inELSE) {
  44760. funcId = stack[stack.length - 1];
  44761. ttContext.functionsUsed[funcId] = true;
  44762. if (funcId in ttContext.functionsStackDeltas) {
  44763. stack.length += ttContext.functionsStackDeltas[funcId];
  44764. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44765. callstack.push({
  44766. data: data,
  44767. i: i,
  44768. stackTop: stack.length - 1
  44769. });
  44770. functionsCalled.push(funcId);
  44771. pc = ttContext.functionsDefined[funcId];
  44772. if (!pc) {
  44773. warn('TT: CALL non-existent function');
  44774. ttContext.hintsValid = false;
  44775. return;
  44776. }
  44777. data = pc.data;
  44778. i = pc.i;
  44779. }
  44780. }
  44781. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44782. if (inFDEF || inELSE) {
  44783. warn('TT: nested FDEFs not allowed');
  44784. tooComplexToFollowFunctions = true;
  44785. }
  44786. inFDEF = true;
  44787. lastDeff = i;
  44788. funcId = stack.pop();
  44789. ttContext.functionsDefined[funcId] = {
  44790. data: data,
  44791. i: i
  44792. };
  44793. } else if (op === 0x2D) {
  44794. if (inFDEF) {
  44795. inFDEF = false;
  44796. lastEndf = i;
  44797. } else {
  44798. pc = callstack.pop();
  44799. if (!pc) {
  44800. warn('TT: ENDF bad stack');
  44801. ttContext.hintsValid = false;
  44802. return;
  44803. }
  44804. funcId = functionsCalled.pop();
  44805. data = pc.data;
  44806. i = pc.i;
  44807. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44808. }
  44809. } else if (op === 0x89) {
  44810. if (inFDEF || inELSE) {
  44811. warn('TT: nested IDEFs not allowed');
  44812. tooComplexToFollowFunctions = true;
  44813. }
  44814. inFDEF = true;
  44815. lastDeff = i;
  44816. } else if (op === 0x58) {
  44817. ++ifLevel;
  44818. } else if (op === 0x1B) {
  44819. inELSE = ifLevel;
  44820. } else if (op === 0x59) {
  44821. if (inELSE === ifLevel) {
  44822. inELSE = 0;
  44823. }
  44824. --ifLevel;
  44825. } else if (op === 0x1C) {
  44826. if (!inFDEF && !inELSE) {
  44827. var offset = stack[stack.length - 1];
  44828. if (offset > 0) {
  44829. i += offset - 1;
  44830. }
  44831. }
  44832. }
  44833. if (!inFDEF && !inELSE) {
  44834. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44835. if (op >= 0x71 && op <= 0x75) {
  44836. n = stack.pop();
  44837. if (!isNaN(n)) {
  44838. stackDelta = -n * 2;
  44839. }
  44840. }
  44841. while (stackDelta < 0 && stack.length > 0) {
  44842. stack.pop();
  44843. stackDelta++;
  44844. }
  44845. while (stackDelta > 0) {
  44846. stack.push(NaN);
  44847. stackDelta--;
  44848. }
  44849. }
  44850. }
  44851. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44852. var content = [data];
  44853. if (i > data.length) {
  44854. content.push(new Uint8Array(i - data.length));
  44855. }
  44856. if (lastDeff > lastEndf) {
  44857. warn('TT: complementing a missing function tail');
  44858. content.push(new Uint8Array([
  44859. 0x22,
  44860. 0x2D
  44861. ]));
  44862. }
  44863. foldTTTable(table, content);
  44864. }
  44865. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44866. if (ttContext.tooComplexToFollowFunctions) {
  44867. return;
  44868. }
  44869. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44870. warn('TT: more functions defined than expected');
  44871. ttContext.hintsValid = false;
  44872. return;
  44873. }
  44874. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44875. if (j > maxFunctionDefs) {
  44876. warn('TT: invalid function id: ' + j);
  44877. ttContext.hintsValid = false;
  44878. return;
  44879. }
  44880. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44881. warn('TT: undefined function: ' + j);
  44882. ttContext.hintsValid = false;
  44883. return;
  44884. }
  44885. }
  44886. }
  44887. function foldTTTable(table, content) {
  44888. if (content.length > 1) {
  44889. var newLength = 0;
  44890. var j, jj;
  44891. for (j = 0, jj = content.length; j < jj; j++) {
  44892. newLength += content[j].length;
  44893. }
  44894. newLength = newLength + 3 & ~3;
  44895. var result = new Uint8Array(newLength);
  44896. var pos = 0;
  44897. for (j = 0, jj = content.length; j < jj; j++) {
  44898. result.set(content[j], pos);
  44899. pos += content[j].length;
  44900. }
  44901. table.data = result;
  44902. table.length = newLength;
  44903. }
  44904. }
  44905. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44906. var ttContext = {
  44907. functionsDefined: [],
  44908. functionsUsed: [],
  44909. functionsStackDeltas: [],
  44910. tooComplexToFollowFunctions: false,
  44911. hintsValid: true
  44912. };
  44913. if (fpgm) {
  44914. sanitizeTTProgram(fpgm, ttContext);
  44915. }
  44916. if (prep) {
  44917. sanitizeTTProgram(prep, ttContext);
  44918. }
  44919. if (fpgm) {
  44920. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44921. }
  44922. if (cvt && cvt.length & 1) {
  44923. var cvtData = new Uint8Array(cvt.length + 1);
  44924. cvtData.set(cvt.data);
  44925. cvt.data = cvtData;
  44926. }
  44927. return ttContext.hintsValid;
  44928. }
  44929. font = new Stream(new Uint8Array(font.getBytes()));
  44930. var VALID_TABLES = [
  44931. 'OS/2',
  44932. 'cmap',
  44933. 'head',
  44934. 'hhea',
  44935. 'hmtx',
  44936. 'maxp',
  44937. 'name',
  44938. 'post',
  44939. 'loca',
  44940. 'glyf',
  44941. 'fpgm',
  44942. 'prep',
  44943. 'cvt ',
  44944. 'CFF '
  44945. ];
  44946. var header = readOpenTypeHeader(font);
  44947. var numTables = header.numTables;
  44948. var cff, cffFile;
  44949. var tables = Object.create(null);
  44950. tables['OS/2'] = null;
  44951. tables['cmap'] = null;
  44952. tables['head'] = null;
  44953. tables['hhea'] = null;
  44954. tables['hmtx'] = null;
  44955. tables['maxp'] = null;
  44956. tables['name'] = null;
  44957. tables['post'] = null;
  44958. var table;
  44959. for (var i = 0; i < numTables; i++) {
  44960. table = readTableEntry(font);
  44961. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44962. continue;
  44963. }
  44964. if (table.length === 0) {
  44965. continue;
  44966. }
  44967. tables[table.tag] = table;
  44968. }
  44969. var isTrueType = !tables['CFF '];
  44970. if (!isTrueType) {
  44971. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44972. cffFile = new Stream(tables['CFF '].data);
  44973. cff = new CFFFont(cffFile, properties);
  44974. adjustWidths(properties);
  44975. return this.convert(name, cff, properties);
  44976. }
  44977. delete tables['glyf'];
  44978. delete tables['loca'];
  44979. delete tables['fpgm'];
  44980. delete tables['prep'];
  44981. delete tables['cvt '];
  44982. this.isOpenType = true;
  44983. } else {
  44984. if (!tables['loca']) {
  44985. error('Required "loca" table is not found');
  44986. }
  44987. if (!tables['glyf']) {
  44988. warn('Required "glyf" table is not found -- trying to recover.');
  44989. tables['glyf'] = {
  44990. tag: 'glyf',
  44991. data: new Uint8Array(0)
  44992. };
  44993. }
  44994. this.isOpenType = false;
  44995. }
  44996. if (!tables['maxp']) {
  44997. error('Required "maxp" table is not found');
  44998. }
  44999. font.pos = (font.start || 0) + tables['maxp'].offset;
  45000. var version = font.getInt32();
  45001. var numGlyphs = font.getUint16();
  45002. var maxFunctionDefs = 0;
  45003. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45004. font.pos += 8;
  45005. var maxZones = font.getUint16();
  45006. if (maxZones > 2) {
  45007. tables['maxp'].data[14] = 0;
  45008. tables['maxp'].data[15] = 2;
  45009. }
  45010. font.pos += 4;
  45011. maxFunctionDefs = font.getUint16();
  45012. }
  45013. var dupFirstEntry = false;
  45014. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45015. dupFirstEntry = true;
  45016. numGlyphs++;
  45017. tables['maxp'].data[4] = numGlyphs >> 8;
  45018. tables['maxp'].data[5] = numGlyphs & 255;
  45019. }
  45020. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45021. if (!hintsValid) {
  45022. delete tables['fpgm'];
  45023. delete tables['prep'];
  45024. delete tables['cvt '];
  45025. }
  45026. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45027. if (!tables['head']) {
  45028. error('Required "head" table is not found');
  45029. }
  45030. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45031. var missingGlyphs = Object.create(null);
  45032. if (isTrueType) {
  45033. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45034. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45035. }
  45036. if (!tables['hhea']) {
  45037. error('Required "hhea" table is not found');
  45038. }
  45039. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45040. tables['hhea'].data[10] = 0xFF;
  45041. tables['hhea'].data[11] = 0xFF;
  45042. }
  45043. var metricsOverride = {
  45044. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45045. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45046. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45047. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45048. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45049. };
  45050. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45051. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45052. if (tables['post']) {
  45053. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45054. if (!valid) {
  45055. tables['post'] = null;
  45056. }
  45057. }
  45058. var charCodeToGlyphId = [], charCode;
  45059. var toUnicode = properties.toUnicode, widths = properties.widths;
  45060. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45061. function hasGlyph(glyphId, charCode, widthCode) {
  45062. if (!missingGlyphs[glyphId]) {
  45063. return true;
  45064. }
  45065. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45066. return true;
  45067. }
  45068. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45069. return true;
  45070. }
  45071. return false;
  45072. }
  45073. if (properties.composite) {
  45074. var cidToGidMap = properties.cidToGidMap || [];
  45075. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45076. properties.cMap.forEach(function (charCode, cid) {
  45077. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45078. var glyphId = -1;
  45079. if (isCidToGidMapEmpty) {
  45080. glyphId = cid;
  45081. } else if (cidToGidMap[cid] !== undefined) {
  45082. glyphId = cidToGidMap[cid];
  45083. }
  45084. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45085. charCodeToGlyphId[charCode] = glyphId;
  45086. }
  45087. });
  45088. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45089. charCodeToGlyphId[0] = numGlyphs - 1;
  45090. }
  45091. } else {
  45092. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45093. var cmapPlatformId = cmapTable.platformId;
  45094. var cmapEncodingId = cmapTable.encodingId;
  45095. var cmapMappings = cmapTable.mappings;
  45096. var cmapMappingsLength = cmapMappings.length;
  45097. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45098. var baseEncoding = [];
  45099. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45100. baseEncoding = getEncoding(properties.baseEncodingName);
  45101. }
  45102. var glyphsUnicodeMap = getGlyphsUnicode();
  45103. for (charCode = 0; charCode < 256; charCode++) {
  45104. var glyphName, standardGlyphName;
  45105. if (this.differences && charCode in this.differences) {
  45106. glyphName = this.differences[charCode];
  45107. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45108. glyphName = baseEncoding[charCode];
  45109. } else {
  45110. glyphName = StandardEncoding[charCode];
  45111. }
  45112. if (!glyphName) {
  45113. continue;
  45114. }
  45115. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45116. var unicodeOrCharCode, isUnicode = false;
  45117. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45118. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45119. isUnicode = true;
  45120. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45121. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45122. }
  45123. var found = false;
  45124. for (i = 0; i < cmapMappingsLength; ++i) {
  45125. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45126. continue;
  45127. }
  45128. var code = isUnicode ? charCode : unicodeOrCharCode;
  45129. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45130. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45131. found = true;
  45132. break;
  45133. }
  45134. }
  45135. if (!found && properties.glyphNames) {
  45136. var glyphId = properties.glyphNames.indexOf(glyphName);
  45137. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45138. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45139. }
  45140. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45141. charCodeToGlyphId[charCode] = glyphId;
  45142. found = true;
  45143. }
  45144. }
  45145. if (!found) {
  45146. charCodeToGlyphId[charCode] = 0;
  45147. }
  45148. }
  45149. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45150. for (i = 0; i < cmapMappingsLength; ++i) {
  45151. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45152. }
  45153. } else {
  45154. for (i = 0; i < cmapMappingsLength; ++i) {
  45155. charCode = cmapMappings[i].charCode & 0xFF;
  45156. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45157. }
  45158. }
  45159. }
  45160. if (charCodeToGlyphId.length === 0) {
  45161. charCodeToGlyphId[0] = 0;
  45162. }
  45163. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45164. this.toFontChar = newMapping.toFontChar;
  45165. tables['cmap'] = {
  45166. tag: 'cmap',
  45167. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45168. };
  45169. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45170. tables['OS/2'] = {
  45171. tag: 'OS/2',
  45172. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45173. };
  45174. }
  45175. if (!tables['post']) {
  45176. tables['post'] = {
  45177. tag: 'post',
  45178. data: createPostTable(properties)
  45179. };
  45180. }
  45181. if (!isTrueType) {
  45182. try {
  45183. cffFile = new Stream(tables['CFF '].data);
  45184. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45185. cff = parser.parse();
  45186. var compiler = new CFFCompiler(cff);
  45187. tables['CFF '].data = compiler.compile();
  45188. } catch (e) {
  45189. warn('Failed to compile font ' + properties.loadedName);
  45190. }
  45191. }
  45192. if (!tables['name']) {
  45193. tables['name'] = {
  45194. tag: 'name',
  45195. data: createNameTable(this.name)
  45196. };
  45197. } else {
  45198. var namePrototype = readNameTable(tables['name']);
  45199. tables['name'].data = createNameTable(name, namePrototype);
  45200. }
  45201. var builder = new OpenTypeFileBuilder(header.version);
  45202. for (var tableTag in tables) {
  45203. builder.addTable(tableTag, tables[tableTag].data);
  45204. }
  45205. return builder.toArray();
  45206. },
  45207. convert: function Font_convert(fontName, font, properties) {
  45208. properties.fixedPitch = false;
  45209. if (properties.builtInEncoding) {
  45210. adjustToUnicode(properties, properties.builtInEncoding);
  45211. }
  45212. var mapping = font.getGlyphMapping(properties);
  45213. var newMapping = adjustMapping(mapping, properties);
  45214. this.toFontChar = newMapping.toFontChar;
  45215. var numGlyphs = font.numGlyphs;
  45216. function getCharCodes(charCodeToGlyphId, glyphId) {
  45217. var charCodes = null;
  45218. for (var charCode in charCodeToGlyphId) {
  45219. if (glyphId === charCodeToGlyphId[charCode]) {
  45220. if (!charCodes) {
  45221. charCodes = [];
  45222. }
  45223. charCodes.push(charCode | 0);
  45224. }
  45225. }
  45226. return charCodes;
  45227. }
  45228. function createCharCode(charCodeToGlyphId, glyphId) {
  45229. for (var charCode in charCodeToGlyphId) {
  45230. if (glyphId === charCodeToGlyphId[charCode]) {
  45231. return charCode | 0;
  45232. }
  45233. }
  45234. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45235. return newMapping.nextAvailableFontCharCode++;
  45236. }
  45237. var seacs = font.seacs;
  45238. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45239. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45240. var charset = font.getCharset();
  45241. var seacMap = Object.create(null);
  45242. for (var glyphId in seacs) {
  45243. glyphId |= 0;
  45244. var seac = seacs[glyphId];
  45245. var baseGlyphName = StandardEncoding[seac[2]];
  45246. var accentGlyphName = StandardEncoding[seac[3]];
  45247. var baseGlyphId = charset.indexOf(baseGlyphName);
  45248. var accentGlyphId = charset.indexOf(accentGlyphName);
  45249. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45250. continue;
  45251. }
  45252. var accentOffset = {
  45253. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45254. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45255. };
  45256. var charCodes = getCharCodes(mapping, glyphId);
  45257. if (!charCodes) {
  45258. continue;
  45259. }
  45260. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45261. var charCode = charCodes[i];
  45262. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45263. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45264. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45265. seacMap[charCode] = {
  45266. baseFontCharCode: baseFontCharCode,
  45267. accentFontCharCode: accentFontCharCode,
  45268. accentOffset: accentOffset
  45269. };
  45270. }
  45271. }
  45272. properties.seacMap = seacMap;
  45273. }
  45274. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45275. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45276. builder.addTable('CFF ', font.data);
  45277. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45278. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45279. 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');
  45280. 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));
  45281. builder.addTable('hmtx', function fontFieldsHmtx() {
  45282. var charstrings = font.charstrings;
  45283. var cffWidths = font.cff ? font.cff.widths : null;
  45284. var hmtx = '\x00\x00\x00\x00';
  45285. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45286. var width = 0;
  45287. if (charstrings) {
  45288. var charstring = charstrings[i - 1];
  45289. width = 'width' in charstring ? charstring.width : 0;
  45290. } else if (cffWidths) {
  45291. width = Math.ceil(cffWidths[i] || 0);
  45292. }
  45293. hmtx += string16(width) + string16(0);
  45294. }
  45295. return hmtx;
  45296. }());
  45297. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45298. builder.addTable('name', createNameTable(fontName));
  45299. builder.addTable('post', createPostTable(properties));
  45300. return builder.toArray();
  45301. },
  45302. get spaceWidth() {
  45303. if ('_shadowWidth' in this) {
  45304. return this._shadowWidth;
  45305. }
  45306. var possibleSpaceReplacements = [
  45307. 'space',
  45308. 'minus',
  45309. 'one',
  45310. 'i',
  45311. 'I'
  45312. ];
  45313. var width;
  45314. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45315. var glyphName = possibleSpaceReplacements[i];
  45316. if (glyphName in this.widths) {
  45317. width = this.widths[glyphName];
  45318. break;
  45319. }
  45320. var glyphsUnicodeMap = getGlyphsUnicode();
  45321. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45322. var charcode = 0;
  45323. if (this.composite) {
  45324. if (this.cMap.contains(glyphUnicode)) {
  45325. charcode = this.cMap.lookup(glyphUnicode);
  45326. }
  45327. }
  45328. if (!charcode && this.toUnicode) {
  45329. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45330. }
  45331. if (charcode <= 0) {
  45332. charcode = glyphUnicode;
  45333. }
  45334. width = this.widths[charcode];
  45335. if (width) {
  45336. break;
  45337. }
  45338. }
  45339. width = width || this.defaultWidth;
  45340. this._shadowWidth = width;
  45341. return width;
  45342. },
  45343. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45344. var fontCharCode, width, operatorListId;
  45345. var widthCode = charcode;
  45346. if (this.cMap && this.cMap.contains(charcode)) {
  45347. widthCode = this.cMap.lookup(charcode);
  45348. }
  45349. width = this.widths[widthCode];
  45350. width = isNum(width) ? width : this.defaultWidth;
  45351. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45352. var unicode = this.toUnicode.get(charcode) || charcode;
  45353. if (typeof unicode === 'number') {
  45354. unicode = String.fromCharCode(unicode);
  45355. }
  45356. var isInFont = charcode in this.toFontChar;
  45357. fontCharCode = this.toFontChar[charcode] || charcode;
  45358. if (this.missingFile) {
  45359. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45360. }
  45361. if (this.isType3Font) {
  45362. operatorListId = fontCharCode;
  45363. }
  45364. var accent = null;
  45365. if (this.seacMap && this.seacMap[charcode]) {
  45366. isInFont = true;
  45367. var seac = this.seacMap[charcode];
  45368. fontCharCode = seac.baseFontCharCode;
  45369. accent = {
  45370. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45371. offset: seac.accentOffset
  45372. };
  45373. }
  45374. var fontChar = String.fromCharCode(fontCharCode);
  45375. var glyph = this.glyphCache[charcode];
  45376. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45377. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45378. this.glyphCache[charcode] = glyph;
  45379. }
  45380. return glyph;
  45381. },
  45382. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45383. var charsCache = this.charsCache;
  45384. var glyphs, glyph, charcode;
  45385. if (charsCache) {
  45386. glyphs = charsCache[chars];
  45387. if (glyphs) {
  45388. return glyphs;
  45389. }
  45390. }
  45391. if (!charsCache) {
  45392. charsCache = this.charsCache = Object.create(null);
  45393. }
  45394. glyphs = [];
  45395. var charsCacheKey = chars;
  45396. var i = 0, ii;
  45397. if (this.cMap) {
  45398. var c = Object.create(null);
  45399. while (i < chars.length) {
  45400. this.cMap.readCharCode(chars, i, c);
  45401. charcode = c.charcode;
  45402. var length = c.length;
  45403. i += length;
  45404. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45405. glyph = this.charToGlyph(charcode, isSpace);
  45406. glyphs.push(glyph);
  45407. }
  45408. } else {
  45409. for (i = 0, ii = chars.length; i < ii; ++i) {
  45410. charcode = chars.charCodeAt(i);
  45411. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45412. glyphs.push(glyph);
  45413. }
  45414. }
  45415. return charsCache[charsCacheKey] = glyphs;
  45416. }
  45417. };
  45418. return Font;
  45419. }();
  45420. var ErrorFont = function ErrorFontClosure() {
  45421. function ErrorFont(error) {
  45422. this.error = error;
  45423. this.loadedName = 'g_font_error';
  45424. this.loading = false;
  45425. }
  45426. ErrorFont.prototype = {
  45427. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45428. return [];
  45429. },
  45430. exportData: function ErrorFont_exportData() {
  45431. return { error: this.error };
  45432. }
  45433. };
  45434. return ErrorFont;
  45435. }();
  45436. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45437. var charCodeToGlyphId = Object.create(null);
  45438. var glyphId, charCode, baseEncoding;
  45439. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45440. if (properties.baseEncodingName) {
  45441. baseEncoding = getEncoding(properties.baseEncodingName);
  45442. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45443. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45444. if (glyphId >= 0) {
  45445. charCodeToGlyphId[charCode] = glyphId;
  45446. } else {
  45447. charCodeToGlyphId[charCode] = 0;
  45448. }
  45449. }
  45450. } else if (isSymbolicFont) {
  45451. for (charCode in builtInEncoding) {
  45452. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45453. }
  45454. } else {
  45455. baseEncoding = StandardEncoding;
  45456. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45457. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45458. if (glyphId >= 0) {
  45459. charCodeToGlyphId[charCode] = glyphId;
  45460. } else {
  45461. charCodeToGlyphId[charCode] = 0;
  45462. }
  45463. }
  45464. }
  45465. var differences = properties.differences, glyphsUnicodeMap;
  45466. if (differences) {
  45467. for (charCode in differences) {
  45468. var glyphName = differences[charCode];
  45469. glyphId = glyphNames.indexOf(glyphName);
  45470. if (glyphId === -1) {
  45471. if (!glyphsUnicodeMap) {
  45472. glyphsUnicodeMap = getGlyphsUnicode();
  45473. }
  45474. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45475. if (standardGlyphName !== glyphName) {
  45476. glyphId = glyphNames.indexOf(standardGlyphName);
  45477. }
  45478. }
  45479. if (glyphId >= 0) {
  45480. charCodeToGlyphId[charCode] = glyphId;
  45481. } else {
  45482. charCodeToGlyphId[charCode] = 0;
  45483. }
  45484. }
  45485. }
  45486. return charCodeToGlyphId;
  45487. }
  45488. var Type1Font = function Type1FontClosure() {
  45489. function findBlock(streamBytes, signature, startIndex) {
  45490. var streamBytesLength = streamBytes.length;
  45491. var signatureLength = signature.length;
  45492. var scanLength = streamBytesLength - signatureLength;
  45493. var i = startIndex, j, found = false;
  45494. while (i < scanLength) {
  45495. j = 0;
  45496. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45497. j++;
  45498. }
  45499. if (j >= signatureLength) {
  45500. i += j;
  45501. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45502. i++;
  45503. }
  45504. found = true;
  45505. break;
  45506. }
  45507. i++;
  45508. }
  45509. return {
  45510. found: found,
  45511. length: i
  45512. };
  45513. }
  45514. function getHeaderBlock(stream, suggestedLength) {
  45515. var EEXEC_SIGNATURE = [
  45516. 0x65,
  45517. 0x65,
  45518. 0x78,
  45519. 0x65,
  45520. 0x63
  45521. ];
  45522. var streamStartPos = stream.pos;
  45523. var headerBytes, headerBytesLength, block;
  45524. try {
  45525. headerBytes = stream.getBytes(suggestedLength);
  45526. headerBytesLength = headerBytes.length;
  45527. } catch (ex) {
  45528. if (ex instanceof MissingDataException) {
  45529. throw ex;
  45530. }
  45531. }
  45532. if (headerBytesLength === suggestedLength) {
  45533. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45534. if (block.found && block.length === suggestedLength) {
  45535. return {
  45536. stream: new Stream(headerBytes),
  45537. length: suggestedLength
  45538. };
  45539. }
  45540. }
  45541. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45542. stream.pos = streamStartPos;
  45543. var SCAN_BLOCK_LENGTH = 2048;
  45544. var actualLength;
  45545. while (true) {
  45546. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45547. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45548. if (block.length === 0) {
  45549. break;
  45550. }
  45551. stream.pos += block.length;
  45552. if (block.found) {
  45553. actualLength = stream.pos - streamStartPos;
  45554. break;
  45555. }
  45556. }
  45557. stream.pos = streamStartPos;
  45558. if (actualLength) {
  45559. return {
  45560. stream: new Stream(stream.getBytes(actualLength)),
  45561. length: actualLength
  45562. };
  45563. }
  45564. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45565. return {
  45566. stream: new Stream(stream.getBytes(suggestedLength)),
  45567. length: suggestedLength
  45568. };
  45569. }
  45570. function getEexecBlock(stream, suggestedLength) {
  45571. var eexecBytes = stream.getBytes();
  45572. return {
  45573. stream: new Stream(eexecBytes),
  45574. length: eexecBytes.length
  45575. };
  45576. }
  45577. function Type1Font(name, file, properties) {
  45578. var PFB_HEADER_SIZE = 6;
  45579. var headerBlockLength = properties.length1;
  45580. var eexecBlockLength = properties.length2;
  45581. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45582. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45583. if (pfbHeaderPresent) {
  45584. file.skip(PFB_HEADER_SIZE);
  45585. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45586. }
  45587. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45588. headerBlockLength = headerBlock.length;
  45589. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45590. headerBlockParser.extractFontHeader(properties);
  45591. if (pfbHeaderPresent) {
  45592. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45593. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45594. }
  45595. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45596. eexecBlockLength = eexecBlock.length;
  45597. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45598. var data = eexecBlockParser.extractFontProgram();
  45599. for (var info in data.properties) {
  45600. properties[info] = data.properties[info];
  45601. }
  45602. var charstrings = data.charstrings;
  45603. var type2Charstrings = this.getType2Charstrings(charstrings);
  45604. var subrs = this.getType2Subrs(data.subrs);
  45605. this.charstrings = charstrings;
  45606. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45607. this.seacs = this.getSeacs(data.charstrings);
  45608. }
  45609. Type1Font.prototype = {
  45610. get numGlyphs() {
  45611. return this.charstrings.length + 1;
  45612. },
  45613. getCharset: function Type1Font_getCharset() {
  45614. var charset = ['.notdef'];
  45615. var charstrings = this.charstrings;
  45616. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45617. charset.push(charstrings[glyphId].glyphName);
  45618. }
  45619. return charset;
  45620. },
  45621. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45622. var charstrings = this.charstrings;
  45623. var glyphNames = ['.notdef'], glyphId;
  45624. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45625. glyphNames.push(charstrings[glyphId].glyphName);
  45626. }
  45627. var encoding = properties.builtInEncoding;
  45628. if (encoding) {
  45629. var builtInEncoding = Object.create(null);
  45630. for (var charCode in encoding) {
  45631. glyphId = glyphNames.indexOf(encoding[charCode]);
  45632. if (glyphId >= 0) {
  45633. builtInEncoding[charCode] = glyphId;
  45634. }
  45635. }
  45636. }
  45637. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45638. },
  45639. getSeacs: function Type1Font_getSeacs(charstrings) {
  45640. var i, ii;
  45641. var seacMap = [];
  45642. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45643. var charstring = charstrings[i];
  45644. if (charstring.seac) {
  45645. seacMap[i + 1] = charstring.seac;
  45646. }
  45647. }
  45648. return seacMap;
  45649. },
  45650. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45651. var type2Charstrings = [];
  45652. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45653. type2Charstrings.push(type1Charstrings[i].charstring);
  45654. }
  45655. return type2Charstrings;
  45656. },
  45657. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45658. var bias = 0;
  45659. var count = type1Subrs.length;
  45660. if (count < 1133) {
  45661. bias = 107;
  45662. } else if (count < 33769) {
  45663. bias = 1131;
  45664. } else {
  45665. bias = 32768;
  45666. }
  45667. var type2Subrs = [];
  45668. var i;
  45669. for (i = 0; i < bias; i++) {
  45670. type2Subrs.push([0x0B]);
  45671. }
  45672. for (i = 0; i < count; i++) {
  45673. type2Subrs.push(type1Subrs[i]);
  45674. }
  45675. return type2Subrs;
  45676. },
  45677. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45678. var cff = new CFF();
  45679. cff.header = new CFFHeader(1, 0, 4, 4);
  45680. cff.names = [name];
  45681. var topDict = new CFFTopDict();
  45682. topDict.setByName('version', 391);
  45683. topDict.setByName('Notice', 392);
  45684. topDict.setByName('FullName', 393);
  45685. topDict.setByName('FamilyName', 394);
  45686. topDict.setByName('Weight', 395);
  45687. topDict.setByName('Encoding', null);
  45688. topDict.setByName('FontMatrix', properties.fontMatrix);
  45689. topDict.setByName('FontBBox', properties.bbox);
  45690. topDict.setByName('charset', null);
  45691. topDict.setByName('CharStrings', null);
  45692. topDict.setByName('Private', null);
  45693. cff.topDict = topDict;
  45694. var strings = new CFFStrings();
  45695. strings.add('Version 0.11');
  45696. strings.add('See original notice');
  45697. strings.add(name);
  45698. strings.add(name);
  45699. strings.add('Medium');
  45700. cff.strings = strings;
  45701. cff.globalSubrIndex = new CFFIndex();
  45702. var count = glyphs.length;
  45703. var charsetArray = [0];
  45704. var i, ii;
  45705. for (i = 0; i < count; i++) {
  45706. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45707. if (index === -1) {
  45708. index = 0;
  45709. }
  45710. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45711. }
  45712. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45713. var charStringsIndex = new CFFIndex();
  45714. charStringsIndex.add([
  45715. 0x8B,
  45716. 0x0E
  45717. ]);
  45718. for (i = 0; i < count; i++) {
  45719. var glyph = glyphs[i];
  45720. if (glyph.length === 0) {
  45721. charStringsIndex.add([
  45722. 0x8B,
  45723. 0x0E
  45724. ]);
  45725. continue;
  45726. }
  45727. charStringsIndex.add(glyph);
  45728. }
  45729. cff.charStrings = charStringsIndex;
  45730. var privateDict = new CFFPrivateDict();
  45731. privateDict.setByName('Subrs', null);
  45732. var fields = [
  45733. 'BlueValues',
  45734. 'OtherBlues',
  45735. 'FamilyBlues',
  45736. 'FamilyOtherBlues',
  45737. 'StemSnapH',
  45738. 'StemSnapV',
  45739. 'BlueShift',
  45740. 'BlueFuzz',
  45741. 'BlueScale',
  45742. 'LanguageGroup',
  45743. 'ExpansionFactor',
  45744. 'ForceBold',
  45745. 'StdHW',
  45746. 'StdVW'
  45747. ];
  45748. for (i = 0, ii = fields.length; i < ii; i++) {
  45749. var field = fields[i];
  45750. if (!(field in properties.privateData)) {
  45751. continue;
  45752. }
  45753. var value = properties.privateData[field];
  45754. if (isArray(value)) {
  45755. for (var j = value.length - 1; j > 0; j--) {
  45756. value[j] -= value[j - 1];
  45757. }
  45758. }
  45759. privateDict.setByName(field, value);
  45760. }
  45761. cff.topDict.privateDict = privateDict;
  45762. var subrIndex = new CFFIndex();
  45763. for (i = 0, ii = subrs.length; i < ii; i++) {
  45764. subrIndex.add(subrs[i]);
  45765. }
  45766. privateDict.subrsIndex = subrIndex;
  45767. var compiler = new CFFCompiler(cff);
  45768. return compiler.compile();
  45769. }
  45770. };
  45771. return Type1Font;
  45772. }();
  45773. var CFFFont = function CFFFontClosure() {
  45774. function CFFFont(file, properties) {
  45775. this.properties = properties;
  45776. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45777. this.cff = parser.parse();
  45778. var compiler = new CFFCompiler(this.cff);
  45779. this.seacs = this.cff.seacs;
  45780. try {
  45781. this.data = compiler.compile();
  45782. } catch (e) {
  45783. warn('Failed to compile font ' + properties.loadedName);
  45784. this.data = file;
  45785. }
  45786. }
  45787. CFFFont.prototype = {
  45788. get numGlyphs() {
  45789. return this.cff.charStrings.count;
  45790. },
  45791. getCharset: function CFFFont_getCharset() {
  45792. return this.cff.charset.charset;
  45793. },
  45794. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45795. var cff = this.cff;
  45796. var properties = this.properties;
  45797. var charsets = cff.charset.charset;
  45798. var charCodeToGlyphId;
  45799. var glyphId;
  45800. if (properties.composite) {
  45801. charCodeToGlyphId = Object.create(null);
  45802. if (cff.isCIDFont) {
  45803. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45804. var cid = charsets[glyphId];
  45805. var charCode = properties.cMap.charCodeOf(cid);
  45806. charCodeToGlyphId[charCode] = glyphId;
  45807. }
  45808. } else {
  45809. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45810. charCodeToGlyphId[glyphId] = glyphId;
  45811. }
  45812. }
  45813. return charCodeToGlyphId;
  45814. }
  45815. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45816. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45817. return charCodeToGlyphId;
  45818. }
  45819. };
  45820. return CFFFont;
  45821. }();
  45822. (function checkSeacSupport() {
  45823. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45824. SEAC_ANALYSIS_ENABLED = true;
  45825. }
  45826. }());
  45827. (function checkChromeWindows() {
  45828. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45829. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45830. }
  45831. }());
  45832. exports.ErrorFont = ErrorFont;
  45833. exports.Font = Font;
  45834. exports.FontFlags = FontFlags;
  45835. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45836. exports.ToUnicodeMap = ToUnicodeMap;
  45837. exports.getFontType = getFontType;
  45838. /***/ }),
  45839. /* 34 */
  45840. /***/ (function(module, exports, __w_pdfjs_require__) {
  45841. "use strict";
  45842. var sharedUtil = __w_pdfjs_require__(0);
  45843. var corePrimitives = __w_pdfjs_require__(1);
  45844. var coreColorSpace = __w_pdfjs_require__(4);
  45845. var coreStream = __w_pdfjs_require__(2);
  45846. var coreJpx = __w_pdfjs_require__(19);
  45847. var ImageKind = sharedUtil.ImageKind;
  45848. var assert = sharedUtil.assert;
  45849. var error = sharedUtil.error;
  45850. var info = sharedUtil.info;
  45851. var isArray = sharedUtil.isArray;
  45852. var warn = sharedUtil.warn;
  45853. var Name = corePrimitives.Name;
  45854. var isStream = corePrimitives.isStream;
  45855. var ColorSpace = coreColorSpace.ColorSpace;
  45856. var DecodeStream = coreStream.DecodeStream;
  45857. var JpegStream = coreStream.JpegStream;
  45858. var JpxImage = coreJpx.JpxImage;
  45859. var PDFImage = function PDFImageClosure() {
  45860. function handleImageData(image, nativeDecoder) {
  45861. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45862. return nativeDecoder.decode(image);
  45863. }
  45864. return Promise.resolve(image);
  45865. }
  45866. function decodeAndClamp(value, addend, coefficient, max) {
  45867. value = addend + value * coefficient;
  45868. return value < 0 ? 0 : value > max ? max : value;
  45869. }
  45870. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45871. var length = w2 * h2;
  45872. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45873. var xRatio = w1 / w2;
  45874. var yRatio = h1 / h2;
  45875. var i, j, py, newIndex = 0, oldIndex;
  45876. var xScaled = new Uint16Array(w2);
  45877. var w1Scanline = w1;
  45878. for (i = 0; i < w2; i++) {
  45879. xScaled[i] = Math.floor(i * xRatio);
  45880. }
  45881. for (i = 0; i < h2; i++) {
  45882. py = Math.floor(i * yRatio) * w1Scanline;
  45883. for (j = 0; j < w2; j++) {
  45884. oldIndex = py + xScaled[j];
  45885. dest[newIndex++] = src[oldIndex];
  45886. }
  45887. }
  45888. return dest;
  45889. }
  45890. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45891. this.image = image;
  45892. var dict = image.dict;
  45893. if (dict.has('Filter')) {
  45894. var filter = dict.get('Filter').name;
  45895. if (filter === 'JPXDecode') {
  45896. var jpxImage = new JpxImage();
  45897. jpxImage.parseImageProperties(image.stream);
  45898. image.stream.reset();
  45899. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45900. image.numComps = jpxImage.componentsCount;
  45901. } else if (filter === 'JBIG2Decode') {
  45902. image.bitsPerComponent = 1;
  45903. image.numComps = 1;
  45904. }
  45905. }
  45906. this.width = dict.get('Width', 'W');
  45907. this.height = dict.get('Height', 'H');
  45908. if (this.width < 1 || this.height < 1) {
  45909. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45910. }
  45911. this.interpolate = dict.get('Interpolate', 'I') || false;
  45912. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45913. this.matte = dict.get('Matte') || false;
  45914. var bitsPerComponent = image.bitsPerComponent;
  45915. if (!bitsPerComponent) {
  45916. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45917. if (!bitsPerComponent) {
  45918. if (this.imageMask) {
  45919. bitsPerComponent = 1;
  45920. } else {
  45921. error('Bits per component missing in image: ' + this.imageMask);
  45922. }
  45923. }
  45924. }
  45925. this.bpc = bitsPerComponent;
  45926. if (!this.imageMask) {
  45927. var colorSpace = dict.get('ColorSpace', 'CS');
  45928. if (!colorSpace) {
  45929. info('JPX images (which do not require color spaces)');
  45930. switch (image.numComps) {
  45931. case 1:
  45932. colorSpace = Name.get('DeviceGray');
  45933. break;
  45934. case 3:
  45935. colorSpace = Name.get('DeviceRGB');
  45936. break;
  45937. case 4:
  45938. colorSpace = Name.get('DeviceCMYK');
  45939. break;
  45940. default:
  45941. error('JPX images with ' + this.numComps + ' color components not supported.');
  45942. }
  45943. }
  45944. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45945. this.numComps = this.colorSpace.numComps;
  45946. }
  45947. this.decode = dict.getArray('Decode', 'D');
  45948. this.needsDecode = false;
  45949. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45950. this.needsDecode = true;
  45951. var max = (1 << bitsPerComponent) - 1;
  45952. this.decodeCoefficients = [];
  45953. this.decodeAddends = [];
  45954. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45955. var dmin = this.decode[i];
  45956. var dmax = this.decode[i + 1];
  45957. this.decodeCoefficients[j] = dmax - dmin;
  45958. this.decodeAddends[j] = max * dmin;
  45959. }
  45960. }
  45961. if (smask) {
  45962. this.smask = new PDFImage(xref, res, smask, false);
  45963. } else if (mask) {
  45964. if (isStream(mask)) {
  45965. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45966. if (!imageMask) {
  45967. warn('Ignoring /Mask in image without /ImageMask.');
  45968. } else {
  45969. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45970. }
  45971. } else {
  45972. this.mask = mask;
  45973. }
  45974. }
  45975. }
  45976. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  45977. var imagePromise = handleImageData(image, nativeDecoder);
  45978. var smaskPromise;
  45979. var maskPromise;
  45980. var smask = image.dict.get('SMask');
  45981. var mask = image.dict.get('Mask');
  45982. if (smask) {
  45983. smaskPromise = handleImageData(smask, nativeDecoder);
  45984. maskPromise = Promise.resolve(null);
  45985. } else {
  45986. smaskPromise = Promise.resolve(null);
  45987. if (mask) {
  45988. if (isStream(mask)) {
  45989. maskPromise = handleImageData(mask, nativeDecoder);
  45990. } else if (isArray(mask)) {
  45991. maskPromise = Promise.resolve(mask);
  45992. } else {
  45993. warn('Unsupported mask format.');
  45994. maskPromise = Promise.resolve(null);
  45995. }
  45996. } else {
  45997. maskPromise = Promise.resolve(null);
  45998. }
  45999. }
  46000. return Promise.all([
  46001. imagePromise,
  46002. smaskPromise,
  46003. maskPromise
  46004. ]).then(function (results) {
  46005. var imageData = results[0];
  46006. var smaskData = results[1];
  46007. var maskData = results[2];
  46008. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46009. });
  46010. };
  46011. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46012. var computedLength = (width + 7 >> 3) * height;
  46013. var actualLength = imgArray.byteLength;
  46014. var haveFullData = computedLength === actualLength;
  46015. var data, i;
  46016. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46017. data = imgArray;
  46018. } else if (!inverseDecode) {
  46019. data = new Uint8Array(actualLength);
  46020. data.set(imgArray);
  46021. } else {
  46022. data = new Uint8Array(computedLength);
  46023. data.set(imgArray);
  46024. for (i = actualLength; i < computedLength; i++) {
  46025. data[i] = 0xff;
  46026. }
  46027. }
  46028. if (inverseDecode) {
  46029. for (i = 0; i < actualLength; i++) {
  46030. data[i] = ~data[i];
  46031. }
  46032. }
  46033. return {
  46034. data: data,
  46035. width: width,
  46036. height: height
  46037. };
  46038. };
  46039. PDFImage.prototype = {
  46040. get drawWidth() {
  46041. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46042. },
  46043. get drawHeight() {
  46044. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46045. },
  46046. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46047. var bpc = this.bpc;
  46048. var numComps = this.numComps;
  46049. var decodeAddends = this.decodeAddends;
  46050. var decodeCoefficients = this.decodeCoefficients;
  46051. var max = (1 << bpc) - 1;
  46052. var i, ii;
  46053. if (bpc === 1) {
  46054. for (i = 0, ii = buffer.length; i < ii; i++) {
  46055. buffer[i] = +!buffer[i];
  46056. }
  46057. return;
  46058. }
  46059. var index = 0;
  46060. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46061. for (var j = 0; j < numComps; j++) {
  46062. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46063. index++;
  46064. }
  46065. }
  46066. },
  46067. getComponents: function PDFImage_getComponents(buffer) {
  46068. var bpc = this.bpc;
  46069. if (bpc === 8) {
  46070. return buffer;
  46071. }
  46072. var width = this.width;
  46073. var height = this.height;
  46074. var numComps = this.numComps;
  46075. var length = width * height * numComps;
  46076. var bufferPos = 0;
  46077. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46078. var rowComps = width * numComps;
  46079. var max = (1 << bpc) - 1;
  46080. var i = 0, ii, buf;
  46081. if (bpc === 1) {
  46082. var mask, loop1End, loop2End;
  46083. for (var j = 0; j < height; j++) {
  46084. loop1End = i + (rowComps & ~7);
  46085. loop2End = i + rowComps;
  46086. while (i < loop1End) {
  46087. buf = buffer[bufferPos++];
  46088. output[i] = buf >> 7 & 1;
  46089. output[i + 1] = buf >> 6 & 1;
  46090. output[i + 2] = buf >> 5 & 1;
  46091. output[i + 3] = buf >> 4 & 1;
  46092. output[i + 4] = buf >> 3 & 1;
  46093. output[i + 5] = buf >> 2 & 1;
  46094. output[i + 6] = buf >> 1 & 1;
  46095. output[i + 7] = buf & 1;
  46096. i += 8;
  46097. }
  46098. if (i < loop2End) {
  46099. buf = buffer[bufferPos++];
  46100. mask = 128;
  46101. while (i < loop2End) {
  46102. output[i++] = +!!(buf & mask);
  46103. mask >>= 1;
  46104. }
  46105. }
  46106. }
  46107. } else {
  46108. var bits = 0;
  46109. buf = 0;
  46110. for (i = 0, ii = length; i < ii; ++i) {
  46111. if (i % rowComps === 0) {
  46112. buf = 0;
  46113. bits = 0;
  46114. }
  46115. while (bits < bpc) {
  46116. buf = buf << 8 | buffer[bufferPos++];
  46117. bits += 8;
  46118. }
  46119. var remainingBits = bits - bpc;
  46120. var value = buf >> remainingBits;
  46121. output[i] = value < 0 ? 0 : value > max ? max : value;
  46122. buf = buf & (1 << remainingBits) - 1;
  46123. bits = remainingBits;
  46124. }
  46125. }
  46126. return output;
  46127. },
  46128. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46129. var smask = this.smask;
  46130. var mask = this.mask;
  46131. var alphaBuf, sw, sh, i, ii, j;
  46132. if (smask) {
  46133. sw = smask.width;
  46134. sh = smask.height;
  46135. alphaBuf = new Uint8Array(sw * sh);
  46136. smask.fillGrayBuffer(alphaBuf);
  46137. if (sw !== width || sh !== height) {
  46138. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46139. }
  46140. } else if (mask) {
  46141. if (mask instanceof PDFImage) {
  46142. sw = mask.width;
  46143. sh = mask.height;
  46144. alphaBuf = new Uint8Array(sw * sh);
  46145. mask.numComps = 1;
  46146. mask.fillGrayBuffer(alphaBuf);
  46147. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46148. alphaBuf[i] = 255 - alphaBuf[i];
  46149. }
  46150. if (sw !== width || sh !== height) {
  46151. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46152. }
  46153. } else if (isArray(mask)) {
  46154. alphaBuf = new Uint8Array(width * height);
  46155. var numComps = this.numComps;
  46156. for (i = 0, ii = width * height; i < ii; ++i) {
  46157. var opacity = 0;
  46158. var imageOffset = i * numComps;
  46159. for (j = 0; j < numComps; ++j) {
  46160. var color = image[imageOffset + j];
  46161. var maskOffset = j * 2;
  46162. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46163. opacity = 255;
  46164. break;
  46165. }
  46166. }
  46167. alphaBuf[i] = opacity;
  46168. }
  46169. } else {
  46170. error('Unknown mask format.');
  46171. }
  46172. }
  46173. if (alphaBuf) {
  46174. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46175. rgbaBuf[j] = alphaBuf[i];
  46176. }
  46177. } else {
  46178. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46179. rgbaBuf[j] = 255;
  46180. }
  46181. }
  46182. },
  46183. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46184. var matte = this.smask && this.smask.matte;
  46185. if (!matte) {
  46186. return;
  46187. }
  46188. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46189. var matteR = matteRgb[0];
  46190. var matteG = matteRgb[1];
  46191. var matteB = matteRgb[2];
  46192. var length = width * height * 4;
  46193. var r, g, b;
  46194. for (var i = 0; i < length; i += 4) {
  46195. var alpha = buffer[i + 3];
  46196. if (alpha === 0) {
  46197. buffer[i] = 255;
  46198. buffer[i + 1] = 255;
  46199. buffer[i + 2] = 255;
  46200. continue;
  46201. }
  46202. var k = 255 / alpha;
  46203. r = (buffer[i] - matteR) * k + matteR;
  46204. g = (buffer[i + 1] - matteG) * k + matteG;
  46205. b = (buffer[i + 2] - matteB) * k + matteB;
  46206. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46207. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46208. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46209. }
  46210. },
  46211. createImageData: function PDFImage_createImageData(forceRGBA) {
  46212. var drawWidth = this.drawWidth;
  46213. var drawHeight = this.drawHeight;
  46214. var imgData = {
  46215. width: drawWidth,
  46216. height: drawHeight
  46217. };
  46218. var numComps = this.numComps;
  46219. var originalWidth = this.width;
  46220. var originalHeight = this.height;
  46221. var bpc = this.bpc;
  46222. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46223. var imgArray;
  46224. if (!forceRGBA) {
  46225. var kind;
  46226. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46227. kind = ImageKind.GRAYSCALE_1BPP;
  46228. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46229. kind = ImageKind.RGB_24BPP;
  46230. }
  46231. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46232. imgData.kind = kind;
  46233. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46234. if (this.image instanceof DecodeStream) {
  46235. imgData.data = imgArray;
  46236. } else {
  46237. var newArray = new Uint8Array(imgArray.length);
  46238. newArray.set(imgArray);
  46239. imgData.data = newArray;
  46240. }
  46241. if (this.needsDecode) {
  46242. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46243. var buffer = imgData.data;
  46244. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46245. buffer[i] ^= 0xff;
  46246. }
  46247. }
  46248. return imgData;
  46249. }
  46250. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46251. imgData.kind = ImageKind.RGB_24BPP;
  46252. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46253. return imgData;
  46254. }
  46255. }
  46256. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46257. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46258. var comps = this.getComponents(imgArray);
  46259. var alpha01, maybeUndoPreblend;
  46260. if (!forceRGBA && !this.smask && !this.mask) {
  46261. imgData.kind = ImageKind.RGB_24BPP;
  46262. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46263. alpha01 = 0;
  46264. maybeUndoPreblend = false;
  46265. } else {
  46266. imgData.kind = ImageKind.RGBA_32BPP;
  46267. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46268. alpha01 = 1;
  46269. maybeUndoPreblend = true;
  46270. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46271. }
  46272. if (this.needsDecode) {
  46273. this.decodeBuffer(comps);
  46274. }
  46275. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46276. if (maybeUndoPreblend) {
  46277. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46278. }
  46279. return imgData;
  46280. },
  46281. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46282. var numComps = this.numComps;
  46283. if (numComps !== 1) {
  46284. error('Reading gray scale from a color image: ' + numComps);
  46285. }
  46286. var width = this.width;
  46287. var height = this.height;
  46288. var bpc = this.bpc;
  46289. var rowBytes = width * numComps * bpc + 7 >> 3;
  46290. var imgArray = this.getImageBytes(height * rowBytes);
  46291. var comps = this.getComponents(imgArray);
  46292. var i, length;
  46293. if (bpc === 1) {
  46294. length = width * height;
  46295. if (this.needsDecode) {
  46296. for (i = 0; i < length; ++i) {
  46297. buffer[i] = comps[i] - 1 & 255;
  46298. }
  46299. } else {
  46300. for (i = 0; i < length; ++i) {
  46301. buffer[i] = -comps[i] & 255;
  46302. }
  46303. }
  46304. return;
  46305. }
  46306. if (this.needsDecode) {
  46307. this.decodeBuffer(comps);
  46308. }
  46309. length = width * height;
  46310. var scale = 255 / ((1 << bpc) - 1);
  46311. for (i = 0; i < length; ++i) {
  46312. buffer[i] = scale * comps[i] | 0;
  46313. }
  46314. },
  46315. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46316. this.image.reset();
  46317. this.image.drawWidth = drawWidth || this.width;
  46318. this.image.drawHeight = drawHeight || this.height;
  46319. this.image.forceRGB = !!forceRGB;
  46320. return this.image.getBytes(length);
  46321. }
  46322. };
  46323. return PDFImage;
  46324. }();
  46325. exports.PDFImage = PDFImage;
  46326. /***/ }),
  46327. /* 35 */
  46328. /***/ (function(module, exports, __w_pdfjs_require__) {
  46329. "use strict";
  46330. var sharedUtil = __w_pdfjs_require__(0);
  46331. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46332. var error = sharedUtil.error;
  46333. var log2 = sharedUtil.log2;
  46334. var readInt8 = sharedUtil.readInt8;
  46335. var readUint16 = sharedUtil.readUint16;
  46336. var readUint32 = sharedUtil.readUint32;
  46337. var shadow = sharedUtil.shadow;
  46338. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46339. var Jbig2Image = function Jbig2ImageClosure() {
  46340. function ContextCache() {
  46341. }
  46342. ContextCache.prototype = {
  46343. getContexts: function (id) {
  46344. if (id in this) {
  46345. return this[id];
  46346. }
  46347. return this[id] = new Int8Array(1 << 16);
  46348. }
  46349. };
  46350. function DecodingContext(data, start, end) {
  46351. this.data = data;
  46352. this.start = start;
  46353. this.end = end;
  46354. }
  46355. DecodingContext.prototype = {
  46356. get decoder() {
  46357. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46358. return shadow(this, 'decoder', decoder);
  46359. },
  46360. get contextCache() {
  46361. var cache = new ContextCache();
  46362. return shadow(this, 'contextCache', cache);
  46363. }
  46364. };
  46365. function decodeInteger(contextCache, procedure, decoder) {
  46366. var contexts = contextCache.getContexts(procedure);
  46367. var prev = 1;
  46368. function readBits(length) {
  46369. var v = 0;
  46370. for (var i = 0; i < length; i++) {
  46371. var bit = decoder.readBit(contexts, prev);
  46372. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46373. v = v << 1 | bit;
  46374. }
  46375. return v >>> 0;
  46376. }
  46377. var sign = readBits(1);
  46378. 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);
  46379. return sign === 0 ? value : value > 0 ? -value : null;
  46380. }
  46381. function decodeIAID(contextCache, decoder, codeLength) {
  46382. var contexts = contextCache.getContexts('IAID');
  46383. var prev = 1;
  46384. for (var i = 0; i < codeLength; i++) {
  46385. var bit = decoder.readBit(contexts, prev);
  46386. prev = prev << 1 | bit;
  46387. }
  46388. if (codeLength < 31) {
  46389. return prev & (1 << codeLength) - 1;
  46390. }
  46391. return prev & 0x7FFFFFFF;
  46392. }
  46393. var SegmentTypes = [
  46394. 'SymbolDictionary',
  46395. null,
  46396. null,
  46397. null,
  46398. 'IntermediateTextRegion',
  46399. null,
  46400. 'ImmediateTextRegion',
  46401. 'ImmediateLosslessTextRegion',
  46402. null,
  46403. null,
  46404. null,
  46405. null,
  46406. null,
  46407. null,
  46408. null,
  46409. null,
  46410. 'patternDictionary',
  46411. null,
  46412. null,
  46413. null,
  46414. 'IntermediateHalftoneRegion',
  46415. null,
  46416. 'ImmediateHalftoneRegion',
  46417. 'ImmediateLosslessHalftoneRegion',
  46418. null,
  46419. null,
  46420. null,
  46421. null,
  46422. null,
  46423. null,
  46424. null,
  46425. null,
  46426. null,
  46427. null,
  46428. null,
  46429. null,
  46430. 'IntermediateGenericRegion',
  46431. null,
  46432. 'ImmediateGenericRegion',
  46433. 'ImmediateLosslessGenericRegion',
  46434. 'IntermediateGenericRefinementRegion',
  46435. null,
  46436. 'ImmediateGenericRefinementRegion',
  46437. 'ImmediateLosslessGenericRefinementRegion',
  46438. null,
  46439. null,
  46440. null,
  46441. null,
  46442. 'PageInformation',
  46443. 'EndOfPage',
  46444. 'EndOfStripe',
  46445. 'EndOfFile',
  46446. 'Profiles',
  46447. 'Tables',
  46448. null,
  46449. null,
  46450. null,
  46451. null,
  46452. null,
  46453. null,
  46454. null,
  46455. null,
  46456. 'Extension'
  46457. ];
  46458. var CodingTemplates = [
  46459. [
  46460. {
  46461. x: -1,
  46462. y: -2
  46463. },
  46464. {
  46465. x: 0,
  46466. y: -2
  46467. },
  46468. {
  46469. x: 1,
  46470. y: -2
  46471. },
  46472. {
  46473. x: -2,
  46474. y: -1
  46475. },
  46476. {
  46477. x: -1,
  46478. y: -1
  46479. },
  46480. {
  46481. x: 0,
  46482. y: -1
  46483. },
  46484. {
  46485. x: 1,
  46486. y: -1
  46487. },
  46488. {
  46489. x: 2,
  46490. y: -1
  46491. },
  46492. {
  46493. x: -4,
  46494. y: 0
  46495. },
  46496. {
  46497. x: -3,
  46498. y: 0
  46499. },
  46500. {
  46501. x: -2,
  46502. y: 0
  46503. },
  46504. {
  46505. x: -1,
  46506. y: 0
  46507. }
  46508. ],
  46509. [
  46510. {
  46511. x: -1,
  46512. y: -2
  46513. },
  46514. {
  46515. x: 0,
  46516. y: -2
  46517. },
  46518. {
  46519. x: 1,
  46520. y: -2
  46521. },
  46522. {
  46523. x: 2,
  46524. y: -2
  46525. },
  46526. {
  46527. x: -2,
  46528. y: -1
  46529. },
  46530. {
  46531. x: -1,
  46532. y: -1
  46533. },
  46534. {
  46535. x: 0,
  46536. y: -1
  46537. },
  46538. {
  46539. x: 1,
  46540. y: -1
  46541. },
  46542. {
  46543. x: 2,
  46544. y: -1
  46545. },
  46546. {
  46547. x: -3,
  46548. y: 0
  46549. },
  46550. {
  46551. x: -2,
  46552. y: 0
  46553. },
  46554. {
  46555. x: -1,
  46556. y: 0
  46557. }
  46558. ],
  46559. [
  46560. {
  46561. x: -1,
  46562. y: -2
  46563. },
  46564. {
  46565. x: 0,
  46566. y: -2
  46567. },
  46568. {
  46569. x: 1,
  46570. y: -2
  46571. },
  46572. {
  46573. x: -2,
  46574. y: -1
  46575. },
  46576. {
  46577. x: -1,
  46578. y: -1
  46579. },
  46580. {
  46581. x: 0,
  46582. y: -1
  46583. },
  46584. {
  46585. x: 1,
  46586. y: -1
  46587. },
  46588. {
  46589. x: -2,
  46590. y: 0
  46591. },
  46592. {
  46593. x: -1,
  46594. y: 0
  46595. }
  46596. ],
  46597. [
  46598. {
  46599. x: -3,
  46600. y: -1
  46601. },
  46602. {
  46603. x: -2,
  46604. y: -1
  46605. },
  46606. {
  46607. x: -1,
  46608. y: -1
  46609. },
  46610. {
  46611. x: 0,
  46612. y: -1
  46613. },
  46614. {
  46615. x: 1,
  46616. y: -1
  46617. },
  46618. {
  46619. x: -4,
  46620. y: 0
  46621. },
  46622. {
  46623. x: -3,
  46624. y: 0
  46625. },
  46626. {
  46627. x: -2,
  46628. y: 0
  46629. },
  46630. {
  46631. x: -1,
  46632. y: 0
  46633. }
  46634. ]
  46635. ];
  46636. var RefinementTemplates = [
  46637. {
  46638. coding: [
  46639. {
  46640. x: 0,
  46641. y: -1
  46642. },
  46643. {
  46644. x: 1,
  46645. y: -1
  46646. },
  46647. {
  46648. x: -1,
  46649. y: 0
  46650. }
  46651. ],
  46652. reference: [
  46653. {
  46654. x: 0,
  46655. y: -1
  46656. },
  46657. {
  46658. x: 1,
  46659. y: -1
  46660. },
  46661. {
  46662. x: -1,
  46663. y: 0
  46664. },
  46665. {
  46666. x: 0,
  46667. y: 0
  46668. },
  46669. {
  46670. x: 1,
  46671. y: 0
  46672. },
  46673. {
  46674. x: -1,
  46675. y: 1
  46676. },
  46677. {
  46678. x: 0,
  46679. y: 1
  46680. },
  46681. {
  46682. x: 1,
  46683. y: 1
  46684. }
  46685. ]
  46686. },
  46687. {
  46688. coding: [
  46689. {
  46690. x: -1,
  46691. y: -1
  46692. },
  46693. {
  46694. x: 0,
  46695. y: -1
  46696. },
  46697. {
  46698. x: 1,
  46699. y: -1
  46700. },
  46701. {
  46702. x: -1,
  46703. y: 0
  46704. }
  46705. ],
  46706. reference: [
  46707. {
  46708. x: 0,
  46709. y: -1
  46710. },
  46711. {
  46712. x: -1,
  46713. y: 0
  46714. },
  46715. {
  46716. x: 0,
  46717. y: 0
  46718. },
  46719. {
  46720. x: 1,
  46721. y: 0
  46722. },
  46723. {
  46724. x: 0,
  46725. y: 1
  46726. },
  46727. {
  46728. x: 1,
  46729. y: 1
  46730. }
  46731. ]
  46732. }
  46733. ];
  46734. var ReusedContexts = [
  46735. 0x9B25,
  46736. 0x0795,
  46737. 0x00E5,
  46738. 0x0195
  46739. ];
  46740. var RefinementReusedContexts = [
  46741. 0x0020,
  46742. 0x0008
  46743. ];
  46744. function decodeBitmapTemplate0(width, height, decodingContext) {
  46745. var decoder = decodingContext.decoder;
  46746. var contexts = decodingContext.contextCache.getContexts('GB');
  46747. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46748. var OLD_PIXEL_MASK = 0x7BF7;
  46749. for (i = 0; i < height; i++) {
  46750. row = bitmap[i] = new Uint8Array(width);
  46751. row1 = i < 1 ? row : bitmap[i - 1];
  46752. row2 = i < 2 ? row : bitmap[i - 2];
  46753. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46754. for (j = 0; j < width; j++) {
  46755. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46756. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46757. }
  46758. }
  46759. return bitmap;
  46760. }
  46761. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46762. if (mmr) {
  46763. error('JBIG2 error: MMR encoding is not supported');
  46764. }
  46765. 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) {
  46766. return decodeBitmapTemplate0(width, height, decodingContext);
  46767. }
  46768. var useskip = !!skip;
  46769. var template = CodingTemplates[templateIndex].concat(at);
  46770. template.sort(function (a, b) {
  46771. return a.y - b.y || a.x - b.x;
  46772. });
  46773. var templateLength = template.length;
  46774. var templateX = new Int8Array(templateLength);
  46775. var templateY = new Int8Array(templateLength);
  46776. var changingTemplateEntries = [];
  46777. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46778. var c, k;
  46779. for (k = 0; k < templateLength; k++) {
  46780. templateX[k] = template[k].x;
  46781. templateY[k] = template[k].y;
  46782. minX = Math.min(minX, template[k].x);
  46783. maxX = Math.max(maxX, template[k].x);
  46784. minY = Math.min(minY, template[k].y);
  46785. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46786. reuseMask |= 1 << templateLength - 1 - k;
  46787. } else {
  46788. changingTemplateEntries.push(k);
  46789. }
  46790. }
  46791. var changingEntriesLength = changingTemplateEntries.length;
  46792. var changingTemplateX = new Int8Array(changingEntriesLength);
  46793. var changingTemplateY = new Int8Array(changingEntriesLength);
  46794. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46795. for (c = 0; c < changingEntriesLength; c++) {
  46796. k = changingTemplateEntries[c];
  46797. changingTemplateX[c] = template[k].x;
  46798. changingTemplateY[c] = template[k].y;
  46799. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46800. }
  46801. var sbb_left = -minX;
  46802. var sbb_top = -minY;
  46803. var sbb_right = width - maxX;
  46804. var pseudoPixelContext = ReusedContexts[templateIndex];
  46805. var row = new Uint8Array(width);
  46806. var bitmap = [];
  46807. var decoder = decodingContext.decoder;
  46808. var contexts = decodingContext.contextCache.getContexts('GB');
  46809. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46810. for (var i = 0; i < height; i++) {
  46811. if (prediction) {
  46812. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46813. ltp ^= sltp;
  46814. if (ltp) {
  46815. bitmap.push(row);
  46816. continue;
  46817. }
  46818. }
  46819. row = new Uint8Array(row);
  46820. bitmap.push(row);
  46821. for (j = 0; j < width; j++) {
  46822. if (useskip && skip[i][j]) {
  46823. row[j] = 0;
  46824. continue;
  46825. }
  46826. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46827. contextLabel = contextLabel << 1 & reuseMask;
  46828. for (k = 0; k < changingEntriesLength; k++) {
  46829. i0 = i + changingTemplateY[k];
  46830. j0 = j + changingTemplateX[k];
  46831. bit = bitmap[i0][j0];
  46832. if (bit) {
  46833. bit = changingTemplateBit[k];
  46834. contextLabel |= bit;
  46835. }
  46836. }
  46837. } else {
  46838. contextLabel = 0;
  46839. shift = templateLength - 1;
  46840. for (k = 0; k < templateLength; k++, shift--) {
  46841. j0 = j + templateX[k];
  46842. if (j0 >= 0 && j0 < width) {
  46843. i0 = i + templateY[k];
  46844. if (i0 >= 0) {
  46845. bit = bitmap[i0][j0];
  46846. if (bit) {
  46847. contextLabel |= bit << shift;
  46848. }
  46849. }
  46850. }
  46851. }
  46852. }
  46853. var pixel = decoder.readBit(contexts, contextLabel);
  46854. row[j] = pixel;
  46855. }
  46856. }
  46857. return bitmap;
  46858. }
  46859. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46860. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46861. if (templateIndex === 0) {
  46862. codingTemplate = codingTemplate.concat([at[0]]);
  46863. }
  46864. var codingTemplateLength = codingTemplate.length;
  46865. var codingTemplateX = new Int32Array(codingTemplateLength);
  46866. var codingTemplateY = new Int32Array(codingTemplateLength);
  46867. var k;
  46868. for (k = 0; k < codingTemplateLength; k++) {
  46869. codingTemplateX[k] = codingTemplate[k].x;
  46870. codingTemplateY[k] = codingTemplate[k].y;
  46871. }
  46872. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46873. if (templateIndex === 0) {
  46874. referenceTemplate = referenceTemplate.concat([at[1]]);
  46875. }
  46876. var referenceTemplateLength = referenceTemplate.length;
  46877. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46878. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46879. for (k = 0; k < referenceTemplateLength; k++) {
  46880. referenceTemplateX[k] = referenceTemplate[k].x;
  46881. referenceTemplateY[k] = referenceTemplate[k].y;
  46882. }
  46883. var referenceWidth = referenceBitmap[0].length;
  46884. var referenceHeight = referenceBitmap.length;
  46885. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46886. var bitmap = [];
  46887. var decoder = decodingContext.decoder;
  46888. var contexts = decodingContext.contextCache.getContexts('GR');
  46889. var ltp = 0;
  46890. for (var i = 0; i < height; i++) {
  46891. if (prediction) {
  46892. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46893. ltp ^= sltp;
  46894. if (ltp) {
  46895. error('JBIG2 error: prediction is not supported');
  46896. }
  46897. }
  46898. var row = new Uint8Array(width);
  46899. bitmap.push(row);
  46900. for (var j = 0; j < width; j++) {
  46901. var i0, j0;
  46902. var contextLabel = 0;
  46903. for (k = 0; k < codingTemplateLength; k++) {
  46904. i0 = i + codingTemplateY[k];
  46905. j0 = j + codingTemplateX[k];
  46906. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46907. contextLabel <<= 1;
  46908. } else {
  46909. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46910. }
  46911. }
  46912. for (k = 0; k < referenceTemplateLength; k++) {
  46913. i0 = i + referenceTemplateY[k] + offsetY;
  46914. j0 = j + referenceTemplateX[k] + offsetX;
  46915. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46916. contextLabel <<= 1;
  46917. } else {
  46918. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46919. }
  46920. }
  46921. var pixel = decoder.readBit(contexts, contextLabel);
  46922. row[j] = pixel;
  46923. }
  46924. }
  46925. return bitmap;
  46926. }
  46927. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46928. if (huffman) {
  46929. error('JBIG2 error: huffman is not supported');
  46930. }
  46931. var newSymbols = [];
  46932. var currentHeight = 0;
  46933. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46934. var decoder = decodingContext.decoder;
  46935. var contextCache = decodingContext.contextCache;
  46936. while (newSymbols.length < numberOfNewSymbols) {
  46937. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46938. currentHeight += deltaHeight;
  46939. var currentWidth = 0;
  46940. while (true) {
  46941. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46942. if (deltaWidth === null) {
  46943. break;
  46944. }
  46945. currentWidth += deltaWidth;
  46946. var bitmap;
  46947. if (refinement) {
  46948. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46949. if (numberOfInstances > 1) {
  46950. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46951. } else {
  46952. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46953. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46954. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46955. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46956. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46957. }
  46958. } else {
  46959. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46960. }
  46961. newSymbols.push(bitmap);
  46962. }
  46963. }
  46964. var exportedSymbols = [];
  46965. var flags = [], currentFlag = false;
  46966. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46967. while (flags.length < totalSymbolsLength) {
  46968. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46969. while (runLength--) {
  46970. flags.push(currentFlag);
  46971. }
  46972. currentFlag = !currentFlag;
  46973. }
  46974. for (var i = 0, ii = symbols.length; i < ii; i++) {
  46975. if (flags[i]) {
  46976. exportedSymbols.push(symbols[i]);
  46977. }
  46978. }
  46979. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  46980. if (flags[i]) {
  46981. exportedSymbols.push(newSymbols[j]);
  46982. }
  46983. }
  46984. return exportedSymbols;
  46985. }
  46986. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  46987. if (huffman) {
  46988. error('JBIG2 error: huffman is not supported');
  46989. }
  46990. var bitmap = [];
  46991. var i, row;
  46992. for (i = 0; i < height; i++) {
  46993. row = new Uint8Array(width);
  46994. if (defaultPixelValue) {
  46995. for (var j = 0; j < width; j++) {
  46996. row[j] = defaultPixelValue;
  46997. }
  46998. }
  46999. bitmap.push(row);
  47000. }
  47001. var decoder = decodingContext.decoder;
  47002. var contextCache = decodingContext.contextCache;
  47003. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47004. var firstS = 0;
  47005. i = 0;
  47006. while (i < numberOfSymbolInstances) {
  47007. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47008. stripT += deltaT;
  47009. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47010. firstS += deltaFirstS;
  47011. var currentS = firstS;
  47012. do {
  47013. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47014. var t = stripSize * stripT + currentT;
  47015. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47016. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47017. var symbolBitmap = inputSymbols[symbolId];
  47018. var symbolWidth = symbolBitmap[0].length;
  47019. var symbolHeight = symbolBitmap.length;
  47020. if (applyRefinement) {
  47021. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47022. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47023. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47024. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47025. symbolWidth += rdw;
  47026. symbolHeight += rdh;
  47027. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47028. }
  47029. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47030. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47031. var s2, t2, symbolRow;
  47032. if (transposed) {
  47033. for (s2 = 0; s2 < symbolHeight; s2++) {
  47034. row = bitmap[offsetS + s2];
  47035. if (!row) {
  47036. continue;
  47037. }
  47038. symbolRow = symbolBitmap[s2];
  47039. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47040. switch (combinationOperator) {
  47041. case 0:
  47042. for (t2 = 0; t2 < maxWidth; t2++) {
  47043. row[offsetT + t2] |= symbolRow[t2];
  47044. }
  47045. break;
  47046. case 2:
  47047. for (t2 = 0; t2 < maxWidth; t2++) {
  47048. row[offsetT + t2] ^= symbolRow[t2];
  47049. }
  47050. break;
  47051. default:
  47052. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47053. }
  47054. }
  47055. currentS += symbolHeight - 1;
  47056. } else {
  47057. for (t2 = 0; t2 < symbolHeight; t2++) {
  47058. row = bitmap[offsetT + t2];
  47059. if (!row) {
  47060. continue;
  47061. }
  47062. symbolRow = symbolBitmap[t2];
  47063. switch (combinationOperator) {
  47064. case 0:
  47065. for (s2 = 0; s2 < symbolWidth; s2++) {
  47066. row[offsetS + s2] |= symbolRow[s2];
  47067. }
  47068. break;
  47069. case 2:
  47070. for (s2 = 0; s2 < symbolWidth; s2++) {
  47071. row[offsetS + s2] ^= symbolRow[s2];
  47072. }
  47073. break;
  47074. default:
  47075. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47076. }
  47077. }
  47078. currentS += symbolWidth - 1;
  47079. }
  47080. i++;
  47081. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47082. if (deltaS === null) {
  47083. break;
  47084. }
  47085. currentS += deltaS + dsOffset;
  47086. } while (true);
  47087. }
  47088. return bitmap;
  47089. }
  47090. function readSegmentHeader(data, start) {
  47091. var segmentHeader = {};
  47092. segmentHeader.number = readUint32(data, start);
  47093. var flags = data[start + 4];
  47094. var segmentType = flags & 0x3F;
  47095. if (!SegmentTypes[segmentType]) {
  47096. error('JBIG2 error: invalid segment type: ' + segmentType);
  47097. }
  47098. segmentHeader.type = segmentType;
  47099. segmentHeader.typeName = SegmentTypes[segmentType];
  47100. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47101. var pageAssociationFieldSize = !!(flags & 0x40);
  47102. var referredFlags = data[start + 5];
  47103. var referredToCount = referredFlags >> 5 & 7;
  47104. var retainBits = [referredFlags & 31];
  47105. var position = start + 6;
  47106. if (referredFlags === 7) {
  47107. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47108. position += 3;
  47109. var bytes = referredToCount + 7 >> 3;
  47110. retainBits[0] = data[position++];
  47111. while (--bytes > 0) {
  47112. retainBits.push(data[position++]);
  47113. }
  47114. } else if (referredFlags === 5 || referredFlags === 6) {
  47115. error('JBIG2 error: invalid referred-to flags');
  47116. }
  47117. segmentHeader.retainBits = retainBits;
  47118. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47119. var referredTo = [];
  47120. var i, ii;
  47121. for (i = 0; i < referredToCount; i++) {
  47122. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47123. referredTo.push(number);
  47124. position += referredToSegmentNumberSize;
  47125. }
  47126. segmentHeader.referredTo = referredTo;
  47127. if (!pageAssociationFieldSize) {
  47128. segmentHeader.pageAssociation = data[position++];
  47129. } else {
  47130. segmentHeader.pageAssociation = readUint32(data, position);
  47131. position += 4;
  47132. }
  47133. segmentHeader.length = readUint32(data, position);
  47134. position += 4;
  47135. if (segmentHeader.length === 0xFFFFFFFF) {
  47136. if (segmentType === 38) {
  47137. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47138. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47139. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47140. var searchPatternLength = 6;
  47141. var searchPattern = new Uint8Array(searchPatternLength);
  47142. if (!genericRegionMmr) {
  47143. searchPattern[0] = 0xFF;
  47144. searchPattern[1] = 0xAC;
  47145. }
  47146. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47147. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47148. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47149. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47150. for (i = position, ii = data.length; i < ii; i++) {
  47151. var j = 0;
  47152. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47153. j++;
  47154. }
  47155. if (j === searchPatternLength) {
  47156. segmentHeader.length = i + searchPatternLength;
  47157. break;
  47158. }
  47159. }
  47160. if (segmentHeader.length === 0xFFFFFFFF) {
  47161. error('JBIG2 error: segment end was not found');
  47162. }
  47163. } else {
  47164. error('JBIG2 error: invalid unknown segment length');
  47165. }
  47166. }
  47167. segmentHeader.headerEnd = position;
  47168. return segmentHeader;
  47169. }
  47170. function readSegments(header, data, start, end) {
  47171. var segments = [];
  47172. var position = start;
  47173. while (position < end) {
  47174. var segmentHeader = readSegmentHeader(data, position);
  47175. position = segmentHeader.headerEnd;
  47176. var segment = {
  47177. header: segmentHeader,
  47178. data: data
  47179. };
  47180. if (!header.randomAccess) {
  47181. segment.start = position;
  47182. position += segmentHeader.length;
  47183. segment.end = position;
  47184. }
  47185. segments.push(segment);
  47186. if (segmentHeader.type === 51) {
  47187. break;
  47188. }
  47189. }
  47190. if (header.randomAccess) {
  47191. for (var i = 0, ii = segments.length; i < ii; i++) {
  47192. segments[i].start = position;
  47193. position += segments[i].header.length;
  47194. segments[i].end = position;
  47195. }
  47196. }
  47197. return segments;
  47198. }
  47199. function readRegionSegmentInformation(data, start) {
  47200. return {
  47201. width: readUint32(data, start),
  47202. height: readUint32(data, start + 4),
  47203. x: readUint32(data, start + 8),
  47204. y: readUint32(data, start + 12),
  47205. combinationOperator: data[start + 16] & 7
  47206. };
  47207. }
  47208. var RegionSegmentInformationFieldLength = 17;
  47209. function processSegment(segment, visitor) {
  47210. var header = segment.header;
  47211. var data = segment.data, position = segment.start, end = segment.end;
  47212. var args, at, i, atLength;
  47213. switch (header.type) {
  47214. case 0:
  47215. var dictionary = {};
  47216. var dictionaryFlags = readUint16(data, position);
  47217. dictionary.huffman = !!(dictionaryFlags & 1);
  47218. dictionary.refinement = !!(dictionaryFlags & 2);
  47219. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47220. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47221. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47222. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47223. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47224. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47225. dictionary.template = dictionaryFlags >> 10 & 3;
  47226. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47227. position += 2;
  47228. if (!dictionary.huffman) {
  47229. atLength = dictionary.template === 0 ? 4 : 1;
  47230. at = [];
  47231. for (i = 0; i < atLength; i++) {
  47232. at.push({
  47233. x: readInt8(data, position),
  47234. y: readInt8(data, position + 1)
  47235. });
  47236. position += 2;
  47237. }
  47238. dictionary.at = at;
  47239. }
  47240. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47241. at = [];
  47242. for (i = 0; i < 2; i++) {
  47243. at.push({
  47244. x: readInt8(data, position),
  47245. y: readInt8(data, position + 1)
  47246. });
  47247. position += 2;
  47248. }
  47249. dictionary.refinementAt = at;
  47250. }
  47251. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47252. position += 4;
  47253. dictionary.numberOfNewSymbols = readUint32(data, position);
  47254. position += 4;
  47255. args = [
  47256. dictionary,
  47257. header.number,
  47258. header.referredTo,
  47259. data,
  47260. position,
  47261. end
  47262. ];
  47263. break;
  47264. case 6:
  47265. case 7:
  47266. var textRegion = {};
  47267. textRegion.info = readRegionSegmentInformation(data, position);
  47268. position += RegionSegmentInformationFieldLength;
  47269. var textRegionSegmentFlags = readUint16(data, position);
  47270. position += 2;
  47271. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47272. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47273. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47274. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47275. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47276. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47277. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47278. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47279. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47280. if (textRegion.huffman) {
  47281. var textRegionHuffmanFlags = readUint16(data, position);
  47282. position += 2;
  47283. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47284. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47285. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47286. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47287. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47288. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47289. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47290. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47291. }
  47292. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47293. at = [];
  47294. for (i = 0; i < 2; i++) {
  47295. at.push({
  47296. x: readInt8(data, position),
  47297. y: readInt8(data, position + 1)
  47298. });
  47299. position += 2;
  47300. }
  47301. textRegion.refinementAt = at;
  47302. }
  47303. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47304. position += 4;
  47305. if (textRegion.huffman) {
  47306. error('JBIG2 error: huffman is not supported');
  47307. }
  47308. args = [
  47309. textRegion,
  47310. header.referredTo,
  47311. data,
  47312. position,
  47313. end
  47314. ];
  47315. break;
  47316. case 38:
  47317. case 39:
  47318. var genericRegion = {};
  47319. genericRegion.info = readRegionSegmentInformation(data, position);
  47320. position += RegionSegmentInformationFieldLength;
  47321. var genericRegionSegmentFlags = data[position++];
  47322. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47323. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47324. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47325. if (!genericRegion.mmr) {
  47326. atLength = genericRegion.template === 0 ? 4 : 1;
  47327. at = [];
  47328. for (i = 0; i < atLength; i++) {
  47329. at.push({
  47330. x: readInt8(data, position),
  47331. y: readInt8(data, position + 1)
  47332. });
  47333. position += 2;
  47334. }
  47335. genericRegion.at = at;
  47336. }
  47337. args = [
  47338. genericRegion,
  47339. data,
  47340. position,
  47341. end
  47342. ];
  47343. break;
  47344. case 48:
  47345. var pageInfo = {
  47346. width: readUint32(data, position),
  47347. height: readUint32(data, position + 4),
  47348. resolutionX: readUint32(data, position + 8),
  47349. resolutionY: readUint32(data, position + 12)
  47350. };
  47351. if (pageInfo.height === 0xFFFFFFFF) {
  47352. delete pageInfo.height;
  47353. }
  47354. var pageSegmentFlags = data[position + 16];
  47355. readUint16(data, position + 17);
  47356. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47357. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47358. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47359. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47360. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47361. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47362. args = [pageInfo];
  47363. break;
  47364. case 49:
  47365. break;
  47366. case 50:
  47367. break;
  47368. case 51:
  47369. break;
  47370. case 62:
  47371. break;
  47372. default:
  47373. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47374. }
  47375. var callbackName = 'on' + header.typeName;
  47376. if (callbackName in visitor) {
  47377. visitor[callbackName].apply(visitor, args);
  47378. }
  47379. }
  47380. function processSegments(segments, visitor) {
  47381. for (var i = 0, ii = segments.length; i < ii; i++) {
  47382. processSegment(segments[i], visitor);
  47383. }
  47384. }
  47385. function parseJbig2(data, start, end) {
  47386. var position = start;
  47387. 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) {
  47388. error('JBIG2 error: invalid header');
  47389. }
  47390. var header = {};
  47391. position += 8;
  47392. var flags = data[position++];
  47393. header.randomAccess = !(flags & 1);
  47394. if (!(flags & 2)) {
  47395. header.numberOfPages = readUint32(data, position);
  47396. position += 4;
  47397. }
  47398. readSegments(header, data, position, end);
  47399. error('Not implemented');
  47400. }
  47401. function parseJbig2Chunks(chunks) {
  47402. var visitor = new SimpleSegmentVisitor();
  47403. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47404. var chunk = chunks[i];
  47405. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47406. processSegments(segments, visitor);
  47407. }
  47408. return visitor.buffer;
  47409. }
  47410. function SimpleSegmentVisitor() {
  47411. }
  47412. SimpleSegmentVisitor.prototype = {
  47413. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47414. this.currentPageInfo = info;
  47415. var rowSize = info.width + 7 >> 3;
  47416. var buffer = new Uint8Array(rowSize * info.height);
  47417. if (info.defaultPixelValue) {
  47418. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47419. buffer[i] = 0xFF;
  47420. }
  47421. }
  47422. this.buffer = buffer;
  47423. },
  47424. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47425. var pageInfo = this.currentPageInfo;
  47426. var width = regionInfo.width, height = regionInfo.height;
  47427. var rowSize = pageInfo.width + 7 >> 3;
  47428. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47429. var buffer = this.buffer;
  47430. var mask0 = 128 >> (regionInfo.x & 7);
  47431. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47432. var i, j, mask, offset;
  47433. switch (combinationOperator) {
  47434. case 0:
  47435. for (i = 0; i < height; i++) {
  47436. mask = mask0;
  47437. offset = offset0;
  47438. for (j = 0; j < width; j++) {
  47439. if (bitmap[i][j]) {
  47440. buffer[offset] |= mask;
  47441. }
  47442. mask >>= 1;
  47443. if (!mask) {
  47444. mask = 128;
  47445. offset++;
  47446. }
  47447. }
  47448. offset0 += rowSize;
  47449. }
  47450. break;
  47451. case 2:
  47452. for (i = 0; i < height; i++) {
  47453. mask = mask0;
  47454. offset = offset0;
  47455. for (j = 0; j < width; j++) {
  47456. if (bitmap[i][j]) {
  47457. buffer[offset] ^= mask;
  47458. }
  47459. mask >>= 1;
  47460. if (!mask) {
  47461. mask = 128;
  47462. offset++;
  47463. }
  47464. }
  47465. offset0 += rowSize;
  47466. }
  47467. break;
  47468. default:
  47469. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47470. }
  47471. },
  47472. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47473. var regionInfo = region.info;
  47474. var decodingContext = new DecodingContext(data, start, end);
  47475. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47476. this.drawBitmap(regionInfo, bitmap);
  47477. },
  47478. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47479. this.onImmediateGenericRegion.apply(this, arguments);
  47480. },
  47481. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47482. var huffmanTables;
  47483. if (dictionary.huffman) {
  47484. error('JBIG2 error: huffman is not supported');
  47485. }
  47486. var symbols = this.symbols;
  47487. if (!symbols) {
  47488. this.symbols = symbols = {};
  47489. }
  47490. var inputSymbols = [];
  47491. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47492. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47493. }
  47494. var decodingContext = new DecodingContext(data, start, end);
  47495. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47496. },
  47497. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47498. var regionInfo = region.info;
  47499. var huffmanTables;
  47500. var symbols = this.symbols;
  47501. var inputSymbols = [];
  47502. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47503. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47504. }
  47505. var symbolCodeLength = log2(inputSymbols.length);
  47506. var decodingContext = new DecodingContext(data, start, end);
  47507. 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);
  47508. this.drawBitmap(regionInfo, bitmap);
  47509. },
  47510. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47511. this.onImmediateTextRegion.apply(this, arguments);
  47512. }
  47513. };
  47514. function Jbig2Image() {
  47515. }
  47516. Jbig2Image.prototype = {
  47517. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47518. return parseJbig2Chunks(chunks);
  47519. }
  47520. };
  47521. return Jbig2Image;
  47522. }();
  47523. exports.Jbig2Image = Jbig2Image;
  47524. /***/ }),
  47525. /* 36 */
  47526. /***/ (function(module, exports, __w_pdfjs_require__) {
  47527. "use strict";
  47528. var sharedUtil = __w_pdfjs_require__(0);
  47529. var error = sharedUtil.error;
  47530. var JpegImage = function JpegImageClosure() {
  47531. var dctZigZag = new Uint8Array([
  47532. 0,
  47533. 1,
  47534. 8,
  47535. 16,
  47536. 9,
  47537. 2,
  47538. 3,
  47539. 10,
  47540. 17,
  47541. 24,
  47542. 32,
  47543. 25,
  47544. 18,
  47545. 11,
  47546. 4,
  47547. 5,
  47548. 12,
  47549. 19,
  47550. 26,
  47551. 33,
  47552. 40,
  47553. 48,
  47554. 41,
  47555. 34,
  47556. 27,
  47557. 20,
  47558. 13,
  47559. 6,
  47560. 7,
  47561. 14,
  47562. 21,
  47563. 28,
  47564. 35,
  47565. 42,
  47566. 49,
  47567. 56,
  47568. 57,
  47569. 50,
  47570. 43,
  47571. 36,
  47572. 29,
  47573. 22,
  47574. 15,
  47575. 23,
  47576. 30,
  47577. 37,
  47578. 44,
  47579. 51,
  47580. 58,
  47581. 59,
  47582. 52,
  47583. 45,
  47584. 38,
  47585. 31,
  47586. 39,
  47587. 46,
  47588. 53,
  47589. 60,
  47590. 61,
  47591. 54,
  47592. 47,
  47593. 55,
  47594. 62,
  47595. 63
  47596. ]);
  47597. var dctCos1 = 4017;
  47598. var dctSin1 = 799;
  47599. var dctCos3 = 3406;
  47600. var dctSin3 = 2276;
  47601. var dctCos6 = 1567;
  47602. var dctSin6 = 3784;
  47603. var dctSqrt2 = 5793;
  47604. var dctSqrt1d2 = 2896;
  47605. function JpegImage() {
  47606. this.decodeTransform = null;
  47607. this.colorTransform = -1;
  47608. }
  47609. function buildHuffmanTable(codeLengths, values) {
  47610. var k = 0, code = [], i, j, length = 16;
  47611. while (length > 0 && !codeLengths[length - 1]) {
  47612. length--;
  47613. }
  47614. code.push({
  47615. children: [],
  47616. index: 0
  47617. });
  47618. var p = code[0], q;
  47619. for (i = 0; i < length; i++) {
  47620. for (j = 0; j < codeLengths[i]; j++) {
  47621. p = code.pop();
  47622. p.children[p.index] = values[k];
  47623. while (p.index > 0) {
  47624. p = code.pop();
  47625. }
  47626. p.index++;
  47627. code.push(p);
  47628. while (code.length <= i) {
  47629. code.push(q = {
  47630. children: [],
  47631. index: 0
  47632. });
  47633. p.children[p.index] = q.children;
  47634. p = q;
  47635. }
  47636. k++;
  47637. }
  47638. if (i + 1 < length) {
  47639. code.push(q = {
  47640. children: [],
  47641. index: 0
  47642. });
  47643. p.children[p.index] = q.children;
  47644. p = q;
  47645. }
  47646. }
  47647. return code[0].children;
  47648. }
  47649. function getBlockBufferOffset(component, row, col) {
  47650. return 64 * ((component.blocksPerLine + 1) * row + col);
  47651. }
  47652. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47653. var mcusPerLine = frame.mcusPerLine;
  47654. var progressive = frame.progressive;
  47655. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47656. function readBit() {
  47657. if (bitsCount > 0) {
  47658. bitsCount--;
  47659. return bitsData >> bitsCount & 1;
  47660. }
  47661. bitsData = data[offset++];
  47662. if (bitsData === 0xFF) {
  47663. var nextByte = data[offset++];
  47664. if (nextByte) {
  47665. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47666. }
  47667. }
  47668. bitsCount = 7;
  47669. return bitsData >>> 7;
  47670. }
  47671. function decodeHuffman(tree) {
  47672. var node = tree;
  47673. while (true) {
  47674. node = node[readBit()];
  47675. if (typeof node === 'number') {
  47676. return node;
  47677. }
  47678. if (typeof node !== 'object') {
  47679. error('JPEG error: invalid huffman sequence');
  47680. }
  47681. }
  47682. }
  47683. function receive(length) {
  47684. var n = 0;
  47685. while (length > 0) {
  47686. n = n << 1 | readBit();
  47687. length--;
  47688. }
  47689. return n;
  47690. }
  47691. function receiveAndExtend(length) {
  47692. if (length === 1) {
  47693. return readBit() === 1 ? 1 : -1;
  47694. }
  47695. var n = receive(length);
  47696. if (n >= 1 << length - 1) {
  47697. return n;
  47698. }
  47699. return n + (-1 << length) + 1;
  47700. }
  47701. function decodeBaseline(component, offset) {
  47702. var t = decodeHuffman(component.huffmanTableDC);
  47703. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47704. component.blockData[offset] = component.pred += diff;
  47705. var k = 1;
  47706. while (k < 64) {
  47707. var rs = decodeHuffman(component.huffmanTableAC);
  47708. var s = rs & 15, r = rs >> 4;
  47709. if (s === 0) {
  47710. if (r < 15) {
  47711. break;
  47712. }
  47713. k += 16;
  47714. continue;
  47715. }
  47716. k += r;
  47717. var z = dctZigZag[k];
  47718. component.blockData[offset + z] = receiveAndExtend(s);
  47719. k++;
  47720. }
  47721. }
  47722. function decodeDCFirst(component, offset) {
  47723. var t = decodeHuffman(component.huffmanTableDC);
  47724. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47725. component.blockData[offset] = component.pred += diff;
  47726. }
  47727. function decodeDCSuccessive(component, offset) {
  47728. component.blockData[offset] |= readBit() << successive;
  47729. }
  47730. var eobrun = 0;
  47731. function decodeACFirst(component, offset) {
  47732. if (eobrun > 0) {
  47733. eobrun--;
  47734. return;
  47735. }
  47736. var k = spectralStart, e = spectralEnd;
  47737. while (k <= e) {
  47738. var rs = decodeHuffman(component.huffmanTableAC);
  47739. var s = rs & 15, r = rs >> 4;
  47740. if (s === 0) {
  47741. if (r < 15) {
  47742. eobrun = receive(r) + (1 << r) - 1;
  47743. break;
  47744. }
  47745. k += 16;
  47746. continue;
  47747. }
  47748. k += r;
  47749. var z = dctZigZag[k];
  47750. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47751. k++;
  47752. }
  47753. }
  47754. var successiveACState = 0, successiveACNextValue;
  47755. function decodeACSuccessive(component, offset) {
  47756. var k = spectralStart;
  47757. var e = spectralEnd;
  47758. var r = 0;
  47759. var s;
  47760. var rs;
  47761. while (k <= e) {
  47762. var z = dctZigZag[k];
  47763. switch (successiveACState) {
  47764. case 0:
  47765. rs = decodeHuffman(component.huffmanTableAC);
  47766. s = rs & 15;
  47767. r = rs >> 4;
  47768. if (s === 0) {
  47769. if (r < 15) {
  47770. eobrun = receive(r) + (1 << r);
  47771. successiveACState = 4;
  47772. } else {
  47773. r = 16;
  47774. successiveACState = 1;
  47775. }
  47776. } else {
  47777. if (s !== 1) {
  47778. error('JPEG error: invalid ACn encoding');
  47779. }
  47780. successiveACNextValue = receiveAndExtend(s);
  47781. successiveACState = r ? 2 : 3;
  47782. }
  47783. continue;
  47784. case 1:
  47785. case 2:
  47786. if (component.blockData[offset + z]) {
  47787. component.blockData[offset + z] += readBit() << successive;
  47788. } else {
  47789. r--;
  47790. if (r === 0) {
  47791. successiveACState = successiveACState === 2 ? 3 : 0;
  47792. }
  47793. }
  47794. break;
  47795. case 3:
  47796. if (component.blockData[offset + z]) {
  47797. component.blockData[offset + z] += readBit() << successive;
  47798. } else {
  47799. component.blockData[offset + z] = successiveACNextValue << successive;
  47800. successiveACState = 0;
  47801. }
  47802. break;
  47803. case 4:
  47804. if (component.blockData[offset + z]) {
  47805. component.blockData[offset + z] += readBit() << successive;
  47806. }
  47807. break;
  47808. }
  47809. k++;
  47810. }
  47811. if (successiveACState === 4) {
  47812. eobrun--;
  47813. if (eobrun === 0) {
  47814. successiveACState = 0;
  47815. }
  47816. }
  47817. }
  47818. function decodeMcu(component, decode, mcu, row, col) {
  47819. var mcuRow = mcu / mcusPerLine | 0;
  47820. var mcuCol = mcu % mcusPerLine;
  47821. var blockRow = mcuRow * component.v + row;
  47822. var blockCol = mcuCol * component.h + col;
  47823. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47824. decode(component, offset);
  47825. }
  47826. function decodeBlock(component, decode, mcu) {
  47827. var blockRow = mcu / component.blocksPerLine | 0;
  47828. var blockCol = mcu % component.blocksPerLine;
  47829. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47830. decode(component, offset);
  47831. }
  47832. var componentsLength = components.length;
  47833. var component, i, j, k, n;
  47834. var decodeFn;
  47835. if (progressive) {
  47836. if (spectralStart === 0) {
  47837. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47838. } else {
  47839. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47840. }
  47841. } else {
  47842. decodeFn = decodeBaseline;
  47843. }
  47844. var mcu = 0, marker;
  47845. var mcuExpected;
  47846. if (componentsLength === 1) {
  47847. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47848. } else {
  47849. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47850. }
  47851. if (!resetInterval) {
  47852. resetInterval = mcuExpected;
  47853. }
  47854. var h, v;
  47855. while (mcu < mcuExpected) {
  47856. for (i = 0; i < componentsLength; i++) {
  47857. components[i].pred = 0;
  47858. }
  47859. eobrun = 0;
  47860. if (componentsLength === 1) {
  47861. component = components[0];
  47862. for (n = 0; n < resetInterval; n++) {
  47863. decodeBlock(component, decodeFn, mcu);
  47864. mcu++;
  47865. }
  47866. } else {
  47867. for (n = 0; n < resetInterval; n++) {
  47868. for (i = 0; i < componentsLength; i++) {
  47869. component = components[i];
  47870. h = component.h;
  47871. v = component.v;
  47872. for (j = 0; j < v; j++) {
  47873. for (k = 0; k < h; k++) {
  47874. decodeMcu(component, decodeFn, mcu, j, k);
  47875. }
  47876. }
  47877. }
  47878. mcu++;
  47879. }
  47880. }
  47881. bitsCount = 0;
  47882. marker = data[offset] << 8 | data[offset + 1];
  47883. while (data[offset] === 0x00 && offset < data.length - 1) {
  47884. offset++;
  47885. marker = data[offset] << 8 | data[offset + 1];
  47886. }
  47887. if (marker <= 0xFF00) {
  47888. error('JPEG error: marker was not found');
  47889. }
  47890. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47891. offset += 2;
  47892. } else {
  47893. break;
  47894. }
  47895. }
  47896. return offset - startOffset;
  47897. }
  47898. function quantizeAndInverse(component, blockBufferOffset, p) {
  47899. var qt = component.quantizationTable, blockData = component.blockData;
  47900. var v0, v1, v2, v3, v4, v5, v6, v7;
  47901. var p0, p1, p2, p3, p4, p5, p6, p7;
  47902. var t;
  47903. if (!qt) {
  47904. error('JPEG error: missing required Quantization Table.');
  47905. }
  47906. for (var row = 0; row < 64; row += 8) {
  47907. p0 = blockData[blockBufferOffset + row];
  47908. p1 = blockData[blockBufferOffset + row + 1];
  47909. p2 = blockData[blockBufferOffset + row + 2];
  47910. p3 = blockData[blockBufferOffset + row + 3];
  47911. p4 = blockData[blockBufferOffset + row + 4];
  47912. p5 = blockData[blockBufferOffset + row + 5];
  47913. p6 = blockData[blockBufferOffset + row + 6];
  47914. p7 = blockData[blockBufferOffset + row + 7];
  47915. p0 *= qt[row];
  47916. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47917. t = dctSqrt2 * p0 + 512 >> 10;
  47918. p[row] = t;
  47919. p[row + 1] = t;
  47920. p[row + 2] = t;
  47921. p[row + 3] = t;
  47922. p[row + 4] = t;
  47923. p[row + 5] = t;
  47924. p[row + 6] = t;
  47925. p[row + 7] = t;
  47926. continue;
  47927. }
  47928. p1 *= qt[row + 1];
  47929. p2 *= qt[row + 2];
  47930. p3 *= qt[row + 3];
  47931. p4 *= qt[row + 4];
  47932. p5 *= qt[row + 5];
  47933. p6 *= qt[row + 6];
  47934. p7 *= qt[row + 7];
  47935. v0 = dctSqrt2 * p0 + 128 >> 8;
  47936. v1 = dctSqrt2 * p4 + 128 >> 8;
  47937. v2 = p2;
  47938. v3 = p6;
  47939. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47940. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47941. v5 = p3 << 4;
  47942. v6 = p5 << 4;
  47943. v0 = v0 + v1 + 1 >> 1;
  47944. v1 = v0 - v1;
  47945. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47946. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47947. v3 = t;
  47948. v4 = v4 + v6 + 1 >> 1;
  47949. v6 = v4 - v6;
  47950. v7 = v7 + v5 + 1 >> 1;
  47951. v5 = v7 - v5;
  47952. v0 = v0 + v3 + 1 >> 1;
  47953. v3 = v0 - v3;
  47954. v1 = v1 + v2 + 1 >> 1;
  47955. v2 = v1 - v2;
  47956. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47957. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47958. v7 = t;
  47959. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47960. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47961. v6 = t;
  47962. p[row] = v0 + v7;
  47963. p[row + 7] = v0 - v7;
  47964. p[row + 1] = v1 + v6;
  47965. p[row + 6] = v1 - v6;
  47966. p[row + 2] = v2 + v5;
  47967. p[row + 5] = v2 - v5;
  47968. p[row + 3] = v3 + v4;
  47969. p[row + 4] = v3 - v4;
  47970. }
  47971. for (var col = 0; col < 8; ++col) {
  47972. p0 = p[col];
  47973. p1 = p[col + 8];
  47974. p2 = p[col + 16];
  47975. p3 = p[col + 24];
  47976. p4 = p[col + 32];
  47977. p5 = p[col + 40];
  47978. p6 = p[col + 48];
  47979. p7 = p[col + 56];
  47980. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47981. t = dctSqrt2 * p0 + 8192 >> 14;
  47982. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  47983. blockData[blockBufferOffset + col] = t;
  47984. blockData[blockBufferOffset + col + 8] = t;
  47985. blockData[blockBufferOffset + col + 16] = t;
  47986. blockData[blockBufferOffset + col + 24] = t;
  47987. blockData[blockBufferOffset + col + 32] = t;
  47988. blockData[blockBufferOffset + col + 40] = t;
  47989. blockData[blockBufferOffset + col + 48] = t;
  47990. blockData[blockBufferOffset + col + 56] = t;
  47991. continue;
  47992. }
  47993. v0 = dctSqrt2 * p0 + 2048 >> 12;
  47994. v1 = dctSqrt2 * p4 + 2048 >> 12;
  47995. v2 = p2;
  47996. v3 = p6;
  47997. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  47998. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  47999. v5 = p3;
  48000. v6 = p5;
  48001. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48002. v1 = v0 - v1;
  48003. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48004. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48005. v3 = t;
  48006. v4 = v4 + v6 + 1 >> 1;
  48007. v6 = v4 - v6;
  48008. v7 = v7 + v5 + 1 >> 1;
  48009. v5 = v7 - v5;
  48010. v0 = v0 + v3 + 1 >> 1;
  48011. v3 = v0 - v3;
  48012. v1 = v1 + v2 + 1 >> 1;
  48013. v2 = v1 - v2;
  48014. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48015. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48016. v7 = t;
  48017. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48018. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48019. v6 = t;
  48020. p0 = v0 + v7;
  48021. p7 = v0 - v7;
  48022. p1 = v1 + v6;
  48023. p6 = v1 - v6;
  48024. p2 = v2 + v5;
  48025. p5 = v2 - v5;
  48026. p3 = v3 + v4;
  48027. p4 = v3 - v4;
  48028. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48029. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48030. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48031. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48032. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48033. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48034. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48035. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48036. blockData[blockBufferOffset + col] = p0;
  48037. blockData[blockBufferOffset + col + 8] = p1;
  48038. blockData[blockBufferOffset + col + 16] = p2;
  48039. blockData[blockBufferOffset + col + 24] = p3;
  48040. blockData[blockBufferOffset + col + 32] = p4;
  48041. blockData[blockBufferOffset + col + 40] = p5;
  48042. blockData[blockBufferOffset + col + 48] = p6;
  48043. blockData[blockBufferOffset + col + 56] = p7;
  48044. }
  48045. }
  48046. function buildComponentData(frame, component) {
  48047. var blocksPerLine = component.blocksPerLine;
  48048. var blocksPerColumn = component.blocksPerColumn;
  48049. var computationBuffer = new Int16Array(64);
  48050. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48051. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48052. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48053. quantizeAndInverse(component, offset, computationBuffer);
  48054. }
  48055. }
  48056. return component.blockData;
  48057. }
  48058. function clamp0to255(a) {
  48059. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48060. }
  48061. JpegImage.prototype = {
  48062. parse: function parse(data) {
  48063. function readUint16() {
  48064. var value = data[offset] << 8 | data[offset + 1];
  48065. offset += 2;
  48066. return value;
  48067. }
  48068. function readDataBlock() {
  48069. var length = readUint16();
  48070. var array = data.subarray(offset, offset + length - 2);
  48071. offset += array.length;
  48072. return array;
  48073. }
  48074. function prepareComponents(frame) {
  48075. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48076. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48077. for (var i = 0; i < frame.components.length; i++) {
  48078. component = frame.components[i];
  48079. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48080. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48081. var blocksPerLineForMcu = mcusPerLine * component.h;
  48082. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48083. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48084. component.blockData = new Int16Array(blocksBufferSize);
  48085. component.blocksPerLine = blocksPerLine;
  48086. component.blocksPerColumn = blocksPerColumn;
  48087. }
  48088. frame.mcusPerLine = mcusPerLine;
  48089. frame.mcusPerColumn = mcusPerColumn;
  48090. }
  48091. var offset = 0;
  48092. var jfif = null;
  48093. var adobe = null;
  48094. var frame, resetInterval;
  48095. var quantizationTables = [];
  48096. var huffmanTablesAC = [], huffmanTablesDC = [];
  48097. var fileMarker = readUint16();
  48098. if (fileMarker !== 0xFFD8) {
  48099. error('JPEG error: SOI not found');
  48100. }
  48101. fileMarker = readUint16();
  48102. while (fileMarker !== 0xFFD9) {
  48103. var i, j, l;
  48104. switch (fileMarker) {
  48105. case 0xFFE0:
  48106. case 0xFFE1:
  48107. case 0xFFE2:
  48108. case 0xFFE3:
  48109. case 0xFFE4:
  48110. case 0xFFE5:
  48111. case 0xFFE6:
  48112. case 0xFFE7:
  48113. case 0xFFE8:
  48114. case 0xFFE9:
  48115. case 0xFFEA:
  48116. case 0xFFEB:
  48117. case 0xFFEC:
  48118. case 0xFFED:
  48119. case 0xFFEE:
  48120. case 0xFFEF:
  48121. case 0xFFFE:
  48122. var appData = readDataBlock();
  48123. if (fileMarker === 0xFFE0) {
  48124. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48125. jfif = {
  48126. version: {
  48127. major: appData[5],
  48128. minor: appData[6]
  48129. },
  48130. densityUnits: appData[7],
  48131. xDensity: appData[8] << 8 | appData[9],
  48132. yDensity: appData[10] << 8 | appData[11],
  48133. thumbWidth: appData[12],
  48134. thumbHeight: appData[13],
  48135. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48136. };
  48137. }
  48138. }
  48139. if (fileMarker === 0xFFEE) {
  48140. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48141. adobe = {
  48142. version: appData[5] << 8 | appData[6],
  48143. flags0: appData[7] << 8 | appData[8],
  48144. flags1: appData[9] << 8 | appData[10],
  48145. transformCode: appData[11]
  48146. };
  48147. }
  48148. }
  48149. break;
  48150. case 0xFFDB:
  48151. var quantizationTablesLength = readUint16();
  48152. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48153. var z;
  48154. while (offset < quantizationTablesEnd) {
  48155. var quantizationTableSpec = data[offset++];
  48156. var tableData = new Uint16Array(64);
  48157. if (quantizationTableSpec >> 4 === 0) {
  48158. for (j = 0; j < 64; j++) {
  48159. z = dctZigZag[j];
  48160. tableData[z] = data[offset++];
  48161. }
  48162. } else if (quantizationTableSpec >> 4 === 1) {
  48163. for (j = 0; j < 64; j++) {
  48164. z = dctZigZag[j];
  48165. tableData[z] = readUint16();
  48166. }
  48167. } else {
  48168. error('JPEG error: DQT - invalid table spec');
  48169. }
  48170. quantizationTables[quantizationTableSpec & 15] = tableData;
  48171. }
  48172. break;
  48173. case 0xFFC0:
  48174. case 0xFFC1:
  48175. case 0xFFC2:
  48176. if (frame) {
  48177. error('JPEG error: Only single frame JPEGs supported');
  48178. }
  48179. readUint16();
  48180. frame = {};
  48181. frame.extended = fileMarker === 0xFFC1;
  48182. frame.progressive = fileMarker === 0xFFC2;
  48183. frame.precision = data[offset++];
  48184. frame.scanLines = readUint16();
  48185. frame.samplesPerLine = readUint16();
  48186. frame.components = [];
  48187. frame.componentIds = {};
  48188. var componentsCount = data[offset++], componentId;
  48189. var maxH = 0, maxV = 0;
  48190. for (i = 0; i < componentsCount; i++) {
  48191. componentId = data[offset];
  48192. var h = data[offset + 1] >> 4;
  48193. var v = data[offset + 1] & 15;
  48194. if (maxH < h) {
  48195. maxH = h;
  48196. }
  48197. if (maxV < v) {
  48198. maxV = v;
  48199. }
  48200. var qId = data[offset + 2];
  48201. l = frame.components.push({
  48202. h: h,
  48203. v: v,
  48204. quantizationId: qId,
  48205. quantizationTable: null
  48206. });
  48207. frame.componentIds[componentId] = l - 1;
  48208. offset += 3;
  48209. }
  48210. frame.maxH = maxH;
  48211. frame.maxV = maxV;
  48212. prepareComponents(frame);
  48213. break;
  48214. case 0xFFC4:
  48215. var huffmanLength = readUint16();
  48216. for (i = 2; i < huffmanLength;) {
  48217. var huffmanTableSpec = data[offset++];
  48218. var codeLengths = new Uint8Array(16);
  48219. var codeLengthSum = 0;
  48220. for (j = 0; j < 16; j++, offset++) {
  48221. codeLengthSum += codeLengths[j] = data[offset];
  48222. }
  48223. var huffmanValues = new Uint8Array(codeLengthSum);
  48224. for (j = 0; j < codeLengthSum; j++, offset++) {
  48225. huffmanValues[j] = data[offset];
  48226. }
  48227. i += 17 + codeLengthSum;
  48228. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48229. }
  48230. break;
  48231. case 0xFFDD:
  48232. readUint16();
  48233. resetInterval = readUint16();
  48234. break;
  48235. case 0xFFDA:
  48236. readUint16();
  48237. var selectorsCount = data[offset++];
  48238. var components = [], component;
  48239. for (i = 0; i < selectorsCount; i++) {
  48240. var componentIndex = frame.componentIds[data[offset++]];
  48241. component = frame.components[componentIndex];
  48242. var tableSpec = data[offset++];
  48243. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48244. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48245. components.push(component);
  48246. }
  48247. var spectralStart = data[offset++];
  48248. var spectralEnd = data[offset++];
  48249. var successiveApproximation = data[offset++];
  48250. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48251. offset += processed;
  48252. break;
  48253. case 0xFFFF:
  48254. if (data[offset] !== 0xFF) {
  48255. offset--;
  48256. }
  48257. break;
  48258. default:
  48259. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48260. offset -= 3;
  48261. break;
  48262. }
  48263. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48264. }
  48265. fileMarker = readUint16();
  48266. }
  48267. this.width = frame.samplesPerLine;
  48268. this.height = frame.scanLines;
  48269. this.jfif = jfif;
  48270. this.adobe = adobe;
  48271. this.components = [];
  48272. for (i = 0; i < frame.components.length; i++) {
  48273. component = frame.components[i];
  48274. var quantizationTable = quantizationTables[component.quantizationId];
  48275. if (quantizationTable) {
  48276. component.quantizationTable = quantizationTable;
  48277. }
  48278. this.components.push({
  48279. output: buildComponentData(frame, component),
  48280. scaleX: component.h / frame.maxH,
  48281. scaleY: component.v / frame.maxV,
  48282. blocksPerLine: component.blocksPerLine,
  48283. blocksPerColumn: component.blocksPerColumn
  48284. });
  48285. }
  48286. this.numComponents = this.components.length;
  48287. },
  48288. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48289. var scaleX = this.width / width, scaleY = this.height / height;
  48290. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48291. var x, y, i, j, k;
  48292. var index;
  48293. var offset = 0;
  48294. var output;
  48295. var numComponents = this.components.length;
  48296. var dataLength = width * height * numComponents;
  48297. var data = new Uint8Array(dataLength);
  48298. var xScaleBlockOffset = new Uint32Array(width);
  48299. var mask3LSB = 0xfffffff8;
  48300. for (i = 0; i < numComponents; i++) {
  48301. component = this.components[i];
  48302. componentScaleX = component.scaleX * scaleX;
  48303. componentScaleY = component.scaleY * scaleY;
  48304. offset = i;
  48305. output = component.output;
  48306. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48307. for (x = 0; x < width; x++) {
  48308. j = 0 | x * componentScaleX;
  48309. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48310. }
  48311. for (y = 0; y < height; y++) {
  48312. j = 0 | y * componentScaleY;
  48313. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48314. for (x = 0; x < width; x++) {
  48315. data[offset] = output[index + xScaleBlockOffset[x]];
  48316. offset += numComponents;
  48317. }
  48318. }
  48319. }
  48320. var transform = this.decodeTransform;
  48321. if (transform) {
  48322. for (i = 0; i < dataLength;) {
  48323. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48324. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48325. }
  48326. }
  48327. }
  48328. return data;
  48329. },
  48330. _isColorConversionNeeded: function isColorConversionNeeded() {
  48331. if (this.adobe && this.adobe.transformCode) {
  48332. return true;
  48333. } else if (this.numComponents === 3) {
  48334. if (!this.adobe && this.colorTransform === 0) {
  48335. return false;
  48336. }
  48337. return true;
  48338. }
  48339. if (!this.adobe && this.colorTransform === 1) {
  48340. return true;
  48341. }
  48342. return false;
  48343. },
  48344. _convertYccToRgb: function convertYccToRgb(data) {
  48345. var Y, Cb, Cr;
  48346. for (var i = 0, length = data.length; i < length; i += 3) {
  48347. Y = data[i];
  48348. Cb = data[i + 1];
  48349. Cr = data[i + 2];
  48350. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48351. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48352. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48353. }
  48354. return data;
  48355. },
  48356. _convertYcckToRgb: function convertYcckToRgb(data) {
  48357. var Y, Cb, Cr, k;
  48358. var offset = 0;
  48359. for (var i = 0, length = data.length; i < length; i += 4) {
  48360. Y = data[i];
  48361. Cb = data[i + 1];
  48362. Cr = data[i + 2];
  48363. k = data[i + 3];
  48364. 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);
  48365. 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);
  48366. 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);
  48367. data[offset++] = clamp0to255(r);
  48368. data[offset++] = clamp0to255(g);
  48369. data[offset++] = clamp0to255(b);
  48370. }
  48371. return data;
  48372. },
  48373. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48374. var Y, Cb, Cr;
  48375. for (var i = 0, length = data.length; i < length; i += 4) {
  48376. Y = data[i];
  48377. Cb = data[i + 1];
  48378. Cr = data[i + 2];
  48379. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48380. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48381. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48382. }
  48383. return data;
  48384. },
  48385. _convertCmykToRgb: function convertCmykToRgb(data) {
  48386. var c, m, y, k;
  48387. var offset = 0;
  48388. var min = -255 * 255 * 255;
  48389. var scale = 1 / 255 / 255;
  48390. for (var i = 0, length = data.length; i < length; i += 4) {
  48391. c = data[i];
  48392. m = data[i + 1];
  48393. y = data[i + 2];
  48394. k = data[i + 3];
  48395. 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);
  48396. 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);
  48397. 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);
  48398. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48399. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48400. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48401. }
  48402. return data;
  48403. },
  48404. getData: function getData(width, height, forceRGBoutput) {
  48405. if (this.numComponents > 4) {
  48406. error('JPEG error: Unsupported color mode');
  48407. }
  48408. var data = this._getLinearizedBlockData(width, height);
  48409. if (this.numComponents === 1 && forceRGBoutput) {
  48410. var dataLength = data.length;
  48411. var rgbData = new Uint8Array(dataLength * 3);
  48412. var offset = 0;
  48413. for (var i = 0; i < dataLength; i++) {
  48414. var grayColor = data[i];
  48415. rgbData[offset++] = grayColor;
  48416. rgbData[offset++] = grayColor;
  48417. rgbData[offset++] = grayColor;
  48418. }
  48419. return rgbData;
  48420. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48421. return this._convertYccToRgb(data);
  48422. } else if (this.numComponents === 4) {
  48423. if (this._isColorConversionNeeded()) {
  48424. if (forceRGBoutput) {
  48425. return this._convertYcckToRgb(data);
  48426. }
  48427. return this._convertYcckToCmyk(data);
  48428. } else if (forceRGBoutput) {
  48429. return this._convertCmykToRgb(data);
  48430. }
  48431. }
  48432. return data;
  48433. }
  48434. };
  48435. return JpegImage;
  48436. }();
  48437. exports.JpegImage = JpegImage;
  48438. /***/ }),
  48439. /* 37 */
  48440. /***/ (function(module, exports, __w_pdfjs_require__) {
  48441. "use strict";
  48442. var sharedUtil = __w_pdfjs_require__(0);
  48443. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48444. var getMetrics = getLookupTableFactory(function (t) {
  48445. t['Courier'] = 600;
  48446. t['Courier-Bold'] = 600;
  48447. t['Courier-BoldOblique'] = 600;
  48448. t['Courier-Oblique'] = 600;
  48449. t['Helvetica'] = getLookupTableFactory(function (t) {
  48450. t['space'] = 278;
  48451. t['exclam'] = 278;
  48452. t['quotedbl'] = 355;
  48453. t['numbersign'] = 556;
  48454. t['dollar'] = 556;
  48455. t['percent'] = 889;
  48456. t['ampersand'] = 667;
  48457. t['quoteright'] = 222;
  48458. t['parenleft'] = 333;
  48459. t['parenright'] = 333;
  48460. t['asterisk'] = 389;
  48461. t['plus'] = 584;
  48462. t['comma'] = 278;
  48463. t['hyphen'] = 333;
  48464. t['period'] = 278;
  48465. t['slash'] = 278;
  48466. t['zero'] = 556;
  48467. t['one'] = 556;
  48468. t['two'] = 556;
  48469. t['three'] = 556;
  48470. t['four'] = 556;
  48471. t['five'] = 556;
  48472. t['six'] = 556;
  48473. t['seven'] = 556;
  48474. t['eight'] = 556;
  48475. t['nine'] = 556;
  48476. t['colon'] = 278;
  48477. t['semicolon'] = 278;
  48478. t['less'] = 584;
  48479. t['equal'] = 584;
  48480. t['greater'] = 584;
  48481. t['question'] = 556;
  48482. t['at'] = 1015;
  48483. t['A'] = 667;
  48484. t['B'] = 667;
  48485. t['C'] = 722;
  48486. t['D'] = 722;
  48487. t['E'] = 667;
  48488. t['F'] = 611;
  48489. t['G'] = 778;
  48490. t['H'] = 722;
  48491. t['I'] = 278;
  48492. t['J'] = 500;
  48493. t['K'] = 667;
  48494. t['L'] = 556;
  48495. t['M'] = 833;
  48496. t['N'] = 722;
  48497. t['O'] = 778;
  48498. t['P'] = 667;
  48499. t['Q'] = 778;
  48500. t['R'] = 722;
  48501. t['S'] = 667;
  48502. t['T'] = 611;
  48503. t['U'] = 722;
  48504. t['V'] = 667;
  48505. t['W'] = 944;
  48506. t['X'] = 667;
  48507. t['Y'] = 667;
  48508. t['Z'] = 611;
  48509. t['bracketleft'] = 278;
  48510. t['backslash'] = 278;
  48511. t['bracketright'] = 278;
  48512. t['asciicircum'] = 469;
  48513. t['underscore'] = 556;
  48514. t['quoteleft'] = 222;
  48515. t['a'] = 556;
  48516. t['b'] = 556;
  48517. t['c'] = 500;
  48518. t['d'] = 556;
  48519. t['e'] = 556;
  48520. t['f'] = 278;
  48521. t['g'] = 556;
  48522. t['h'] = 556;
  48523. t['i'] = 222;
  48524. t['j'] = 222;
  48525. t['k'] = 500;
  48526. t['l'] = 222;
  48527. t['m'] = 833;
  48528. t['n'] = 556;
  48529. t['o'] = 556;
  48530. t['p'] = 556;
  48531. t['q'] = 556;
  48532. t['r'] = 333;
  48533. t['s'] = 500;
  48534. t['t'] = 278;
  48535. t['u'] = 556;
  48536. t['v'] = 500;
  48537. t['w'] = 722;
  48538. t['x'] = 500;
  48539. t['y'] = 500;
  48540. t['z'] = 500;
  48541. t['braceleft'] = 334;
  48542. t['bar'] = 260;
  48543. t['braceright'] = 334;
  48544. t['asciitilde'] = 584;
  48545. t['exclamdown'] = 333;
  48546. t['cent'] = 556;
  48547. t['sterling'] = 556;
  48548. t['fraction'] = 167;
  48549. t['yen'] = 556;
  48550. t['florin'] = 556;
  48551. t['section'] = 556;
  48552. t['currency'] = 556;
  48553. t['quotesingle'] = 191;
  48554. t['quotedblleft'] = 333;
  48555. t['guillemotleft'] = 556;
  48556. t['guilsinglleft'] = 333;
  48557. t['guilsinglright'] = 333;
  48558. t['fi'] = 500;
  48559. t['fl'] = 500;
  48560. t['endash'] = 556;
  48561. t['dagger'] = 556;
  48562. t['daggerdbl'] = 556;
  48563. t['periodcentered'] = 278;
  48564. t['paragraph'] = 537;
  48565. t['bullet'] = 350;
  48566. t['quotesinglbase'] = 222;
  48567. t['quotedblbase'] = 333;
  48568. t['quotedblright'] = 333;
  48569. t['guillemotright'] = 556;
  48570. t['ellipsis'] = 1000;
  48571. t['perthousand'] = 1000;
  48572. t['questiondown'] = 611;
  48573. t['grave'] = 333;
  48574. t['acute'] = 333;
  48575. t['circumflex'] = 333;
  48576. t['tilde'] = 333;
  48577. t['macron'] = 333;
  48578. t['breve'] = 333;
  48579. t['dotaccent'] = 333;
  48580. t['dieresis'] = 333;
  48581. t['ring'] = 333;
  48582. t['cedilla'] = 333;
  48583. t['hungarumlaut'] = 333;
  48584. t['ogonek'] = 333;
  48585. t['caron'] = 333;
  48586. t['emdash'] = 1000;
  48587. t['AE'] = 1000;
  48588. t['ordfeminine'] = 370;
  48589. t['Lslash'] = 556;
  48590. t['Oslash'] = 778;
  48591. t['OE'] = 1000;
  48592. t['ordmasculine'] = 365;
  48593. t['ae'] = 889;
  48594. t['dotlessi'] = 278;
  48595. t['lslash'] = 222;
  48596. t['oslash'] = 611;
  48597. t['oe'] = 944;
  48598. t['germandbls'] = 611;
  48599. t['Idieresis'] = 278;
  48600. t['eacute'] = 556;
  48601. t['abreve'] = 556;
  48602. t['uhungarumlaut'] = 556;
  48603. t['ecaron'] = 556;
  48604. t['Ydieresis'] = 667;
  48605. t['divide'] = 584;
  48606. t['Yacute'] = 667;
  48607. t['Acircumflex'] = 667;
  48608. t['aacute'] = 556;
  48609. t['Ucircumflex'] = 722;
  48610. t['yacute'] = 500;
  48611. t['scommaaccent'] = 500;
  48612. t['ecircumflex'] = 556;
  48613. t['Uring'] = 722;
  48614. t['Udieresis'] = 722;
  48615. t['aogonek'] = 556;
  48616. t['Uacute'] = 722;
  48617. t['uogonek'] = 556;
  48618. t['Edieresis'] = 667;
  48619. t['Dcroat'] = 722;
  48620. t['commaaccent'] = 250;
  48621. t['copyright'] = 737;
  48622. t['Emacron'] = 667;
  48623. t['ccaron'] = 500;
  48624. t['aring'] = 556;
  48625. t['Ncommaaccent'] = 722;
  48626. t['lacute'] = 222;
  48627. t['agrave'] = 556;
  48628. t['Tcommaaccent'] = 611;
  48629. t['Cacute'] = 722;
  48630. t['atilde'] = 556;
  48631. t['Edotaccent'] = 667;
  48632. t['scaron'] = 500;
  48633. t['scedilla'] = 500;
  48634. t['iacute'] = 278;
  48635. t['lozenge'] = 471;
  48636. t['Rcaron'] = 722;
  48637. t['Gcommaaccent'] = 778;
  48638. t['ucircumflex'] = 556;
  48639. t['acircumflex'] = 556;
  48640. t['Amacron'] = 667;
  48641. t['rcaron'] = 333;
  48642. t['ccedilla'] = 500;
  48643. t['Zdotaccent'] = 611;
  48644. t['Thorn'] = 667;
  48645. t['Omacron'] = 778;
  48646. t['Racute'] = 722;
  48647. t['Sacute'] = 667;
  48648. t['dcaron'] = 643;
  48649. t['Umacron'] = 722;
  48650. t['uring'] = 556;
  48651. t['threesuperior'] = 333;
  48652. t['Ograve'] = 778;
  48653. t['Agrave'] = 667;
  48654. t['Abreve'] = 667;
  48655. t['multiply'] = 584;
  48656. t['uacute'] = 556;
  48657. t['Tcaron'] = 611;
  48658. t['partialdiff'] = 476;
  48659. t['ydieresis'] = 500;
  48660. t['Nacute'] = 722;
  48661. t['icircumflex'] = 278;
  48662. t['Ecircumflex'] = 667;
  48663. t['adieresis'] = 556;
  48664. t['edieresis'] = 556;
  48665. t['cacute'] = 500;
  48666. t['nacute'] = 556;
  48667. t['umacron'] = 556;
  48668. t['Ncaron'] = 722;
  48669. t['Iacute'] = 278;
  48670. t['plusminus'] = 584;
  48671. t['brokenbar'] = 260;
  48672. t['registered'] = 737;
  48673. t['Gbreve'] = 778;
  48674. t['Idotaccent'] = 278;
  48675. t['summation'] = 600;
  48676. t['Egrave'] = 667;
  48677. t['racute'] = 333;
  48678. t['omacron'] = 556;
  48679. t['Zacute'] = 611;
  48680. t['Zcaron'] = 611;
  48681. t['greaterequal'] = 549;
  48682. t['Eth'] = 722;
  48683. t['Ccedilla'] = 722;
  48684. t['lcommaaccent'] = 222;
  48685. t['tcaron'] = 317;
  48686. t['eogonek'] = 556;
  48687. t['Uogonek'] = 722;
  48688. t['Aacute'] = 667;
  48689. t['Adieresis'] = 667;
  48690. t['egrave'] = 556;
  48691. t['zacute'] = 500;
  48692. t['iogonek'] = 222;
  48693. t['Oacute'] = 778;
  48694. t['oacute'] = 556;
  48695. t['amacron'] = 556;
  48696. t['sacute'] = 500;
  48697. t['idieresis'] = 278;
  48698. t['Ocircumflex'] = 778;
  48699. t['Ugrave'] = 722;
  48700. t['Delta'] = 612;
  48701. t['thorn'] = 556;
  48702. t['twosuperior'] = 333;
  48703. t['Odieresis'] = 778;
  48704. t['mu'] = 556;
  48705. t['igrave'] = 278;
  48706. t['ohungarumlaut'] = 556;
  48707. t['Eogonek'] = 667;
  48708. t['dcroat'] = 556;
  48709. t['threequarters'] = 834;
  48710. t['Scedilla'] = 667;
  48711. t['lcaron'] = 299;
  48712. t['Kcommaaccent'] = 667;
  48713. t['Lacute'] = 556;
  48714. t['trademark'] = 1000;
  48715. t['edotaccent'] = 556;
  48716. t['Igrave'] = 278;
  48717. t['Imacron'] = 278;
  48718. t['Lcaron'] = 556;
  48719. t['onehalf'] = 834;
  48720. t['lessequal'] = 549;
  48721. t['ocircumflex'] = 556;
  48722. t['ntilde'] = 556;
  48723. t['Uhungarumlaut'] = 722;
  48724. t['Eacute'] = 667;
  48725. t['emacron'] = 556;
  48726. t['gbreve'] = 556;
  48727. t['onequarter'] = 834;
  48728. t['Scaron'] = 667;
  48729. t['Scommaaccent'] = 667;
  48730. t['Ohungarumlaut'] = 778;
  48731. t['degree'] = 400;
  48732. t['ograve'] = 556;
  48733. t['Ccaron'] = 722;
  48734. t['ugrave'] = 556;
  48735. t['radical'] = 453;
  48736. t['Dcaron'] = 722;
  48737. t['rcommaaccent'] = 333;
  48738. t['Ntilde'] = 722;
  48739. t['otilde'] = 556;
  48740. t['Rcommaaccent'] = 722;
  48741. t['Lcommaaccent'] = 556;
  48742. t['Atilde'] = 667;
  48743. t['Aogonek'] = 667;
  48744. t['Aring'] = 667;
  48745. t['Otilde'] = 778;
  48746. t['zdotaccent'] = 500;
  48747. t['Ecaron'] = 667;
  48748. t['Iogonek'] = 278;
  48749. t['kcommaaccent'] = 500;
  48750. t['minus'] = 584;
  48751. t['Icircumflex'] = 278;
  48752. t['ncaron'] = 556;
  48753. t['tcommaaccent'] = 278;
  48754. t['logicalnot'] = 584;
  48755. t['odieresis'] = 556;
  48756. t['udieresis'] = 556;
  48757. t['notequal'] = 549;
  48758. t['gcommaaccent'] = 556;
  48759. t['eth'] = 556;
  48760. t['zcaron'] = 500;
  48761. t['ncommaaccent'] = 556;
  48762. t['onesuperior'] = 333;
  48763. t['imacron'] = 278;
  48764. t['Euro'] = 556;
  48765. });
  48766. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48767. t['space'] = 278;
  48768. t['exclam'] = 333;
  48769. t['quotedbl'] = 474;
  48770. t['numbersign'] = 556;
  48771. t['dollar'] = 556;
  48772. t['percent'] = 889;
  48773. t['ampersand'] = 722;
  48774. t['quoteright'] = 278;
  48775. t['parenleft'] = 333;
  48776. t['parenright'] = 333;
  48777. t['asterisk'] = 389;
  48778. t['plus'] = 584;
  48779. t['comma'] = 278;
  48780. t['hyphen'] = 333;
  48781. t['period'] = 278;
  48782. t['slash'] = 278;
  48783. t['zero'] = 556;
  48784. t['one'] = 556;
  48785. t['two'] = 556;
  48786. t['three'] = 556;
  48787. t['four'] = 556;
  48788. t['five'] = 556;
  48789. t['six'] = 556;
  48790. t['seven'] = 556;
  48791. t['eight'] = 556;
  48792. t['nine'] = 556;
  48793. t['colon'] = 333;
  48794. t['semicolon'] = 333;
  48795. t['less'] = 584;
  48796. t['equal'] = 584;
  48797. t['greater'] = 584;
  48798. t['question'] = 611;
  48799. t['at'] = 975;
  48800. t['A'] = 722;
  48801. t['B'] = 722;
  48802. t['C'] = 722;
  48803. t['D'] = 722;
  48804. t['E'] = 667;
  48805. t['F'] = 611;
  48806. t['G'] = 778;
  48807. t['H'] = 722;
  48808. t['I'] = 278;
  48809. t['J'] = 556;
  48810. t['K'] = 722;
  48811. t['L'] = 611;
  48812. t['M'] = 833;
  48813. t['N'] = 722;
  48814. t['O'] = 778;
  48815. t['P'] = 667;
  48816. t['Q'] = 778;
  48817. t['R'] = 722;
  48818. t['S'] = 667;
  48819. t['T'] = 611;
  48820. t['U'] = 722;
  48821. t['V'] = 667;
  48822. t['W'] = 944;
  48823. t['X'] = 667;
  48824. t['Y'] = 667;
  48825. t['Z'] = 611;
  48826. t['bracketleft'] = 333;
  48827. t['backslash'] = 278;
  48828. t['bracketright'] = 333;
  48829. t['asciicircum'] = 584;
  48830. t['underscore'] = 556;
  48831. t['quoteleft'] = 278;
  48832. t['a'] = 556;
  48833. t['b'] = 611;
  48834. t['c'] = 556;
  48835. t['d'] = 611;
  48836. t['e'] = 556;
  48837. t['f'] = 333;
  48838. t['g'] = 611;
  48839. t['h'] = 611;
  48840. t['i'] = 278;
  48841. t['j'] = 278;
  48842. t['k'] = 556;
  48843. t['l'] = 278;
  48844. t['m'] = 889;
  48845. t['n'] = 611;
  48846. t['o'] = 611;
  48847. t['p'] = 611;
  48848. t['q'] = 611;
  48849. t['r'] = 389;
  48850. t['s'] = 556;
  48851. t['t'] = 333;
  48852. t['u'] = 611;
  48853. t['v'] = 556;
  48854. t['w'] = 778;
  48855. t['x'] = 556;
  48856. t['y'] = 556;
  48857. t['z'] = 500;
  48858. t['braceleft'] = 389;
  48859. t['bar'] = 280;
  48860. t['braceright'] = 389;
  48861. t['asciitilde'] = 584;
  48862. t['exclamdown'] = 333;
  48863. t['cent'] = 556;
  48864. t['sterling'] = 556;
  48865. t['fraction'] = 167;
  48866. t['yen'] = 556;
  48867. t['florin'] = 556;
  48868. t['section'] = 556;
  48869. t['currency'] = 556;
  48870. t['quotesingle'] = 238;
  48871. t['quotedblleft'] = 500;
  48872. t['guillemotleft'] = 556;
  48873. t['guilsinglleft'] = 333;
  48874. t['guilsinglright'] = 333;
  48875. t['fi'] = 611;
  48876. t['fl'] = 611;
  48877. t['endash'] = 556;
  48878. t['dagger'] = 556;
  48879. t['daggerdbl'] = 556;
  48880. t['periodcentered'] = 278;
  48881. t['paragraph'] = 556;
  48882. t['bullet'] = 350;
  48883. t['quotesinglbase'] = 278;
  48884. t['quotedblbase'] = 500;
  48885. t['quotedblright'] = 500;
  48886. t['guillemotright'] = 556;
  48887. t['ellipsis'] = 1000;
  48888. t['perthousand'] = 1000;
  48889. t['questiondown'] = 611;
  48890. t['grave'] = 333;
  48891. t['acute'] = 333;
  48892. t['circumflex'] = 333;
  48893. t['tilde'] = 333;
  48894. t['macron'] = 333;
  48895. t['breve'] = 333;
  48896. t['dotaccent'] = 333;
  48897. t['dieresis'] = 333;
  48898. t['ring'] = 333;
  48899. t['cedilla'] = 333;
  48900. t['hungarumlaut'] = 333;
  48901. t['ogonek'] = 333;
  48902. t['caron'] = 333;
  48903. t['emdash'] = 1000;
  48904. t['AE'] = 1000;
  48905. t['ordfeminine'] = 370;
  48906. t['Lslash'] = 611;
  48907. t['Oslash'] = 778;
  48908. t['OE'] = 1000;
  48909. t['ordmasculine'] = 365;
  48910. t['ae'] = 889;
  48911. t['dotlessi'] = 278;
  48912. t['lslash'] = 278;
  48913. t['oslash'] = 611;
  48914. t['oe'] = 944;
  48915. t['germandbls'] = 611;
  48916. t['Idieresis'] = 278;
  48917. t['eacute'] = 556;
  48918. t['abreve'] = 556;
  48919. t['uhungarumlaut'] = 611;
  48920. t['ecaron'] = 556;
  48921. t['Ydieresis'] = 667;
  48922. t['divide'] = 584;
  48923. t['Yacute'] = 667;
  48924. t['Acircumflex'] = 722;
  48925. t['aacute'] = 556;
  48926. t['Ucircumflex'] = 722;
  48927. t['yacute'] = 556;
  48928. t['scommaaccent'] = 556;
  48929. t['ecircumflex'] = 556;
  48930. t['Uring'] = 722;
  48931. t['Udieresis'] = 722;
  48932. t['aogonek'] = 556;
  48933. t['Uacute'] = 722;
  48934. t['uogonek'] = 611;
  48935. t['Edieresis'] = 667;
  48936. t['Dcroat'] = 722;
  48937. t['commaaccent'] = 250;
  48938. t['copyright'] = 737;
  48939. t['Emacron'] = 667;
  48940. t['ccaron'] = 556;
  48941. t['aring'] = 556;
  48942. t['Ncommaaccent'] = 722;
  48943. t['lacute'] = 278;
  48944. t['agrave'] = 556;
  48945. t['Tcommaaccent'] = 611;
  48946. t['Cacute'] = 722;
  48947. t['atilde'] = 556;
  48948. t['Edotaccent'] = 667;
  48949. t['scaron'] = 556;
  48950. t['scedilla'] = 556;
  48951. t['iacute'] = 278;
  48952. t['lozenge'] = 494;
  48953. t['Rcaron'] = 722;
  48954. t['Gcommaaccent'] = 778;
  48955. t['ucircumflex'] = 611;
  48956. t['acircumflex'] = 556;
  48957. t['Amacron'] = 722;
  48958. t['rcaron'] = 389;
  48959. t['ccedilla'] = 556;
  48960. t['Zdotaccent'] = 611;
  48961. t['Thorn'] = 667;
  48962. t['Omacron'] = 778;
  48963. t['Racute'] = 722;
  48964. t['Sacute'] = 667;
  48965. t['dcaron'] = 743;
  48966. t['Umacron'] = 722;
  48967. t['uring'] = 611;
  48968. t['threesuperior'] = 333;
  48969. t['Ograve'] = 778;
  48970. t['Agrave'] = 722;
  48971. t['Abreve'] = 722;
  48972. t['multiply'] = 584;
  48973. t['uacute'] = 611;
  48974. t['Tcaron'] = 611;
  48975. t['partialdiff'] = 494;
  48976. t['ydieresis'] = 556;
  48977. t['Nacute'] = 722;
  48978. t['icircumflex'] = 278;
  48979. t['Ecircumflex'] = 667;
  48980. t['adieresis'] = 556;
  48981. t['edieresis'] = 556;
  48982. t['cacute'] = 556;
  48983. t['nacute'] = 611;
  48984. t['umacron'] = 611;
  48985. t['Ncaron'] = 722;
  48986. t['Iacute'] = 278;
  48987. t['plusminus'] = 584;
  48988. t['brokenbar'] = 280;
  48989. t['registered'] = 737;
  48990. t['Gbreve'] = 778;
  48991. t['Idotaccent'] = 278;
  48992. t['summation'] = 600;
  48993. t['Egrave'] = 667;
  48994. t['racute'] = 389;
  48995. t['omacron'] = 611;
  48996. t['Zacute'] = 611;
  48997. t['Zcaron'] = 611;
  48998. t['greaterequal'] = 549;
  48999. t['Eth'] = 722;
  49000. t['Ccedilla'] = 722;
  49001. t['lcommaaccent'] = 278;
  49002. t['tcaron'] = 389;
  49003. t['eogonek'] = 556;
  49004. t['Uogonek'] = 722;
  49005. t['Aacute'] = 722;
  49006. t['Adieresis'] = 722;
  49007. t['egrave'] = 556;
  49008. t['zacute'] = 500;
  49009. t['iogonek'] = 278;
  49010. t['Oacute'] = 778;
  49011. t['oacute'] = 611;
  49012. t['amacron'] = 556;
  49013. t['sacute'] = 556;
  49014. t['idieresis'] = 278;
  49015. t['Ocircumflex'] = 778;
  49016. t['Ugrave'] = 722;
  49017. t['Delta'] = 612;
  49018. t['thorn'] = 611;
  49019. t['twosuperior'] = 333;
  49020. t['Odieresis'] = 778;
  49021. t['mu'] = 611;
  49022. t['igrave'] = 278;
  49023. t['ohungarumlaut'] = 611;
  49024. t['Eogonek'] = 667;
  49025. t['dcroat'] = 611;
  49026. t['threequarters'] = 834;
  49027. t['Scedilla'] = 667;
  49028. t['lcaron'] = 400;
  49029. t['Kcommaaccent'] = 722;
  49030. t['Lacute'] = 611;
  49031. t['trademark'] = 1000;
  49032. t['edotaccent'] = 556;
  49033. t['Igrave'] = 278;
  49034. t['Imacron'] = 278;
  49035. t['Lcaron'] = 611;
  49036. t['onehalf'] = 834;
  49037. t['lessequal'] = 549;
  49038. t['ocircumflex'] = 611;
  49039. t['ntilde'] = 611;
  49040. t['Uhungarumlaut'] = 722;
  49041. t['Eacute'] = 667;
  49042. t['emacron'] = 556;
  49043. t['gbreve'] = 611;
  49044. t['onequarter'] = 834;
  49045. t['Scaron'] = 667;
  49046. t['Scommaaccent'] = 667;
  49047. t['Ohungarumlaut'] = 778;
  49048. t['degree'] = 400;
  49049. t['ograve'] = 611;
  49050. t['Ccaron'] = 722;
  49051. t['ugrave'] = 611;
  49052. t['radical'] = 549;
  49053. t['Dcaron'] = 722;
  49054. t['rcommaaccent'] = 389;
  49055. t['Ntilde'] = 722;
  49056. t['otilde'] = 611;
  49057. t['Rcommaaccent'] = 722;
  49058. t['Lcommaaccent'] = 611;
  49059. t['Atilde'] = 722;
  49060. t['Aogonek'] = 722;
  49061. t['Aring'] = 722;
  49062. t['Otilde'] = 778;
  49063. t['zdotaccent'] = 500;
  49064. t['Ecaron'] = 667;
  49065. t['Iogonek'] = 278;
  49066. t['kcommaaccent'] = 556;
  49067. t['minus'] = 584;
  49068. t['Icircumflex'] = 278;
  49069. t['ncaron'] = 611;
  49070. t['tcommaaccent'] = 333;
  49071. t['logicalnot'] = 584;
  49072. t['odieresis'] = 611;
  49073. t['udieresis'] = 611;
  49074. t['notequal'] = 549;
  49075. t['gcommaaccent'] = 611;
  49076. t['eth'] = 611;
  49077. t['zcaron'] = 500;
  49078. t['ncommaaccent'] = 611;
  49079. t['onesuperior'] = 333;
  49080. t['imacron'] = 278;
  49081. t['Euro'] = 556;
  49082. });
  49083. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49084. t['space'] = 278;
  49085. t['exclam'] = 333;
  49086. t['quotedbl'] = 474;
  49087. t['numbersign'] = 556;
  49088. t['dollar'] = 556;
  49089. t['percent'] = 889;
  49090. t['ampersand'] = 722;
  49091. t['quoteright'] = 278;
  49092. t['parenleft'] = 333;
  49093. t['parenright'] = 333;
  49094. t['asterisk'] = 389;
  49095. t['plus'] = 584;
  49096. t['comma'] = 278;
  49097. t['hyphen'] = 333;
  49098. t['period'] = 278;
  49099. t['slash'] = 278;
  49100. t['zero'] = 556;
  49101. t['one'] = 556;
  49102. t['two'] = 556;
  49103. t['three'] = 556;
  49104. t['four'] = 556;
  49105. t['five'] = 556;
  49106. t['six'] = 556;
  49107. t['seven'] = 556;
  49108. t['eight'] = 556;
  49109. t['nine'] = 556;
  49110. t['colon'] = 333;
  49111. t['semicolon'] = 333;
  49112. t['less'] = 584;
  49113. t['equal'] = 584;
  49114. t['greater'] = 584;
  49115. t['question'] = 611;
  49116. t['at'] = 975;
  49117. t['A'] = 722;
  49118. t['B'] = 722;
  49119. t['C'] = 722;
  49120. t['D'] = 722;
  49121. t['E'] = 667;
  49122. t['F'] = 611;
  49123. t['G'] = 778;
  49124. t['H'] = 722;
  49125. t['I'] = 278;
  49126. t['J'] = 556;
  49127. t['K'] = 722;
  49128. t['L'] = 611;
  49129. t['M'] = 833;
  49130. t['N'] = 722;
  49131. t['O'] = 778;
  49132. t['P'] = 667;
  49133. t['Q'] = 778;
  49134. t['R'] = 722;
  49135. t['S'] = 667;
  49136. t['T'] = 611;
  49137. t['U'] = 722;
  49138. t['V'] = 667;
  49139. t['W'] = 944;
  49140. t['X'] = 667;
  49141. t['Y'] = 667;
  49142. t['Z'] = 611;
  49143. t['bracketleft'] = 333;
  49144. t['backslash'] = 278;
  49145. t['bracketright'] = 333;
  49146. t['asciicircum'] = 584;
  49147. t['underscore'] = 556;
  49148. t['quoteleft'] = 278;
  49149. t['a'] = 556;
  49150. t['b'] = 611;
  49151. t['c'] = 556;
  49152. t['d'] = 611;
  49153. t['e'] = 556;
  49154. t['f'] = 333;
  49155. t['g'] = 611;
  49156. t['h'] = 611;
  49157. t['i'] = 278;
  49158. t['j'] = 278;
  49159. t['k'] = 556;
  49160. t['l'] = 278;
  49161. t['m'] = 889;
  49162. t['n'] = 611;
  49163. t['o'] = 611;
  49164. t['p'] = 611;
  49165. t['q'] = 611;
  49166. t['r'] = 389;
  49167. t['s'] = 556;
  49168. t['t'] = 333;
  49169. t['u'] = 611;
  49170. t['v'] = 556;
  49171. t['w'] = 778;
  49172. t['x'] = 556;
  49173. t['y'] = 556;
  49174. t['z'] = 500;
  49175. t['braceleft'] = 389;
  49176. t['bar'] = 280;
  49177. t['braceright'] = 389;
  49178. t['asciitilde'] = 584;
  49179. t['exclamdown'] = 333;
  49180. t['cent'] = 556;
  49181. t['sterling'] = 556;
  49182. t['fraction'] = 167;
  49183. t['yen'] = 556;
  49184. t['florin'] = 556;
  49185. t['section'] = 556;
  49186. t['currency'] = 556;
  49187. t['quotesingle'] = 238;
  49188. t['quotedblleft'] = 500;
  49189. t['guillemotleft'] = 556;
  49190. t['guilsinglleft'] = 333;
  49191. t['guilsinglright'] = 333;
  49192. t['fi'] = 611;
  49193. t['fl'] = 611;
  49194. t['endash'] = 556;
  49195. t['dagger'] = 556;
  49196. t['daggerdbl'] = 556;
  49197. t['periodcentered'] = 278;
  49198. t['paragraph'] = 556;
  49199. t['bullet'] = 350;
  49200. t['quotesinglbase'] = 278;
  49201. t['quotedblbase'] = 500;
  49202. t['quotedblright'] = 500;
  49203. t['guillemotright'] = 556;
  49204. t['ellipsis'] = 1000;
  49205. t['perthousand'] = 1000;
  49206. t['questiondown'] = 611;
  49207. t['grave'] = 333;
  49208. t['acute'] = 333;
  49209. t['circumflex'] = 333;
  49210. t['tilde'] = 333;
  49211. t['macron'] = 333;
  49212. t['breve'] = 333;
  49213. t['dotaccent'] = 333;
  49214. t['dieresis'] = 333;
  49215. t['ring'] = 333;
  49216. t['cedilla'] = 333;
  49217. t['hungarumlaut'] = 333;
  49218. t['ogonek'] = 333;
  49219. t['caron'] = 333;
  49220. t['emdash'] = 1000;
  49221. t['AE'] = 1000;
  49222. t['ordfeminine'] = 370;
  49223. t['Lslash'] = 611;
  49224. t['Oslash'] = 778;
  49225. t['OE'] = 1000;
  49226. t['ordmasculine'] = 365;
  49227. t['ae'] = 889;
  49228. t['dotlessi'] = 278;
  49229. t['lslash'] = 278;
  49230. t['oslash'] = 611;
  49231. t['oe'] = 944;
  49232. t['germandbls'] = 611;
  49233. t['Idieresis'] = 278;
  49234. t['eacute'] = 556;
  49235. t['abreve'] = 556;
  49236. t['uhungarumlaut'] = 611;
  49237. t['ecaron'] = 556;
  49238. t['Ydieresis'] = 667;
  49239. t['divide'] = 584;
  49240. t['Yacute'] = 667;
  49241. t['Acircumflex'] = 722;
  49242. t['aacute'] = 556;
  49243. t['Ucircumflex'] = 722;
  49244. t['yacute'] = 556;
  49245. t['scommaaccent'] = 556;
  49246. t['ecircumflex'] = 556;
  49247. t['Uring'] = 722;
  49248. t['Udieresis'] = 722;
  49249. t['aogonek'] = 556;
  49250. t['Uacute'] = 722;
  49251. t['uogonek'] = 611;
  49252. t['Edieresis'] = 667;
  49253. t['Dcroat'] = 722;
  49254. t['commaaccent'] = 250;
  49255. t['copyright'] = 737;
  49256. t['Emacron'] = 667;
  49257. t['ccaron'] = 556;
  49258. t['aring'] = 556;
  49259. t['Ncommaaccent'] = 722;
  49260. t['lacute'] = 278;
  49261. t['agrave'] = 556;
  49262. t['Tcommaaccent'] = 611;
  49263. t['Cacute'] = 722;
  49264. t['atilde'] = 556;
  49265. t['Edotaccent'] = 667;
  49266. t['scaron'] = 556;
  49267. t['scedilla'] = 556;
  49268. t['iacute'] = 278;
  49269. t['lozenge'] = 494;
  49270. t['Rcaron'] = 722;
  49271. t['Gcommaaccent'] = 778;
  49272. t['ucircumflex'] = 611;
  49273. t['acircumflex'] = 556;
  49274. t['Amacron'] = 722;
  49275. t['rcaron'] = 389;
  49276. t['ccedilla'] = 556;
  49277. t['Zdotaccent'] = 611;
  49278. t['Thorn'] = 667;
  49279. t['Omacron'] = 778;
  49280. t['Racute'] = 722;
  49281. t['Sacute'] = 667;
  49282. t['dcaron'] = 743;
  49283. t['Umacron'] = 722;
  49284. t['uring'] = 611;
  49285. t['threesuperior'] = 333;
  49286. t['Ograve'] = 778;
  49287. t['Agrave'] = 722;
  49288. t['Abreve'] = 722;
  49289. t['multiply'] = 584;
  49290. t['uacute'] = 611;
  49291. t['Tcaron'] = 611;
  49292. t['partialdiff'] = 494;
  49293. t['ydieresis'] = 556;
  49294. t['Nacute'] = 722;
  49295. t['icircumflex'] = 278;
  49296. t['Ecircumflex'] = 667;
  49297. t['adieresis'] = 556;
  49298. t['edieresis'] = 556;
  49299. t['cacute'] = 556;
  49300. t['nacute'] = 611;
  49301. t['umacron'] = 611;
  49302. t['Ncaron'] = 722;
  49303. t['Iacute'] = 278;
  49304. t['plusminus'] = 584;
  49305. t['brokenbar'] = 280;
  49306. t['registered'] = 737;
  49307. t['Gbreve'] = 778;
  49308. t['Idotaccent'] = 278;
  49309. t['summation'] = 600;
  49310. t['Egrave'] = 667;
  49311. t['racute'] = 389;
  49312. t['omacron'] = 611;
  49313. t['Zacute'] = 611;
  49314. t['Zcaron'] = 611;
  49315. t['greaterequal'] = 549;
  49316. t['Eth'] = 722;
  49317. t['Ccedilla'] = 722;
  49318. t['lcommaaccent'] = 278;
  49319. t['tcaron'] = 389;
  49320. t['eogonek'] = 556;
  49321. t['Uogonek'] = 722;
  49322. t['Aacute'] = 722;
  49323. t['Adieresis'] = 722;
  49324. t['egrave'] = 556;
  49325. t['zacute'] = 500;
  49326. t['iogonek'] = 278;
  49327. t['Oacute'] = 778;
  49328. t['oacute'] = 611;
  49329. t['amacron'] = 556;
  49330. t['sacute'] = 556;
  49331. t['idieresis'] = 278;
  49332. t['Ocircumflex'] = 778;
  49333. t['Ugrave'] = 722;
  49334. t['Delta'] = 612;
  49335. t['thorn'] = 611;
  49336. t['twosuperior'] = 333;
  49337. t['Odieresis'] = 778;
  49338. t['mu'] = 611;
  49339. t['igrave'] = 278;
  49340. t['ohungarumlaut'] = 611;
  49341. t['Eogonek'] = 667;
  49342. t['dcroat'] = 611;
  49343. t['threequarters'] = 834;
  49344. t['Scedilla'] = 667;
  49345. t['lcaron'] = 400;
  49346. t['Kcommaaccent'] = 722;
  49347. t['Lacute'] = 611;
  49348. t['trademark'] = 1000;
  49349. t['edotaccent'] = 556;
  49350. t['Igrave'] = 278;
  49351. t['Imacron'] = 278;
  49352. t['Lcaron'] = 611;
  49353. t['onehalf'] = 834;
  49354. t['lessequal'] = 549;
  49355. t['ocircumflex'] = 611;
  49356. t['ntilde'] = 611;
  49357. t['Uhungarumlaut'] = 722;
  49358. t['Eacute'] = 667;
  49359. t['emacron'] = 556;
  49360. t['gbreve'] = 611;
  49361. t['onequarter'] = 834;
  49362. t['Scaron'] = 667;
  49363. t['Scommaaccent'] = 667;
  49364. t['Ohungarumlaut'] = 778;
  49365. t['degree'] = 400;
  49366. t['ograve'] = 611;
  49367. t['Ccaron'] = 722;
  49368. t['ugrave'] = 611;
  49369. t['radical'] = 549;
  49370. t['Dcaron'] = 722;
  49371. t['rcommaaccent'] = 389;
  49372. t['Ntilde'] = 722;
  49373. t['otilde'] = 611;
  49374. t['Rcommaaccent'] = 722;
  49375. t['Lcommaaccent'] = 611;
  49376. t['Atilde'] = 722;
  49377. t['Aogonek'] = 722;
  49378. t['Aring'] = 722;
  49379. t['Otilde'] = 778;
  49380. t['zdotaccent'] = 500;
  49381. t['Ecaron'] = 667;
  49382. t['Iogonek'] = 278;
  49383. t['kcommaaccent'] = 556;
  49384. t['minus'] = 584;
  49385. t['Icircumflex'] = 278;
  49386. t['ncaron'] = 611;
  49387. t['tcommaaccent'] = 333;
  49388. t['logicalnot'] = 584;
  49389. t['odieresis'] = 611;
  49390. t['udieresis'] = 611;
  49391. t['notequal'] = 549;
  49392. t['gcommaaccent'] = 611;
  49393. t['eth'] = 611;
  49394. t['zcaron'] = 500;
  49395. t['ncommaaccent'] = 611;
  49396. t['onesuperior'] = 333;
  49397. t['imacron'] = 278;
  49398. t['Euro'] = 556;
  49399. });
  49400. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49401. t['space'] = 278;
  49402. t['exclam'] = 278;
  49403. t['quotedbl'] = 355;
  49404. t['numbersign'] = 556;
  49405. t['dollar'] = 556;
  49406. t['percent'] = 889;
  49407. t['ampersand'] = 667;
  49408. t['quoteright'] = 222;
  49409. t['parenleft'] = 333;
  49410. t['parenright'] = 333;
  49411. t['asterisk'] = 389;
  49412. t['plus'] = 584;
  49413. t['comma'] = 278;
  49414. t['hyphen'] = 333;
  49415. t['period'] = 278;
  49416. t['slash'] = 278;
  49417. t['zero'] = 556;
  49418. t['one'] = 556;
  49419. t['two'] = 556;
  49420. t['three'] = 556;
  49421. t['four'] = 556;
  49422. t['five'] = 556;
  49423. t['six'] = 556;
  49424. t['seven'] = 556;
  49425. t['eight'] = 556;
  49426. t['nine'] = 556;
  49427. t['colon'] = 278;
  49428. t['semicolon'] = 278;
  49429. t['less'] = 584;
  49430. t['equal'] = 584;
  49431. t['greater'] = 584;
  49432. t['question'] = 556;
  49433. t['at'] = 1015;
  49434. t['A'] = 667;
  49435. t['B'] = 667;
  49436. t['C'] = 722;
  49437. t['D'] = 722;
  49438. t['E'] = 667;
  49439. t['F'] = 611;
  49440. t['G'] = 778;
  49441. t['H'] = 722;
  49442. t['I'] = 278;
  49443. t['J'] = 500;
  49444. t['K'] = 667;
  49445. t['L'] = 556;
  49446. t['M'] = 833;
  49447. t['N'] = 722;
  49448. t['O'] = 778;
  49449. t['P'] = 667;
  49450. t['Q'] = 778;
  49451. t['R'] = 722;
  49452. t['S'] = 667;
  49453. t['T'] = 611;
  49454. t['U'] = 722;
  49455. t['V'] = 667;
  49456. t['W'] = 944;
  49457. t['X'] = 667;
  49458. t['Y'] = 667;
  49459. t['Z'] = 611;
  49460. t['bracketleft'] = 278;
  49461. t['backslash'] = 278;
  49462. t['bracketright'] = 278;
  49463. t['asciicircum'] = 469;
  49464. t['underscore'] = 556;
  49465. t['quoteleft'] = 222;
  49466. t['a'] = 556;
  49467. t['b'] = 556;
  49468. t['c'] = 500;
  49469. t['d'] = 556;
  49470. t['e'] = 556;
  49471. t['f'] = 278;
  49472. t['g'] = 556;
  49473. t['h'] = 556;
  49474. t['i'] = 222;
  49475. t['j'] = 222;
  49476. t['k'] = 500;
  49477. t['l'] = 222;
  49478. t['m'] = 833;
  49479. t['n'] = 556;
  49480. t['o'] = 556;
  49481. t['p'] = 556;
  49482. t['q'] = 556;
  49483. t['r'] = 333;
  49484. t['s'] = 500;
  49485. t['t'] = 278;
  49486. t['u'] = 556;
  49487. t['v'] = 500;
  49488. t['w'] = 722;
  49489. t['x'] = 500;
  49490. t['y'] = 500;
  49491. t['z'] = 500;
  49492. t['braceleft'] = 334;
  49493. t['bar'] = 260;
  49494. t['braceright'] = 334;
  49495. t['asciitilde'] = 584;
  49496. t['exclamdown'] = 333;
  49497. t['cent'] = 556;
  49498. t['sterling'] = 556;
  49499. t['fraction'] = 167;
  49500. t['yen'] = 556;
  49501. t['florin'] = 556;
  49502. t['section'] = 556;
  49503. t['currency'] = 556;
  49504. t['quotesingle'] = 191;
  49505. t['quotedblleft'] = 333;
  49506. t['guillemotleft'] = 556;
  49507. t['guilsinglleft'] = 333;
  49508. t['guilsinglright'] = 333;
  49509. t['fi'] = 500;
  49510. t['fl'] = 500;
  49511. t['endash'] = 556;
  49512. t['dagger'] = 556;
  49513. t['daggerdbl'] = 556;
  49514. t['periodcentered'] = 278;
  49515. t['paragraph'] = 537;
  49516. t['bullet'] = 350;
  49517. t['quotesinglbase'] = 222;
  49518. t['quotedblbase'] = 333;
  49519. t['quotedblright'] = 333;
  49520. t['guillemotright'] = 556;
  49521. t['ellipsis'] = 1000;
  49522. t['perthousand'] = 1000;
  49523. t['questiondown'] = 611;
  49524. t['grave'] = 333;
  49525. t['acute'] = 333;
  49526. t['circumflex'] = 333;
  49527. t['tilde'] = 333;
  49528. t['macron'] = 333;
  49529. t['breve'] = 333;
  49530. t['dotaccent'] = 333;
  49531. t['dieresis'] = 333;
  49532. t['ring'] = 333;
  49533. t['cedilla'] = 333;
  49534. t['hungarumlaut'] = 333;
  49535. t['ogonek'] = 333;
  49536. t['caron'] = 333;
  49537. t['emdash'] = 1000;
  49538. t['AE'] = 1000;
  49539. t['ordfeminine'] = 370;
  49540. t['Lslash'] = 556;
  49541. t['Oslash'] = 778;
  49542. t['OE'] = 1000;
  49543. t['ordmasculine'] = 365;
  49544. t['ae'] = 889;
  49545. t['dotlessi'] = 278;
  49546. t['lslash'] = 222;
  49547. t['oslash'] = 611;
  49548. t['oe'] = 944;
  49549. t['germandbls'] = 611;
  49550. t['Idieresis'] = 278;
  49551. t['eacute'] = 556;
  49552. t['abreve'] = 556;
  49553. t['uhungarumlaut'] = 556;
  49554. t['ecaron'] = 556;
  49555. t['Ydieresis'] = 667;
  49556. t['divide'] = 584;
  49557. t['Yacute'] = 667;
  49558. t['Acircumflex'] = 667;
  49559. t['aacute'] = 556;
  49560. t['Ucircumflex'] = 722;
  49561. t['yacute'] = 500;
  49562. t['scommaaccent'] = 500;
  49563. t['ecircumflex'] = 556;
  49564. t['Uring'] = 722;
  49565. t['Udieresis'] = 722;
  49566. t['aogonek'] = 556;
  49567. t['Uacute'] = 722;
  49568. t['uogonek'] = 556;
  49569. t['Edieresis'] = 667;
  49570. t['Dcroat'] = 722;
  49571. t['commaaccent'] = 250;
  49572. t['copyright'] = 737;
  49573. t['Emacron'] = 667;
  49574. t['ccaron'] = 500;
  49575. t['aring'] = 556;
  49576. t['Ncommaaccent'] = 722;
  49577. t['lacute'] = 222;
  49578. t['agrave'] = 556;
  49579. t['Tcommaaccent'] = 611;
  49580. t['Cacute'] = 722;
  49581. t['atilde'] = 556;
  49582. t['Edotaccent'] = 667;
  49583. t['scaron'] = 500;
  49584. t['scedilla'] = 500;
  49585. t['iacute'] = 278;
  49586. t['lozenge'] = 471;
  49587. t['Rcaron'] = 722;
  49588. t['Gcommaaccent'] = 778;
  49589. t['ucircumflex'] = 556;
  49590. t['acircumflex'] = 556;
  49591. t['Amacron'] = 667;
  49592. t['rcaron'] = 333;
  49593. t['ccedilla'] = 500;
  49594. t['Zdotaccent'] = 611;
  49595. t['Thorn'] = 667;
  49596. t['Omacron'] = 778;
  49597. t['Racute'] = 722;
  49598. t['Sacute'] = 667;
  49599. t['dcaron'] = 643;
  49600. t['Umacron'] = 722;
  49601. t['uring'] = 556;
  49602. t['threesuperior'] = 333;
  49603. t['Ograve'] = 778;
  49604. t['Agrave'] = 667;
  49605. t['Abreve'] = 667;
  49606. t['multiply'] = 584;
  49607. t['uacute'] = 556;
  49608. t['Tcaron'] = 611;
  49609. t['partialdiff'] = 476;
  49610. t['ydieresis'] = 500;
  49611. t['Nacute'] = 722;
  49612. t['icircumflex'] = 278;
  49613. t['Ecircumflex'] = 667;
  49614. t['adieresis'] = 556;
  49615. t['edieresis'] = 556;
  49616. t['cacute'] = 500;
  49617. t['nacute'] = 556;
  49618. t['umacron'] = 556;
  49619. t['Ncaron'] = 722;
  49620. t['Iacute'] = 278;
  49621. t['plusminus'] = 584;
  49622. t['brokenbar'] = 260;
  49623. t['registered'] = 737;
  49624. t['Gbreve'] = 778;
  49625. t['Idotaccent'] = 278;
  49626. t['summation'] = 600;
  49627. t['Egrave'] = 667;
  49628. t['racute'] = 333;
  49629. t['omacron'] = 556;
  49630. t['Zacute'] = 611;
  49631. t['Zcaron'] = 611;
  49632. t['greaterequal'] = 549;
  49633. t['Eth'] = 722;
  49634. t['Ccedilla'] = 722;
  49635. t['lcommaaccent'] = 222;
  49636. t['tcaron'] = 317;
  49637. t['eogonek'] = 556;
  49638. t['Uogonek'] = 722;
  49639. t['Aacute'] = 667;
  49640. t['Adieresis'] = 667;
  49641. t['egrave'] = 556;
  49642. t['zacute'] = 500;
  49643. t['iogonek'] = 222;
  49644. t['Oacute'] = 778;
  49645. t['oacute'] = 556;
  49646. t['amacron'] = 556;
  49647. t['sacute'] = 500;
  49648. t['idieresis'] = 278;
  49649. t['Ocircumflex'] = 778;
  49650. t['Ugrave'] = 722;
  49651. t['Delta'] = 612;
  49652. t['thorn'] = 556;
  49653. t['twosuperior'] = 333;
  49654. t['Odieresis'] = 778;
  49655. t['mu'] = 556;
  49656. t['igrave'] = 278;
  49657. t['ohungarumlaut'] = 556;
  49658. t['Eogonek'] = 667;
  49659. t['dcroat'] = 556;
  49660. t['threequarters'] = 834;
  49661. t['Scedilla'] = 667;
  49662. t['lcaron'] = 299;
  49663. t['Kcommaaccent'] = 667;
  49664. t['Lacute'] = 556;
  49665. t['trademark'] = 1000;
  49666. t['edotaccent'] = 556;
  49667. t['Igrave'] = 278;
  49668. t['Imacron'] = 278;
  49669. t['Lcaron'] = 556;
  49670. t['onehalf'] = 834;
  49671. t['lessequal'] = 549;
  49672. t['ocircumflex'] = 556;
  49673. t['ntilde'] = 556;
  49674. t['Uhungarumlaut'] = 722;
  49675. t['Eacute'] = 667;
  49676. t['emacron'] = 556;
  49677. t['gbreve'] = 556;
  49678. t['onequarter'] = 834;
  49679. t['Scaron'] = 667;
  49680. t['Scommaaccent'] = 667;
  49681. t['Ohungarumlaut'] = 778;
  49682. t['degree'] = 400;
  49683. t['ograve'] = 556;
  49684. t['Ccaron'] = 722;
  49685. t['ugrave'] = 556;
  49686. t['radical'] = 453;
  49687. t['Dcaron'] = 722;
  49688. t['rcommaaccent'] = 333;
  49689. t['Ntilde'] = 722;
  49690. t['otilde'] = 556;
  49691. t['Rcommaaccent'] = 722;
  49692. t['Lcommaaccent'] = 556;
  49693. t['Atilde'] = 667;
  49694. t['Aogonek'] = 667;
  49695. t['Aring'] = 667;
  49696. t['Otilde'] = 778;
  49697. t['zdotaccent'] = 500;
  49698. t['Ecaron'] = 667;
  49699. t['Iogonek'] = 278;
  49700. t['kcommaaccent'] = 500;
  49701. t['minus'] = 584;
  49702. t['Icircumflex'] = 278;
  49703. t['ncaron'] = 556;
  49704. t['tcommaaccent'] = 278;
  49705. t['logicalnot'] = 584;
  49706. t['odieresis'] = 556;
  49707. t['udieresis'] = 556;
  49708. t['notequal'] = 549;
  49709. t['gcommaaccent'] = 556;
  49710. t['eth'] = 556;
  49711. t['zcaron'] = 500;
  49712. t['ncommaaccent'] = 556;
  49713. t['onesuperior'] = 333;
  49714. t['imacron'] = 278;
  49715. t['Euro'] = 556;
  49716. });
  49717. t['Symbol'] = getLookupTableFactory(function (t) {
  49718. t['space'] = 250;
  49719. t['exclam'] = 333;
  49720. t['universal'] = 713;
  49721. t['numbersign'] = 500;
  49722. t['existential'] = 549;
  49723. t['percent'] = 833;
  49724. t['ampersand'] = 778;
  49725. t['suchthat'] = 439;
  49726. t['parenleft'] = 333;
  49727. t['parenright'] = 333;
  49728. t['asteriskmath'] = 500;
  49729. t['plus'] = 549;
  49730. t['comma'] = 250;
  49731. t['minus'] = 549;
  49732. t['period'] = 250;
  49733. t['slash'] = 278;
  49734. t['zero'] = 500;
  49735. t['one'] = 500;
  49736. t['two'] = 500;
  49737. t['three'] = 500;
  49738. t['four'] = 500;
  49739. t['five'] = 500;
  49740. t['six'] = 500;
  49741. t['seven'] = 500;
  49742. t['eight'] = 500;
  49743. t['nine'] = 500;
  49744. t['colon'] = 278;
  49745. t['semicolon'] = 278;
  49746. t['less'] = 549;
  49747. t['equal'] = 549;
  49748. t['greater'] = 549;
  49749. t['question'] = 444;
  49750. t['congruent'] = 549;
  49751. t['Alpha'] = 722;
  49752. t['Beta'] = 667;
  49753. t['Chi'] = 722;
  49754. t['Delta'] = 612;
  49755. t['Epsilon'] = 611;
  49756. t['Phi'] = 763;
  49757. t['Gamma'] = 603;
  49758. t['Eta'] = 722;
  49759. t['Iota'] = 333;
  49760. t['theta1'] = 631;
  49761. t['Kappa'] = 722;
  49762. t['Lambda'] = 686;
  49763. t['Mu'] = 889;
  49764. t['Nu'] = 722;
  49765. t['Omicron'] = 722;
  49766. t['Pi'] = 768;
  49767. t['Theta'] = 741;
  49768. t['Rho'] = 556;
  49769. t['Sigma'] = 592;
  49770. t['Tau'] = 611;
  49771. t['Upsilon'] = 690;
  49772. t['sigma1'] = 439;
  49773. t['Omega'] = 768;
  49774. t['Xi'] = 645;
  49775. t['Psi'] = 795;
  49776. t['Zeta'] = 611;
  49777. t['bracketleft'] = 333;
  49778. t['therefore'] = 863;
  49779. t['bracketright'] = 333;
  49780. t['perpendicular'] = 658;
  49781. t['underscore'] = 500;
  49782. t['radicalex'] = 500;
  49783. t['alpha'] = 631;
  49784. t['beta'] = 549;
  49785. t['chi'] = 549;
  49786. t['delta'] = 494;
  49787. t['epsilon'] = 439;
  49788. t['phi'] = 521;
  49789. t['gamma'] = 411;
  49790. t['eta'] = 603;
  49791. t['iota'] = 329;
  49792. t['phi1'] = 603;
  49793. t['kappa'] = 549;
  49794. t['lambda'] = 549;
  49795. t['mu'] = 576;
  49796. t['nu'] = 521;
  49797. t['omicron'] = 549;
  49798. t['pi'] = 549;
  49799. t['theta'] = 521;
  49800. t['rho'] = 549;
  49801. t['sigma'] = 603;
  49802. t['tau'] = 439;
  49803. t['upsilon'] = 576;
  49804. t['omega1'] = 713;
  49805. t['omega'] = 686;
  49806. t['xi'] = 493;
  49807. t['psi'] = 686;
  49808. t['zeta'] = 494;
  49809. t['braceleft'] = 480;
  49810. t['bar'] = 200;
  49811. t['braceright'] = 480;
  49812. t['similar'] = 549;
  49813. t['Euro'] = 750;
  49814. t['Upsilon1'] = 620;
  49815. t['minute'] = 247;
  49816. t['lessequal'] = 549;
  49817. t['fraction'] = 167;
  49818. t['infinity'] = 713;
  49819. t['florin'] = 500;
  49820. t['club'] = 753;
  49821. t['diamond'] = 753;
  49822. t['heart'] = 753;
  49823. t['spade'] = 753;
  49824. t['arrowboth'] = 1042;
  49825. t['arrowleft'] = 987;
  49826. t['arrowup'] = 603;
  49827. t['arrowright'] = 987;
  49828. t['arrowdown'] = 603;
  49829. t['degree'] = 400;
  49830. t['plusminus'] = 549;
  49831. t['second'] = 411;
  49832. t['greaterequal'] = 549;
  49833. t['multiply'] = 549;
  49834. t['proportional'] = 713;
  49835. t['partialdiff'] = 494;
  49836. t['bullet'] = 460;
  49837. t['divide'] = 549;
  49838. t['notequal'] = 549;
  49839. t['equivalence'] = 549;
  49840. t['approxequal'] = 549;
  49841. t['ellipsis'] = 1000;
  49842. t['arrowvertex'] = 603;
  49843. t['arrowhorizex'] = 1000;
  49844. t['carriagereturn'] = 658;
  49845. t['aleph'] = 823;
  49846. t['Ifraktur'] = 686;
  49847. t['Rfraktur'] = 795;
  49848. t['weierstrass'] = 987;
  49849. t['circlemultiply'] = 768;
  49850. t['circleplus'] = 768;
  49851. t['emptyset'] = 823;
  49852. t['intersection'] = 768;
  49853. t['union'] = 768;
  49854. t['propersuperset'] = 713;
  49855. t['reflexsuperset'] = 713;
  49856. t['notsubset'] = 713;
  49857. t['propersubset'] = 713;
  49858. t['reflexsubset'] = 713;
  49859. t['element'] = 713;
  49860. t['notelement'] = 713;
  49861. t['angle'] = 768;
  49862. t['gradient'] = 713;
  49863. t['registerserif'] = 790;
  49864. t['copyrightserif'] = 790;
  49865. t['trademarkserif'] = 890;
  49866. t['product'] = 823;
  49867. t['radical'] = 549;
  49868. t['dotmath'] = 250;
  49869. t['logicalnot'] = 713;
  49870. t['logicaland'] = 603;
  49871. t['logicalor'] = 603;
  49872. t['arrowdblboth'] = 1042;
  49873. t['arrowdblleft'] = 987;
  49874. t['arrowdblup'] = 603;
  49875. t['arrowdblright'] = 987;
  49876. t['arrowdbldown'] = 603;
  49877. t['lozenge'] = 494;
  49878. t['angleleft'] = 329;
  49879. t['registersans'] = 790;
  49880. t['copyrightsans'] = 790;
  49881. t['trademarksans'] = 786;
  49882. t['summation'] = 713;
  49883. t['parenlefttp'] = 384;
  49884. t['parenleftex'] = 384;
  49885. t['parenleftbt'] = 384;
  49886. t['bracketlefttp'] = 384;
  49887. t['bracketleftex'] = 384;
  49888. t['bracketleftbt'] = 384;
  49889. t['bracelefttp'] = 494;
  49890. t['braceleftmid'] = 494;
  49891. t['braceleftbt'] = 494;
  49892. t['braceex'] = 494;
  49893. t['angleright'] = 329;
  49894. t['integral'] = 274;
  49895. t['integraltp'] = 686;
  49896. t['integralex'] = 686;
  49897. t['integralbt'] = 686;
  49898. t['parenrighttp'] = 384;
  49899. t['parenrightex'] = 384;
  49900. t['parenrightbt'] = 384;
  49901. t['bracketrighttp'] = 384;
  49902. t['bracketrightex'] = 384;
  49903. t['bracketrightbt'] = 384;
  49904. t['bracerighttp'] = 494;
  49905. t['bracerightmid'] = 494;
  49906. t['bracerightbt'] = 494;
  49907. t['apple'] = 790;
  49908. });
  49909. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49910. t['space'] = 250;
  49911. t['exclam'] = 333;
  49912. t['quotedbl'] = 408;
  49913. t['numbersign'] = 500;
  49914. t['dollar'] = 500;
  49915. t['percent'] = 833;
  49916. t['ampersand'] = 778;
  49917. t['quoteright'] = 333;
  49918. t['parenleft'] = 333;
  49919. t['parenright'] = 333;
  49920. t['asterisk'] = 500;
  49921. t['plus'] = 564;
  49922. t['comma'] = 250;
  49923. t['hyphen'] = 333;
  49924. t['period'] = 250;
  49925. t['slash'] = 278;
  49926. t['zero'] = 500;
  49927. t['one'] = 500;
  49928. t['two'] = 500;
  49929. t['three'] = 500;
  49930. t['four'] = 500;
  49931. t['five'] = 500;
  49932. t['six'] = 500;
  49933. t['seven'] = 500;
  49934. t['eight'] = 500;
  49935. t['nine'] = 500;
  49936. t['colon'] = 278;
  49937. t['semicolon'] = 278;
  49938. t['less'] = 564;
  49939. t['equal'] = 564;
  49940. t['greater'] = 564;
  49941. t['question'] = 444;
  49942. t['at'] = 921;
  49943. t['A'] = 722;
  49944. t['B'] = 667;
  49945. t['C'] = 667;
  49946. t['D'] = 722;
  49947. t['E'] = 611;
  49948. t['F'] = 556;
  49949. t['G'] = 722;
  49950. t['H'] = 722;
  49951. t['I'] = 333;
  49952. t['J'] = 389;
  49953. t['K'] = 722;
  49954. t['L'] = 611;
  49955. t['M'] = 889;
  49956. t['N'] = 722;
  49957. t['O'] = 722;
  49958. t['P'] = 556;
  49959. t['Q'] = 722;
  49960. t['R'] = 667;
  49961. t['S'] = 556;
  49962. t['T'] = 611;
  49963. t['U'] = 722;
  49964. t['V'] = 722;
  49965. t['W'] = 944;
  49966. t['X'] = 722;
  49967. t['Y'] = 722;
  49968. t['Z'] = 611;
  49969. t['bracketleft'] = 333;
  49970. t['backslash'] = 278;
  49971. t['bracketright'] = 333;
  49972. t['asciicircum'] = 469;
  49973. t['underscore'] = 500;
  49974. t['quoteleft'] = 333;
  49975. t['a'] = 444;
  49976. t['b'] = 500;
  49977. t['c'] = 444;
  49978. t['d'] = 500;
  49979. t['e'] = 444;
  49980. t['f'] = 333;
  49981. t['g'] = 500;
  49982. t['h'] = 500;
  49983. t['i'] = 278;
  49984. t['j'] = 278;
  49985. t['k'] = 500;
  49986. t['l'] = 278;
  49987. t['m'] = 778;
  49988. t['n'] = 500;
  49989. t['o'] = 500;
  49990. t['p'] = 500;
  49991. t['q'] = 500;
  49992. t['r'] = 333;
  49993. t['s'] = 389;
  49994. t['t'] = 278;
  49995. t['u'] = 500;
  49996. t['v'] = 500;
  49997. t['w'] = 722;
  49998. t['x'] = 500;
  49999. t['y'] = 500;
  50000. t['z'] = 444;
  50001. t['braceleft'] = 480;
  50002. t['bar'] = 200;
  50003. t['braceright'] = 480;
  50004. t['asciitilde'] = 541;
  50005. t['exclamdown'] = 333;
  50006. t['cent'] = 500;
  50007. t['sterling'] = 500;
  50008. t['fraction'] = 167;
  50009. t['yen'] = 500;
  50010. t['florin'] = 500;
  50011. t['section'] = 500;
  50012. t['currency'] = 500;
  50013. t['quotesingle'] = 180;
  50014. t['quotedblleft'] = 444;
  50015. t['guillemotleft'] = 500;
  50016. t['guilsinglleft'] = 333;
  50017. t['guilsinglright'] = 333;
  50018. t['fi'] = 556;
  50019. t['fl'] = 556;
  50020. t['endash'] = 500;
  50021. t['dagger'] = 500;
  50022. t['daggerdbl'] = 500;
  50023. t['periodcentered'] = 250;
  50024. t['paragraph'] = 453;
  50025. t['bullet'] = 350;
  50026. t['quotesinglbase'] = 333;
  50027. t['quotedblbase'] = 444;
  50028. t['quotedblright'] = 444;
  50029. t['guillemotright'] = 500;
  50030. t['ellipsis'] = 1000;
  50031. t['perthousand'] = 1000;
  50032. t['questiondown'] = 444;
  50033. t['grave'] = 333;
  50034. t['acute'] = 333;
  50035. t['circumflex'] = 333;
  50036. t['tilde'] = 333;
  50037. t['macron'] = 333;
  50038. t['breve'] = 333;
  50039. t['dotaccent'] = 333;
  50040. t['dieresis'] = 333;
  50041. t['ring'] = 333;
  50042. t['cedilla'] = 333;
  50043. t['hungarumlaut'] = 333;
  50044. t['ogonek'] = 333;
  50045. t['caron'] = 333;
  50046. t['emdash'] = 1000;
  50047. t['AE'] = 889;
  50048. t['ordfeminine'] = 276;
  50049. t['Lslash'] = 611;
  50050. t['Oslash'] = 722;
  50051. t['OE'] = 889;
  50052. t['ordmasculine'] = 310;
  50053. t['ae'] = 667;
  50054. t['dotlessi'] = 278;
  50055. t['lslash'] = 278;
  50056. t['oslash'] = 500;
  50057. t['oe'] = 722;
  50058. t['germandbls'] = 500;
  50059. t['Idieresis'] = 333;
  50060. t['eacute'] = 444;
  50061. t['abreve'] = 444;
  50062. t['uhungarumlaut'] = 500;
  50063. t['ecaron'] = 444;
  50064. t['Ydieresis'] = 722;
  50065. t['divide'] = 564;
  50066. t['Yacute'] = 722;
  50067. t['Acircumflex'] = 722;
  50068. t['aacute'] = 444;
  50069. t['Ucircumflex'] = 722;
  50070. t['yacute'] = 500;
  50071. t['scommaaccent'] = 389;
  50072. t['ecircumflex'] = 444;
  50073. t['Uring'] = 722;
  50074. t['Udieresis'] = 722;
  50075. t['aogonek'] = 444;
  50076. t['Uacute'] = 722;
  50077. t['uogonek'] = 500;
  50078. t['Edieresis'] = 611;
  50079. t['Dcroat'] = 722;
  50080. t['commaaccent'] = 250;
  50081. t['copyright'] = 760;
  50082. t['Emacron'] = 611;
  50083. t['ccaron'] = 444;
  50084. t['aring'] = 444;
  50085. t['Ncommaaccent'] = 722;
  50086. t['lacute'] = 278;
  50087. t['agrave'] = 444;
  50088. t['Tcommaaccent'] = 611;
  50089. t['Cacute'] = 667;
  50090. t['atilde'] = 444;
  50091. t['Edotaccent'] = 611;
  50092. t['scaron'] = 389;
  50093. t['scedilla'] = 389;
  50094. t['iacute'] = 278;
  50095. t['lozenge'] = 471;
  50096. t['Rcaron'] = 667;
  50097. t['Gcommaaccent'] = 722;
  50098. t['ucircumflex'] = 500;
  50099. t['acircumflex'] = 444;
  50100. t['Amacron'] = 722;
  50101. t['rcaron'] = 333;
  50102. t['ccedilla'] = 444;
  50103. t['Zdotaccent'] = 611;
  50104. t['Thorn'] = 556;
  50105. t['Omacron'] = 722;
  50106. t['Racute'] = 667;
  50107. t['Sacute'] = 556;
  50108. t['dcaron'] = 588;
  50109. t['Umacron'] = 722;
  50110. t['uring'] = 500;
  50111. t['threesuperior'] = 300;
  50112. t['Ograve'] = 722;
  50113. t['Agrave'] = 722;
  50114. t['Abreve'] = 722;
  50115. t['multiply'] = 564;
  50116. t['uacute'] = 500;
  50117. t['Tcaron'] = 611;
  50118. t['partialdiff'] = 476;
  50119. t['ydieresis'] = 500;
  50120. t['Nacute'] = 722;
  50121. t['icircumflex'] = 278;
  50122. t['Ecircumflex'] = 611;
  50123. t['adieresis'] = 444;
  50124. t['edieresis'] = 444;
  50125. t['cacute'] = 444;
  50126. t['nacute'] = 500;
  50127. t['umacron'] = 500;
  50128. t['Ncaron'] = 722;
  50129. t['Iacute'] = 333;
  50130. t['plusminus'] = 564;
  50131. t['brokenbar'] = 200;
  50132. t['registered'] = 760;
  50133. t['Gbreve'] = 722;
  50134. t['Idotaccent'] = 333;
  50135. t['summation'] = 600;
  50136. t['Egrave'] = 611;
  50137. t['racute'] = 333;
  50138. t['omacron'] = 500;
  50139. t['Zacute'] = 611;
  50140. t['Zcaron'] = 611;
  50141. t['greaterequal'] = 549;
  50142. t['Eth'] = 722;
  50143. t['Ccedilla'] = 667;
  50144. t['lcommaaccent'] = 278;
  50145. t['tcaron'] = 326;
  50146. t['eogonek'] = 444;
  50147. t['Uogonek'] = 722;
  50148. t['Aacute'] = 722;
  50149. t['Adieresis'] = 722;
  50150. t['egrave'] = 444;
  50151. t['zacute'] = 444;
  50152. t['iogonek'] = 278;
  50153. t['Oacute'] = 722;
  50154. t['oacute'] = 500;
  50155. t['amacron'] = 444;
  50156. t['sacute'] = 389;
  50157. t['idieresis'] = 278;
  50158. t['Ocircumflex'] = 722;
  50159. t['Ugrave'] = 722;
  50160. t['Delta'] = 612;
  50161. t['thorn'] = 500;
  50162. t['twosuperior'] = 300;
  50163. t['Odieresis'] = 722;
  50164. t['mu'] = 500;
  50165. t['igrave'] = 278;
  50166. t['ohungarumlaut'] = 500;
  50167. t['Eogonek'] = 611;
  50168. t['dcroat'] = 500;
  50169. t['threequarters'] = 750;
  50170. t['Scedilla'] = 556;
  50171. t['lcaron'] = 344;
  50172. t['Kcommaaccent'] = 722;
  50173. t['Lacute'] = 611;
  50174. t['trademark'] = 980;
  50175. t['edotaccent'] = 444;
  50176. t['Igrave'] = 333;
  50177. t['Imacron'] = 333;
  50178. t['Lcaron'] = 611;
  50179. t['onehalf'] = 750;
  50180. t['lessequal'] = 549;
  50181. t['ocircumflex'] = 500;
  50182. t['ntilde'] = 500;
  50183. t['Uhungarumlaut'] = 722;
  50184. t['Eacute'] = 611;
  50185. t['emacron'] = 444;
  50186. t['gbreve'] = 500;
  50187. t['onequarter'] = 750;
  50188. t['Scaron'] = 556;
  50189. t['Scommaaccent'] = 556;
  50190. t['Ohungarumlaut'] = 722;
  50191. t['degree'] = 400;
  50192. t['ograve'] = 500;
  50193. t['Ccaron'] = 667;
  50194. t['ugrave'] = 500;
  50195. t['radical'] = 453;
  50196. t['Dcaron'] = 722;
  50197. t['rcommaaccent'] = 333;
  50198. t['Ntilde'] = 722;
  50199. t['otilde'] = 500;
  50200. t['Rcommaaccent'] = 667;
  50201. t['Lcommaaccent'] = 611;
  50202. t['Atilde'] = 722;
  50203. t['Aogonek'] = 722;
  50204. t['Aring'] = 722;
  50205. t['Otilde'] = 722;
  50206. t['zdotaccent'] = 444;
  50207. t['Ecaron'] = 611;
  50208. t['Iogonek'] = 333;
  50209. t['kcommaaccent'] = 500;
  50210. t['minus'] = 564;
  50211. t['Icircumflex'] = 333;
  50212. t['ncaron'] = 500;
  50213. t['tcommaaccent'] = 278;
  50214. t['logicalnot'] = 564;
  50215. t['odieresis'] = 500;
  50216. t['udieresis'] = 500;
  50217. t['notequal'] = 549;
  50218. t['gcommaaccent'] = 500;
  50219. t['eth'] = 500;
  50220. t['zcaron'] = 444;
  50221. t['ncommaaccent'] = 500;
  50222. t['onesuperior'] = 300;
  50223. t['imacron'] = 278;
  50224. t['Euro'] = 500;
  50225. });
  50226. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50227. t['space'] = 250;
  50228. t['exclam'] = 333;
  50229. t['quotedbl'] = 555;
  50230. t['numbersign'] = 500;
  50231. t['dollar'] = 500;
  50232. t['percent'] = 1000;
  50233. t['ampersand'] = 833;
  50234. t['quoteright'] = 333;
  50235. t['parenleft'] = 333;
  50236. t['parenright'] = 333;
  50237. t['asterisk'] = 500;
  50238. t['plus'] = 570;
  50239. t['comma'] = 250;
  50240. t['hyphen'] = 333;
  50241. t['period'] = 250;
  50242. t['slash'] = 278;
  50243. t['zero'] = 500;
  50244. t['one'] = 500;
  50245. t['two'] = 500;
  50246. t['three'] = 500;
  50247. t['four'] = 500;
  50248. t['five'] = 500;
  50249. t['six'] = 500;
  50250. t['seven'] = 500;
  50251. t['eight'] = 500;
  50252. t['nine'] = 500;
  50253. t['colon'] = 333;
  50254. t['semicolon'] = 333;
  50255. t['less'] = 570;
  50256. t['equal'] = 570;
  50257. t['greater'] = 570;
  50258. t['question'] = 500;
  50259. t['at'] = 930;
  50260. t['A'] = 722;
  50261. t['B'] = 667;
  50262. t['C'] = 722;
  50263. t['D'] = 722;
  50264. t['E'] = 667;
  50265. t['F'] = 611;
  50266. t['G'] = 778;
  50267. t['H'] = 778;
  50268. t['I'] = 389;
  50269. t['J'] = 500;
  50270. t['K'] = 778;
  50271. t['L'] = 667;
  50272. t['M'] = 944;
  50273. t['N'] = 722;
  50274. t['O'] = 778;
  50275. t['P'] = 611;
  50276. t['Q'] = 778;
  50277. t['R'] = 722;
  50278. t['S'] = 556;
  50279. t['T'] = 667;
  50280. t['U'] = 722;
  50281. t['V'] = 722;
  50282. t['W'] = 1000;
  50283. t['X'] = 722;
  50284. t['Y'] = 722;
  50285. t['Z'] = 667;
  50286. t['bracketleft'] = 333;
  50287. t['backslash'] = 278;
  50288. t['bracketright'] = 333;
  50289. t['asciicircum'] = 581;
  50290. t['underscore'] = 500;
  50291. t['quoteleft'] = 333;
  50292. t['a'] = 500;
  50293. t['b'] = 556;
  50294. t['c'] = 444;
  50295. t['d'] = 556;
  50296. t['e'] = 444;
  50297. t['f'] = 333;
  50298. t['g'] = 500;
  50299. t['h'] = 556;
  50300. t['i'] = 278;
  50301. t['j'] = 333;
  50302. t['k'] = 556;
  50303. t['l'] = 278;
  50304. t['m'] = 833;
  50305. t['n'] = 556;
  50306. t['o'] = 500;
  50307. t['p'] = 556;
  50308. t['q'] = 556;
  50309. t['r'] = 444;
  50310. t['s'] = 389;
  50311. t['t'] = 333;
  50312. t['u'] = 556;
  50313. t['v'] = 500;
  50314. t['w'] = 722;
  50315. t['x'] = 500;
  50316. t['y'] = 500;
  50317. t['z'] = 444;
  50318. t['braceleft'] = 394;
  50319. t['bar'] = 220;
  50320. t['braceright'] = 394;
  50321. t['asciitilde'] = 520;
  50322. t['exclamdown'] = 333;
  50323. t['cent'] = 500;
  50324. t['sterling'] = 500;
  50325. t['fraction'] = 167;
  50326. t['yen'] = 500;
  50327. t['florin'] = 500;
  50328. t['section'] = 500;
  50329. t['currency'] = 500;
  50330. t['quotesingle'] = 278;
  50331. t['quotedblleft'] = 500;
  50332. t['guillemotleft'] = 500;
  50333. t['guilsinglleft'] = 333;
  50334. t['guilsinglright'] = 333;
  50335. t['fi'] = 556;
  50336. t['fl'] = 556;
  50337. t['endash'] = 500;
  50338. t['dagger'] = 500;
  50339. t['daggerdbl'] = 500;
  50340. t['periodcentered'] = 250;
  50341. t['paragraph'] = 540;
  50342. t['bullet'] = 350;
  50343. t['quotesinglbase'] = 333;
  50344. t['quotedblbase'] = 500;
  50345. t['quotedblright'] = 500;
  50346. t['guillemotright'] = 500;
  50347. t['ellipsis'] = 1000;
  50348. t['perthousand'] = 1000;
  50349. t['questiondown'] = 500;
  50350. t['grave'] = 333;
  50351. t['acute'] = 333;
  50352. t['circumflex'] = 333;
  50353. t['tilde'] = 333;
  50354. t['macron'] = 333;
  50355. t['breve'] = 333;
  50356. t['dotaccent'] = 333;
  50357. t['dieresis'] = 333;
  50358. t['ring'] = 333;
  50359. t['cedilla'] = 333;
  50360. t['hungarumlaut'] = 333;
  50361. t['ogonek'] = 333;
  50362. t['caron'] = 333;
  50363. t['emdash'] = 1000;
  50364. t['AE'] = 1000;
  50365. t['ordfeminine'] = 300;
  50366. t['Lslash'] = 667;
  50367. t['Oslash'] = 778;
  50368. t['OE'] = 1000;
  50369. t['ordmasculine'] = 330;
  50370. t['ae'] = 722;
  50371. t['dotlessi'] = 278;
  50372. t['lslash'] = 278;
  50373. t['oslash'] = 500;
  50374. t['oe'] = 722;
  50375. t['germandbls'] = 556;
  50376. t['Idieresis'] = 389;
  50377. t['eacute'] = 444;
  50378. t['abreve'] = 500;
  50379. t['uhungarumlaut'] = 556;
  50380. t['ecaron'] = 444;
  50381. t['Ydieresis'] = 722;
  50382. t['divide'] = 570;
  50383. t['Yacute'] = 722;
  50384. t['Acircumflex'] = 722;
  50385. t['aacute'] = 500;
  50386. t['Ucircumflex'] = 722;
  50387. t['yacute'] = 500;
  50388. t['scommaaccent'] = 389;
  50389. t['ecircumflex'] = 444;
  50390. t['Uring'] = 722;
  50391. t['Udieresis'] = 722;
  50392. t['aogonek'] = 500;
  50393. t['Uacute'] = 722;
  50394. t['uogonek'] = 556;
  50395. t['Edieresis'] = 667;
  50396. t['Dcroat'] = 722;
  50397. t['commaaccent'] = 250;
  50398. t['copyright'] = 747;
  50399. t['Emacron'] = 667;
  50400. t['ccaron'] = 444;
  50401. t['aring'] = 500;
  50402. t['Ncommaaccent'] = 722;
  50403. t['lacute'] = 278;
  50404. t['agrave'] = 500;
  50405. t['Tcommaaccent'] = 667;
  50406. t['Cacute'] = 722;
  50407. t['atilde'] = 500;
  50408. t['Edotaccent'] = 667;
  50409. t['scaron'] = 389;
  50410. t['scedilla'] = 389;
  50411. t['iacute'] = 278;
  50412. t['lozenge'] = 494;
  50413. t['Rcaron'] = 722;
  50414. t['Gcommaaccent'] = 778;
  50415. t['ucircumflex'] = 556;
  50416. t['acircumflex'] = 500;
  50417. t['Amacron'] = 722;
  50418. t['rcaron'] = 444;
  50419. t['ccedilla'] = 444;
  50420. t['Zdotaccent'] = 667;
  50421. t['Thorn'] = 611;
  50422. t['Omacron'] = 778;
  50423. t['Racute'] = 722;
  50424. t['Sacute'] = 556;
  50425. t['dcaron'] = 672;
  50426. t['Umacron'] = 722;
  50427. t['uring'] = 556;
  50428. t['threesuperior'] = 300;
  50429. t['Ograve'] = 778;
  50430. t['Agrave'] = 722;
  50431. t['Abreve'] = 722;
  50432. t['multiply'] = 570;
  50433. t['uacute'] = 556;
  50434. t['Tcaron'] = 667;
  50435. t['partialdiff'] = 494;
  50436. t['ydieresis'] = 500;
  50437. t['Nacute'] = 722;
  50438. t['icircumflex'] = 278;
  50439. t['Ecircumflex'] = 667;
  50440. t['adieresis'] = 500;
  50441. t['edieresis'] = 444;
  50442. t['cacute'] = 444;
  50443. t['nacute'] = 556;
  50444. t['umacron'] = 556;
  50445. t['Ncaron'] = 722;
  50446. t['Iacute'] = 389;
  50447. t['plusminus'] = 570;
  50448. t['brokenbar'] = 220;
  50449. t['registered'] = 747;
  50450. t['Gbreve'] = 778;
  50451. t['Idotaccent'] = 389;
  50452. t['summation'] = 600;
  50453. t['Egrave'] = 667;
  50454. t['racute'] = 444;
  50455. t['omacron'] = 500;
  50456. t['Zacute'] = 667;
  50457. t['Zcaron'] = 667;
  50458. t['greaterequal'] = 549;
  50459. t['Eth'] = 722;
  50460. t['Ccedilla'] = 722;
  50461. t['lcommaaccent'] = 278;
  50462. t['tcaron'] = 416;
  50463. t['eogonek'] = 444;
  50464. t['Uogonek'] = 722;
  50465. t['Aacute'] = 722;
  50466. t['Adieresis'] = 722;
  50467. t['egrave'] = 444;
  50468. t['zacute'] = 444;
  50469. t['iogonek'] = 278;
  50470. t['Oacute'] = 778;
  50471. t['oacute'] = 500;
  50472. t['amacron'] = 500;
  50473. t['sacute'] = 389;
  50474. t['idieresis'] = 278;
  50475. t['Ocircumflex'] = 778;
  50476. t['Ugrave'] = 722;
  50477. t['Delta'] = 612;
  50478. t['thorn'] = 556;
  50479. t['twosuperior'] = 300;
  50480. t['Odieresis'] = 778;
  50481. t['mu'] = 556;
  50482. t['igrave'] = 278;
  50483. t['ohungarumlaut'] = 500;
  50484. t['Eogonek'] = 667;
  50485. t['dcroat'] = 556;
  50486. t['threequarters'] = 750;
  50487. t['Scedilla'] = 556;
  50488. t['lcaron'] = 394;
  50489. t['Kcommaaccent'] = 778;
  50490. t['Lacute'] = 667;
  50491. t['trademark'] = 1000;
  50492. t['edotaccent'] = 444;
  50493. t['Igrave'] = 389;
  50494. t['Imacron'] = 389;
  50495. t['Lcaron'] = 667;
  50496. t['onehalf'] = 750;
  50497. t['lessequal'] = 549;
  50498. t['ocircumflex'] = 500;
  50499. t['ntilde'] = 556;
  50500. t['Uhungarumlaut'] = 722;
  50501. t['Eacute'] = 667;
  50502. t['emacron'] = 444;
  50503. t['gbreve'] = 500;
  50504. t['onequarter'] = 750;
  50505. t['Scaron'] = 556;
  50506. t['Scommaaccent'] = 556;
  50507. t['Ohungarumlaut'] = 778;
  50508. t['degree'] = 400;
  50509. t['ograve'] = 500;
  50510. t['Ccaron'] = 722;
  50511. t['ugrave'] = 556;
  50512. t['radical'] = 549;
  50513. t['Dcaron'] = 722;
  50514. t['rcommaaccent'] = 444;
  50515. t['Ntilde'] = 722;
  50516. t['otilde'] = 500;
  50517. t['Rcommaaccent'] = 722;
  50518. t['Lcommaaccent'] = 667;
  50519. t['Atilde'] = 722;
  50520. t['Aogonek'] = 722;
  50521. t['Aring'] = 722;
  50522. t['Otilde'] = 778;
  50523. t['zdotaccent'] = 444;
  50524. t['Ecaron'] = 667;
  50525. t['Iogonek'] = 389;
  50526. t['kcommaaccent'] = 556;
  50527. t['minus'] = 570;
  50528. t['Icircumflex'] = 389;
  50529. t['ncaron'] = 556;
  50530. t['tcommaaccent'] = 333;
  50531. t['logicalnot'] = 570;
  50532. t['odieresis'] = 500;
  50533. t['udieresis'] = 556;
  50534. t['notequal'] = 549;
  50535. t['gcommaaccent'] = 500;
  50536. t['eth'] = 500;
  50537. t['zcaron'] = 444;
  50538. t['ncommaaccent'] = 556;
  50539. t['onesuperior'] = 300;
  50540. t['imacron'] = 278;
  50541. t['Euro'] = 500;
  50542. });
  50543. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50544. t['space'] = 250;
  50545. t['exclam'] = 389;
  50546. t['quotedbl'] = 555;
  50547. t['numbersign'] = 500;
  50548. t['dollar'] = 500;
  50549. t['percent'] = 833;
  50550. t['ampersand'] = 778;
  50551. t['quoteright'] = 333;
  50552. t['parenleft'] = 333;
  50553. t['parenright'] = 333;
  50554. t['asterisk'] = 500;
  50555. t['plus'] = 570;
  50556. t['comma'] = 250;
  50557. t['hyphen'] = 333;
  50558. t['period'] = 250;
  50559. t['slash'] = 278;
  50560. t['zero'] = 500;
  50561. t['one'] = 500;
  50562. t['two'] = 500;
  50563. t['three'] = 500;
  50564. t['four'] = 500;
  50565. t['five'] = 500;
  50566. t['six'] = 500;
  50567. t['seven'] = 500;
  50568. t['eight'] = 500;
  50569. t['nine'] = 500;
  50570. t['colon'] = 333;
  50571. t['semicolon'] = 333;
  50572. t['less'] = 570;
  50573. t['equal'] = 570;
  50574. t['greater'] = 570;
  50575. t['question'] = 500;
  50576. t['at'] = 832;
  50577. t['A'] = 667;
  50578. t['B'] = 667;
  50579. t['C'] = 667;
  50580. t['D'] = 722;
  50581. t['E'] = 667;
  50582. t['F'] = 667;
  50583. t['G'] = 722;
  50584. t['H'] = 778;
  50585. t['I'] = 389;
  50586. t['J'] = 500;
  50587. t['K'] = 667;
  50588. t['L'] = 611;
  50589. t['M'] = 889;
  50590. t['N'] = 722;
  50591. t['O'] = 722;
  50592. t['P'] = 611;
  50593. t['Q'] = 722;
  50594. t['R'] = 667;
  50595. t['S'] = 556;
  50596. t['T'] = 611;
  50597. t['U'] = 722;
  50598. t['V'] = 667;
  50599. t['W'] = 889;
  50600. t['X'] = 667;
  50601. t['Y'] = 611;
  50602. t['Z'] = 611;
  50603. t['bracketleft'] = 333;
  50604. t['backslash'] = 278;
  50605. t['bracketright'] = 333;
  50606. t['asciicircum'] = 570;
  50607. t['underscore'] = 500;
  50608. t['quoteleft'] = 333;
  50609. t['a'] = 500;
  50610. t['b'] = 500;
  50611. t['c'] = 444;
  50612. t['d'] = 500;
  50613. t['e'] = 444;
  50614. t['f'] = 333;
  50615. t['g'] = 500;
  50616. t['h'] = 556;
  50617. t['i'] = 278;
  50618. t['j'] = 278;
  50619. t['k'] = 500;
  50620. t['l'] = 278;
  50621. t['m'] = 778;
  50622. t['n'] = 556;
  50623. t['o'] = 500;
  50624. t['p'] = 500;
  50625. t['q'] = 500;
  50626. t['r'] = 389;
  50627. t['s'] = 389;
  50628. t['t'] = 278;
  50629. t['u'] = 556;
  50630. t['v'] = 444;
  50631. t['w'] = 667;
  50632. t['x'] = 500;
  50633. t['y'] = 444;
  50634. t['z'] = 389;
  50635. t['braceleft'] = 348;
  50636. t['bar'] = 220;
  50637. t['braceright'] = 348;
  50638. t['asciitilde'] = 570;
  50639. t['exclamdown'] = 389;
  50640. t['cent'] = 500;
  50641. t['sterling'] = 500;
  50642. t['fraction'] = 167;
  50643. t['yen'] = 500;
  50644. t['florin'] = 500;
  50645. t['section'] = 500;
  50646. t['currency'] = 500;
  50647. t['quotesingle'] = 278;
  50648. t['quotedblleft'] = 500;
  50649. t['guillemotleft'] = 500;
  50650. t['guilsinglleft'] = 333;
  50651. t['guilsinglright'] = 333;
  50652. t['fi'] = 556;
  50653. t['fl'] = 556;
  50654. t['endash'] = 500;
  50655. t['dagger'] = 500;
  50656. t['daggerdbl'] = 500;
  50657. t['periodcentered'] = 250;
  50658. t['paragraph'] = 500;
  50659. t['bullet'] = 350;
  50660. t['quotesinglbase'] = 333;
  50661. t['quotedblbase'] = 500;
  50662. t['quotedblright'] = 500;
  50663. t['guillemotright'] = 500;
  50664. t['ellipsis'] = 1000;
  50665. t['perthousand'] = 1000;
  50666. t['questiondown'] = 500;
  50667. t['grave'] = 333;
  50668. t['acute'] = 333;
  50669. t['circumflex'] = 333;
  50670. t['tilde'] = 333;
  50671. t['macron'] = 333;
  50672. t['breve'] = 333;
  50673. t['dotaccent'] = 333;
  50674. t['dieresis'] = 333;
  50675. t['ring'] = 333;
  50676. t['cedilla'] = 333;
  50677. t['hungarumlaut'] = 333;
  50678. t['ogonek'] = 333;
  50679. t['caron'] = 333;
  50680. t['emdash'] = 1000;
  50681. t['AE'] = 944;
  50682. t['ordfeminine'] = 266;
  50683. t['Lslash'] = 611;
  50684. t['Oslash'] = 722;
  50685. t['OE'] = 944;
  50686. t['ordmasculine'] = 300;
  50687. t['ae'] = 722;
  50688. t['dotlessi'] = 278;
  50689. t['lslash'] = 278;
  50690. t['oslash'] = 500;
  50691. t['oe'] = 722;
  50692. t['germandbls'] = 500;
  50693. t['Idieresis'] = 389;
  50694. t['eacute'] = 444;
  50695. t['abreve'] = 500;
  50696. t['uhungarumlaut'] = 556;
  50697. t['ecaron'] = 444;
  50698. t['Ydieresis'] = 611;
  50699. t['divide'] = 570;
  50700. t['Yacute'] = 611;
  50701. t['Acircumflex'] = 667;
  50702. t['aacute'] = 500;
  50703. t['Ucircumflex'] = 722;
  50704. t['yacute'] = 444;
  50705. t['scommaaccent'] = 389;
  50706. t['ecircumflex'] = 444;
  50707. t['Uring'] = 722;
  50708. t['Udieresis'] = 722;
  50709. t['aogonek'] = 500;
  50710. t['Uacute'] = 722;
  50711. t['uogonek'] = 556;
  50712. t['Edieresis'] = 667;
  50713. t['Dcroat'] = 722;
  50714. t['commaaccent'] = 250;
  50715. t['copyright'] = 747;
  50716. t['Emacron'] = 667;
  50717. t['ccaron'] = 444;
  50718. t['aring'] = 500;
  50719. t['Ncommaaccent'] = 722;
  50720. t['lacute'] = 278;
  50721. t['agrave'] = 500;
  50722. t['Tcommaaccent'] = 611;
  50723. t['Cacute'] = 667;
  50724. t['atilde'] = 500;
  50725. t['Edotaccent'] = 667;
  50726. t['scaron'] = 389;
  50727. t['scedilla'] = 389;
  50728. t['iacute'] = 278;
  50729. t['lozenge'] = 494;
  50730. t['Rcaron'] = 667;
  50731. t['Gcommaaccent'] = 722;
  50732. t['ucircumflex'] = 556;
  50733. t['acircumflex'] = 500;
  50734. t['Amacron'] = 667;
  50735. t['rcaron'] = 389;
  50736. t['ccedilla'] = 444;
  50737. t['Zdotaccent'] = 611;
  50738. t['Thorn'] = 611;
  50739. t['Omacron'] = 722;
  50740. t['Racute'] = 667;
  50741. t['Sacute'] = 556;
  50742. t['dcaron'] = 608;
  50743. t['Umacron'] = 722;
  50744. t['uring'] = 556;
  50745. t['threesuperior'] = 300;
  50746. t['Ograve'] = 722;
  50747. t['Agrave'] = 667;
  50748. t['Abreve'] = 667;
  50749. t['multiply'] = 570;
  50750. t['uacute'] = 556;
  50751. t['Tcaron'] = 611;
  50752. t['partialdiff'] = 494;
  50753. t['ydieresis'] = 444;
  50754. t['Nacute'] = 722;
  50755. t['icircumflex'] = 278;
  50756. t['Ecircumflex'] = 667;
  50757. t['adieresis'] = 500;
  50758. t['edieresis'] = 444;
  50759. t['cacute'] = 444;
  50760. t['nacute'] = 556;
  50761. t['umacron'] = 556;
  50762. t['Ncaron'] = 722;
  50763. t['Iacute'] = 389;
  50764. t['plusminus'] = 570;
  50765. t['brokenbar'] = 220;
  50766. t['registered'] = 747;
  50767. t['Gbreve'] = 722;
  50768. t['Idotaccent'] = 389;
  50769. t['summation'] = 600;
  50770. t['Egrave'] = 667;
  50771. t['racute'] = 389;
  50772. t['omacron'] = 500;
  50773. t['Zacute'] = 611;
  50774. t['Zcaron'] = 611;
  50775. t['greaterequal'] = 549;
  50776. t['Eth'] = 722;
  50777. t['Ccedilla'] = 667;
  50778. t['lcommaaccent'] = 278;
  50779. t['tcaron'] = 366;
  50780. t['eogonek'] = 444;
  50781. t['Uogonek'] = 722;
  50782. t['Aacute'] = 667;
  50783. t['Adieresis'] = 667;
  50784. t['egrave'] = 444;
  50785. t['zacute'] = 389;
  50786. t['iogonek'] = 278;
  50787. t['Oacute'] = 722;
  50788. t['oacute'] = 500;
  50789. t['amacron'] = 500;
  50790. t['sacute'] = 389;
  50791. t['idieresis'] = 278;
  50792. t['Ocircumflex'] = 722;
  50793. t['Ugrave'] = 722;
  50794. t['Delta'] = 612;
  50795. t['thorn'] = 500;
  50796. t['twosuperior'] = 300;
  50797. t['Odieresis'] = 722;
  50798. t['mu'] = 576;
  50799. t['igrave'] = 278;
  50800. t['ohungarumlaut'] = 500;
  50801. t['Eogonek'] = 667;
  50802. t['dcroat'] = 500;
  50803. t['threequarters'] = 750;
  50804. t['Scedilla'] = 556;
  50805. t['lcaron'] = 382;
  50806. t['Kcommaaccent'] = 667;
  50807. t['Lacute'] = 611;
  50808. t['trademark'] = 1000;
  50809. t['edotaccent'] = 444;
  50810. t['Igrave'] = 389;
  50811. t['Imacron'] = 389;
  50812. t['Lcaron'] = 611;
  50813. t['onehalf'] = 750;
  50814. t['lessequal'] = 549;
  50815. t['ocircumflex'] = 500;
  50816. t['ntilde'] = 556;
  50817. t['Uhungarumlaut'] = 722;
  50818. t['Eacute'] = 667;
  50819. t['emacron'] = 444;
  50820. t['gbreve'] = 500;
  50821. t['onequarter'] = 750;
  50822. t['Scaron'] = 556;
  50823. t['Scommaaccent'] = 556;
  50824. t['Ohungarumlaut'] = 722;
  50825. t['degree'] = 400;
  50826. t['ograve'] = 500;
  50827. t['Ccaron'] = 667;
  50828. t['ugrave'] = 556;
  50829. t['radical'] = 549;
  50830. t['Dcaron'] = 722;
  50831. t['rcommaaccent'] = 389;
  50832. t['Ntilde'] = 722;
  50833. t['otilde'] = 500;
  50834. t['Rcommaaccent'] = 667;
  50835. t['Lcommaaccent'] = 611;
  50836. t['Atilde'] = 667;
  50837. t['Aogonek'] = 667;
  50838. t['Aring'] = 667;
  50839. t['Otilde'] = 722;
  50840. t['zdotaccent'] = 389;
  50841. t['Ecaron'] = 667;
  50842. t['Iogonek'] = 389;
  50843. t['kcommaaccent'] = 500;
  50844. t['minus'] = 606;
  50845. t['Icircumflex'] = 389;
  50846. t['ncaron'] = 556;
  50847. t['tcommaaccent'] = 278;
  50848. t['logicalnot'] = 606;
  50849. t['odieresis'] = 500;
  50850. t['udieresis'] = 556;
  50851. t['notequal'] = 549;
  50852. t['gcommaaccent'] = 500;
  50853. t['eth'] = 500;
  50854. t['zcaron'] = 389;
  50855. t['ncommaaccent'] = 556;
  50856. t['onesuperior'] = 300;
  50857. t['imacron'] = 278;
  50858. t['Euro'] = 500;
  50859. });
  50860. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50861. t['space'] = 250;
  50862. t['exclam'] = 333;
  50863. t['quotedbl'] = 420;
  50864. t['numbersign'] = 500;
  50865. t['dollar'] = 500;
  50866. t['percent'] = 833;
  50867. t['ampersand'] = 778;
  50868. t['quoteright'] = 333;
  50869. t['parenleft'] = 333;
  50870. t['parenright'] = 333;
  50871. t['asterisk'] = 500;
  50872. t['plus'] = 675;
  50873. t['comma'] = 250;
  50874. t['hyphen'] = 333;
  50875. t['period'] = 250;
  50876. t['slash'] = 278;
  50877. t['zero'] = 500;
  50878. t['one'] = 500;
  50879. t['two'] = 500;
  50880. t['three'] = 500;
  50881. t['four'] = 500;
  50882. t['five'] = 500;
  50883. t['six'] = 500;
  50884. t['seven'] = 500;
  50885. t['eight'] = 500;
  50886. t['nine'] = 500;
  50887. t['colon'] = 333;
  50888. t['semicolon'] = 333;
  50889. t['less'] = 675;
  50890. t['equal'] = 675;
  50891. t['greater'] = 675;
  50892. t['question'] = 500;
  50893. t['at'] = 920;
  50894. t['A'] = 611;
  50895. t['B'] = 611;
  50896. t['C'] = 667;
  50897. t['D'] = 722;
  50898. t['E'] = 611;
  50899. t['F'] = 611;
  50900. t['G'] = 722;
  50901. t['H'] = 722;
  50902. t['I'] = 333;
  50903. t['J'] = 444;
  50904. t['K'] = 667;
  50905. t['L'] = 556;
  50906. t['M'] = 833;
  50907. t['N'] = 667;
  50908. t['O'] = 722;
  50909. t['P'] = 611;
  50910. t['Q'] = 722;
  50911. t['R'] = 611;
  50912. t['S'] = 500;
  50913. t['T'] = 556;
  50914. t['U'] = 722;
  50915. t['V'] = 611;
  50916. t['W'] = 833;
  50917. t['X'] = 611;
  50918. t['Y'] = 556;
  50919. t['Z'] = 556;
  50920. t['bracketleft'] = 389;
  50921. t['backslash'] = 278;
  50922. t['bracketright'] = 389;
  50923. t['asciicircum'] = 422;
  50924. t['underscore'] = 500;
  50925. t['quoteleft'] = 333;
  50926. t['a'] = 500;
  50927. t['b'] = 500;
  50928. t['c'] = 444;
  50929. t['d'] = 500;
  50930. t['e'] = 444;
  50931. t['f'] = 278;
  50932. t['g'] = 500;
  50933. t['h'] = 500;
  50934. t['i'] = 278;
  50935. t['j'] = 278;
  50936. t['k'] = 444;
  50937. t['l'] = 278;
  50938. t['m'] = 722;
  50939. t['n'] = 500;
  50940. t['o'] = 500;
  50941. t['p'] = 500;
  50942. t['q'] = 500;
  50943. t['r'] = 389;
  50944. t['s'] = 389;
  50945. t['t'] = 278;
  50946. t['u'] = 500;
  50947. t['v'] = 444;
  50948. t['w'] = 667;
  50949. t['x'] = 444;
  50950. t['y'] = 444;
  50951. t['z'] = 389;
  50952. t['braceleft'] = 400;
  50953. t['bar'] = 275;
  50954. t['braceright'] = 400;
  50955. t['asciitilde'] = 541;
  50956. t['exclamdown'] = 389;
  50957. t['cent'] = 500;
  50958. t['sterling'] = 500;
  50959. t['fraction'] = 167;
  50960. t['yen'] = 500;
  50961. t['florin'] = 500;
  50962. t['section'] = 500;
  50963. t['currency'] = 500;
  50964. t['quotesingle'] = 214;
  50965. t['quotedblleft'] = 556;
  50966. t['guillemotleft'] = 500;
  50967. t['guilsinglleft'] = 333;
  50968. t['guilsinglright'] = 333;
  50969. t['fi'] = 500;
  50970. t['fl'] = 500;
  50971. t['endash'] = 500;
  50972. t['dagger'] = 500;
  50973. t['daggerdbl'] = 500;
  50974. t['periodcentered'] = 250;
  50975. t['paragraph'] = 523;
  50976. t['bullet'] = 350;
  50977. t['quotesinglbase'] = 333;
  50978. t['quotedblbase'] = 556;
  50979. t['quotedblright'] = 556;
  50980. t['guillemotright'] = 500;
  50981. t['ellipsis'] = 889;
  50982. t['perthousand'] = 1000;
  50983. t['questiondown'] = 500;
  50984. t['grave'] = 333;
  50985. t['acute'] = 333;
  50986. t['circumflex'] = 333;
  50987. t['tilde'] = 333;
  50988. t['macron'] = 333;
  50989. t['breve'] = 333;
  50990. t['dotaccent'] = 333;
  50991. t['dieresis'] = 333;
  50992. t['ring'] = 333;
  50993. t['cedilla'] = 333;
  50994. t['hungarumlaut'] = 333;
  50995. t['ogonek'] = 333;
  50996. t['caron'] = 333;
  50997. t['emdash'] = 889;
  50998. t['AE'] = 889;
  50999. t['ordfeminine'] = 276;
  51000. t['Lslash'] = 556;
  51001. t['Oslash'] = 722;
  51002. t['OE'] = 944;
  51003. t['ordmasculine'] = 310;
  51004. t['ae'] = 667;
  51005. t['dotlessi'] = 278;
  51006. t['lslash'] = 278;
  51007. t['oslash'] = 500;
  51008. t['oe'] = 667;
  51009. t['germandbls'] = 500;
  51010. t['Idieresis'] = 333;
  51011. t['eacute'] = 444;
  51012. t['abreve'] = 500;
  51013. t['uhungarumlaut'] = 500;
  51014. t['ecaron'] = 444;
  51015. t['Ydieresis'] = 556;
  51016. t['divide'] = 675;
  51017. t['Yacute'] = 556;
  51018. t['Acircumflex'] = 611;
  51019. t['aacute'] = 500;
  51020. t['Ucircumflex'] = 722;
  51021. t['yacute'] = 444;
  51022. t['scommaaccent'] = 389;
  51023. t['ecircumflex'] = 444;
  51024. t['Uring'] = 722;
  51025. t['Udieresis'] = 722;
  51026. t['aogonek'] = 500;
  51027. t['Uacute'] = 722;
  51028. t['uogonek'] = 500;
  51029. t['Edieresis'] = 611;
  51030. t['Dcroat'] = 722;
  51031. t['commaaccent'] = 250;
  51032. t['copyright'] = 760;
  51033. t['Emacron'] = 611;
  51034. t['ccaron'] = 444;
  51035. t['aring'] = 500;
  51036. t['Ncommaaccent'] = 667;
  51037. t['lacute'] = 278;
  51038. t['agrave'] = 500;
  51039. t['Tcommaaccent'] = 556;
  51040. t['Cacute'] = 667;
  51041. t['atilde'] = 500;
  51042. t['Edotaccent'] = 611;
  51043. t['scaron'] = 389;
  51044. t['scedilla'] = 389;
  51045. t['iacute'] = 278;
  51046. t['lozenge'] = 471;
  51047. t['Rcaron'] = 611;
  51048. t['Gcommaaccent'] = 722;
  51049. t['ucircumflex'] = 500;
  51050. t['acircumflex'] = 500;
  51051. t['Amacron'] = 611;
  51052. t['rcaron'] = 389;
  51053. t['ccedilla'] = 444;
  51054. t['Zdotaccent'] = 556;
  51055. t['Thorn'] = 611;
  51056. t['Omacron'] = 722;
  51057. t['Racute'] = 611;
  51058. t['Sacute'] = 500;
  51059. t['dcaron'] = 544;
  51060. t['Umacron'] = 722;
  51061. t['uring'] = 500;
  51062. t['threesuperior'] = 300;
  51063. t['Ograve'] = 722;
  51064. t['Agrave'] = 611;
  51065. t['Abreve'] = 611;
  51066. t['multiply'] = 675;
  51067. t['uacute'] = 500;
  51068. t['Tcaron'] = 556;
  51069. t['partialdiff'] = 476;
  51070. t['ydieresis'] = 444;
  51071. t['Nacute'] = 667;
  51072. t['icircumflex'] = 278;
  51073. t['Ecircumflex'] = 611;
  51074. t['adieresis'] = 500;
  51075. t['edieresis'] = 444;
  51076. t['cacute'] = 444;
  51077. t['nacute'] = 500;
  51078. t['umacron'] = 500;
  51079. t['Ncaron'] = 667;
  51080. t['Iacute'] = 333;
  51081. t['plusminus'] = 675;
  51082. t['brokenbar'] = 275;
  51083. t['registered'] = 760;
  51084. t['Gbreve'] = 722;
  51085. t['Idotaccent'] = 333;
  51086. t['summation'] = 600;
  51087. t['Egrave'] = 611;
  51088. t['racute'] = 389;
  51089. t['omacron'] = 500;
  51090. t['Zacute'] = 556;
  51091. t['Zcaron'] = 556;
  51092. t['greaterequal'] = 549;
  51093. t['Eth'] = 722;
  51094. t['Ccedilla'] = 667;
  51095. t['lcommaaccent'] = 278;
  51096. t['tcaron'] = 300;
  51097. t['eogonek'] = 444;
  51098. t['Uogonek'] = 722;
  51099. t['Aacute'] = 611;
  51100. t['Adieresis'] = 611;
  51101. t['egrave'] = 444;
  51102. t['zacute'] = 389;
  51103. t['iogonek'] = 278;
  51104. t['Oacute'] = 722;
  51105. t['oacute'] = 500;
  51106. t['amacron'] = 500;
  51107. t['sacute'] = 389;
  51108. t['idieresis'] = 278;
  51109. t['Ocircumflex'] = 722;
  51110. t['Ugrave'] = 722;
  51111. t['Delta'] = 612;
  51112. t['thorn'] = 500;
  51113. t['twosuperior'] = 300;
  51114. t['Odieresis'] = 722;
  51115. t['mu'] = 500;
  51116. t['igrave'] = 278;
  51117. t['ohungarumlaut'] = 500;
  51118. t['Eogonek'] = 611;
  51119. t['dcroat'] = 500;
  51120. t['threequarters'] = 750;
  51121. t['Scedilla'] = 500;
  51122. t['lcaron'] = 300;
  51123. t['Kcommaaccent'] = 667;
  51124. t['Lacute'] = 556;
  51125. t['trademark'] = 980;
  51126. t['edotaccent'] = 444;
  51127. t['Igrave'] = 333;
  51128. t['Imacron'] = 333;
  51129. t['Lcaron'] = 611;
  51130. t['onehalf'] = 750;
  51131. t['lessequal'] = 549;
  51132. t['ocircumflex'] = 500;
  51133. t['ntilde'] = 500;
  51134. t['Uhungarumlaut'] = 722;
  51135. t['Eacute'] = 611;
  51136. t['emacron'] = 444;
  51137. t['gbreve'] = 500;
  51138. t['onequarter'] = 750;
  51139. t['Scaron'] = 500;
  51140. t['Scommaaccent'] = 500;
  51141. t['Ohungarumlaut'] = 722;
  51142. t['degree'] = 400;
  51143. t['ograve'] = 500;
  51144. t['Ccaron'] = 667;
  51145. t['ugrave'] = 500;
  51146. t['radical'] = 453;
  51147. t['Dcaron'] = 722;
  51148. t['rcommaaccent'] = 389;
  51149. t['Ntilde'] = 667;
  51150. t['otilde'] = 500;
  51151. t['Rcommaaccent'] = 611;
  51152. t['Lcommaaccent'] = 556;
  51153. t['Atilde'] = 611;
  51154. t['Aogonek'] = 611;
  51155. t['Aring'] = 611;
  51156. t['Otilde'] = 722;
  51157. t['zdotaccent'] = 389;
  51158. t['Ecaron'] = 611;
  51159. t['Iogonek'] = 333;
  51160. t['kcommaaccent'] = 444;
  51161. t['minus'] = 675;
  51162. t['Icircumflex'] = 333;
  51163. t['ncaron'] = 500;
  51164. t['tcommaaccent'] = 278;
  51165. t['logicalnot'] = 675;
  51166. t['odieresis'] = 500;
  51167. t['udieresis'] = 500;
  51168. t['notequal'] = 549;
  51169. t['gcommaaccent'] = 500;
  51170. t['eth'] = 500;
  51171. t['zcaron'] = 389;
  51172. t['ncommaaccent'] = 500;
  51173. t['onesuperior'] = 300;
  51174. t['imacron'] = 278;
  51175. t['Euro'] = 500;
  51176. });
  51177. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51178. t['space'] = 278;
  51179. t['a1'] = 974;
  51180. t['a2'] = 961;
  51181. t['a202'] = 974;
  51182. t['a3'] = 980;
  51183. t['a4'] = 719;
  51184. t['a5'] = 789;
  51185. t['a119'] = 790;
  51186. t['a118'] = 791;
  51187. t['a117'] = 690;
  51188. t['a11'] = 960;
  51189. t['a12'] = 939;
  51190. t['a13'] = 549;
  51191. t['a14'] = 855;
  51192. t['a15'] = 911;
  51193. t['a16'] = 933;
  51194. t['a105'] = 911;
  51195. t['a17'] = 945;
  51196. t['a18'] = 974;
  51197. t['a19'] = 755;
  51198. t['a20'] = 846;
  51199. t['a21'] = 762;
  51200. t['a22'] = 761;
  51201. t['a23'] = 571;
  51202. t['a24'] = 677;
  51203. t['a25'] = 763;
  51204. t['a26'] = 760;
  51205. t['a27'] = 759;
  51206. t['a28'] = 754;
  51207. t['a6'] = 494;
  51208. t['a7'] = 552;
  51209. t['a8'] = 537;
  51210. t['a9'] = 577;
  51211. t['a10'] = 692;
  51212. t['a29'] = 786;
  51213. t['a30'] = 788;
  51214. t['a31'] = 788;
  51215. t['a32'] = 790;
  51216. t['a33'] = 793;
  51217. t['a34'] = 794;
  51218. t['a35'] = 816;
  51219. t['a36'] = 823;
  51220. t['a37'] = 789;
  51221. t['a38'] = 841;
  51222. t['a39'] = 823;
  51223. t['a40'] = 833;
  51224. t['a41'] = 816;
  51225. t['a42'] = 831;
  51226. t['a43'] = 923;
  51227. t['a44'] = 744;
  51228. t['a45'] = 723;
  51229. t['a46'] = 749;
  51230. t['a47'] = 790;
  51231. t['a48'] = 792;
  51232. t['a49'] = 695;
  51233. t['a50'] = 776;
  51234. t['a51'] = 768;
  51235. t['a52'] = 792;
  51236. t['a53'] = 759;
  51237. t['a54'] = 707;
  51238. t['a55'] = 708;
  51239. t['a56'] = 682;
  51240. t['a57'] = 701;
  51241. t['a58'] = 826;
  51242. t['a59'] = 815;
  51243. t['a60'] = 789;
  51244. t['a61'] = 789;
  51245. t['a62'] = 707;
  51246. t['a63'] = 687;
  51247. t['a64'] = 696;
  51248. t['a65'] = 689;
  51249. t['a66'] = 786;
  51250. t['a67'] = 787;
  51251. t['a68'] = 713;
  51252. t['a69'] = 791;
  51253. t['a70'] = 785;
  51254. t['a71'] = 791;
  51255. t['a72'] = 873;
  51256. t['a73'] = 761;
  51257. t['a74'] = 762;
  51258. t['a203'] = 762;
  51259. t['a75'] = 759;
  51260. t['a204'] = 759;
  51261. t['a76'] = 892;
  51262. t['a77'] = 892;
  51263. t['a78'] = 788;
  51264. t['a79'] = 784;
  51265. t['a81'] = 438;
  51266. t['a82'] = 138;
  51267. t['a83'] = 277;
  51268. t['a84'] = 415;
  51269. t['a97'] = 392;
  51270. t['a98'] = 392;
  51271. t['a99'] = 668;
  51272. t['a100'] = 668;
  51273. t['a89'] = 390;
  51274. t['a90'] = 390;
  51275. t['a93'] = 317;
  51276. t['a94'] = 317;
  51277. t['a91'] = 276;
  51278. t['a92'] = 276;
  51279. t['a205'] = 509;
  51280. t['a85'] = 509;
  51281. t['a206'] = 410;
  51282. t['a86'] = 410;
  51283. t['a87'] = 234;
  51284. t['a88'] = 234;
  51285. t['a95'] = 334;
  51286. t['a96'] = 334;
  51287. t['a101'] = 732;
  51288. t['a102'] = 544;
  51289. t['a103'] = 544;
  51290. t['a104'] = 910;
  51291. t['a106'] = 667;
  51292. t['a107'] = 760;
  51293. t['a108'] = 760;
  51294. t['a112'] = 776;
  51295. t['a111'] = 595;
  51296. t['a110'] = 694;
  51297. t['a109'] = 626;
  51298. t['a120'] = 788;
  51299. t['a121'] = 788;
  51300. t['a122'] = 788;
  51301. t['a123'] = 788;
  51302. t['a124'] = 788;
  51303. t['a125'] = 788;
  51304. t['a126'] = 788;
  51305. t['a127'] = 788;
  51306. t['a128'] = 788;
  51307. t['a129'] = 788;
  51308. t['a130'] = 788;
  51309. t['a131'] = 788;
  51310. t['a132'] = 788;
  51311. t['a133'] = 788;
  51312. t['a134'] = 788;
  51313. t['a135'] = 788;
  51314. t['a136'] = 788;
  51315. t['a137'] = 788;
  51316. t['a138'] = 788;
  51317. t['a139'] = 788;
  51318. t['a140'] = 788;
  51319. t['a141'] = 788;
  51320. t['a142'] = 788;
  51321. t['a143'] = 788;
  51322. t['a144'] = 788;
  51323. t['a145'] = 788;
  51324. t['a146'] = 788;
  51325. t['a147'] = 788;
  51326. t['a148'] = 788;
  51327. t['a149'] = 788;
  51328. t['a150'] = 788;
  51329. t['a151'] = 788;
  51330. t['a152'] = 788;
  51331. t['a153'] = 788;
  51332. t['a154'] = 788;
  51333. t['a155'] = 788;
  51334. t['a156'] = 788;
  51335. t['a157'] = 788;
  51336. t['a158'] = 788;
  51337. t['a159'] = 788;
  51338. t['a160'] = 894;
  51339. t['a161'] = 838;
  51340. t['a163'] = 1016;
  51341. t['a164'] = 458;
  51342. t['a196'] = 748;
  51343. t['a165'] = 924;
  51344. t['a192'] = 748;
  51345. t['a166'] = 918;
  51346. t['a167'] = 927;
  51347. t['a168'] = 928;
  51348. t['a169'] = 928;
  51349. t['a170'] = 834;
  51350. t['a171'] = 873;
  51351. t['a172'] = 828;
  51352. t['a173'] = 924;
  51353. t['a162'] = 924;
  51354. t['a174'] = 917;
  51355. t['a175'] = 930;
  51356. t['a176'] = 931;
  51357. t['a177'] = 463;
  51358. t['a178'] = 883;
  51359. t['a179'] = 836;
  51360. t['a193'] = 836;
  51361. t['a180'] = 867;
  51362. t['a199'] = 867;
  51363. t['a181'] = 696;
  51364. t['a200'] = 696;
  51365. t['a182'] = 874;
  51366. t['a201'] = 874;
  51367. t['a183'] = 760;
  51368. t['a184'] = 946;
  51369. t['a197'] = 771;
  51370. t['a185'] = 865;
  51371. t['a194'] = 771;
  51372. t['a198'] = 888;
  51373. t['a186'] = 967;
  51374. t['a195'] = 888;
  51375. t['a187'] = 831;
  51376. t['a188'] = 873;
  51377. t['a189'] = 927;
  51378. t['a190'] = 970;
  51379. t['a191'] = 918;
  51380. });
  51381. });
  51382. exports.getMetrics = getMetrics;
  51383. /***/ }),
  51384. /* 38 */
  51385. /***/ (function(module, exports, __w_pdfjs_require__) {
  51386. "use strict";
  51387. var sharedUtil = __w_pdfjs_require__(0);
  51388. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51389. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51390. var MASK_HIGH = 0xffff0000;
  51391. var MASK_LOW = 0xffff;
  51392. function MurmurHash3_64(seed) {
  51393. var SEED = 0xc3d2e1f0;
  51394. this.h1 = seed ? seed & 0xffffffff : SEED;
  51395. this.h2 = seed ? seed & 0xffffffff : SEED;
  51396. }
  51397. var alwaysUseUint32ArrayView = false;
  51398. try {
  51399. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51400. } catch (e) {
  51401. alwaysUseUint32ArrayView = true;
  51402. }
  51403. MurmurHash3_64.prototype = {
  51404. update: function MurmurHash3_64_update(input) {
  51405. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51406. var i;
  51407. if (typeof input === 'string') {
  51408. var data = new Uint8Array(input.length * 2);
  51409. var length = 0;
  51410. for (i = 0; i < input.length; i++) {
  51411. var code = input.charCodeAt(i);
  51412. if (code <= 0xff) {
  51413. data[length++] = code;
  51414. } else {
  51415. data[length++] = code >>> 8;
  51416. data[length++] = code & 0xff;
  51417. }
  51418. }
  51419. } else if (input instanceof Uint8Array) {
  51420. data = input;
  51421. length = data.length;
  51422. } else if (typeof input === 'object' && 'length' in input) {
  51423. data = input;
  51424. length = data.length;
  51425. useUint32ArrayView = true;
  51426. } else {
  51427. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51428. }
  51429. var blockCounts = length >> 2;
  51430. var tailLength = length - blockCounts * 4;
  51431. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51432. var k1 = 0;
  51433. var k2 = 0;
  51434. var h1 = this.h1;
  51435. var h2 = this.h2;
  51436. var C1 = 0xcc9e2d51;
  51437. var C2 = 0x1b873593;
  51438. var C1_LOW = C1 & MASK_LOW;
  51439. var C2_LOW = C2 & MASK_LOW;
  51440. for (i = 0; i < blockCounts; i++) {
  51441. if (i & 1) {
  51442. k1 = dataUint32[i];
  51443. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51444. k1 = k1 << 15 | k1 >>> 17;
  51445. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51446. h1 ^= k1;
  51447. h1 = h1 << 13 | h1 >>> 19;
  51448. h1 = h1 * 5 + 0xe6546b64;
  51449. } else {
  51450. k2 = dataUint32[i];
  51451. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51452. k2 = k2 << 15 | k2 >>> 17;
  51453. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51454. h2 ^= k2;
  51455. h2 = h2 << 13 | h2 >>> 19;
  51456. h2 = h2 * 5 + 0xe6546b64;
  51457. }
  51458. }
  51459. k1 = 0;
  51460. switch (tailLength) {
  51461. case 3:
  51462. k1 ^= data[blockCounts * 4 + 2] << 16;
  51463. case 2:
  51464. k1 ^= data[blockCounts * 4 + 1] << 8;
  51465. case 1:
  51466. k1 ^= data[blockCounts * 4];
  51467. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51468. k1 = k1 << 15 | k1 >>> 17;
  51469. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51470. if (blockCounts & 1) {
  51471. h1 ^= k1;
  51472. } else {
  51473. h2 ^= k1;
  51474. }
  51475. }
  51476. this.h1 = h1;
  51477. this.h2 = h2;
  51478. return this;
  51479. },
  51480. hexdigest: function MurmurHash3_64_hexdigest() {
  51481. var h1 = this.h1;
  51482. var h2 = this.h2;
  51483. h1 ^= h2 >>> 1;
  51484. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51485. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51486. h1 ^= h2 >>> 1;
  51487. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51488. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51489. h1 ^= h2 >>> 1;
  51490. for (var i = 0, arr = [
  51491. h1,
  51492. h2
  51493. ], str = ''; i < arr.length; i++) {
  51494. var hex = (arr[i] >>> 0).toString(16);
  51495. while (hex.length < 8) {
  51496. hex = '0' + hex;
  51497. }
  51498. str += hex;
  51499. }
  51500. return str;
  51501. }
  51502. };
  51503. return MurmurHash3_64;
  51504. }();
  51505. exports.MurmurHash3_64 = MurmurHash3_64;
  51506. /***/ }),
  51507. /* 39 */
  51508. /***/ (function(module, exports, __w_pdfjs_require__) {
  51509. "use strict";
  51510. var sharedUtil = __w_pdfjs_require__(0);
  51511. var coreWorker = __w_pdfjs_require__(23);
  51512. var OK_RESPONSE = 200;
  51513. var PARTIAL_CONTENT_RESPONSE = 206;
  51514. function NetworkManager(url, args) {
  51515. this.url = url;
  51516. args = args || {};
  51517. this.isHttp = /^https?:/i.test(url);
  51518. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51519. this.withCredentials = args.withCredentials || false;
  51520. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51521. return new XMLHttpRequest();
  51522. };
  51523. this.currXhrId = 0;
  51524. this.pendingRequests = Object.create(null);
  51525. this.loadedRequests = Object.create(null);
  51526. }
  51527. function getArrayBuffer(xhr) {
  51528. var data = xhr.response;
  51529. if (typeof data !== 'string') {
  51530. return data;
  51531. }
  51532. var length = data.length;
  51533. var array = new Uint8Array(length);
  51534. for (var i = 0; i < length; i++) {
  51535. array[i] = data.charCodeAt(i) & 0xFF;
  51536. }
  51537. return array.buffer;
  51538. }
  51539. var supportsMozChunked = function supportsMozChunkedClosure() {
  51540. try {
  51541. var x = new XMLHttpRequest();
  51542. x.open('GET', 'https://example.com');
  51543. x.responseType = 'moz-chunked-arraybuffer';
  51544. return x.responseType === 'moz-chunked-arraybuffer';
  51545. } catch (e) {
  51546. return false;
  51547. }
  51548. }();
  51549. NetworkManager.prototype = {
  51550. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51551. var args = {
  51552. begin: begin,
  51553. end: end
  51554. };
  51555. for (var prop in listeners) {
  51556. args[prop] = listeners[prop];
  51557. }
  51558. return this.request(args);
  51559. },
  51560. requestFull: function NetworkManager_requestFull(listeners) {
  51561. return this.request(listeners);
  51562. },
  51563. request: function NetworkManager_request(args) {
  51564. var xhr = this.getXhr();
  51565. var xhrId = this.currXhrId++;
  51566. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51567. xhr.open('GET', this.url);
  51568. xhr.withCredentials = this.withCredentials;
  51569. for (var property in this.httpHeaders) {
  51570. var value = this.httpHeaders[property];
  51571. if (typeof value === 'undefined') {
  51572. continue;
  51573. }
  51574. xhr.setRequestHeader(property, value);
  51575. }
  51576. if (this.isHttp && 'begin' in args && 'end' in args) {
  51577. var rangeStr = args.begin + '-' + (args.end - 1);
  51578. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51579. pendingRequest.expectedStatus = 206;
  51580. } else {
  51581. pendingRequest.expectedStatus = 200;
  51582. }
  51583. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51584. if (useMozChunkedLoading) {
  51585. xhr.responseType = 'moz-chunked-arraybuffer';
  51586. pendingRequest.onProgressiveData = args.onProgressiveData;
  51587. pendingRequest.mozChunked = true;
  51588. } else {
  51589. xhr.responseType = 'arraybuffer';
  51590. }
  51591. if (args.onError) {
  51592. xhr.onerror = function (evt) {
  51593. args.onError(xhr.status);
  51594. };
  51595. }
  51596. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51597. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51598. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51599. pendingRequest.onDone = args.onDone;
  51600. pendingRequest.onError = args.onError;
  51601. pendingRequest.onProgress = args.onProgress;
  51602. xhr.send(null);
  51603. return xhrId;
  51604. },
  51605. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51606. var pendingRequest = this.pendingRequests[xhrId];
  51607. if (!pendingRequest) {
  51608. return;
  51609. }
  51610. if (pendingRequest.mozChunked) {
  51611. var chunk = getArrayBuffer(pendingRequest.xhr);
  51612. pendingRequest.onProgressiveData(chunk);
  51613. }
  51614. var onProgress = pendingRequest.onProgress;
  51615. if (onProgress) {
  51616. onProgress(evt);
  51617. }
  51618. },
  51619. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51620. var pendingRequest = this.pendingRequests[xhrId];
  51621. if (!pendingRequest) {
  51622. return;
  51623. }
  51624. var xhr = pendingRequest.xhr;
  51625. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51626. pendingRequest.onHeadersReceived();
  51627. delete pendingRequest.onHeadersReceived;
  51628. }
  51629. if (xhr.readyState !== 4) {
  51630. return;
  51631. }
  51632. if (!(xhrId in this.pendingRequests)) {
  51633. return;
  51634. }
  51635. delete this.pendingRequests[xhrId];
  51636. if (xhr.status === 0 && this.isHttp) {
  51637. if (pendingRequest.onError) {
  51638. pendingRequest.onError(xhr.status);
  51639. }
  51640. return;
  51641. }
  51642. var xhrStatus = xhr.status || OK_RESPONSE;
  51643. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51644. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51645. if (pendingRequest.onError) {
  51646. pendingRequest.onError(xhr.status);
  51647. }
  51648. return;
  51649. }
  51650. this.loadedRequests[xhrId] = true;
  51651. var chunk = getArrayBuffer(xhr);
  51652. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51653. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51654. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51655. var begin = parseInt(matches[1], 10);
  51656. pendingRequest.onDone({
  51657. begin: begin,
  51658. chunk: chunk
  51659. });
  51660. } else if (pendingRequest.onProgressiveData) {
  51661. pendingRequest.onDone(null);
  51662. } else if (chunk) {
  51663. pendingRequest.onDone({
  51664. begin: 0,
  51665. chunk: chunk
  51666. });
  51667. } else if (pendingRequest.onError) {
  51668. pendingRequest.onError(xhr.status);
  51669. }
  51670. },
  51671. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51672. for (var xhrId in this.pendingRequests) {
  51673. return true;
  51674. }
  51675. return false;
  51676. },
  51677. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51678. return this.pendingRequests[xhrId].xhr;
  51679. },
  51680. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51681. return !!this.pendingRequests[xhrId].onProgressiveData;
  51682. },
  51683. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51684. return xhrId in this.pendingRequests;
  51685. },
  51686. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51687. return xhrId in this.loadedRequests;
  51688. },
  51689. abortAllRequests: function NetworkManager_abortAllRequests() {
  51690. for (var xhrId in this.pendingRequests) {
  51691. this.abortRequest(xhrId | 0);
  51692. }
  51693. },
  51694. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51695. var xhr = this.pendingRequests[xhrId].xhr;
  51696. delete this.pendingRequests[xhrId];
  51697. xhr.abort();
  51698. }
  51699. };
  51700. var assert = sharedUtil.assert;
  51701. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51702. var isInt = sharedUtil.isInt;
  51703. var MissingPDFException = sharedUtil.MissingPDFException;
  51704. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51705. function PDFNetworkStream(options) {
  51706. this._options = options;
  51707. var source = options.source;
  51708. this._manager = new NetworkManager(source.url, {
  51709. httpHeaders: source.httpHeaders,
  51710. withCredentials: source.withCredentials
  51711. });
  51712. this._rangeChunkSize = source.rangeChunkSize;
  51713. this._fullRequestReader = null;
  51714. this._rangeRequestReaders = [];
  51715. }
  51716. PDFNetworkStream.prototype = {
  51717. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51718. var i = this._rangeRequestReaders.indexOf(reader);
  51719. if (i >= 0) {
  51720. this._rangeRequestReaders.splice(i, 1);
  51721. }
  51722. },
  51723. getFullReader: function PDFNetworkStream_getFullReader() {
  51724. assert(!this._fullRequestReader);
  51725. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51726. return this._fullRequestReader;
  51727. },
  51728. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51729. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51730. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51731. this._rangeRequestReaders.push(reader);
  51732. return reader;
  51733. },
  51734. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51735. if (this._fullRequestReader) {
  51736. this._fullRequestReader.cancel(reason);
  51737. }
  51738. var readers = this._rangeRequestReaders.slice(0);
  51739. readers.forEach(function (reader) {
  51740. reader.cancel(reason);
  51741. });
  51742. }
  51743. };
  51744. function PDFNetworkStreamFullRequestReader(manager, options) {
  51745. this._manager = manager;
  51746. var source = options.source;
  51747. var args = {
  51748. onHeadersReceived: this._onHeadersReceived.bind(this),
  51749. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51750. onDone: this._onDone.bind(this),
  51751. onError: this._onError.bind(this),
  51752. onProgress: this._onProgress.bind(this)
  51753. };
  51754. this._url = source.url;
  51755. this._fullRequestId = manager.requestFull(args);
  51756. this._headersReceivedCapability = createPromiseCapability();
  51757. this._disableRange = options.disableRange || false;
  51758. this._contentLength = source.length;
  51759. this._rangeChunkSize = source.rangeChunkSize;
  51760. if (!this._rangeChunkSize && !this._disableRange) {
  51761. this._disableRange = true;
  51762. }
  51763. this._isStreamingSupported = false;
  51764. this._isRangeSupported = false;
  51765. this._cachedChunks = [];
  51766. this._requests = [];
  51767. this._done = false;
  51768. this._storedError = undefined;
  51769. this.onProgress = null;
  51770. }
  51771. PDFNetworkStreamFullRequestReader.prototype = {
  51772. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51773. if (this._disableRange) {
  51774. return false;
  51775. }
  51776. var networkManager = this._manager;
  51777. if (!networkManager.isHttp) {
  51778. return false;
  51779. }
  51780. var fullRequestXhrId = this._fullRequestId;
  51781. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51782. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51783. return false;
  51784. }
  51785. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51786. if (contentEncoding !== 'identity') {
  51787. return false;
  51788. }
  51789. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51790. length = parseInt(length, 10);
  51791. if (!isInt(length)) {
  51792. return false;
  51793. }
  51794. this._contentLength = length;
  51795. if (length <= 2 * this._rangeChunkSize) {
  51796. return false;
  51797. }
  51798. return true;
  51799. },
  51800. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51801. if (this._validateRangeRequestCapabilities()) {
  51802. this._isRangeSupported = true;
  51803. }
  51804. var networkManager = this._manager;
  51805. var fullRequestXhrId = this._fullRequestId;
  51806. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51807. this._isStreamingSupported = true;
  51808. } else if (this._isRangeSupported) {
  51809. networkManager.abortRequest(fullRequestXhrId);
  51810. }
  51811. this._headersReceivedCapability.resolve();
  51812. },
  51813. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51814. if (this._requests.length > 0) {
  51815. var requestCapability = this._requests.shift();
  51816. requestCapability.resolve({
  51817. value: chunk,
  51818. done: false
  51819. });
  51820. } else {
  51821. this._cachedChunks.push(chunk);
  51822. }
  51823. },
  51824. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51825. if (args) {
  51826. this._onProgressiveData(args.chunk);
  51827. }
  51828. this._done = true;
  51829. if (this._cachedChunks.length > 0) {
  51830. return;
  51831. }
  51832. this._requests.forEach(function (requestCapability) {
  51833. requestCapability.resolve({
  51834. value: undefined,
  51835. done: true
  51836. });
  51837. });
  51838. this._requests = [];
  51839. },
  51840. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51841. var url = this._url;
  51842. var exception;
  51843. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51844. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51845. } else {
  51846. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51847. }
  51848. this._storedError = exception;
  51849. this._headersReceivedCapability.reject(exception);
  51850. this._requests.forEach(function (requestCapability) {
  51851. requestCapability.reject(exception);
  51852. });
  51853. this._requests = [];
  51854. this._cachedChunks = [];
  51855. },
  51856. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51857. if (this.onProgress) {
  51858. this.onProgress({
  51859. loaded: data.loaded,
  51860. total: data.lengthComputable ? data.total : this._contentLength
  51861. });
  51862. }
  51863. },
  51864. get isRangeSupported() {
  51865. return this._isRangeSupported;
  51866. },
  51867. get isStreamingSupported() {
  51868. return this._isStreamingSupported;
  51869. },
  51870. get contentLength() {
  51871. return this._contentLength;
  51872. },
  51873. get headersReady() {
  51874. return this._headersReceivedCapability.promise;
  51875. },
  51876. read: function PDFNetworkStreamFullRequestReader_read() {
  51877. if (this._storedError) {
  51878. return Promise.reject(this._storedError);
  51879. }
  51880. if (this._cachedChunks.length > 0) {
  51881. var chunk = this._cachedChunks.shift();
  51882. return Promise.resolve(chunk);
  51883. }
  51884. if (this._done) {
  51885. return Promise.resolve({
  51886. value: undefined,
  51887. done: true
  51888. });
  51889. }
  51890. var requestCapability = createPromiseCapability();
  51891. this._requests.push(requestCapability);
  51892. return requestCapability.promise;
  51893. },
  51894. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51895. this._done = true;
  51896. this._headersReceivedCapability.reject(reason);
  51897. this._requests.forEach(function (requestCapability) {
  51898. requestCapability.resolve({
  51899. value: undefined,
  51900. done: true
  51901. });
  51902. });
  51903. this._requests = [];
  51904. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51905. this._manager.abortRequest(this._fullRequestId);
  51906. }
  51907. this._fullRequestReader = null;
  51908. }
  51909. };
  51910. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51911. this._manager = manager;
  51912. var args = {
  51913. onDone: this._onDone.bind(this),
  51914. onProgress: this._onProgress.bind(this)
  51915. };
  51916. this._requestId = manager.requestRange(begin, end, args);
  51917. this._requests = [];
  51918. this._queuedChunk = null;
  51919. this._done = false;
  51920. this.onProgress = null;
  51921. this.onClosed = null;
  51922. }
  51923. PDFNetworkStreamRangeRequestReader.prototype = {
  51924. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51925. if (this.onClosed) {
  51926. this.onClosed(this);
  51927. }
  51928. },
  51929. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51930. var chunk = data.chunk;
  51931. if (this._requests.length > 0) {
  51932. var requestCapability = this._requests.shift();
  51933. requestCapability.resolve({
  51934. value: chunk,
  51935. done: false
  51936. });
  51937. } else {
  51938. this._queuedChunk = chunk;
  51939. }
  51940. this._done = true;
  51941. this._requests.forEach(function (requestCapability) {
  51942. requestCapability.resolve({
  51943. value: undefined,
  51944. done: true
  51945. });
  51946. });
  51947. this._requests = [];
  51948. this._close();
  51949. },
  51950. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51951. if (!this.isStreamingSupported && this.onProgress) {
  51952. this.onProgress({ loaded: evt.loaded });
  51953. }
  51954. },
  51955. get isStreamingSupported() {
  51956. return false;
  51957. },
  51958. read: function PDFNetworkStreamRangeRequestReader_read() {
  51959. if (this._queuedChunk !== null) {
  51960. var chunk = this._queuedChunk;
  51961. this._queuedChunk = null;
  51962. return Promise.resolve({
  51963. value: chunk,
  51964. done: false
  51965. });
  51966. }
  51967. if (this._done) {
  51968. return Promise.resolve({
  51969. value: undefined,
  51970. done: true
  51971. });
  51972. }
  51973. var requestCapability = createPromiseCapability();
  51974. this._requests.push(requestCapability);
  51975. return requestCapability.promise;
  51976. },
  51977. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  51978. this._done = true;
  51979. this._requests.forEach(function (requestCapability) {
  51980. requestCapability.resolve({
  51981. value: undefined,
  51982. done: true
  51983. });
  51984. });
  51985. this._requests = [];
  51986. if (this._manager.isPendingRequest(this._requestId)) {
  51987. this._manager.abortRequest(this._requestId);
  51988. }
  51989. this._close();
  51990. }
  51991. };
  51992. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  51993. exports.PDFNetworkStream = PDFNetworkStream;
  51994. exports.NetworkManager = NetworkManager;
  51995. /***/ }),
  51996. /* 40 */
  51997. /***/ (function(module, exports, __w_pdfjs_require__) {
  51998. "use strict";
  51999. var sharedUtil = __w_pdfjs_require__(0);
  52000. var corePrimitives = __w_pdfjs_require__(1);
  52001. var coreFunction = __w_pdfjs_require__(7);
  52002. var coreColorSpace = __w_pdfjs_require__(4);
  52003. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52004. var MissingDataException = sharedUtil.MissingDataException;
  52005. var Util = sharedUtil.Util;
  52006. var assert = sharedUtil.assert;
  52007. var error = sharedUtil.error;
  52008. var info = sharedUtil.info;
  52009. var warn = sharedUtil.warn;
  52010. var isStream = corePrimitives.isStream;
  52011. var PDFFunction = coreFunction.PDFFunction;
  52012. var ColorSpace = coreColorSpace.ColorSpace;
  52013. var ShadingType = {
  52014. FUNCTION_BASED: 1,
  52015. AXIAL: 2,
  52016. RADIAL: 3,
  52017. FREE_FORM_MESH: 4,
  52018. LATTICE_FORM_MESH: 5,
  52019. COONS_PATCH_MESH: 6,
  52020. TENSOR_PATCH_MESH: 7
  52021. };
  52022. var Pattern = function PatternClosure() {
  52023. function Pattern() {
  52024. error('should not call Pattern constructor');
  52025. }
  52026. Pattern.prototype = {
  52027. getPattern: function Pattern_getPattern(ctx) {
  52028. error('Should not call Pattern.getStyle: ' + ctx);
  52029. }
  52030. };
  52031. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52032. var dict = isStream(shading) ? shading.dict : shading;
  52033. var type = dict.get('ShadingType');
  52034. try {
  52035. switch (type) {
  52036. case ShadingType.AXIAL:
  52037. case ShadingType.RADIAL:
  52038. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52039. case ShadingType.FREE_FORM_MESH:
  52040. case ShadingType.LATTICE_FORM_MESH:
  52041. case ShadingType.COONS_PATCH_MESH:
  52042. case ShadingType.TENSOR_PATCH_MESH:
  52043. return new Shadings.Mesh(shading, matrix, xref, res);
  52044. default:
  52045. throw new Error('Unsupported ShadingType: ' + type);
  52046. }
  52047. } catch (ex) {
  52048. if (ex instanceof MissingDataException) {
  52049. throw ex;
  52050. }
  52051. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52052. warn(ex);
  52053. return new Shadings.Dummy();
  52054. }
  52055. };
  52056. return Pattern;
  52057. }();
  52058. var Shadings = {};
  52059. Shadings.SMALL_NUMBER = 1e-6;
  52060. Shadings.RadialAxial = function RadialAxialClosure() {
  52061. function RadialAxial(dict, matrix, xref, res) {
  52062. this.matrix = matrix;
  52063. this.coordsArr = dict.getArray('Coords');
  52064. this.shadingType = dict.get('ShadingType');
  52065. this.type = 'Pattern';
  52066. var cs = dict.get('ColorSpace', 'CS');
  52067. cs = ColorSpace.parse(cs, xref, res);
  52068. this.cs = cs;
  52069. var t0 = 0.0, t1 = 1.0;
  52070. if (dict.has('Domain')) {
  52071. var domainArr = dict.getArray('Domain');
  52072. t0 = domainArr[0];
  52073. t1 = domainArr[1];
  52074. }
  52075. var extendStart = false, extendEnd = false;
  52076. if (dict.has('Extend')) {
  52077. var extendArr = dict.getArray('Extend');
  52078. extendStart = extendArr[0];
  52079. extendEnd = extendArr[1];
  52080. }
  52081. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52082. var x1 = this.coordsArr[0];
  52083. var y1 = this.coordsArr[1];
  52084. var r1 = this.coordsArr[2];
  52085. var x2 = this.coordsArr[3];
  52086. var y2 = this.coordsArr[4];
  52087. var r2 = this.coordsArr[5];
  52088. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52089. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52090. warn('Unsupported radial gradient.');
  52091. }
  52092. }
  52093. this.extendStart = extendStart;
  52094. this.extendEnd = extendEnd;
  52095. var fnObj = dict.get('Function');
  52096. var fn = PDFFunction.parseArray(xref, fnObj);
  52097. var diff = t1 - t0;
  52098. var step = diff / 10;
  52099. var colorStops = this.colorStops = [];
  52100. if (t0 >= t1 || step <= 0) {
  52101. info('Bad shading domain.');
  52102. return;
  52103. }
  52104. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52105. var rgbColor;
  52106. for (var i = t0; i <= t1; i += step) {
  52107. ratio[0] = i;
  52108. fn(ratio, 0, color, 0);
  52109. rgbColor = cs.getRgb(color, 0);
  52110. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52111. colorStops.push([
  52112. (i - t0) / diff,
  52113. cssColor
  52114. ]);
  52115. }
  52116. var background = 'transparent';
  52117. if (dict.has('Background')) {
  52118. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52119. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52120. }
  52121. if (!extendStart) {
  52122. colorStops.unshift([
  52123. 0,
  52124. background
  52125. ]);
  52126. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52127. }
  52128. if (!extendEnd) {
  52129. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52130. colorStops.push([
  52131. 1,
  52132. background
  52133. ]);
  52134. }
  52135. this.colorStops = colorStops;
  52136. }
  52137. RadialAxial.prototype = {
  52138. getIR: function RadialAxial_getIR() {
  52139. var coordsArr = this.coordsArr;
  52140. var shadingType = this.shadingType;
  52141. var type, p0, p1, r0, r1;
  52142. if (shadingType === ShadingType.AXIAL) {
  52143. p0 = [
  52144. coordsArr[0],
  52145. coordsArr[1]
  52146. ];
  52147. p1 = [
  52148. coordsArr[2],
  52149. coordsArr[3]
  52150. ];
  52151. r0 = null;
  52152. r1 = null;
  52153. type = 'axial';
  52154. } else if (shadingType === ShadingType.RADIAL) {
  52155. p0 = [
  52156. coordsArr[0],
  52157. coordsArr[1]
  52158. ];
  52159. p1 = [
  52160. coordsArr[3],
  52161. coordsArr[4]
  52162. ];
  52163. r0 = coordsArr[2];
  52164. r1 = coordsArr[5];
  52165. type = 'radial';
  52166. } else {
  52167. error('getPattern type unknown: ' + shadingType);
  52168. }
  52169. var matrix = this.matrix;
  52170. if (matrix) {
  52171. p0 = Util.applyTransform(p0, matrix);
  52172. p1 = Util.applyTransform(p1, matrix);
  52173. if (shadingType === ShadingType.RADIAL) {
  52174. var scale = Util.singularValueDecompose2dScale(matrix);
  52175. r0 *= scale[0];
  52176. r1 *= scale[1];
  52177. }
  52178. }
  52179. return [
  52180. 'RadialAxial',
  52181. type,
  52182. this.colorStops,
  52183. p0,
  52184. p1,
  52185. r0,
  52186. r1
  52187. ];
  52188. }
  52189. };
  52190. return RadialAxial;
  52191. }();
  52192. Shadings.Mesh = function MeshClosure() {
  52193. function MeshStreamReader(stream, context) {
  52194. this.stream = stream;
  52195. this.context = context;
  52196. this.buffer = 0;
  52197. this.bufferLength = 0;
  52198. var numComps = context.numComps;
  52199. this.tmpCompsBuf = new Float32Array(numComps);
  52200. var csNumComps = context.colorSpace.numComps;
  52201. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52202. }
  52203. MeshStreamReader.prototype = {
  52204. get hasData() {
  52205. if (this.stream.end) {
  52206. return this.stream.pos < this.stream.end;
  52207. }
  52208. if (this.bufferLength > 0) {
  52209. return true;
  52210. }
  52211. var nextByte = this.stream.getByte();
  52212. if (nextByte < 0) {
  52213. return false;
  52214. }
  52215. this.buffer = nextByte;
  52216. this.bufferLength = 8;
  52217. return true;
  52218. },
  52219. readBits: function MeshStreamReader_readBits(n) {
  52220. var buffer = this.buffer;
  52221. var bufferLength = this.bufferLength;
  52222. if (n === 32) {
  52223. if (bufferLength === 0) {
  52224. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52225. }
  52226. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52227. var nextByte = this.stream.getByte();
  52228. this.buffer = nextByte & (1 << bufferLength) - 1;
  52229. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52230. }
  52231. if (n === 8 && bufferLength === 0) {
  52232. return this.stream.getByte();
  52233. }
  52234. while (bufferLength < n) {
  52235. buffer = buffer << 8 | this.stream.getByte();
  52236. bufferLength += 8;
  52237. }
  52238. bufferLength -= n;
  52239. this.bufferLength = bufferLength;
  52240. this.buffer = buffer & (1 << bufferLength) - 1;
  52241. return buffer >> bufferLength;
  52242. },
  52243. align: function MeshStreamReader_align() {
  52244. this.buffer = 0;
  52245. this.bufferLength = 0;
  52246. },
  52247. readFlag: function MeshStreamReader_readFlag() {
  52248. return this.readBits(this.context.bitsPerFlag);
  52249. },
  52250. readCoordinate: function MeshStreamReader_readCoordinate() {
  52251. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52252. var xi = this.readBits(bitsPerCoordinate);
  52253. var yi = this.readBits(bitsPerCoordinate);
  52254. var decode = this.context.decode;
  52255. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52256. return [
  52257. xi * scale * (decode[1] - decode[0]) + decode[0],
  52258. yi * scale * (decode[3] - decode[2]) + decode[2]
  52259. ];
  52260. },
  52261. readComponents: function MeshStreamReader_readComponents() {
  52262. var numComps = this.context.numComps;
  52263. var bitsPerComponent = this.context.bitsPerComponent;
  52264. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52265. var decode = this.context.decode;
  52266. var components = this.tmpCompsBuf;
  52267. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52268. var ci = this.readBits(bitsPerComponent);
  52269. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52270. }
  52271. var color = this.tmpCsCompsBuf;
  52272. if (this.context.colorFn) {
  52273. this.context.colorFn(components, 0, color, 0);
  52274. }
  52275. return this.context.colorSpace.getRgb(color, 0);
  52276. }
  52277. };
  52278. function decodeType4Shading(mesh, reader) {
  52279. var coords = mesh.coords;
  52280. var colors = mesh.colors;
  52281. var operators = [];
  52282. var ps = [];
  52283. var verticesLeft = 0;
  52284. while (reader.hasData) {
  52285. var f = reader.readFlag();
  52286. var coord = reader.readCoordinate();
  52287. var color = reader.readComponents();
  52288. if (verticesLeft === 0) {
  52289. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52290. switch (f) {
  52291. case 0:
  52292. verticesLeft = 3;
  52293. break;
  52294. case 1:
  52295. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52296. verticesLeft = 1;
  52297. break;
  52298. case 2:
  52299. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52300. verticesLeft = 1;
  52301. break;
  52302. }
  52303. operators.push(f);
  52304. }
  52305. ps.push(coords.length);
  52306. coords.push(coord);
  52307. colors.push(color);
  52308. verticesLeft--;
  52309. reader.align();
  52310. }
  52311. mesh.figures.push({
  52312. type: 'triangles',
  52313. coords: new Int32Array(ps),
  52314. colors: new Int32Array(ps)
  52315. });
  52316. }
  52317. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52318. var coords = mesh.coords;
  52319. var colors = mesh.colors;
  52320. var ps = [];
  52321. while (reader.hasData) {
  52322. var coord = reader.readCoordinate();
  52323. var color = reader.readComponents();
  52324. ps.push(coords.length);
  52325. coords.push(coord);
  52326. colors.push(color);
  52327. }
  52328. mesh.figures.push({
  52329. type: 'lattice',
  52330. coords: new Int32Array(ps),
  52331. colors: new Int32Array(ps),
  52332. verticesPerRow: verticesPerRow
  52333. });
  52334. }
  52335. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52336. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52337. var TRIANGLE_DENSITY = 20;
  52338. var getB = function getBClosure() {
  52339. function buildB(count) {
  52340. var lut = [];
  52341. for (var i = 0; i <= count; i++) {
  52342. var t = i / count, t_ = 1 - t;
  52343. lut.push(new Float32Array([
  52344. t_ * t_ * t_,
  52345. 3 * t * t_ * t_,
  52346. 3 * t * t * t_,
  52347. t * t * t
  52348. ]));
  52349. }
  52350. return lut;
  52351. }
  52352. var cache = [];
  52353. return function getB(count) {
  52354. if (!cache[count]) {
  52355. cache[count] = buildB(count);
  52356. }
  52357. return cache[count];
  52358. };
  52359. }();
  52360. function buildFigureFromPatch(mesh, index) {
  52361. var figure = mesh.figures[index];
  52362. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52363. var coords = mesh.coords, colors = mesh.colors;
  52364. var pi = figure.coords;
  52365. var ci = figure.colors;
  52366. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52367. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52368. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52369. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52370. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52371. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52372. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52373. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52374. var verticesPerRow = splitXBy + 1;
  52375. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52376. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52377. var k = 0;
  52378. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52379. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52380. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52381. for (var row = 0; row <= splitYBy; row++) {
  52382. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52383. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52384. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52385. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52386. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52387. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52388. for (var col = 0; col <= splitXBy; col++, k++) {
  52389. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52390. continue;
  52391. }
  52392. var x = 0, y = 0;
  52393. var q = 0;
  52394. for (var i = 0; i <= 3; i++) {
  52395. for (var j = 0; j <= 3; j++, q++) {
  52396. var m = bRow[row][i] * bCol[col][j];
  52397. x += coords[pi[q]][0] * m;
  52398. y += coords[pi[q]][1] * m;
  52399. }
  52400. }
  52401. figureCoords[k] = coords.length;
  52402. coords.push([
  52403. x,
  52404. y
  52405. ]);
  52406. figureColors[k] = colors.length;
  52407. var newColor = new Uint8Array(3);
  52408. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52409. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52410. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52411. colors.push(newColor);
  52412. }
  52413. }
  52414. figureCoords[0] = pi[0];
  52415. figureColors[0] = ci[0];
  52416. figureCoords[splitXBy] = pi[3];
  52417. figureColors[splitXBy] = ci[1];
  52418. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52419. figureColors[verticesPerRow * splitYBy] = ci[2];
  52420. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52421. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52422. mesh.figures[index] = {
  52423. type: 'lattice',
  52424. coords: figureCoords,
  52425. colors: figureColors,
  52426. verticesPerRow: verticesPerRow
  52427. };
  52428. }
  52429. function decodeType6Shading(mesh, reader) {
  52430. var coords = mesh.coords;
  52431. var colors = mesh.colors;
  52432. var ps = new Int32Array(16);
  52433. var cs = new Int32Array(4);
  52434. while (reader.hasData) {
  52435. var f = reader.readFlag();
  52436. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52437. var i, ii;
  52438. var pi = coords.length;
  52439. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52440. coords.push(reader.readCoordinate());
  52441. }
  52442. var ci = colors.length;
  52443. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52444. colors.push(reader.readComponents());
  52445. }
  52446. var tmp1, tmp2, tmp3, tmp4;
  52447. switch (f) {
  52448. case 0:
  52449. ps[12] = pi + 3;
  52450. ps[13] = pi + 4;
  52451. ps[14] = pi + 5;
  52452. ps[15] = pi + 6;
  52453. ps[8] = pi + 2;
  52454. ps[11] = pi + 7;
  52455. ps[4] = pi + 1;
  52456. ps[7] = pi + 8;
  52457. ps[0] = pi;
  52458. ps[1] = pi + 11;
  52459. ps[2] = pi + 10;
  52460. ps[3] = pi + 9;
  52461. cs[2] = ci + 1;
  52462. cs[3] = ci + 2;
  52463. cs[0] = ci;
  52464. cs[1] = ci + 3;
  52465. break;
  52466. case 1:
  52467. tmp1 = ps[12];
  52468. tmp2 = ps[13];
  52469. tmp3 = ps[14];
  52470. tmp4 = ps[15];
  52471. ps[12] = tmp4;
  52472. ps[13] = pi + 0;
  52473. ps[14] = pi + 1;
  52474. ps[15] = pi + 2;
  52475. ps[8] = tmp3;
  52476. ps[11] = pi + 3;
  52477. ps[4] = tmp2;
  52478. ps[7] = pi + 4;
  52479. ps[0] = tmp1;
  52480. ps[1] = pi + 7;
  52481. ps[2] = pi + 6;
  52482. ps[3] = pi + 5;
  52483. tmp1 = cs[2];
  52484. tmp2 = cs[3];
  52485. cs[2] = tmp2;
  52486. cs[3] = ci;
  52487. cs[0] = tmp1;
  52488. cs[1] = ci + 1;
  52489. break;
  52490. case 2:
  52491. tmp1 = ps[15];
  52492. tmp2 = ps[11];
  52493. ps[12] = ps[3];
  52494. ps[13] = pi + 0;
  52495. ps[14] = pi + 1;
  52496. ps[15] = pi + 2;
  52497. ps[8] = ps[7];
  52498. ps[11] = pi + 3;
  52499. ps[4] = tmp2;
  52500. ps[7] = pi + 4;
  52501. ps[0] = tmp1;
  52502. ps[1] = pi + 7;
  52503. ps[2] = pi + 6;
  52504. ps[3] = pi + 5;
  52505. tmp1 = cs[3];
  52506. cs[2] = cs[1];
  52507. cs[3] = ci;
  52508. cs[0] = tmp1;
  52509. cs[1] = ci + 1;
  52510. break;
  52511. case 3:
  52512. ps[12] = ps[0];
  52513. ps[13] = pi + 0;
  52514. ps[14] = pi + 1;
  52515. ps[15] = pi + 2;
  52516. ps[8] = ps[1];
  52517. ps[11] = pi + 3;
  52518. ps[4] = ps[2];
  52519. ps[7] = pi + 4;
  52520. ps[0] = ps[3];
  52521. ps[1] = pi + 7;
  52522. ps[2] = pi + 6;
  52523. ps[3] = pi + 5;
  52524. cs[2] = cs[0];
  52525. cs[3] = ci;
  52526. cs[0] = cs[1];
  52527. cs[1] = ci + 1;
  52528. break;
  52529. }
  52530. ps[5] = coords.length;
  52531. coords.push([
  52532. (-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,
  52533. (-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
  52534. ]);
  52535. ps[6] = coords.length;
  52536. coords.push([
  52537. (-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,
  52538. (-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
  52539. ]);
  52540. ps[9] = coords.length;
  52541. coords.push([
  52542. (-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,
  52543. (-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
  52544. ]);
  52545. ps[10] = coords.length;
  52546. coords.push([
  52547. (-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,
  52548. (-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
  52549. ]);
  52550. mesh.figures.push({
  52551. type: 'patch',
  52552. coords: new Int32Array(ps),
  52553. colors: new Int32Array(cs)
  52554. });
  52555. }
  52556. }
  52557. function decodeType7Shading(mesh, reader) {
  52558. var coords = mesh.coords;
  52559. var colors = mesh.colors;
  52560. var ps = new Int32Array(16);
  52561. var cs = new Int32Array(4);
  52562. while (reader.hasData) {
  52563. var f = reader.readFlag();
  52564. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52565. var i, ii;
  52566. var pi = coords.length;
  52567. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52568. coords.push(reader.readCoordinate());
  52569. }
  52570. var ci = colors.length;
  52571. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52572. colors.push(reader.readComponents());
  52573. }
  52574. var tmp1, tmp2, tmp3, tmp4;
  52575. switch (f) {
  52576. case 0:
  52577. ps[12] = pi + 3;
  52578. ps[13] = pi + 4;
  52579. ps[14] = pi + 5;
  52580. ps[15] = pi + 6;
  52581. ps[8] = pi + 2;
  52582. ps[9] = pi + 13;
  52583. ps[10] = pi + 14;
  52584. ps[11] = pi + 7;
  52585. ps[4] = pi + 1;
  52586. ps[5] = pi + 12;
  52587. ps[6] = pi + 15;
  52588. ps[7] = pi + 8;
  52589. ps[0] = pi;
  52590. ps[1] = pi + 11;
  52591. ps[2] = pi + 10;
  52592. ps[3] = pi + 9;
  52593. cs[2] = ci + 1;
  52594. cs[3] = ci + 2;
  52595. cs[0] = ci;
  52596. cs[1] = ci + 3;
  52597. break;
  52598. case 1:
  52599. tmp1 = ps[12];
  52600. tmp2 = ps[13];
  52601. tmp3 = ps[14];
  52602. tmp4 = ps[15];
  52603. ps[12] = tmp4;
  52604. ps[13] = pi + 0;
  52605. ps[14] = pi + 1;
  52606. ps[15] = pi + 2;
  52607. ps[8] = tmp3;
  52608. ps[9] = pi + 9;
  52609. ps[10] = pi + 10;
  52610. ps[11] = pi + 3;
  52611. ps[4] = tmp2;
  52612. ps[5] = pi + 8;
  52613. ps[6] = pi + 11;
  52614. ps[7] = pi + 4;
  52615. ps[0] = tmp1;
  52616. ps[1] = pi + 7;
  52617. ps[2] = pi + 6;
  52618. ps[3] = pi + 5;
  52619. tmp1 = cs[2];
  52620. tmp2 = cs[3];
  52621. cs[2] = tmp2;
  52622. cs[3] = ci;
  52623. cs[0] = tmp1;
  52624. cs[1] = ci + 1;
  52625. break;
  52626. case 2:
  52627. tmp1 = ps[15];
  52628. tmp2 = ps[11];
  52629. ps[12] = ps[3];
  52630. ps[13] = pi + 0;
  52631. ps[14] = pi + 1;
  52632. ps[15] = pi + 2;
  52633. ps[8] = ps[7];
  52634. ps[9] = pi + 9;
  52635. ps[10] = pi + 10;
  52636. ps[11] = pi + 3;
  52637. ps[4] = tmp2;
  52638. ps[5] = pi + 8;
  52639. ps[6] = pi + 11;
  52640. ps[7] = pi + 4;
  52641. ps[0] = tmp1;
  52642. ps[1] = pi + 7;
  52643. ps[2] = pi + 6;
  52644. ps[3] = pi + 5;
  52645. tmp1 = cs[3];
  52646. cs[2] = cs[1];
  52647. cs[3] = ci;
  52648. cs[0] = tmp1;
  52649. cs[1] = ci + 1;
  52650. break;
  52651. case 3:
  52652. ps[12] = ps[0];
  52653. ps[13] = pi + 0;
  52654. ps[14] = pi + 1;
  52655. ps[15] = pi + 2;
  52656. ps[8] = ps[1];
  52657. ps[9] = pi + 9;
  52658. ps[10] = pi + 10;
  52659. ps[11] = pi + 3;
  52660. ps[4] = ps[2];
  52661. ps[5] = pi + 8;
  52662. ps[6] = pi + 11;
  52663. ps[7] = pi + 4;
  52664. ps[0] = ps[3];
  52665. ps[1] = pi + 7;
  52666. ps[2] = pi + 6;
  52667. ps[3] = pi + 5;
  52668. cs[2] = cs[0];
  52669. cs[3] = ci;
  52670. cs[0] = cs[1];
  52671. cs[1] = ci + 1;
  52672. break;
  52673. }
  52674. mesh.figures.push({
  52675. type: 'patch',
  52676. coords: new Int32Array(ps),
  52677. colors: new Int32Array(cs)
  52678. });
  52679. }
  52680. }
  52681. function updateBounds(mesh) {
  52682. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52683. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52684. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52685. minX = minX > x ? x : minX;
  52686. minY = minY > y ? y : minY;
  52687. maxX = maxX < x ? x : maxX;
  52688. maxY = maxY < y ? y : maxY;
  52689. }
  52690. mesh.bounds = [
  52691. minX,
  52692. minY,
  52693. maxX,
  52694. maxY
  52695. ];
  52696. }
  52697. function packData(mesh) {
  52698. var i, ii, j, jj;
  52699. var coords = mesh.coords;
  52700. var coordsPacked = new Float32Array(coords.length * 2);
  52701. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52702. var xy = coords[i];
  52703. coordsPacked[j++] = xy[0];
  52704. coordsPacked[j++] = xy[1];
  52705. }
  52706. mesh.coords = coordsPacked;
  52707. var colors = mesh.colors;
  52708. var colorsPacked = new Uint8Array(colors.length * 3);
  52709. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52710. var c = colors[i];
  52711. colorsPacked[j++] = c[0];
  52712. colorsPacked[j++] = c[1];
  52713. colorsPacked[j++] = c[2];
  52714. }
  52715. mesh.colors = colorsPacked;
  52716. var figures = mesh.figures;
  52717. for (i = 0, ii = figures.length; i < ii; i++) {
  52718. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52719. for (j = 0, jj = ps.length; j < jj; j++) {
  52720. ps[j] *= 2;
  52721. cs[j] *= 3;
  52722. }
  52723. }
  52724. }
  52725. function Mesh(stream, matrix, xref, res) {
  52726. assert(isStream(stream), 'Mesh data is not a stream');
  52727. var dict = stream.dict;
  52728. this.matrix = matrix;
  52729. this.shadingType = dict.get('ShadingType');
  52730. this.type = 'Pattern';
  52731. this.bbox = dict.getArray('BBox');
  52732. var cs = dict.get('ColorSpace', 'CS');
  52733. cs = ColorSpace.parse(cs, xref, res);
  52734. this.cs = cs;
  52735. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52736. var fnObj = dict.get('Function');
  52737. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52738. this.coords = [];
  52739. this.colors = [];
  52740. this.figures = [];
  52741. var decodeContext = {
  52742. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52743. bitsPerComponent: dict.get('BitsPerComponent'),
  52744. bitsPerFlag: dict.get('BitsPerFlag'),
  52745. decode: dict.getArray('Decode'),
  52746. colorFn: fn,
  52747. colorSpace: cs,
  52748. numComps: fn ? 1 : cs.numComps
  52749. };
  52750. var reader = new MeshStreamReader(stream, decodeContext);
  52751. var patchMesh = false;
  52752. switch (this.shadingType) {
  52753. case ShadingType.FREE_FORM_MESH:
  52754. decodeType4Shading(this, reader);
  52755. break;
  52756. case ShadingType.LATTICE_FORM_MESH:
  52757. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52758. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52759. decodeType5Shading(this, reader, verticesPerRow);
  52760. break;
  52761. case ShadingType.COONS_PATCH_MESH:
  52762. decodeType6Shading(this, reader);
  52763. patchMesh = true;
  52764. break;
  52765. case ShadingType.TENSOR_PATCH_MESH:
  52766. decodeType7Shading(this, reader);
  52767. patchMesh = true;
  52768. break;
  52769. default:
  52770. error('Unsupported mesh type.');
  52771. break;
  52772. }
  52773. if (patchMesh) {
  52774. updateBounds(this);
  52775. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52776. buildFigureFromPatch(this, i);
  52777. }
  52778. }
  52779. updateBounds(this);
  52780. packData(this);
  52781. }
  52782. Mesh.prototype = {
  52783. getIR: function Mesh_getIR() {
  52784. return [
  52785. 'Mesh',
  52786. this.shadingType,
  52787. this.coords,
  52788. this.colors,
  52789. this.figures,
  52790. this.bounds,
  52791. this.matrix,
  52792. this.bbox,
  52793. this.background
  52794. ];
  52795. }
  52796. };
  52797. return Mesh;
  52798. }();
  52799. Shadings.Dummy = function DummyClosure() {
  52800. function Dummy() {
  52801. this.type = 'Pattern';
  52802. }
  52803. Dummy.prototype = {
  52804. getIR: function Dummy_getIR() {
  52805. return ['Dummy'];
  52806. }
  52807. };
  52808. return Dummy;
  52809. }();
  52810. function getTilingPatternIR(operatorList, dict, args) {
  52811. var matrix = dict.getArray('Matrix');
  52812. var bbox = dict.getArray('BBox');
  52813. var xstep = dict.get('XStep');
  52814. var ystep = dict.get('YStep');
  52815. var paintType = dict.get('PaintType');
  52816. var tilingType = dict.get('TilingType');
  52817. return [
  52818. 'TilingPattern',
  52819. args,
  52820. operatorList,
  52821. matrix,
  52822. bbox,
  52823. xstep,
  52824. ystep,
  52825. paintType,
  52826. tilingType
  52827. ];
  52828. }
  52829. exports.Pattern = Pattern;
  52830. exports.getTilingPatternIR = getTilingPatternIR;
  52831. /***/ }),
  52832. /* 41 */
  52833. /***/ (function(module, exports, __w_pdfjs_require__) {
  52834. "use strict";
  52835. var sharedUtil = __w_pdfjs_require__(0);
  52836. var coreStream = __w_pdfjs_require__(2);
  52837. var coreChunkedStream = __w_pdfjs_require__(16);
  52838. var coreDocument = __w_pdfjs_require__(31);
  52839. var warn = sharedUtil.warn;
  52840. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52841. var shadow = sharedUtil.shadow;
  52842. var NotImplementedException = sharedUtil.NotImplementedException;
  52843. var MissingDataException = sharedUtil.MissingDataException;
  52844. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52845. var Util = sharedUtil.Util;
  52846. var Stream = coreStream.Stream;
  52847. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52848. var PDFDocument = coreDocument.PDFDocument;
  52849. var BasePdfManager = function BasePdfManagerClosure() {
  52850. function BasePdfManager() {
  52851. throw new Error('Cannot initialize BaseManagerManager');
  52852. }
  52853. BasePdfManager.prototype = {
  52854. get docId() {
  52855. return this._docId;
  52856. },
  52857. get password() {
  52858. return this._password;
  52859. },
  52860. get docBaseUrl() {
  52861. var docBaseUrl = null;
  52862. if (this._docBaseUrl) {
  52863. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52864. if (absoluteUrl) {
  52865. docBaseUrl = absoluteUrl.href;
  52866. } else {
  52867. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52868. }
  52869. }
  52870. return shadow(this, 'docBaseUrl', docBaseUrl);
  52871. },
  52872. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52873. throw new NotImplementedException();
  52874. },
  52875. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52876. return this.ensure(this.pdfDocument, prop, args);
  52877. },
  52878. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52879. return this.ensure(this.pdfDocument.xref, prop, args);
  52880. },
  52881. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52882. return this.ensure(this.pdfDocument.catalog, prop, args);
  52883. },
  52884. getPage: function BasePdfManager_getPage(pageIndex) {
  52885. return this.pdfDocument.getPage(pageIndex);
  52886. },
  52887. cleanup: function BasePdfManager_cleanup() {
  52888. return this.pdfDocument.cleanup();
  52889. },
  52890. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52891. return new NotImplementedException();
  52892. },
  52893. requestRange: function BasePdfManager_requestRange(begin, end) {
  52894. return new NotImplementedException();
  52895. },
  52896. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52897. return new NotImplementedException();
  52898. },
  52899. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52900. return new NotImplementedException();
  52901. },
  52902. updatePassword: function BasePdfManager_updatePassword(password) {
  52903. this._password = password;
  52904. },
  52905. terminate: function BasePdfManager_terminate() {
  52906. return new NotImplementedException();
  52907. }
  52908. };
  52909. return BasePdfManager;
  52910. }();
  52911. var LocalPdfManager = function LocalPdfManagerClosure() {
  52912. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52913. this._docId = docId;
  52914. this._password = password;
  52915. this._docBaseUrl = docBaseUrl;
  52916. this.evaluatorOptions = evaluatorOptions;
  52917. var stream = new Stream(data);
  52918. this.pdfDocument = new PDFDocument(this, stream);
  52919. this._loadedStreamCapability = createPromiseCapability();
  52920. this._loadedStreamCapability.resolve(stream);
  52921. }
  52922. Util.inherit(LocalPdfManager, BasePdfManager, {
  52923. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52924. return new Promise(function (resolve, reject) {
  52925. try {
  52926. var value = obj[prop];
  52927. var result;
  52928. if (typeof value === 'function') {
  52929. result = value.apply(obj, args);
  52930. } else {
  52931. result = value;
  52932. }
  52933. resolve(result);
  52934. } catch (e) {
  52935. reject(e);
  52936. }
  52937. });
  52938. },
  52939. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52940. return Promise.resolve();
  52941. },
  52942. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52943. },
  52944. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52945. return this._loadedStreamCapability.promise;
  52946. },
  52947. terminate: function LocalPdfManager_terminate() {
  52948. }
  52949. });
  52950. return LocalPdfManager;
  52951. }();
  52952. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52953. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52954. this._docId = docId;
  52955. this._password = args.password;
  52956. this._docBaseUrl = docBaseUrl;
  52957. this.msgHandler = args.msgHandler;
  52958. this.evaluatorOptions = evaluatorOptions;
  52959. var params = {
  52960. msgHandler: args.msgHandler,
  52961. url: args.url,
  52962. length: args.length,
  52963. disableAutoFetch: args.disableAutoFetch,
  52964. rangeChunkSize: args.rangeChunkSize
  52965. };
  52966. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  52967. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  52968. }
  52969. Util.inherit(NetworkPdfManager, BasePdfManager, {
  52970. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  52971. var pdfManager = this;
  52972. return new Promise(function (resolve, reject) {
  52973. function ensureHelper() {
  52974. try {
  52975. var result;
  52976. var value = obj[prop];
  52977. if (typeof value === 'function') {
  52978. result = value.apply(obj, args);
  52979. } else {
  52980. result = value;
  52981. }
  52982. resolve(result);
  52983. } catch (e) {
  52984. if (!(e instanceof MissingDataException)) {
  52985. reject(e);
  52986. return;
  52987. }
  52988. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  52989. }
  52990. }
  52991. ensureHelper();
  52992. });
  52993. },
  52994. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  52995. return this.streamManager.requestRange(begin, end);
  52996. },
  52997. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  52998. this.streamManager.requestAllChunks();
  52999. },
  53000. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53001. this.streamManager.onReceiveData({ chunk: chunk });
  53002. },
  53003. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53004. return this.streamManager.onLoadedStream();
  53005. },
  53006. terminate: function NetworkPdfManager_terminate() {
  53007. this.streamManager.abort();
  53008. }
  53009. });
  53010. return NetworkPdfManager;
  53011. }();
  53012. exports.LocalPdfManager = LocalPdfManager;
  53013. exports.NetworkPdfManager = NetworkPdfManager;
  53014. /***/ }),
  53015. /* 42 */
  53016. /***/ (function(module, exports, __w_pdfjs_require__) {
  53017. "use strict";
  53018. var sharedUtil = __w_pdfjs_require__(0);
  53019. var corePrimitives = __w_pdfjs_require__(1);
  53020. var error = sharedUtil.error;
  53021. var isSpace = sharedUtil.isSpace;
  53022. var EOF = corePrimitives.EOF;
  53023. var PostScriptParser = function PostScriptParserClosure() {
  53024. function PostScriptParser(lexer) {
  53025. this.lexer = lexer;
  53026. this.operators = [];
  53027. this.token = null;
  53028. this.prev = null;
  53029. }
  53030. PostScriptParser.prototype = {
  53031. nextToken: function PostScriptParser_nextToken() {
  53032. this.prev = this.token;
  53033. this.token = this.lexer.getToken();
  53034. },
  53035. accept: function PostScriptParser_accept(type) {
  53036. if (this.token.type === type) {
  53037. this.nextToken();
  53038. return true;
  53039. }
  53040. return false;
  53041. },
  53042. expect: function PostScriptParser_expect(type) {
  53043. if (this.accept(type)) {
  53044. return true;
  53045. }
  53046. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53047. },
  53048. parse: function PostScriptParser_parse() {
  53049. this.nextToken();
  53050. this.expect(PostScriptTokenTypes.LBRACE);
  53051. this.parseBlock();
  53052. this.expect(PostScriptTokenTypes.RBRACE);
  53053. return this.operators;
  53054. },
  53055. parseBlock: function PostScriptParser_parseBlock() {
  53056. while (true) {
  53057. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53058. this.operators.push(this.prev.value);
  53059. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53060. this.operators.push(this.prev.value);
  53061. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53062. this.parseCondition();
  53063. } else {
  53064. return;
  53065. }
  53066. }
  53067. },
  53068. parseCondition: function PostScriptParser_parseCondition() {
  53069. var conditionLocation = this.operators.length;
  53070. this.operators.push(null, null);
  53071. this.parseBlock();
  53072. this.expect(PostScriptTokenTypes.RBRACE);
  53073. if (this.accept(PostScriptTokenTypes.IF)) {
  53074. this.operators[conditionLocation] = this.operators.length;
  53075. this.operators[conditionLocation + 1] = 'jz';
  53076. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53077. var jumpLocation = this.operators.length;
  53078. this.operators.push(null, null);
  53079. var endOfTrue = this.operators.length;
  53080. this.parseBlock();
  53081. this.expect(PostScriptTokenTypes.RBRACE);
  53082. this.expect(PostScriptTokenTypes.IFELSE);
  53083. this.operators[jumpLocation] = this.operators.length;
  53084. this.operators[jumpLocation + 1] = 'j';
  53085. this.operators[conditionLocation] = endOfTrue;
  53086. this.operators[conditionLocation + 1] = 'jz';
  53087. } else {
  53088. error('PS Function: error parsing conditional.');
  53089. }
  53090. }
  53091. };
  53092. return PostScriptParser;
  53093. }();
  53094. var PostScriptTokenTypes = {
  53095. LBRACE: 0,
  53096. RBRACE: 1,
  53097. NUMBER: 2,
  53098. OPERATOR: 3,
  53099. IF: 4,
  53100. IFELSE: 5
  53101. };
  53102. var PostScriptToken = function PostScriptTokenClosure() {
  53103. function PostScriptToken(type, value) {
  53104. this.type = type;
  53105. this.value = value;
  53106. }
  53107. var opCache = Object.create(null);
  53108. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53109. var opValue = opCache[op];
  53110. if (opValue) {
  53111. return opValue;
  53112. }
  53113. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53114. };
  53115. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53116. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53117. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53118. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53119. return PostScriptToken;
  53120. }();
  53121. var PostScriptLexer = function PostScriptLexerClosure() {
  53122. function PostScriptLexer(stream) {
  53123. this.stream = stream;
  53124. this.nextChar();
  53125. this.strBuf = [];
  53126. }
  53127. PostScriptLexer.prototype = {
  53128. nextChar: function PostScriptLexer_nextChar() {
  53129. return this.currentChar = this.stream.getByte();
  53130. },
  53131. getToken: function PostScriptLexer_getToken() {
  53132. var comment = false;
  53133. var ch = this.currentChar;
  53134. while (true) {
  53135. if (ch < 0) {
  53136. return EOF;
  53137. }
  53138. if (comment) {
  53139. if (ch === 0x0A || ch === 0x0D) {
  53140. comment = false;
  53141. }
  53142. } else if (ch === 0x25) {
  53143. comment = true;
  53144. } else if (!isSpace(ch)) {
  53145. break;
  53146. }
  53147. ch = this.nextChar();
  53148. }
  53149. switch (ch | 0) {
  53150. case 0x30:
  53151. case 0x31:
  53152. case 0x32:
  53153. case 0x33:
  53154. case 0x34:
  53155. case 0x35:
  53156. case 0x36:
  53157. case 0x37:
  53158. case 0x38:
  53159. case 0x39:
  53160. case 0x2B:
  53161. case 0x2D:
  53162. case 0x2E:
  53163. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53164. case 0x7B:
  53165. this.nextChar();
  53166. return PostScriptToken.LBRACE;
  53167. case 0x7D:
  53168. this.nextChar();
  53169. return PostScriptToken.RBRACE;
  53170. }
  53171. var strBuf = this.strBuf;
  53172. strBuf.length = 0;
  53173. strBuf[0] = String.fromCharCode(ch);
  53174. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53175. strBuf.push(String.fromCharCode(ch));
  53176. }
  53177. var str = strBuf.join('');
  53178. switch (str.toLowerCase()) {
  53179. case 'if':
  53180. return PostScriptToken.IF;
  53181. case 'ifelse':
  53182. return PostScriptToken.IFELSE;
  53183. default:
  53184. return PostScriptToken.getOperator(str);
  53185. }
  53186. },
  53187. getNumber: function PostScriptLexer_getNumber() {
  53188. var ch = this.currentChar;
  53189. var strBuf = this.strBuf;
  53190. strBuf.length = 0;
  53191. strBuf[0] = String.fromCharCode(ch);
  53192. while ((ch = this.nextChar()) >= 0) {
  53193. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53194. strBuf.push(String.fromCharCode(ch));
  53195. } else {
  53196. break;
  53197. }
  53198. }
  53199. var value = parseFloat(strBuf.join(''));
  53200. if (isNaN(value)) {
  53201. error('Invalid floating point number: ' + value);
  53202. }
  53203. return value;
  53204. }
  53205. };
  53206. return PostScriptLexer;
  53207. }();
  53208. exports.PostScriptLexer = PostScriptLexer;
  53209. exports.PostScriptParser = PostScriptParser;
  53210. /***/ }),
  53211. /* 43 */
  53212. /***/ (function(module, exports, __w_pdfjs_require__) {
  53213. "use strict";
  53214. var sharedUtil = __w_pdfjs_require__(0);
  53215. var coreStream = __w_pdfjs_require__(2);
  53216. var coreEncodings = __w_pdfjs_require__(5);
  53217. var warn = sharedUtil.warn;
  53218. var isSpace = sharedUtil.isSpace;
  53219. var Stream = coreStream.Stream;
  53220. var getEncoding = coreEncodings.getEncoding;
  53221. var HINTING_ENABLED = false;
  53222. var Type1CharString = function Type1CharStringClosure() {
  53223. var COMMAND_MAP = {
  53224. 'hstem': [1],
  53225. 'vstem': [3],
  53226. 'vmoveto': [4],
  53227. 'rlineto': [5],
  53228. 'hlineto': [6],
  53229. 'vlineto': [7],
  53230. 'rrcurveto': [8],
  53231. 'callsubr': [10],
  53232. 'flex': [
  53233. 12,
  53234. 35
  53235. ],
  53236. 'drop': [
  53237. 12,
  53238. 18
  53239. ],
  53240. 'endchar': [14],
  53241. 'rmoveto': [21],
  53242. 'hmoveto': [22],
  53243. 'vhcurveto': [30],
  53244. 'hvcurveto': [31]
  53245. };
  53246. function Type1CharString() {
  53247. this.width = 0;
  53248. this.lsb = 0;
  53249. this.flexing = false;
  53250. this.output = [];
  53251. this.stack = [];
  53252. }
  53253. Type1CharString.prototype = {
  53254. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53255. var count = encoded.length;
  53256. var error = false;
  53257. var wx, sbx, subrNumber;
  53258. for (var i = 0; i < count; i++) {
  53259. var value = encoded[i];
  53260. if (value < 32) {
  53261. if (value === 12) {
  53262. value = (value << 8) + encoded[++i];
  53263. }
  53264. switch (value) {
  53265. case 1:
  53266. if (!HINTING_ENABLED) {
  53267. this.stack = [];
  53268. break;
  53269. }
  53270. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53271. break;
  53272. case 3:
  53273. if (!HINTING_ENABLED) {
  53274. this.stack = [];
  53275. break;
  53276. }
  53277. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53278. break;
  53279. case 4:
  53280. if (this.flexing) {
  53281. if (this.stack.length < 1) {
  53282. error = true;
  53283. break;
  53284. }
  53285. var dy = this.stack.pop();
  53286. this.stack.push(0, dy);
  53287. break;
  53288. }
  53289. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53290. break;
  53291. case 5:
  53292. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53293. break;
  53294. case 6:
  53295. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53296. break;
  53297. case 7:
  53298. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53299. break;
  53300. case 8:
  53301. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53302. break;
  53303. case 9:
  53304. this.stack = [];
  53305. break;
  53306. case 10:
  53307. if (this.stack.length < 1) {
  53308. error = true;
  53309. break;
  53310. }
  53311. subrNumber = this.stack.pop();
  53312. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53313. break;
  53314. case 11:
  53315. return error;
  53316. case 13:
  53317. if (this.stack.length < 2) {
  53318. error = true;
  53319. break;
  53320. }
  53321. wx = this.stack.pop();
  53322. sbx = this.stack.pop();
  53323. this.lsb = sbx;
  53324. this.width = wx;
  53325. this.stack.push(wx, sbx);
  53326. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53327. break;
  53328. case 14:
  53329. this.output.push(COMMAND_MAP.endchar[0]);
  53330. break;
  53331. case 21:
  53332. if (this.flexing) {
  53333. break;
  53334. }
  53335. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53336. break;
  53337. case 22:
  53338. if (this.flexing) {
  53339. this.stack.push(0);
  53340. break;
  53341. }
  53342. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53343. break;
  53344. case 30:
  53345. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53346. break;
  53347. case 31:
  53348. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53349. break;
  53350. case (12 << 8) + 0:
  53351. this.stack = [];
  53352. break;
  53353. case (12 << 8) + 1:
  53354. if (!HINTING_ENABLED) {
  53355. this.stack = [];
  53356. break;
  53357. }
  53358. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53359. break;
  53360. case (12 << 8) + 2:
  53361. if (!HINTING_ENABLED) {
  53362. this.stack = [];
  53363. break;
  53364. }
  53365. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53366. break;
  53367. case (12 << 8) + 6:
  53368. if (seacAnalysisEnabled) {
  53369. this.seac = this.stack.splice(-4, 4);
  53370. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53371. } else {
  53372. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53373. }
  53374. break;
  53375. case (12 << 8) + 7:
  53376. if (this.stack.length < 4) {
  53377. error = true;
  53378. break;
  53379. }
  53380. this.stack.pop();
  53381. wx = this.stack.pop();
  53382. var sby = this.stack.pop();
  53383. sbx = this.stack.pop();
  53384. this.lsb = sbx;
  53385. this.width = wx;
  53386. this.stack.push(wx, sbx, sby);
  53387. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53388. break;
  53389. case (12 << 8) + 12:
  53390. if (this.stack.length < 2) {
  53391. error = true;
  53392. break;
  53393. }
  53394. var num2 = this.stack.pop();
  53395. var num1 = this.stack.pop();
  53396. this.stack.push(num1 / num2);
  53397. break;
  53398. case (12 << 8) + 16:
  53399. if (this.stack.length < 2) {
  53400. error = true;
  53401. break;
  53402. }
  53403. subrNumber = this.stack.pop();
  53404. var numArgs = this.stack.pop();
  53405. if (subrNumber === 0 && numArgs === 3) {
  53406. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53407. 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]);
  53408. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53409. this.flexing = false;
  53410. this.stack.push(flexArgs[15], flexArgs[16]);
  53411. } else if (subrNumber === 1 && numArgs === 0) {
  53412. this.flexing = true;
  53413. }
  53414. break;
  53415. case (12 << 8) + 17:
  53416. break;
  53417. case (12 << 8) + 33:
  53418. this.stack = [];
  53419. break;
  53420. default:
  53421. warn('Unknown type 1 charstring command of "' + value + '"');
  53422. break;
  53423. }
  53424. if (error) {
  53425. break;
  53426. }
  53427. continue;
  53428. } else if (value <= 246) {
  53429. value = value - 139;
  53430. } else if (value <= 250) {
  53431. value = (value - 247) * 256 + encoded[++i] + 108;
  53432. } else if (value <= 254) {
  53433. value = -((value - 251) * 256) - encoded[++i] - 108;
  53434. } else {
  53435. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53436. }
  53437. this.stack.push(value);
  53438. }
  53439. return error;
  53440. },
  53441. executeCommand: function (howManyArgs, command, keepStack) {
  53442. var stackLength = this.stack.length;
  53443. if (howManyArgs > stackLength) {
  53444. return true;
  53445. }
  53446. var start = stackLength - howManyArgs;
  53447. for (var i = start; i < stackLength; i++) {
  53448. var value = this.stack[i];
  53449. if (value === (value | 0)) {
  53450. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53451. } else {
  53452. value = 65536 * value | 0;
  53453. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53454. }
  53455. }
  53456. this.output.push.apply(this.output, command);
  53457. if (keepStack) {
  53458. this.stack.splice(start, howManyArgs);
  53459. } else {
  53460. this.stack.length = 0;
  53461. }
  53462. return false;
  53463. }
  53464. };
  53465. return Type1CharString;
  53466. }();
  53467. var Type1Parser = function Type1ParserClosure() {
  53468. var EEXEC_ENCRYPT_KEY = 55665;
  53469. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53470. function isHexDigit(code) {
  53471. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53472. }
  53473. function decrypt(data, key, discardNumber) {
  53474. if (discardNumber >= data.length) {
  53475. return new Uint8Array(0);
  53476. }
  53477. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53478. for (i = 0; i < discardNumber; i++) {
  53479. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53480. }
  53481. var count = data.length - discardNumber;
  53482. var decrypted = new Uint8Array(count);
  53483. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53484. var value = data[i];
  53485. decrypted[j] = value ^ r >> 8;
  53486. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53487. }
  53488. return decrypted;
  53489. }
  53490. function decryptAscii(data, key, discardNumber) {
  53491. var r = key | 0, c1 = 52845, c2 = 22719;
  53492. var count = data.length, maybeLength = count >>> 1;
  53493. var decrypted = new Uint8Array(maybeLength);
  53494. var i, j;
  53495. for (i = 0, j = 0; i < count; i++) {
  53496. var digit1 = data[i];
  53497. if (!isHexDigit(digit1)) {
  53498. continue;
  53499. }
  53500. i++;
  53501. var digit2;
  53502. while (i < count && !isHexDigit(digit2 = data[i])) {
  53503. i++;
  53504. }
  53505. if (i < count) {
  53506. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53507. decrypted[j++] = value ^ r >> 8;
  53508. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53509. }
  53510. }
  53511. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53512. }
  53513. function isSpecial(c) {
  53514. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53515. }
  53516. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53517. if (encrypted) {
  53518. var data = stream.getBytes();
  53519. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53520. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53521. }
  53522. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53523. this.stream = stream;
  53524. this.nextChar();
  53525. }
  53526. Type1Parser.prototype = {
  53527. readNumberArray: function Type1Parser_readNumberArray() {
  53528. this.getToken();
  53529. var array = [];
  53530. while (true) {
  53531. var token = this.getToken();
  53532. if (token === null || token === ']' || token === '}') {
  53533. break;
  53534. }
  53535. array.push(parseFloat(token || 0));
  53536. }
  53537. return array;
  53538. },
  53539. readNumber: function Type1Parser_readNumber() {
  53540. var token = this.getToken();
  53541. return parseFloat(token || 0);
  53542. },
  53543. readInt: function Type1Parser_readInt() {
  53544. var token = this.getToken();
  53545. return parseInt(token || 0, 10) | 0;
  53546. },
  53547. readBoolean: function Type1Parser_readBoolean() {
  53548. var token = this.getToken();
  53549. return token === 'true' ? 1 : 0;
  53550. },
  53551. nextChar: function Type1_nextChar() {
  53552. return this.currentChar = this.stream.getByte();
  53553. },
  53554. getToken: function Type1Parser_getToken() {
  53555. var comment = false;
  53556. var ch = this.currentChar;
  53557. while (true) {
  53558. if (ch === -1) {
  53559. return null;
  53560. }
  53561. if (comment) {
  53562. if (ch === 0x0A || ch === 0x0D) {
  53563. comment = false;
  53564. }
  53565. } else if (ch === 0x25) {
  53566. comment = true;
  53567. } else if (!isSpace(ch)) {
  53568. break;
  53569. }
  53570. ch = this.nextChar();
  53571. }
  53572. if (isSpecial(ch)) {
  53573. this.nextChar();
  53574. return String.fromCharCode(ch);
  53575. }
  53576. var token = '';
  53577. do {
  53578. token += String.fromCharCode(ch);
  53579. ch = this.nextChar();
  53580. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53581. return token;
  53582. },
  53583. extractFontProgram: function Type1Parser_extractFontProgram() {
  53584. var stream = this.stream;
  53585. var subrs = [], charstrings = [];
  53586. var privateData = Object.create(null);
  53587. privateData['lenIV'] = 4;
  53588. var program = {
  53589. subrs: [],
  53590. charstrings: [],
  53591. properties: { 'privateData': privateData }
  53592. };
  53593. var token, length, data, lenIV, encoded;
  53594. while ((token = this.getToken()) !== null) {
  53595. if (token !== '/') {
  53596. continue;
  53597. }
  53598. token = this.getToken();
  53599. switch (token) {
  53600. case 'CharStrings':
  53601. this.getToken();
  53602. this.getToken();
  53603. this.getToken();
  53604. this.getToken();
  53605. while (true) {
  53606. token = this.getToken();
  53607. if (token === null || token === 'end') {
  53608. break;
  53609. }
  53610. if (token !== '/') {
  53611. continue;
  53612. }
  53613. var glyph = this.getToken();
  53614. length = this.readInt();
  53615. this.getToken();
  53616. data = stream.makeSubStream(stream.pos, length);
  53617. lenIV = program.properties.privateData['lenIV'];
  53618. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53619. stream.skip(length);
  53620. this.nextChar();
  53621. token = this.getToken();
  53622. if (token === 'noaccess') {
  53623. this.getToken();
  53624. }
  53625. charstrings.push({
  53626. glyph: glyph,
  53627. encoded: encoded
  53628. });
  53629. }
  53630. break;
  53631. case 'Subrs':
  53632. this.readInt();
  53633. this.getToken();
  53634. while ((token = this.getToken()) === 'dup') {
  53635. var index = this.readInt();
  53636. length = this.readInt();
  53637. this.getToken();
  53638. data = stream.makeSubStream(stream.pos, length);
  53639. lenIV = program.properties.privateData['lenIV'];
  53640. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53641. stream.skip(length);
  53642. this.nextChar();
  53643. token = this.getToken();
  53644. if (token === 'noaccess') {
  53645. this.getToken();
  53646. }
  53647. subrs[index] = encoded;
  53648. }
  53649. break;
  53650. case 'BlueValues':
  53651. case 'OtherBlues':
  53652. case 'FamilyBlues':
  53653. case 'FamilyOtherBlues':
  53654. var blueArray = this.readNumberArray();
  53655. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53656. program.properties.privateData[token] = blueArray;
  53657. }
  53658. break;
  53659. case 'StemSnapH':
  53660. case 'StemSnapV':
  53661. program.properties.privateData[token] = this.readNumberArray();
  53662. break;
  53663. case 'StdHW':
  53664. case 'StdVW':
  53665. program.properties.privateData[token] = this.readNumberArray()[0];
  53666. break;
  53667. case 'BlueShift':
  53668. case 'lenIV':
  53669. case 'BlueFuzz':
  53670. case 'BlueScale':
  53671. case 'LanguageGroup':
  53672. case 'ExpansionFactor':
  53673. program.properties.privateData[token] = this.readNumber();
  53674. break;
  53675. case 'ForceBold':
  53676. program.properties.privateData[token] = this.readBoolean();
  53677. break;
  53678. }
  53679. }
  53680. for (var i = 0; i < charstrings.length; i++) {
  53681. glyph = charstrings[i].glyph;
  53682. encoded = charstrings[i].encoded;
  53683. var charString = new Type1CharString();
  53684. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53685. var output = charString.output;
  53686. if (error) {
  53687. output = [14];
  53688. }
  53689. program.charstrings.push({
  53690. glyphName: glyph,
  53691. charstring: output,
  53692. width: charString.width,
  53693. lsb: charString.lsb,
  53694. seac: charString.seac
  53695. });
  53696. }
  53697. return program;
  53698. },
  53699. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53700. var token;
  53701. while ((token = this.getToken()) !== null) {
  53702. if (token !== '/') {
  53703. continue;
  53704. }
  53705. token = this.getToken();
  53706. switch (token) {
  53707. case 'FontMatrix':
  53708. var matrix = this.readNumberArray();
  53709. properties.fontMatrix = matrix;
  53710. break;
  53711. case 'Encoding':
  53712. var encodingArg = this.getToken();
  53713. var encoding;
  53714. if (!/^\d+$/.test(encodingArg)) {
  53715. encoding = getEncoding(encodingArg);
  53716. } else {
  53717. encoding = [];
  53718. var size = parseInt(encodingArg, 10) | 0;
  53719. this.getToken();
  53720. for (var j = 0; j < size; j++) {
  53721. token = this.getToken();
  53722. while (token !== 'dup' && token !== 'def') {
  53723. token = this.getToken();
  53724. if (token === null) {
  53725. return;
  53726. }
  53727. }
  53728. if (token === 'def') {
  53729. break;
  53730. }
  53731. var index = this.readInt();
  53732. this.getToken();
  53733. var glyph = this.getToken();
  53734. encoding[index] = glyph;
  53735. this.getToken();
  53736. }
  53737. }
  53738. properties.builtInEncoding = encoding;
  53739. break;
  53740. case 'FontBBox':
  53741. var fontBBox = this.readNumberArray();
  53742. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53743. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53744. properties.ascentScaled = true;
  53745. break;
  53746. }
  53747. }
  53748. }
  53749. };
  53750. return Type1Parser;
  53751. }();
  53752. exports.Type1Parser = Type1Parser;
  53753. /***/ }),
  53754. /* 44 */
  53755. /***/ (function(module, exports, __w_pdfjs_require__) {
  53756. "use strict";
  53757. var sharedUtil = __w_pdfjs_require__(0);
  53758. var displayDOMUtils = __w_pdfjs_require__(3);
  53759. var displayPatternHelper = __w_pdfjs_require__(46);
  53760. var displayWebGL = __w_pdfjs_require__(25);
  53761. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53762. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53763. var ImageKind = sharedUtil.ImageKind;
  53764. var OPS = sharedUtil.OPS;
  53765. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53766. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53767. var Util = sharedUtil.Util;
  53768. var assert = sharedUtil.assert;
  53769. var info = sharedUtil.info;
  53770. var isNum = sharedUtil.isNum;
  53771. var isArray = sharedUtil.isArray;
  53772. var isLittleEndian = sharedUtil.isLittleEndian;
  53773. var error = sharedUtil.error;
  53774. var shadow = sharedUtil.shadow;
  53775. var warn = sharedUtil.warn;
  53776. var TilingPattern = displayPatternHelper.TilingPattern;
  53777. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53778. var WebGLUtils = displayWebGL.WebGLUtils;
  53779. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53780. var MIN_FONT_SIZE = 16;
  53781. var MAX_FONT_SIZE = 100;
  53782. var MAX_GROUP_SIZE = 4096;
  53783. var MIN_WIDTH_FACTOR = 0.65;
  53784. var COMPILE_TYPE3_GLYPHS = true;
  53785. var MAX_SIZE_TO_COMPILE = 1000;
  53786. var FULL_CHUNK_HEIGHT = 16;
  53787. var HasCanvasTypedArraysCached = {
  53788. get value() {
  53789. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53790. }
  53791. };
  53792. var IsLittleEndianCached = {
  53793. get value() {
  53794. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53795. }
  53796. };
  53797. function addContextCurrentTransform(ctx) {
  53798. if (!ctx.mozCurrentTransform) {
  53799. ctx._originalSave = ctx.save;
  53800. ctx._originalRestore = ctx.restore;
  53801. ctx._originalRotate = ctx.rotate;
  53802. ctx._originalScale = ctx.scale;
  53803. ctx._originalTranslate = ctx.translate;
  53804. ctx._originalTransform = ctx.transform;
  53805. ctx._originalSetTransform = ctx.setTransform;
  53806. ctx._transformMatrix = ctx._transformMatrix || [
  53807. 1,
  53808. 0,
  53809. 0,
  53810. 1,
  53811. 0,
  53812. 0
  53813. ];
  53814. ctx._transformStack = [];
  53815. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53816. get: function getCurrentTransform() {
  53817. return this._transformMatrix;
  53818. }
  53819. });
  53820. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53821. get: function getCurrentTransformInverse() {
  53822. var m = this._transformMatrix;
  53823. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53824. var ad_bc = a * d - b * c;
  53825. var bc_ad = b * c - a * d;
  53826. return [
  53827. d / ad_bc,
  53828. b / bc_ad,
  53829. c / bc_ad,
  53830. a / ad_bc,
  53831. (d * e - c * f) / bc_ad,
  53832. (b * e - a * f) / ad_bc
  53833. ];
  53834. }
  53835. });
  53836. ctx.save = function ctxSave() {
  53837. var old = this._transformMatrix;
  53838. this._transformStack.push(old);
  53839. this._transformMatrix = old.slice(0, 6);
  53840. this._originalSave();
  53841. };
  53842. ctx.restore = function ctxRestore() {
  53843. var prev = this._transformStack.pop();
  53844. if (prev) {
  53845. this._transformMatrix = prev;
  53846. this._originalRestore();
  53847. }
  53848. };
  53849. ctx.translate = function ctxTranslate(x, y) {
  53850. var m = this._transformMatrix;
  53851. m[4] = m[0] * x + m[2] * y + m[4];
  53852. m[5] = m[1] * x + m[3] * y + m[5];
  53853. this._originalTranslate(x, y);
  53854. };
  53855. ctx.scale = function ctxScale(x, y) {
  53856. var m = this._transformMatrix;
  53857. m[0] = m[0] * x;
  53858. m[1] = m[1] * x;
  53859. m[2] = m[2] * y;
  53860. m[3] = m[3] * y;
  53861. this._originalScale(x, y);
  53862. };
  53863. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53864. var m = this._transformMatrix;
  53865. this._transformMatrix = [
  53866. m[0] * a + m[2] * b,
  53867. m[1] * a + m[3] * b,
  53868. m[0] * c + m[2] * d,
  53869. m[1] * c + m[3] * d,
  53870. m[0] * e + m[2] * f + m[4],
  53871. m[1] * e + m[3] * f + m[5]
  53872. ];
  53873. ctx._originalTransform(a, b, c, d, e, f);
  53874. };
  53875. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53876. this._transformMatrix = [
  53877. a,
  53878. b,
  53879. c,
  53880. d,
  53881. e,
  53882. f
  53883. ];
  53884. ctx._originalSetTransform(a, b, c, d, e, f);
  53885. };
  53886. ctx.rotate = function ctxRotate(angle) {
  53887. var cosValue = Math.cos(angle);
  53888. var sinValue = Math.sin(angle);
  53889. var m = this._transformMatrix;
  53890. this._transformMatrix = [
  53891. m[0] * cosValue + m[2] * sinValue,
  53892. m[1] * cosValue + m[3] * sinValue,
  53893. m[0] * -sinValue + m[2] * cosValue,
  53894. m[1] * -sinValue + m[3] * cosValue,
  53895. m[4],
  53896. m[5]
  53897. ];
  53898. this._originalRotate(angle);
  53899. };
  53900. }
  53901. }
  53902. var CachedCanvases = function CachedCanvasesClosure() {
  53903. function CachedCanvases(canvasFactory) {
  53904. this.canvasFactory = canvasFactory;
  53905. this.cache = Object.create(null);
  53906. }
  53907. CachedCanvases.prototype = {
  53908. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53909. var canvasEntry;
  53910. if (this.cache[id] !== undefined) {
  53911. canvasEntry = this.cache[id];
  53912. this.canvasFactory.reset(canvasEntry, width, height);
  53913. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53914. } else {
  53915. canvasEntry = this.canvasFactory.create(width, height);
  53916. this.cache[id] = canvasEntry;
  53917. }
  53918. if (trackTransform) {
  53919. addContextCurrentTransform(canvasEntry.context);
  53920. }
  53921. return canvasEntry;
  53922. },
  53923. clear: function () {
  53924. for (var id in this.cache) {
  53925. var canvasEntry = this.cache[id];
  53926. this.canvasFactory.destroy(canvasEntry);
  53927. delete this.cache[id];
  53928. }
  53929. }
  53930. };
  53931. return CachedCanvases;
  53932. }();
  53933. function compileType3Glyph(imgData) {
  53934. var POINT_TO_PROCESS_LIMIT = 1000;
  53935. var width = imgData.width, height = imgData.height;
  53936. var i, j, j0, width1 = width + 1;
  53937. var points = new Uint8Array(width1 * (height + 1));
  53938. var POINT_TYPES = new Uint8Array([
  53939. 0,
  53940. 2,
  53941. 4,
  53942. 0,
  53943. 1,
  53944. 0,
  53945. 5,
  53946. 4,
  53947. 8,
  53948. 10,
  53949. 0,
  53950. 8,
  53951. 0,
  53952. 2,
  53953. 1,
  53954. 0
  53955. ]);
  53956. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53957. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  53958. for (i = 0, ii = data0.length; i < ii; i++) {
  53959. var mask = 128, elem = data0[i];
  53960. while (mask > 0) {
  53961. data[pos++] = elem & mask ? 0 : 255;
  53962. mask >>= 1;
  53963. }
  53964. }
  53965. var count = 0;
  53966. pos = 0;
  53967. if (data[pos] !== 0) {
  53968. points[0] = 1;
  53969. ++count;
  53970. }
  53971. for (j = 1; j < width; j++) {
  53972. if (data[pos] !== data[pos + 1]) {
  53973. points[j] = data[pos] ? 2 : 1;
  53974. ++count;
  53975. }
  53976. pos++;
  53977. }
  53978. if (data[pos] !== 0) {
  53979. points[j] = 2;
  53980. ++count;
  53981. }
  53982. for (i = 1; i < height; i++) {
  53983. pos = i * lineSize;
  53984. j0 = i * width1;
  53985. if (data[pos - lineSize] !== data[pos]) {
  53986. points[j0] = data[pos] ? 1 : 8;
  53987. ++count;
  53988. }
  53989. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  53990. for (j = 1; j < width; j++) {
  53991. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  53992. if (POINT_TYPES[sum]) {
  53993. points[j0 + j] = POINT_TYPES[sum];
  53994. ++count;
  53995. }
  53996. pos++;
  53997. }
  53998. if (data[pos - lineSize] !== data[pos]) {
  53999. points[j0 + j] = data[pos] ? 2 : 4;
  54000. ++count;
  54001. }
  54002. if (count > POINT_TO_PROCESS_LIMIT) {
  54003. return null;
  54004. }
  54005. }
  54006. pos = lineSize * (height - 1);
  54007. j0 = i * width1;
  54008. if (data[pos] !== 0) {
  54009. points[j0] = 8;
  54010. ++count;
  54011. }
  54012. for (j = 1; j < width; j++) {
  54013. if (data[pos] !== data[pos + 1]) {
  54014. points[j0 + j] = data[pos] ? 4 : 8;
  54015. ++count;
  54016. }
  54017. pos++;
  54018. }
  54019. if (data[pos] !== 0) {
  54020. points[j0 + j] = 4;
  54021. ++count;
  54022. }
  54023. if (count > POINT_TO_PROCESS_LIMIT) {
  54024. return null;
  54025. }
  54026. var steps = new Int32Array([
  54027. 0,
  54028. width1,
  54029. -1,
  54030. 0,
  54031. -width1,
  54032. 0,
  54033. 0,
  54034. 0,
  54035. 1
  54036. ]);
  54037. var outlines = [];
  54038. for (i = 0; count && i <= height; i++) {
  54039. var p = i * width1;
  54040. var end = p + width;
  54041. while (p < end && !points[p]) {
  54042. p++;
  54043. }
  54044. if (p === end) {
  54045. continue;
  54046. }
  54047. var coords = [
  54048. p % width1,
  54049. i
  54050. ];
  54051. var type = points[p], p0 = p, pp;
  54052. do {
  54053. var step = steps[type];
  54054. do {
  54055. p += step;
  54056. } while (!points[p]);
  54057. pp = points[p];
  54058. if (pp !== 5 && pp !== 10) {
  54059. type = pp;
  54060. points[p] = 0;
  54061. } else {
  54062. type = pp & 0x33 * type >> 4;
  54063. points[p] &= type >> 2 | type << 2;
  54064. }
  54065. coords.push(p % width1);
  54066. coords.push(p / width1 | 0);
  54067. --count;
  54068. } while (p0 !== p);
  54069. outlines.push(coords);
  54070. --i;
  54071. }
  54072. var drawOutline = function (c) {
  54073. c.save();
  54074. c.scale(1 / width, -1 / height);
  54075. c.translate(0, -height);
  54076. c.beginPath();
  54077. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54078. var o = outlines[i];
  54079. c.moveTo(o[0], o[1]);
  54080. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54081. c.lineTo(o[j], o[j + 1]);
  54082. }
  54083. }
  54084. c.fill();
  54085. c.beginPath();
  54086. c.restore();
  54087. };
  54088. return drawOutline;
  54089. }
  54090. var CanvasExtraState = function CanvasExtraStateClosure() {
  54091. function CanvasExtraState(old) {
  54092. this.alphaIsShape = false;
  54093. this.fontSize = 0;
  54094. this.fontSizeScale = 1;
  54095. this.textMatrix = IDENTITY_MATRIX;
  54096. this.textMatrixScale = 1;
  54097. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54098. this.leading = 0;
  54099. this.x = 0;
  54100. this.y = 0;
  54101. this.lineX = 0;
  54102. this.lineY = 0;
  54103. this.charSpacing = 0;
  54104. this.wordSpacing = 0;
  54105. this.textHScale = 1;
  54106. this.textRenderingMode = TextRenderingMode.FILL;
  54107. this.textRise = 0;
  54108. this.fillColor = '#000000';
  54109. this.strokeColor = '#000000';
  54110. this.patternFill = false;
  54111. this.fillAlpha = 1;
  54112. this.strokeAlpha = 1;
  54113. this.lineWidth = 1;
  54114. this.activeSMask = null;
  54115. this.resumeSMaskCtx = null;
  54116. this.old = old;
  54117. }
  54118. CanvasExtraState.prototype = {
  54119. clone: function CanvasExtraState_clone() {
  54120. return Object.create(this);
  54121. },
  54122. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54123. this.x = x;
  54124. this.y = y;
  54125. }
  54126. };
  54127. return CanvasExtraState;
  54128. }();
  54129. var CanvasGraphics = function CanvasGraphicsClosure() {
  54130. var EXECUTION_TIME = 15;
  54131. var EXECUTION_STEPS = 10;
  54132. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54133. this.ctx = canvasCtx;
  54134. this.current = new CanvasExtraState();
  54135. this.stateStack = [];
  54136. this.pendingClip = null;
  54137. this.pendingEOFill = false;
  54138. this.res = null;
  54139. this.xobjs = null;
  54140. this.commonObjs = commonObjs;
  54141. this.objs = objs;
  54142. this.canvasFactory = canvasFactory;
  54143. this.imageLayer = imageLayer;
  54144. this.groupStack = [];
  54145. this.processingType3 = null;
  54146. this.baseTransform = null;
  54147. this.baseTransformStack = [];
  54148. this.groupLevel = 0;
  54149. this.smaskStack = [];
  54150. this.smaskCounter = 0;
  54151. this.tempSMask = null;
  54152. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54153. if (canvasCtx) {
  54154. addContextCurrentTransform(canvasCtx);
  54155. }
  54156. this.cachedGetSinglePixelWidth = null;
  54157. }
  54158. function putBinaryImageData(ctx, imgData) {
  54159. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54160. ctx.putImageData(imgData, 0, 0);
  54161. return;
  54162. }
  54163. var height = imgData.height, width = imgData.width;
  54164. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54165. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54166. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54167. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54168. var srcPos = 0, destPos;
  54169. var src = imgData.data;
  54170. var dest = chunkImgData.data;
  54171. var i, j, thisChunkHeight, elemsInThisChunk;
  54172. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54173. var srcLength = src.byteLength;
  54174. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54175. var dest32DataLength = dest32.length;
  54176. var fullSrcDiff = width + 7 >> 3;
  54177. var white = 0xFFFFFFFF;
  54178. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54179. for (i = 0; i < totalChunks; i++) {
  54180. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54181. destPos = 0;
  54182. for (j = 0; j < thisChunkHeight; j++) {
  54183. var srcDiff = srcLength - srcPos;
  54184. var k = 0;
  54185. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54186. var kEndUnrolled = kEnd & ~7;
  54187. var mask = 0;
  54188. var srcByte = 0;
  54189. for (; k < kEndUnrolled; k += 8) {
  54190. srcByte = src[srcPos++];
  54191. dest32[destPos++] = srcByte & 128 ? white : black;
  54192. dest32[destPos++] = srcByte & 64 ? white : black;
  54193. dest32[destPos++] = srcByte & 32 ? white : black;
  54194. dest32[destPos++] = srcByte & 16 ? white : black;
  54195. dest32[destPos++] = srcByte & 8 ? white : black;
  54196. dest32[destPos++] = srcByte & 4 ? white : black;
  54197. dest32[destPos++] = srcByte & 2 ? white : black;
  54198. dest32[destPos++] = srcByte & 1 ? white : black;
  54199. }
  54200. for (; k < kEnd; k++) {
  54201. if (mask === 0) {
  54202. srcByte = src[srcPos++];
  54203. mask = 128;
  54204. }
  54205. dest32[destPos++] = srcByte & mask ? white : black;
  54206. mask >>= 1;
  54207. }
  54208. }
  54209. while (destPos < dest32DataLength) {
  54210. dest32[destPos++] = 0;
  54211. }
  54212. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54213. }
  54214. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54215. j = 0;
  54216. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54217. for (i = 0; i < fullChunks; i++) {
  54218. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54219. srcPos += elemsInThisChunk;
  54220. ctx.putImageData(chunkImgData, 0, j);
  54221. j += FULL_CHUNK_HEIGHT;
  54222. }
  54223. if (i < totalChunks) {
  54224. elemsInThisChunk = width * partialChunkHeight * 4;
  54225. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54226. ctx.putImageData(chunkImgData, 0, j);
  54227. }
  54228. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54229. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54230. elemsInThisChunk = width * thisChunkHeight;
  54231. for (i = 0; i < totalChunks; i++) {
  54232. if (i >= fullChunks) {
  54233. thisChunkHeight = partialChunkHeight;
  54234. elemsInThisChunk = width * thisChunkHeight;
  54235. }
  54236. destPos = 0;
  54237. for (j = elemsInThisChunk; j--;) {
  54238. dest[destPos++] = src[srcPos++];
  54239. dest[destPos++] = src[srcPos++];
  54240. dest[destPos++] = src[srcPos++];
  54241. dest[destPos++] = 255;
  54242. }
  54243. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54244. }
  54245. } else {
  54246. error('bad image kind: ' + imgData.kind);
  54247. }
  54248. }
  54249. function putBinaryImageMask(ctx, imgData) {
  54250. var height = imgData.height, width = imgData.width;
  54251. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54252. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54253. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54254. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54255. var srcPos = 0;
  54256. var src = imgData.data;
  54257. var dest = chunkImgData.data;
  54258. for (var i = 0; i < totalChunks; i++) {
  54259. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54260. var destPos = 3;
  54261. for (var j = 0; j < thisChunkHeight; j++) {
  54262. var mask = 0;
  54263. for (var k = 0; k < width; k++) {
  54264. if (!mask) {
  54265. var elem = src[srcPos++];
  54266. mask = 128;
  54267. }
  54268. dest[destPos] = elem & mask ? 0 : 255;
  54269. destPos += 4;
  54270. mask >>= 1;
  54271. }
  54272. }
  54273. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54274. }
  54275. }
  54276. function copyCtxState(sourceCtx, destCtx) {
  54277. var properties = [
  54278. 'strokeStyle',
  54279. 'fillStyle',
  54280. 'fillRule',
  54281. 'globalAlpha',
  54282. 'lineWidth',
  54283. 'lineCap',
  54284. 'lineJoin',
  54285. 'miterLimit',
  54286. 'globalCompositeOperation',
  54287. 'font'
  54288. ];
  54289. for (var i = 0, ii = properties.length; i < ii; i++) {
  54290. var property = properties[i];
  54291. if (sourceCtx[property] !== undefined) {
  54292. destCtx[property] = sourceCtx[property];
  54293. }
  54294. }
  54295. if (sourceCtx.setLineDash !== undefined) {
  54296. destCtx.setLineDash(sourceCtx.getLineDash());
  54297. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54298. }
  54299. }
  54300. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54301. var length = bytes.length;
  54302. for (var i = 3; i < length; i += 4) {
  54303. var alpha = bytes[i];
  54304. if (alpha === 0) {
  54305. bytes[i - 3] = r0;
  54306. bytes[i - 2] = g0;
  54307. bytes[i - 1] = b0;
  54308. } else if (alpha < 255) {
  54309. var alpha_ = 255 - alpha;
  54310. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54311. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54312. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54313. }
  54314. }
  54315. }
  54316. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54317. var length = maskData.length;
  54318. var scale = 1 / 255;
  54319. for (var i = 3; i < length; i += 4) {
  54320. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54321. layerData[i] = layerData[i] * alpha * scale | 0;
  54322. }
  54323. }
  54324. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54325. var length = maskData.length;
  54326. for (var i = 3; i < length; i += 4) {
  54327. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54328. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54329. }
  54330. }
  54331. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54332. var hasBackdrop = !!backdrop;
  54333. var r0 = hasBackdrop ? backdrop[0] : 0;
  54334. var g0 = hasBackdrop ? backdrop[1] : 0;
  54335. var b0 = hasBackdrop ? backdrop[2] : 0;
  54336. var composeFn;
  54337. if (subtype === 'Luminosity') {
  54338. composeFn = composeSMaskLuminosity;
  54339. } else {
  54340. composeFn = composeSMaskAlpha;
  54341. }
  54342. var PIXELS_TO_PROCESS = 1048576;
  54343. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54344. for (var row = 0; row < height; row += chunkSize) {
  54345. var chunkHeight = Math.min(chunkSize, height - row);
  54346. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54347. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54348. if (hasBackdrop) {
  54349. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54350. }
  54351. composeFn(maskData.data, layerData.data, transferMap);
  54352. maskCtx.putImageData(layerData, 0, row);
  54353. }
  54354. }
  54355. function composeSMask(ctx, smask, layerCtx) {
  54356. var mask = smask.canvas;
  54357. var maskCtx = smask.context;
  54358. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54359. var backdrop = smask.backdrop || null;
  54360. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54361. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54362. subtype: smask.subtype,
  54363. backdrop: backdrop
  54364. });
  54365. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54366. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54367. return;
  54368. }
  54369. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54370. ctx.drawImage(mask, 0, 0);
  54371. }
  54372. var LINE_CAP_STYLES = [
  54373. 'butt',
  54374. 'round',
  54375. 'square'
  54376. ];
  54377. var LINE_JOIN_STYLES = [
  54378. 'miter',
  54379. 'round',
  54380. 'bevel'
  54381. ];
  54382. var NORMAL_CLIP = {};
  54383. var EO_CLIP = {};
  54384. CanvasGraphics.prototype = {
  54385. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54386. var width = this.ctx.canvas.width;
  54387. var height = this.ctx.canvas.height;
  54388. this.ctx.save();
  54389. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54390. this.ctx.fillRect(0, 0, width, height);
  54391. this.ctx.restore();
  54392. if (transparency) {
  54393. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54394. this.compositeCtx = this.ctx;
  54395. this.transparentCanvas = transparentCanvas.canvas;
  54396. this.ctx = transparentCanvas.context;
  54397. this.ctx.save();
  54398. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54399. }
  54400. this.ctx.save();
  54401. if (transform) {
  54402. this.ctx.transform.apply(this.ctx, transform);
  54403. }
  54404. this.ctx.transform.apply(this.ctx, viewport.transform);
  54405. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54406. if (this.imageLayer) {
  54407. this.imageLayer.beginLayout();
  54408. }
  54409. },
  54410. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54411. var argsArray = operatorList.argsArray;
  54412. var fnArray = operatorList.fnArray;
  54413. var i = executionStartIdx || 0;
  54414. var argsArrayLen = argsArray.length;
  54415. if (argsArrayLen === i) {
  54416. return i;
  54417. }
  54418. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54419. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54420. var steps = 0;
  54421. var commonObjs = this.commonObjs;
  54422. var objs = this.objs;
  54423. var fnId;
  54424. while (true) {
  54425. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54426. stepper.breakIt(i, continueCallback);
  54427. return i;
  54428. }
  54429. fnId = fnArray[i];
  54430. if (fnId !== OPS.dependency) {
  54431. this[fnId].apply(this, argsArray[i]);
  54432. } else {
  54433. var deps = argsArray[i];
  54434. for (var n = 0, nn = deps.length; n < nn; n++) {
  54435. var depObjId = deps[n];
  54436. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54437. var objsPool = common ? commonObjs : objs;
  54438. if (!objsPool.isResolved(depObjId)) {
  54439. objsPool.get(depObjId, continueCallback);
  54440. return i;
  54441. }
  54442. }
  54443. }
  54444. i++;
  54445. if (i === argsArrayLen) {
  54446. return i;
  54447. }
  54448. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54449. if (Date.now() > endTime) {
  54450. continueCallback();
  54451. return i;
  54452. }
  54453. steps = 0;
  54454. }
  54455. }
  54456. },
  54457. endDrawing: function CanvasGraphics_endDrawing() {
  54458. if (this.current.activeSMask !== null) {
  54459. this.endSMaskGroup();
  54460. }
  54461. this.ctx.restore();
  54462. if (this.transparentCanvas) {
  54463. this.ctx = this.compositeCtx;
  54464. this.ctx.save();
  54465. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54466. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54467. this.ctx.restore();
  54468. this.transparentCanvas = null;
  54469. }
  54470. this.cachedCanvases.clear();
  54471. WebGLUtils.clear();
  54472. if (this.imageLayer) {
  54473. this.imageLayer.endLayout();
  54474. }
  54475. },
  54476. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54477. this.current.lineWidth = width;
  54478. this.ctx.lineWidth = width;
  54479. },
  54480. setLineCap: function CanvasGraphics_setLineCap(style) {
  54481. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54482. },
  54483. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54484. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54485. },
  54486. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54487. this.ctx.miterLimit = limit;
  54488. },
  54489. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54490. var ctx = this.ctx;
  54491. if (ctx.setLineDash !== undefined) {
  54492. ctx.setLineDash(dashArray);
  54493. ctx.lineDashOffset = dashPhase;
  54494. }
  54495. },
  54496. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54497. },
  54498. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54499. },
  54500. setGState: function CanvasGraphics_setGState(states) {
  54501. for (var i = 0, ii = states.length; i < ii; i++) {
  54502. var state = states[i];
  54503. var key = state[0];
  54504. var value = state[1];
  54505. switch (key) {
  54506. case 'LW':
  54507. this.setLineWidth(value);
  54508. break;
  54509. case 'LC':
  54510. this.setLineCap(value);
  54511. break;
  54512. case 'LJ':
  54513. this.setLineJoin(value);
  54514. break;
  54515. case 'ML':
  54516. this.setMiterLimit(value);
  54517. break;
  54518. case 'D':
  54519. this.setDash(value[0], value[1]);
  54520. break;
  54521. case 'RI':
  54522. this.setRenderingIntent(value);
  54523. break;
  54524. case 'FL':
  54525. this.setFlatness(value);
  54526. break;
  54527. case 'Font':
  54528. this.setFont(value[0], value[1]);
  54529. break;
  54530. case 'CA':
  54531. this.current.strokeAlpha = state[1];
  54532. break;
  54533. case 'ca':
  54534. this.current.fillAlpha = state[1];
  54535. this.ctx.globalAlpha = state[1];
  54536. break;
  54537. case 'BM':
  54538. if (value && value.name && value.name !== 'Normal') {
  54539. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54540. return '-' + c.toLowerCase();
  54541. }).substring(1);
  54542. this.ctx.globalCompositeOperation = mode;
  54543. if (this.ctx.globalCompositeOperation !== mode) {
  54544. warn('globalCompositeOperation "' + mode + '" is not supported');
  54545. }
  54546. } else {
  54547. this.ctx.globalCompositeOperation = 'source-over';
  54548. }
  54549. break;
  54550. case 'SMask':
  54551. if (this.current.activeSMask) {
  54552. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54553. this.suspendSMaskGroup();
  54554. } else {
  54555. this.endSMaskGroup();
  54556. }
  54557. }
  54558. this.current.activeSMask = value ? this.tempSMask : null;
  54559. if (this.current.activeSMask) {
  54560. this.beginSMaskGroup();
  54561. }
  54562. this.tempSMask = null;
  54563. break;
  54564. }
  54565. }
  54566. },
  54567. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54568. var activeSMask = this.current.activeSMask;
  54569. var drawnWidth = activeSMask.canvas.width;
  54570. var drawnHeight = activeSMask.canvas.height;
  54571. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54572. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54573. var currentCtx = this.ctx;
  54574. var currentTransform = currentCtx.mozCurrentTransform;
  54575. this.ctx.save();
  54576. var groupCtx = scratchCanvas.context;
  54577. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54578. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54579. groupCtx.transform.apply(groupCtx, currentTransform);
  54580. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54581. copyCtxState(currentCtx, groupCtx);
  54582. this.ctx = groupCtx;
  54583. this.setGState([
  54584. [
  54585. 'BM',
  54586. 'Normal'
  54587. ],
  54588. [
  54589. 'ca',
  54590. 1
  54591. ],
  54592. [
  54593. 'CA',
  54594. 1
  54595. ]
  54596. ]);
  54597. this.groupStack.push(currentCtx);
  54598. this.groupLevel++;
  54599. },
  54600. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54601. var groupCtx = this.ctx;
  54602. this.groupLevel--;
  54603. this.ctx = this.groupStack.pop();
  54604. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54605. this.ctx.restore();
  54606. this.ctx.save();
  54607. copyCtxState(groupCtx, this.ctx);
  54608. this.current.resumeSMaskCtx = groupCtx;
  54609. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54610. this.ctx.transform.apply(this.ctx, deltaTransform);
  54611. groupCtx.save();
  54612. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54613. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54614. groupCtx.restore();
  54615. },
  54616. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54617. var groupCtx = this.current.resumeSMaskCtx;
  54618. var currentCtx = this.ctx;
  54619. this.ctx = groupCtx;
  54620. this.groupStack.push(currentCtx);
  54621. this.groupLevel++;
  54622. },
  54623. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54624. var groupCtx = this.ctx;
  54625. this.groupLevel--;
  54626. this.ctx = this.groupStack.pop();
  54627. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54628. this.ctx.restore();
  54629. copyCtxState(groupCtx, this.ctx);
  54630. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54631. this.ctx.transform.apply(this.ctx, deltaTransform);
  54632. },
  54633. save: function CanvasGraphics_save() {
  54634. this.ctx.save();
  54635. var old = this.current;
  54636. this.stateStack.push(old);
  54637. this.current = old.clone();
  54638. this.current.resumeSMaskCtx = null;
  54639. },
  54640. restore: function CanvasGraphics_restore() {
  54641. if (this.current.resumeSMaskCtx) {
  54642. this.resumeSMaskGroup();
  54643. }
  54644. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54645. this.endSMaskGroup();
  54646. }
  54647. if (this.stateStack.length !== 0) {
  54648. this.current = this.stateStack.pop();
  54649. this.ctx.restore();
  54650. this.pendingClip = null;
  54651. this.cachedGetSinglePixelWidth = null;
  54652. }
  54653. },
  54654. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54655. this.ctx.transform(a, b, c, d, e, f);
  54656. this.cachedGetSinglePixelWidth = null;
  54657. },
  54658. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54659. var ctx = this.ctx;
  54660. var current = this.current;
  54661. var x = current.x, y = current.y;
  54662. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54663. switch (ops[i] | 0) {
  54664. case OPS.rectangle:
  54665. x = args[j++];
  54666. y = args[j++];
  54667. var width = args[j++];
  54668. var height = args[j++];
  54669. if (width === 0) {
  54670. width = this.getSinglePixelWidth();
  54671. }
  54672. if (height === 0) {
  54673. height = this.getSinglePixelWidth();
  54674. }
  54675. var xw = x + width;
  54676. var yh = y + height;
  54677. this.ctx.moveTo(x, y);
  54678. this.ctx.lineTo(xw, y);
  54679. this.ctx.lineTo(xw, yh);
  54680. this.ctx.lineTo(x, yh);
  54681. this.ctx.lineTo(x, y);
  54682. this.ctx.closePath();
  54683. break;
  54684. case OPS.moveTo:
  54685. x = args[j++];
  54686. y = args[j++];
  54687. ctx.moveTo(x, y);
  54688. break;
  54689. case OPS.lineTo:
  54690. x = args[j++];
  54691. y = args[j++];
  54692. ctx.lineTo(x, y);
  54693. break;
  54694. case OPS.curveTo:
  54695. x = args[j + 4];
  54696. y = args[j + 5];
  54697. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54698. j += 6;
  54699. break;
  54700. case OPS.curveTo2:
  54701. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54702. x = args[j + 2];
  54703. y = args[j + 3];
  54704. j += 4;
  54705. break;
  54706. case OPS.curveTo3:
  54707. x = args[j + 2];
  54708. y = args[j + 3];
  54709. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54710. j += 4;
  54711. break;
  54712. case OPS.closePath:
  54713. ctx.closePath();
  54714. break;
  54715. }
  54716. }
  54717. current.setCurrentPoint(x, y);
  54718. },
  54719. closePath: function CanvasGraphics_closePath() {
  54720. this.ctx.closePath();
  54721. },
  54722. stroke: function CanvasGraphics_stroke(consumePath) {
  54723. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54724. var ctx = this.ctx;
  54725. var strokeColor = this.current.strokeColor;
  54726. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54727. ctx.globalAlpha = this.current.strokeAlpha;
  54728. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54729. ctx.save();
  54730. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54731. ctx.stroke();
  54732. ctx.restore();
  54733. } else {
  54734. ctx.stroke();
  54735. }
  54736. if (consumePath) {
  54737. this.consumePath();
  54738. }
  54739. ctx.globalAlpha = this.current.fillAlpha;
  54740. },
  54741. closeStroke: function CanvasGraphics_closeStroke() {
  54742. this.closePath();
  54743. this.stroke();
  54744. },
  54745. fill: function CanvasGraphics_fill(consumePath) {
  54746. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54747. var ctx = this.ctx;
  54748. var fillColor = this.current.fillColor;
  54749. var isPatternFill = this.current.patternFill;
  54750. var needRestore = false;
  54751. if (isPatternFill) {
  54752. ctx.save();
  54753. if (this.baseTransform) {
  54754. ctx.setTransform.apply(ctx, this.baseTransform);
  54755. }
  54756. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54757. needRestore = true;
  54758. }
  54759. if (this.pendingEOFill) {
  54760. ctx.fill('evenodd');
  54761. this.pendingEOFill = false;
  54762. } else {
  54763. ctx.fill();
  54764. }
  54765. if (needRestore) {
  54766. ctx.restore();
  54767. }
  54768. if (consumePath) {
  54769. this.consumePath();
  54770. }
  54771. },
  54772. eoFill: function CanvasGraphics_eoFill() {
  54773. this.pendingEOFill = true;
  54774. this.fill();
  54775. },
  54776. fillStroke: function CanvasGraphics_fillStroke() {
  54777. this.fill(false);
  54778. this.stroke(false);
  54779. this.consumePath();
  54780. },
  54781. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54782. this.pendingEOFill = true;
  54783. this.fillStroke();
  54784. },
  54785. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54786. this.closePath();
  54787. this.fillStroke();
  54788. },
  54789. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54790. this.pendingEOFill = true;
  54791. this.closePath();
  54792. this.fillStroke();
  54793. },
  54794. endPath: function CanvasGraphics_endPath() {
  54795. this.consumePath();
  54796. },
  54797. clip: function CanvasGraphics_clip() {
  54798. this.pendingClip = NORMAL_CLIP;
  54799. },
  54800. eoClip: function CanvasGraphics_eoClip() {
  54801. this.pendingClip = EO_CLIP;
  54802. },
  54803. beginText: function CanvasGraphics_beginText() {
  54804. this.current.textMatrix = IDENTITY_MATRIX;
  54805. this.current.textMatrixScale = 1;
  54806. this.current.x = this.current.lineX = 0;
  54807. this.current.y = this.current.lineY = 0;
  54808. },
  54809. endText: function CanvasGraphics_endText() {
  54810. var paths = this.pendingTextPaths;
  54811. var ctx = this.ctx;
  54812. if (paths === undefined) {
  54813. ctx.beginPath();
  54814. return;
  54815. }
  54816. ctx.save();
  54817. ctx.beginPath();
  54818. for (var i = 0; i < paths.length; i++) {
  54819. var path = paths[i];
  54820. ctx.setTransform.apply(ctx, path.transform);
  54821. ctx.translate(path.x, path.y);
  54822. path.addToPath(ctx, path.fontSize);
  54823. }
  54824. ctx.restore();
  54825. ctx.clip();
  54826. ctx.beginPath();
  54827. delete this.pendingTextPaths;
  54828. },
  54829. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54830. this.current.charSpacing = spacing;
  54831. },
  54832. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54833. this.current.wordSpacing = spacing;
  54834. },
  54835. setHScale: function CanvasGraphics_setHScale(scale) {
  54836. this.current.textHScale = scale / 100;
  54837. },
  54838. setLeading: function CanvasGraphics_setLeading(leading) {
  54839. this.current.leading = -leading;
  54840. },
  54841. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54842. var fontObj = this.commonObjs.get(fontRefName);
  54843. var current = this.current;
  54844. if (!fontObj) {
  54845. error('Can\'t find font for ' + fontRefName);
  54846. }
  54847. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54848. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54849. warn('Invalid font matrix for font ' + fontRefName);
  54850. }
  54851. if (size < 0) {
  54852. size = -size;
  54853. current.fontDirection = -1;
  54854. } else {
  54855. current.fontDirection = 1;
  54856. }
  54857. this.current.font = fontObj;
  54858. this.current.fontSize = size;
  54859. if (fontObj.isType3Font) {
  54860. return;
  54861. }
  54862. var name = fontObj.loadedName || 'sans-serif';
  54863. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54864. var italic = fontObj.italic ? 'italic' : 'normal';
  54865. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54866. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54867. this.current.fontSizeScale = size / browserFontSize;
  54868. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54869. this.ctx.font = rule;
  54870. },
  54871. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54872. this.current.textRenderingMode = mode;
  54873. },
  54874. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54875. this.current.textRise = rise;
  54876. },
  54877. moveText: function CanvasGraphics_moveText(x, y) {
  54878. this.current.x = this.current.lineX += x;
  54879. this.current.y = this.current.lineY += y;
  54880. },
  54881. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54882. this.setLeading(-y);
  54883. this.moveText(x, y);
  54884. },
  54885. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54886. this.current.textMatrix = [
  54887. a,
  54888. b,
  54889. c,
  54890. d,
  54891. e,
  54892. f
  54893. ];
  54894. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54895. this.current.x = this.current.lineX = 0;
  54896. this.current.y = this.current.lineY = 0;
  54897. },
  54898. nextLine: function CanvasGraphics_nextLine() {
  54899. this.moveText(0, this.current.leading);
  54900. },
  54901. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54902. var ctx = this.ctx;
  54903. var current = this.current;
  54904. var font = current.font;
  54905. var textRenderingMode = current.textRenderingMode;
  54906. var fontSize = current.fontSize / current.fontSizeScale;
  54907. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54908. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54909. var addToPath;
  54910. if (font.disableFontFace || isAddToPathSet) {
  54911. addToPath = font.getPathGenerator(this.commonObjs, character);
  54912. }
  54913. if (font.disableFontFace) {
  54914. ctx.save();
  54915. ctx.translate(x, y);
  54916. ctx.beginPath();
  54917. addToPath(ctx, fontSize);
  54918. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54919. ctx.fill();
  54920. }
  54921. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54922. ctx.stroke();
  54923. }
  54924. ctx.restore();
  54925. } else {
  54926. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54927. ctx.fillText(character, x, y);
  54928. }
  54929. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54930. ctx.strokeText(character, x, y);
  54931. }
  54932. }
  54933. if (isAddToPathSet) {
  54934. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54935. paths.push({
  54936. transform: ctx.mozCurrentTransform,
  54937. x: x,
  54938. y: y,
  54939. fontSize: fontSize,
  54940. addToPath: addToPath
  54941. });
  54942. }
  54943. },
  54944. get isFontSubpixelAAEnabled() {
  54945. var ctx = this.canvasFactory.create(10, 10).context;
  54946. ctx.scale(1.5, 1);
  54947. ctx.fillText('I', 0, 10);
  54948. var data = ctx.getImageData(0, 0, 10, 10).data;
  54949. var enabled = false;
  54950. for (var i = 3; i < data.length; i += 4) {
  54951. if (data[i] > 0 && data[i] < 255) {
  54952. enabled = true;
  54953. break;
  54954. }
  54955. }
  54956. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54957. },
  54958. showText: function CanvasGraphics_showText(glyphs) {
  54959. var current = this.current;
  54960. var font = current.font;
  54961. if (font.isType3Font) {
  54962. return this.showType3Text(glyphs);
  54963. }
  54964. var fontSize = current.fontSize;
  54965. if (fontSize === 0) {
  54966. return;
  54967. }
  54968. var ctx = this.ctx;
  54969. var fontSizeScale = current.fontSizeScale;
  54970. var charSpacing = current.charSpacing;
  54971. var wordSpacing = current.wordSpacing;
  54972. var fontDirection = current.fontDirection;
  54973. var textHScale = current.textHScale * fontDirection;
  54974. var glyphsLength = glyphs.length;
  54975. var vertical = font.vertical;
  54976. var spacingDir = vertical ? 1 : -1;
  54977. var defaultVMetrics = font.defaultVMetrics;
  54978. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  54979. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  54980. ctx.save();
  54981. ctx.transform.apply(ctx, current.textMatrix);
  54982. ctx.translate(current.x, current.y + current.textRise);
  54983. if (current.patternFill) {
  54984. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  54985. }
  54986. if (fontDirection > 0) {
  54987. ctx.scale(textHScale, -1);
  54988. } else {
  54989. ctx.scale(textHScale, 1);
  54990. }
  54991. var lineWidth = current.lineWidth;
  54992. var scale = current.textMatrixScale;
  54993. if (scale === 0 || lineWidth === 0) {
  54994. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54995. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54996. this.cachedGetSinglePixelWidth = null;
  54997. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  54998. }
  54999. } else {
  55000. lineWidth /= scale;
  55001. }
  55002. if (fontSizeScale !== 1.0) {
  55003. ctx.scale(fontSizeScale, fontSizeScale);
  55004. lineWidth /= fontSizeScale;
  55005. }
  55006. ctx.lineWidth = lineWidth;
  55007. var x = 0, i;
  55008. for (i = 0; i < glyphsLength; ++i) {
  55009. var glyph = glyphs[i];
  55010. if (isNum(glyph)) {
  55011. x += spacingDir * glyph * fontSize / 1000;
  55012. continue;
  55013. }
  55014. var restoreNeeded = false;
  55015. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55016. var character = glyph.fontChar;
  55017. var accent = glyph.accent;
  55018. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55019. var width = glyph.width;
  55020. if (vertical) {
  55021. var vmetric, vx, vy;
  55022. vmetric = glyph.vmetric || defaultVMetrics;
  55023. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55024. vx = -vx * widthAdvanceScale;
  55025. vy = vmetric[2] * widthAdvanceScale;
  55026. width = vmetric ? -vmetric[0] : width;
  55027. scaledX = vx / fontSizeScale;
  55028. scaledY = (x + vy) / fontSizeScale;
  55029. } else {
  55030. scaledX = x / fontSizeScale;
  55031. scaledY = 0;
  55032. }
  55033. if (font.remeasure && width > 0) {
  55034. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55035. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55036. var characterScaleX = width / measuredWidth;
  55037. restoreNeeded = true;
  55038. ctx.save();
  55039. ctx.scale(characterScaleX, 1);
  55040. scaledX /= characterScaleX;
  55041. } else if (width !== measuredWidth) {
  55042. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55043. }
  55044. }
  55045. if (glyph.isInFont || font.missingFile) {
  55046. if (simpleFillText && !accent) {
  55047. ctx.fillText(character, scaledX, scaledY);
  55048. } else {
  55049. this.paintChar(character, scaledX, scaledY);
  55050. if (accent) {
  55051. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55052. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55053. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55054. }
  55055. }
  55056. }
  55057. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55058. x += charWidth;
  55059. if (restoreNeeded) {
  55060. ctx.restore();
  55061. }
  55062. }
  55063. if (vertical) {
  55064. current.y -= x * textHScale;
  55065. } else {
  55066. current.x += x * textHScale;
  55067. }
  55068. ctx.restore();
  55069. },
  55070. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55071. var ctx = this.ctx;
  55072. var current = this.current;
  55073. var font = current.font;
  55074. var fontSize = current.fontSize;
  55075. var fontDirection = current.fontDirection;
  55076. var spacingDir = font.vertical ? 1 : -1;
  55077. var charSpacing = current.charSpacing;
  55078. var wordSpacing = current.wordSpacing;
  55079. var textHScale = current.textHScale * fontDirection;
  55080. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55081. var glyphsLength = glyphs.length;
  55082. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55083. var i, glyph, width, spacingLength;
  55084. if (isTextInvisible || fontSize === 0) {
  55085. return;
  55086. }
  55087. this.cachedGetSinglePixelWidth = null;
  55088. ctx.save();
  55089. ctx.transform.apply(ctx, current.textMatrix);
  55090. ctx.translate(current.x, current.y);
  55091. ctx.scale(textHScale, fontDirection);
  55092. for (i = 0; i < glyphsLength; ++i) {
  55093. glyph = glyphs[i];
  55094. if (isNum(glyph)) {
  55095. spacingLength = spacingDir * glyph * fontSize / 1000;
  55096. this.ctx.translate(spacingLength, 0);
  55097. current.x += spacingLength * textHScale;
  55098. continue;
  55099. }
  55100. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55101. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55102. if (!operatorList) {
  55103. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55104. continue;
  55105. }
  55106. this.processingType3 = glyph;
  55107. this.save();
  55108. ctx.scale(fontSize, fontSize);
  55109. ctx.transform.apply(ctx, fontMatrix);
  55110. this.executeOperatorList(operatorList);
  55111. this.restore();
  55112. var transformed = Util.applyTransform([
  55113. glyph.width,
  55114. 0
  55115. ], fontMatrix);
  55116. width = transformed[0] * fontSize + spacing;
  55117. ctx.translate(width, 0);
  55118. current.x += width * textHScale;
  55119. }
  55120. ctx.restore();
  55121. this.processingType3 = null;
  55122. },
  55123. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55124. },
  55125. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55126. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55127. this.clip();
  55128. this.endPath();
  55129. },
  55130. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55131. var pattern;
  55132. if (IR[0] === 'TilingPattern') {
  55133. var color = IR[1];
  55134. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55135. var self = this;
  55136. var canvasGraphicsFactory = {
  55137. createCanvasGraphics: function (ctx) {
  55138. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55139. }
  55140. };
  55141. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55142. } else {
  55143. pattern = getShadingPatternFromIR(IR);
  55144. }
  55145. return pattern;
  55146. },
  55147. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55148. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55149. },
  55150. setFillColorN: function CanvasGraphics_setFillColorN() {
  55151. this.current.fillColor = this.getColorN_Pattern(arguments);
  55152. this.current.patternFill = true;
  55153. },
  55154. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55155. var color = Util.makeCssRgb(r, g, b);
  55156. this.ctx.strokeStyle = color;
  55157. this.current.strokeColor = color;
  55158. },
  55159. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55160. var color = Util.makeCssRgb(r, g, b);
  55161. this.ctx.fillStyle = color;
  55162. this.current.fillColor = color;
  55163. this.current.patternFill = false;
  55164. },
  55165. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55166. var ctx = this.ctx;
  55167. this.save();
  55168. var pattern = getShadingPatternFromIR(patternIR);
  55169. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55170. var inv = ctx.mozCurrentTransformInverse;
  55171. if (inv) {
  55172. var canvas = ctx.canvas;
  55173. var width = canvas.width;
  55174. var height = canvas.height;
  55175. var bl = Util.applyTransform([
  55176. 0,
  55177. 0
  55178. ], inv);
  55179. var br = Util.applyTransform([
  55180. 0,
  55181. height
  55182. ], inv);
  55183. var ul = Util.applyTransform([
  55184. width,
  55185. 0
  55186. ], inv);
  55187. var ur = Util.applyTransform([
  55188. width,
  55189. height
  55190. ], inv);
  55191. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55192. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55193. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55194. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55195. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55196. } else {
  55197. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55198. }
  55199. this.restore();
  55200. },
  55201. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55202. error('Should not call beginInlineImage');
  55203. },
  55204. beginImageData: function CanvasGraphics_beginImageData() {
  55205. error('Should not call beginImageData');
  55206. },
  55207. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55208. this.save();
  55209. this.baseTransformStack.push(this.baseTransform);
  55210. if (isArray(matrix) && matrix.length === 6) {
  55211. this.transform.apply(this, matrix);
  55212. }
  55213. this.baseTransform = this.ctx.mozCurrentTransform;
  55214. if (isArray(bbox) && bbox.length === 4) {
  55215. var width = bbox[2] - bbox[0];
  55216. var height = bbox[3] - bbox[1];
  55217. this.ctx.rect(bbox[0], bbox[1], width, height);
  55218. this.clip();
  55219. this.endPath();
  55220. }
  55221. },
  55222. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55223. this.restore();
  55224. this.baseTransform = this.baseTransformStack.pop();
  55225. },
  55226. beginGroup: function CanvasGraphics_beginGroup(group) {
  55227. this.save();
  55228. var currentCtx = this.ctx;
  55229. if (!group.isolated) {
  55230. info('TODO: Support non-isolated groups.');
  55231. }
  55232. if (group.knockout) {
  55233. warn('Knockout groups not supported.');
  55234. }
  55235. var currentTransform = currentCtx.mozCurrentTransform;
  55236. if (group.matrix) {
  55237. currentCtx.transform.apply(currentCtx, group.matrix);
  55238. }
  55239. assert(group.bbox, 'Bounding box is required.');
  55240. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55241. var canvasBounds = [
  55242. 0,
  55243. 0,
  55244. currentCtx.canvas.width,
  55245. currentCtx.canvas.height
  55246. ];
  55247. bounds = Util.intersect(bounds, canvasBounds) || [
  55248. 0,
  55249. 0,
  55250. 0,
  55251. 0
  55252. ];
  55253. var offsetX = Math.floor(bounds[0]);
  55254. var offsetY = Math.floor(bounds[1]);
  55255. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55256. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55257. var scaleX = 1, scaleY = 1;
  55258. if (drawnWidth > MAX_GROUP_SIZE) {
  55259. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55260. drawnWidth = MAX_GROUP_SIZE;
  55261. }
  55262. if (drawnHeight > MAX_GROUP_SIZE) {
  55263. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55264. drawnHeight = MAX_GROUP_SIZE;
  55265. }
  55266. var cacheId = 'groupAt' + this.groupLevel;
  55267. if (group.smask) {
  55268. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55269. }
  55270. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55271. var groupCtx = scratchCanvas.context;
  55272. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55273. groupCtx.translate(-offsetX, -offsetY);
  55274. groupCtx.transform.apply(groupCtx, currentTransform);
  55275. if (group.smask) {
  55276. this.smaskStack.push({
  55277. canvas: scratchCanvas.canvas,
  55278. context: groupCtx,
  55279. offsetX: offsetX,
  55280. offsetY: offsetY,
  55281. scaleX: scaleX,
  55282. scaleY: scaleY,
  55283. subtype: group.smask.subtype,
  55284. backdrop: group.smask.backdrop,
  55285. transferMap: group.smask.transferMap || null,
  55286. startTransformInverse: null
  55287. });
  55288. } else {
  55289. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55290. currentCtx.translate(offsetX, offsetY);
  55291. currentCtx.scale(scaleX, scaleY);
  55292. }
  55293. copyCtxState(currentCtx, groupCtx);
  55294. this.ctx = groupCtx;
  55295. this.setGState([
  55296. [
  55297. 'BM',
  55298. 'Normal'
  55299. ],
  55300. [
  55301. 'ca',
  55302. 1
  55303. ],
  55304. [
  55305. 'CA',
  55306. 1
  55307. ]
  55308. ]);
  55309. this.groupStack.push(currentCtx);
  55310. this.groupLevel++;
  55311. this.current.activeSMask = null;
  55312. },
  55313. endGroup: function CanvasGraphics_endGroup(group) {
  55314. this.groupLevel--;
  55315. var groupCtx = this.ctx;
  55316. this.ctx = this.groupStack.pop();
  55317. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55318. this.ctx.imageSmoothingEnabled = false;
  55319. } else {
  55320. this.ctx.mozImageSmoothingEnabled = false;
  55321. }
  55322. if (group.smask) {
  55323. this.tempSMask = this.smaskStack.pop();
  55324. } else {
  55325. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55326. }
  55327. this.restore();
  55328. },
  55329. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55330. this.save();
  55331. this.current = new CanvasExtraState();
  55332. if (this.baseTransform) {
  55333. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55334. }
  55335. },
  55336. endAnnotations: function CanvasGraphics_endAnnotations() {
  55337. this.restore();
  55338. },
  55339. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55340. this.save();
  55341. if (isArray(rect) && rect.length === 4) {
  55342. var width = rect[2] - rect[0];
  55343. var height = rect[3] - rect[1];
  55344. this.ctx.rect(rect[0], rect[1], width, height);
  55345. this.clip();
  55346. this.endPath();
  55347. }
  55348. this.transform.apply(this, transform);
  55349. this.transform.apply(this, matrix);
  55350. },
  55351. endAnnotation: function CanvasGraphics_endAnnotation() {
  55352. this.restore();
  55353. },
  55354. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55355. var domImage = this.objs.get(objId);
  55356. if (!domImage) {
  55357. warn('Dependent image isn\'t ready yet');
  55358. return;
  55359. }
  55360. this.save();
  55361. var ctx = this.ctx;
  55362. ctx.scale(1 / w, -1 / h);
  55363. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55364. if (this.imageLayer) {
  55365. var currentTransform = ctx.mozCurrentTransformInverse;
  55366. var position = this.getCanvasPosition(0, 0);
  55367. this.imageLayer.appendImage({
  55368. objId: objId,
  55369. left: position[0],
  55370. top: position[1],
  55371. width: w / currentTransform[0],
  55372. height: h / currentTransform[3]
  55373. });
  55374. }
  55375. this.restore();
  55376. },
  55377. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55378. var ctx = this.ctx;
  55379. var width = img.width, height = img.height;
  55380. var fillColor = this.current.fillColor;
  55381. var isPatternFill = this.current.patternFill;
  55382. var glyph = this.processingType3;
  55383. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55384. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55385. glyph.compiled = compileType3Glyph({
  55386. data: img.data,
  55387. width: width,
  55388. height: height
  55389. });
  55390. } else {
  55391. glyph.compiled = null;
  55392. }
  55393. }
  55394. if (glyph && glyph.compiled) {
  55395. glyph.compiled(ctx);
  55396. return;
  55397. }
  55398. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55399. var maskCtx = maskCanvas.context;
  55400. maskCtx.save();
  55401. putBinaryImageMask(maskCtx, img);
  55402. maskCtx.globalCompositeOperation = 'source-in';
  55403. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55404. maskCtx.fillRect(0, 0, width, height);
  55405. maskCtx.restore();
  55406. this.paintInlineImageXObject(maskCanvas.canvas);
  55407. },
  55408. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55409. var width = imgData.width;
  55410. var height = imgData.height;
  55411. var fillColor = this.current.fillColor;
  55412. var isPatternFill = this.current.patternFill;
  55413. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55414. var maskCtx = maskCanvas.context;
  55415. maskCtx.save();
  55416. putBinaryImageMask(maskCtx, imgData);
  55417. maskCtx.globalCompositeOperation = 'source-in';
  55418. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55419. maskCtx.fillRect(0, 0, width, height);
  55420. maskCtx.restore();
  55421. var ctx = this.ctx;
  55422. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55423. ctx.save();
  55424. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55425. ctx.scale(1, -1);
  55426. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55427. ctx.restore();
  55428. }
  55429. },
  55430. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55431. var ctx = this.ctx;
  55432. var fillColor = this.current.fillColor;
  55433. var isPatternFill = this.current.patternFill;
  55434. for (var i = 0, ii = images.length; i < ii; i++) {
  55435. var image = images[i];
  55436. var width = image.width, height = image.height;
  55437. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55438. var maskCtx = maskCanvas.context;
  55439. maskCtx.save();
  55440. putBinaryImageMask(maskCtx, image);
  55441. maskCtx.globalCompositeOperation = 'source-in';
  55442. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55443. maskCtx.fillRect(0, 0, width, height);
  55444. maskCtx.restore();
  55445. ctx.save();
  55446. ctx.transform.apply(ctx, image.transform);
  55447. ctx.scale(1, -1);
  55448. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55449. ctx.restore();
  55450. }
  55451. },
  55452. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55453. var imgData = this.objs.get(objId);
  55454. if (!imgData) {
  55455. warn('Dependent image isn\'t ready yet');
  55456. return;
  55457. }
  55458. this.paintInlineImageXObject(imgData);
  55459. },
  55460. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55461. var imgData = this.objs.get(objId);
  55462. if (!imgData) {
  55463. warn('Dependent image isn\'t ready yet');
  55464. return;
  55465. }
  55466. var width = imgData.width;
  55467. var height = imgData.height;
  55468. var map = [];
  55469. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55470. map.push({
  55471. transform: [
  55472. scaleX,
  55473. 0,
  55474. 0,
  55475. scaleY,
  55476. positions[i],
  55477. positions[i + 1]
  55478. ],
  55479. x: 0,
  55480. y: 0,
  55481. w: width,
  55482. h: height
  55483. });
  55484. }
  55485. this.paintInlineImageXObjectGroup(imgData, map);
  55486. },
  55487. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55488. var width = imgData.width;
  55489. var height = imgData.height;
  55490. var ctx = this.ctx;
  55491. this.save();
  55492. ctx.scale(1 / width, -1 / height);
  55493. var currentTransform = ctx.mozCurrentTransformInverse;
  55494. var a = currentTransform[0], b = currentTransform[1];
  55495. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55496. var c = currentTransform[2], d = currentTransform[3];
  55497. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55498. var imgToPaint, tmpCanvas;
  55499. if (imgData instanceof HTMLElement || !imgData.data) {
  55500. imgToPaint = imgData;
  55501. } else {
  55502. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55503. var tmpCtx = tmpCanvas.context;
  55504. putBinaryImageData(tmpCtx, imgData);
  55505. imgToPaint = tmpCanvas.canvas;
  55506. }
  55507. var paintWidth = width, paintHeight = height;
  55508. var tmpCanvasId = 'prescale1';
  55509. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55510. var newWidth = paintWidth, newHeight = paintHeight;
  55511. if (widthScale > 2 && paintWidth > 1) {
  55512. newWidth = Math.ceil(paintWidth / 2);
  55513. widthScale /= paintWidth / newWidth;
  55514. }
  55515. if (heightScale > 2 && paintHeight > 1) {
  55516. newHeight = Math.ceil(paintHeight / 2);
  55517. heightScale /= paintHeight / newHeight;
  55518. }
  55519. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55520. tmpCtx = tmpCanvas.context;
  55521. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55522. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55523. imgToPaint = tmpCanvas.canvas;
  55524. paintWidth = newWidth;
  55525. paintHeight = newHeight;
  55526. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55527. }
  55528. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55529. if (this.imageLayer) {
  55530. var position = this.getCanvasPosition(0, -height);
  55531. this.imageLayer.appendImage({
  55532. imgData: imgData,
  55533. left: position[0],
  55534. top: position[1],
  55535. width: width / currentTransform[0],
  55536. height: height / currentTransform[3]
  55537. });
  55538. }
  55539. this.restore();
  55540. },
  55541. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55542. var ctx = this.ctx;
  55543. var w = imgData.width;
  55544. var h = imgData.height;
  55545. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55546. var tmpCtx = tmpCanvas.context;
  55547. putBinaryImageData(tmpCtx, imgData);
  55548. for (var i = 0, ii = map.length; i < ii; i++) {
  55549. var entry = map[i];
  55550. ctx.save();
  55551. ctx.transform.apply(ctx, entry.transform);
  55552. ctx.scale(1, -1);
  55553. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55554. if (this.imageLayer) {
  55555. var position = this.getCanvasPosition(entry.x, entry.y);
  55556. this.imageLayer.appendImage({
  55557. imgData: imgData,
  55558. left: position[0],
  55559. top: position[1],
  55560. width: w,
  55561. height: h
  55562. });
  55563. }
  55564. ctx.restore();
  55565. }
  55566. },
  55567. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55568. this.ctx.fillRect(0, 0, 1, 1);
  55569. },
  55570. paintXObject: function CanvasGraphics_paintXObject() {
  55571. warn('Unsupported \'paintXObject\' command.');
  55572. },
  55573. markPoint: function CanvasGraphics_markPoint(tag) {
  55574. },
  55575. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55576. },
  55577. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55578. },
  55579. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55580. },
  55581. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55582. },
  55583. beginCompat: function CanvasGraphics_beginCompat() {
  55584. },
  55585. endCompat: function CanvasGraphics_endCompat() {
  55586. },
  55587. consumePath: function CanvasGraphics_consumePath() {
  55588. var ctx = this.ctx;
  55589. if (this.pendingClip) {
  55590. if (this.pendingClip === EO_CLIP) {
  55591. ctx.clip('evenodd');
  55592. } else {
  55593. ctx.clip();
  55594. }
  55595. this.pendingClip = null;
  55596. }
  55597. ctx.beginPath();
  55598. },
  55599. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55600. if (this.cachedGetSinglePixelWidth === null) {
  55601. this.ctx.save();
  55602. var inverse = this.ctx.mozCurrentTransformInverse;
  55603. this.ctx.restore();
  55604. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55605. }
  55606. return this.cachedGetSinglePixelWidth;
  55607. },
  55608. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55609. var transform = this.ctx.mozCurrentTransform;
  55610. return [
  55611. transform[0] * x + transform[2] * y + transform[4],
  55612. transform[1] * x + transform[3] * y + transform[5]
  55613. ];
  55614. }
  55615. };
  55616. for (var op in OPS) {
  55617. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55618. }
  55619. return CanvasGraphics;
  55620. }();
  55621. exports.CanvasGraphics = CanvasGraphics;
  55622. /***/ }),
  55623. /* 45 */
  55624. /***/ (function(module, exports, __w_pdfjs_require__) {
  55625. "use strict";
  55626. var sharedUtil = __w_pdfjs_require__(0);
  55627. var assert = sharedUtil.assert;
  55628. var bytesToString = sharedUtil.bytesToString;
  55629. var string32 = sharedUtil.string32;
  55630. var shadow = sharedUtil.shadow;
  55631. var warn = sharedUtil.warn;
  55632. function FontLoader(docId) {
  55633. this.docId = docId;
  55634. this.styleElement = null;
  55635. this.nativeFontFaces = [];
  55636. this.loadTestFontId = 0;
  55637. this.loadingContext = {
  55638. requests: [],
  55639. nextRequestId: 0
  55640. };
  55641. }
  55642. FontLoader.prototype = {
  55643. insertRule: function fontLoaderInsertRule(rule) {
  55644. var styleElement = this.styleElement;
  55645. if (!styleElement) {
  55646. styleElement = this.styleElement = document.createElement('style');
  55647. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55648. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55649. }
  55650. var styleSheet = styleElement.sheet;
  55651. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55652. },
  55653. clear: function fontLoaderClear() {
  55654. if (this.styleElement) {
  55655. this.styleElement.remove();
  55656. this.styleElement = null;
  55657. }
  55658. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55659. document.fonts.delete(nativeFontFace);
  55660. });
  55661. this.nativeFontFaces.length = 0;
  55662. }
  55663. };
  55664. var getLoadTestFont = function () {
  55665. 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==');
  55666. };
  55667. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55668. get: function () {
  55669. return shadow(this, 'loadTestFont', getLoadTestFont());
  55670. },
  55671. configurable: true
  55672. });
  55673. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55674. this.nativeFontFaces.push(nativeFontFace);
  55675. document.fonts.add(nativeFontFace);
  55676. };
  55677. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55678. var rules = [];
  55679. var fontsToLoad = [];
  55680. var fontLoadPromises = [];
  55681. var getNativeFontPromise = function (nativeFontFace) {
  55682. return nativeFontFace.loaded.catch(function (e) {
  55683. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55684. });
  55685. };
  55686. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55687. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55688. var font = fonts[i];
  55689. if (font.attached || font.loading === false) {
  55690. continue;
  55691. }
  55692. font.attached = true;
  55693. if (isFontLoadingAPISupported) {
  55694. var nativeFontFace = font.createNativeFontFace();
  55695. if (nativeFontFace) {
  55696. this.addNativeFontFace(nativeFontFace);
  55697. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55698. }
  55699. } else {
  55700. var rule = font.createFontFaceRule();
  55701. if (rule) {
  55702. this.insertRule(rule);
  55703. rules.push(rule);
  55704. fontsToLoad.push(font);
  55705. }
  55706. }
  55707. }
  55708. var request = this.queueLoadingCallback(callback);
  55709. if (isFontLoadingAPISupported) {
  55710. Promise.all(fontLoadPromises).then(function () {
  55711. request.complete();
  55712. });
  55713. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55714. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55715. } else {
  55716. request.complete();
  55717. }
  55718. };
  55719. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55720. function LoadLoader_completeRequest() {
  55721. assert(!request.end, 'completeRequest() cannot be called twice');
  55722. request.end = Date.now();
  55723. while (context.requests.length > 0 && context.requests[0].end) {
  55724. var otherRequest = context.requests.shift();
  55725. setTimeout(otherRequest.callback, 0);
  55726. }
  55727. }
  55728. var context = this.loadingContext;
  55729. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55730. var request = {
  55731. id: requestId,
  55732. complete: LoadLoader_completeRequest,
  55733. callback: callback,
  55734. started: Date.now()
  55735. };
  55736. context.requests.push(request);
  55737. return request;
  55738. };
  55739. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55740. function int32(data, offset) {
  55741. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55742. }
  55743. function spliceString(s, offset, remove, insert) {
  55744. var chunk1 = s.substr(0, offset);
  55745. var chunk2 = s.substr(offset + remove);
  55746. return chunk1 + insert + chunk2;
  55747. }
  55748. var i, ii;
  55749. var canvas = document.createElement('canvas');
  55750. canvas.width = 1;
  55751. canvas.height = 1;
  55752. var ctx = canvas.getContext('2d');
  55753. var called = 0;
  55754. function isFontReady(name, callback) {
  55755. called++;
  55756. if (called > 30) {
  55757. warn('Load test font never loaded.');
  55758. callback();
  55759. return;
  55760. }
  55761. ctx.font = '30px ' + name;
  55762. ctx.fillText('.', 0, 20);
  55763. var imageData = ctx.getImageData(0, 0, 1, 1);
  55764. if (imageData.data[3] > 0) {
  55765. callback();
  55766. return;
  55767. }
  55768. setTimeout(isFontReady.bind(null, name, callback));
  55769. }
  55770. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55771. var data = this.loadTestFont;
  55772. var COMMENT_OFFSET = 976;
  55773. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55774. var CFF_CHECKSUM_OFFSET = 16;
  55775. var XXXX_VALUE = 0x58585858;
  55776. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55777. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55778. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55779. }
  55780. if (i < loadTestFontId.length) {
  55781. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55782. }
  55783. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55784. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55785. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55786. this.insertRule(rule);
  55787. var names = [];
  55788. for (i = 0, ii = fonts.length; i < ii; i++) {
  55789. names.push(fonts[i].loadedName);
  55790. }
  55791. names.push(loadTestFontId);
  55792. var div = document.createElement('div');
  55793. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55794. for (i = 0, ii = names.length; i < ii; ++i) {
  55795. var span = document.createElement('span');
  55796. span.textContent = 'Hi';
  55797. span.style.fontFamily = names[i];
  55798. div.appendChild(span);
  55799. }
  55800. document.body.appendChild(div);
  55801. isFontReady(loadTestFontId, function () {
  55802. document.body.removeChild(div);
  55803. request.complete();
  55804. });
  55805. };
  55806. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55807. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55808. if (typeof navigator === 'undefined') {
  55809. return true;
  55810. }
  55811. var supported = false;
  55812. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55813. if (m && m[1] >= 14) {
  55814. supported = true;
  55815. }
  55816. return supported;
  55817. };
  55818. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55819. get: function () {
  55820. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55821. },
  55822. enumerable: true,
  55823. configurable: true
  55824. });
  55825. var IsEvalSupportedCached = {
  55826. get value() {
  55827. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55828. }
  55829. };
  55830. var FontFaceObject = function FontFaceObjectClosure() {
  55831. function FontFaceObject(translatedData, options) {
  55832. this.compiledGlyphs = Object.create(null);
  55833. for (var i in translatedData) {
  55834. this[i] = translatedData[i];
  55835. }
  55836. this.options = options;
  55837. }
  55838. FontFaceObject.prototype = {
  55839. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55840. if (!this.data) {
  55841. return null;
  55842. }
  55843. if (this.options.disableFontFace) {
  55844. this.disableFontFace = true;
  55845. return null;
  55846. }
  55847. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55848. if (this.options.fontRegistry) {
  55849. this.options.fontRegistry.registerFont(this);
  55850. }
  55851. return nativeFontFace;
  55852. },
  55853. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55854. if (!this.data) {
  55855. return null;
  55856. }
  55857. if (this.options.disableFontFace) {
  55858. this.disableFontFace = true;
  55859. return null;
  55860. }
  55861. var data = bytesToString(new Uint8Array(this.data));
  55862. var fontName = this.loadedName;
  55863. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55864. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55865. if (this.options.fontRegistry) {
  55866. this.options.fontRegistry.registerFont(this, url);
  55867. }
  55868. return rule;
  55869. },
  55870. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55871. if (!(character in this.compiledGlyphs)) {
  55872. var cmds = objs.get(this.loadedName + '_path_' + character);
  55873. var current, i, len;
  55874. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55875. var args, js = '';
  55876. for (i = 0, len = cmds.length; i < len; i++) {
  55877. current = cmds[i];
  55878. if (current.args !== undefined) {
  55879. args = current.args.join(',');
  55880. } else {
  55881. args = '';
  55882. }
  55883. js += 'c.' + current.cmd + '(' + args + ');\n';
  55884. }
  55885. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55886. } else {
  55887. this.compiledGlyphs[character] = function (c, size) {
  55888. for (i = 0, len = cmds.length; i < len; i++) {
  55889. current = cmds[i];
  55890. if (current.cmd === 'scale') {
  55891. current.args = [
  55892. size,
  55893. -size
  55894. ];
  55895. }
  55896. c[current.cmd].apply(c, current.args);
  55897. }
  55898. };
  55899. }
  55900. }
  55901. return this.compiledGlyphs[character];
  55902. }
  55903. };
  55904. return FontFaceObject;
  55905. }();
  55906. exports.FontFaceObject = FontFaceObject;
  55907. exports.FontLoader = FontLoader;
  55908. /***/ }),
  55909. /* 46 */
  55910. /***/ (function(module, exports, __w_pdfjs_require__) {
  55911. "use strict";
  55912. var sharedUtil = __w_pdfjs_require__(0);
  55913. var displayWebGL = __w_pdfjs_require__(25);
  55914. var Util = sharedUtil.Util;
  55915. var info = sharedUtil.info;
  55916. var isArray = sharedUtil.isArray;
  55917. var error = sharedUtil.error;
  55918. var WebGLUtils = displayWebGL.WebGLUtils;
  55919. var ShadingIRs = {};
  55920. ShadingIRs.RadialAxial = {
  55921. fromIR: function RadialAxial_fromIR(raw) {
  55922. var type = raw[1];
  55923. var colorStops = raw[2];
  55924. var p0 = raw[3];
  55925. var p1 = raw[4];
  55926. var r0 = raw[5];
  55927. var r1 = raw[6];
  55928. return {
  55929. type: 'Pattern',
  55930. getPattern: function RadialAxial_getPattern(ctx) {
  55931. var grad;
  55932. if (type === 'axial') {
  55933. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55934. } else if (type === 'radial') {
  55935. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55936. }
  55937. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55938. var c = colorStops[i];
  55939. grad.addColorStop(c[0], c[1]);
  55940. }
  55941. return grad;
  55942. }
  55943. };
  55944. }
  55945. };
  55946. var createMeshCanvas = function createMeshCanvasClosure() {
  55947. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55948. var coords = context.coords, colors = context.colors;
  55949. var bytes = data.data, rowSize = data.width * 4;
  55950. var tmp;
  55951. if (coords[p1 + 1] > coords[p2 + 1]) {
  55952. tmp = p1;
  55953. p1 = p2;
  55954. p2 = tmp;
  55955. tmp = c1;
  55956. c1 = c2;
  55957. c2 = tmp;
  55958. }
  55959. if (coords[p2 + 1] > coords[p3 + 1]) {
  55960. tmp = p2;
  55961. p2 = p3;
  55962. p3 = tmp;
  55963. tmp = c2;
  55964. c2 = c3;
  55965. c3 = tmp;
  55966. }
  55967. if (coords[p1 + 1] > coords[p2 + 1]) {
  55968. tmp = p1;
  55969. p1 = p2;
  55970. p2 = tmp;
  55971. tmp = c1;
  55972. c1 = c2;
  55973. c2 = tmp;
  55974. }
  55975. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  55976. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  55977. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  55978. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  55979. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  55980. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  55981. if (y1 >= y3) {
  55982. return;
  55983. }
  55984. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  55985. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  55986. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  55987. var minY = Math.round(y1), maxY = Math.round(y3);
  55988. var xa, car, cag, cab;
  55989. var xb, cbr, cbg, cbb;
  55990. var k;
  55991. for (var y = minY; y <= maxY; y++) {
  55992. if (y < y2) {
  55993. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  55994. xa = x1 - (x1 - x2) * k;
  55995. car = c1r - (c1r - c2r) * k;
  55996. cag = c1g - (c1g - c2g) * k;
  55997. cab = c1b - (c1b - c2b) * k;
  55998. } else {
  55999. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56000. xa = x2 - (x2 - x3) * k;
  56001. car = c2r - (c2r - c3r) * k;
  56002. cag = c2g - (c2g - c3g) * k;
  56003. cab = c2b - (c2b - c3b) * k;
  56004. }
  56005. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56006. xb = x1 - (x1 - x3) * k;
  56007. cbr = c1r - (c1r - c3r) * k;
  56008. cbg = c1g - (c1g - c3g) * k;
  56009. cbb = c1b - (c1b - c3b) * k;
  56010. var x1_ = Math.round(Math.min(xa, xb));
  56011. var x2_ = Math.round(Math.max(xa, xb));
  56012. var j = rowSize * y + x1_ * 4;
  56013. for (var x = x1_; x <= x2_; x++) {
  56014. k = (xa - x) / (xa - xb);
  56015. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56016. bytes[j++] = car - (car - cbr) * k | 0;
  56017. bytes[j++] = cag - (cag - cbg) * k | 0;
  56018. bytes[j++] = cab - (cab - cbb) * k | 0;
  56019. bytes[j++] = 255;
  56020. }
  56021. }
  56022. }
  56023. function drawFigure(data, figure, context) {
  56024. var ps = figure.coords;
  56025. var cs = figure.colors;
  56026. var i, ii;
  56027. switch (figure.type) {
  56028. case 'lattice':
  56029. var verticesPerRow = figure.verticesPerRow;
  56030. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56031. var cols = verticesPerRow - 1;
  56032. for (i = 0; i < rows; i++) {
  56033. var q = i * verticesPerRow;
  56034. for (var j = 0; j < cols; j++, q++) {
  56035. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56036. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56037. }
  56038. }
  56039. break;
  56040. case 'triangles':
  56041. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56042. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56043. }
  56044. break;
  56045. default:
  56046. error('illigal figure');
  56047. break;
  56048. }
  56049. }
  56050. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56051. var EXPECTED_SCALE = 1.1;
  56052. var MAX_PATTERN_SIZE = 3000;
  56053. var BORDER_SIZE = 2;
  56054. var offsetX = Math.floor(bounds[0]);
  56055. var offsetY = Math.floor(bounds[1]);
  56056. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56057. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56058. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56059. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56060. var scaleX = boundsWidth / width;
  56061. var scaleY = boundsHeight / height;
  56062. var context = {
  56063. coords: coords,
  56064. colors: colors,
  56065. offsetX: -offsetX,
  56066. offsetY: -offsetY,
  56067. scaleX: 1 / scaleX,
  56068. scaleY: 1 / scaleY
  56069. };
  56070. var paddedWidth = width + BORDER_SIZE * 2;
  56071. var paddedHeight = height + BORDER_SIZE * 2;
  56072. var canvas, tmpCanvas, i, ii;
  56073. if (WebGLUtils.isEnabled) {
  56074. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56075. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56076. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56077. canvas = tmpCanvas.canvas;
  56078. } else {
  56079. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56080. var tmpCtx = tmpCanvas.context;
  56081. var data = tmpCtx.createImageData(width, height);
  56082. if (backgroundColor) {
  56083. var bytes = data.data;
  56084. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56085. bytes[i] = backgroundColor[0];
  56086. bytes[i + 1] = backgroundColor[1];
  56087. bytes[i + 2] = backgroundColor[2];
  56088. bytes[i + 3] = 255;
  56089. }
  56090. }
  56091. for (i = 0; i < figures.length; i++) {
  56092. drawFigure(data, figures[i], context);
  56093. }
  56094. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56095. canvas = tmpCanvas.canvas;
  56096. }
  56097. return {
  56098. canvas: canvas,
  56099. offsetX: offsetX - BORDER_SIZE * scaleX,
  56100. offsetY: offsetY - BORDER_SIZE * scaleY,
  56101. scaleX: scaleX,
  56102. scaleY: scaleY
  56103. };
  56104. }
  56105. return createMeshCanvas;
  56106. }();
  56107. ShadingIRs.Mesh = {
  56108. fromIR: function Mesh_fromIR(raw) {
  56109. var coords = raw[2];
  56110. var colors = raw[3];
  56111. var figures = raw[4];
  56112. var bounds = raw[5];
  56113. var matrix = raw[6];
  56114. var background = raw[8];
  56115. return {
  56116. type: 'Pattern',
  56117. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56118. var scale;
  56119. if (shadingFill) {
  56120. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56121. } else {
  56122. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56123. if (matrix) {
  56124. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56125. scale = [
  56126. scale[0] * matrixScale[0],
  56127. scale[1] * matrixScale[1]
  56128. ];
  56129. }
  56130. }
  56131. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56132. if (!shadingFill) {
  56133. ctx.setTransform.apply(ctx, owner.baseTransform);
  56134. if (matrix) {
  56135. ctx.transform.apply(ctx, matrix);
  56136. }
  56137. }
  56138. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56139. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56140. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56141. }
  56142. };
  56143. }
  56144. };
  56145. ShadingIRs.Dummy = {
  56146. fromIR: function Dummy_fromIR() {
  56147. return {
  56148. type: 'Pattern',
  56149. getPattern: function Dummy_fromIR_getPattern() {
  56150. return 'hotpink';
  56151. }
  56152. };
  56153. }
  56154. };
  56155. function getShadingPatternFromIR(raw) {
  56156. var shadingIR = ShadingIRs[raw[0]];
  56157. if (!shadingIR) {
  56158. error('Unknown IR type: ' + raw[0]);
  56159. }
  56160. return shadingIR.fromIR(raw);
  56161. }
  56162. var TilingPattern = function TilingPatternClosure() {
  56163. var PaintType = {
  56164. COLORED: 1,
  56165. UNCOLORED: 2
  56166. };
  56167. var MAX_PATTERN_SIZE = 3000;
  56168. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56169. this.operatorList = IR[2];
  56170. this.matrix = IR[3] || [
  56171. 1,
  56172. 0,
  56173. 0,
  56174. 1,
  56175. 0,
  56176. 0
  56177. ];
  56178. this.bbox = IR[4];
  56179. this.xstep = IR[5];
  56180. this.ystep = IR[6];
  56181. this.paintType = IR[7];
  56182. this.tilingType = IR[8];
  56183. this.color = color;
  56184. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56185. this.baseTransform = baseTransform;
  56186. this.type = 'Pattern';
  56187. this.ctx = ctx;
  56188. }
  56189. TilingPattern.prototype = {
  56190. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56191. var operatorList = this.operatorList;
  56192. var bbox = this.bbox;
  56193. var xstep = this.xstep;
  56194. var ystep = this.ystep;
  56195. var paintType = this.paintType;
  56196. var tilingType = this.tilingType;
  56197. var color = this.color;
  56198. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56199. info('TilingType: ' + tilingType);
  56200. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56201. var topLeft = [
  56202. x0,
  56203. y0
  56204. ];
  56205. var botRight = [
  56206. x0 + xstep,
  56207. y0 + ystep
  56208. ];
  56209. var width = botRight[0] - topLeft[0];
  56210. var height = botRight[1] - topLeft[1];
  56211. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56212. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56213. var combinedScale = [
  56214. matrixScale[0] * curMatrixScale[0],
  56215. matrixScale[1] * curMatrixScale[1]
  56216. ];
  56217. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56218. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56219. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56220. var tmpCtx = tmpCanvas.context;
  56221. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56222. graphics.groupLevel = owner.groupLevel;
  56223. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56224. this.setScale(width, height, xstep, ystep);
  56225. this.transformToScale(graphics);
  56226. var tmpTranslate = [
  56227. 1,
  56228. 0,
  56229. 0,
  56230. 1,
  56231. -topLeft[0],
  56232. -topLeft[1]
  56233. ];
  56234. graphics.transform.apply(graphics, tmpTranslate);
  56235. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56236. graphics.executeOperatorList(operatorList);
  56237. return tmpCanvas.canvas;
  56238. },
  56239. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56240. this.scale = [
  56241. width / xstep,
  56242. height / ystep
  56243. ];
  56244. },
  56245. transformToScale: function TilingPattern_transformToScale(graphics) {
  56246. var scale = this.scale;
  56247. var tmpScale = [
  56248. scale[0],
  56249. 0,
  56250. 0,
  56251. scale[1],
  56252. 0,
  56253. 0
  56254. ];
  56255. graphics.transform.apply(graphics, tmpScale);
  56256. },
  56257. scaleToContext: function TilingPattern_scaleToContext() {
  56258. var scale = this.scale;
  56259. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56260. },
  56261. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56262. if (bbox && isArray(bbox) && bbox.length === 4) {
  56263. var bboxWidth = x1 - x0;
  56264. var bboxHeight = y1 - y0;
  56265. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56266. graphics.clip();
  56267. graphics.endPath();
  56268. }
  56269. },
  56270. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56271. switch (paintType) {
  56272. case PaintType.COLORED:
  56273. var ctx = this.ctx;
  56274. context.fillStyle = ctx.fillStyle;
  56275. context.strokeStyle = ctx.strokeStyle;
  56276. break;
  56277. case PaintType.UNCOLORED:
  56278. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56279. context.fillStyle = cssColor;
  56280. context.strokeStyle = cssColor;
  56281. break;
  56282. default:
  56283. error('Unsupported paint type: ' + paintType);
  56284. }
  56285. },
  56286. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56287. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56288. ctx = this.ctx;
  56289. ctx.setTransform.apply(ctx, this.baseTransform);
  56290. ctx.transform.apply(ctx, this.matrix);
  56291. this.scaleToContext();
  56292. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56293. }
  56294. };
  56295. return TilingPattern;
  56296. }();
  56297. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56298. exports.TilingPattern = TilingPattern;
  56299. /***/ }),
  56300. /* 47 */
  56301. /***/ (function(module, exports, __w_pdfjs_require__) {
  56302. "use strict";
  56303. /* WEBPACK VAR INJECTION */(function(global) {
  56304. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56305. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56306. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56307. var isAndroid = /Android/.test(userAgent);
  56308. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56309. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56310. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56311. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56312. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56313. var isIE = userAgent.indexOf('Trident') >= 0;
  56314. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56315. var isOpera = userAgent.indexOf('Opera') >= 0;
  56316. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56317. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56318. if (typeof PDFJS === 'undefined') {
  56319. globalScope.PDFJS = {};
  56320. }
  56321. PDFJS.compatibilityChecked = true;
  56322. (function checkTypedArrayCompatibility() {
  56323. if (typeof Uint8Array !== 'undefined') {
  56324. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56325. Uint8Array.prototype.subarray = function subarray(start, end) {
  56326. return new Uint8Array(this.slice(start, end));
  56327. };
  56328. Float32Array.prototype.subarray = function subarray(start, end) {
  56329. return new Float32Array(this.slice(start, end));
  56330. };
  56331. }
  56332. if (typeof Float64Array === 'undefined') {
  56333. globalScope.Float64Array = Float32Array;
  56334. }
  56335. return;
  56336. }
  56337. function subarray(start, end) {
  56338. return new TypedArray(this.slice(start, end));
  56339. }
  56340. function setArrayOffset(array, offset) {
  56341. if (arguments.length < 2) {
  56342. offset = 0;
  56343. }
  56344. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56345. this[offset] = array[i] & 0xFF;
  56346. }
  56347. }
  56348. function TypedArray(arg1) {
  56349. var result, i, n;
  56350. if (typeof arg1 === 'number') {
  56351. result = [];
  56352. for (i = 0; i < arg1; ++i) {
  56353. result[i] = 0;
  56354. }
  56355. } else if ('slice' in arg1) {
  56356. result = arg1.slice(0);
  56357. } else {
  56358. result = [];
  56359. for (i = 0, n = arg1.length; i < n; ++i) {
  56360. result[i] = arg1[i];
  56361. }
  56362. }
  56363. result.subarray = subarray;
  56364. result.buffer = result;
  56365. result.byteLength = result.length;
  56366. result.set = setArrayOffset;
  56367. if (typeof arg1 === 'object' && arg1.buffer) {
  56368. result.buffer = arg1.buffer;
  56369. }
  56370. return result;
  56371. }
  56372. globalScope.Uint8Array = TypedArray;
  56373. globalScope.Int8Array = TypedArray;
  56374. globalScope.Uint32Array = TypedArray;
  56375. globalScope.Int32Array = TypedArray;
  56376. globalScope.Uint16Array = TypedArray;
  56377. globalScope.Float32Array = TypedArray;
  56378. globalScope.Float64Array = TypedArray;
  56379. }());
  56380. (function normalizeURLObject() {
  56381. if (!globalScope.URL) {
  56382. globalScope.URL = globalScope.webkitURL;
  56383. }
  56384. }());
  56385. (function checkObjectDefinePropertyCompatibility() {
  56386. if (typeof Object.defineProperty !== 'undefined') {
  56387. var definePropertyPossible = true;
  56388. try {
  56389. if (hasDOM) {
  56390. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56391. }
  56392. var Test = function Test() {
  56393. };
  56394. Test.prototype = {
  56395. get id() {
  56396. }
  56397. };
  56398. Object.defineProperty(new Test(), 'id', {
  56399. value: '',
  56400. configurable: true,
  56401. enumerable: true,
  56402. writable: false
  56403. });
  56404. } catch (e) {
  56405. definePropertyPossible = false;
  56406. }
  56407. if (definePropertyPossible) {
  56408. return;
  56409. }
  56410. }
  56411. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56412. delete obj[name];
  56413. if ('get' in def) {
  56414. obj.__defineGetter__(name, def['get']);
  56415. }
  56416. if ('set' in def) {
  56417. obj.__defineSetter__(name, def['set']);
  56418. }
  56419. if ('value' in def) {
  56420. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56421. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56422. return value;
  56423. });
  56424. return value;
  56425. });
  56426. obj[name] = def.value;
  56427. }
  56428. };
  56429. }());
  56430. (function checkXMLHttpRequestResponseCompatibility() {
  56431. if (typeof XMLHttpRequest === 'undefined') {
  56432. return;
  56433. }
  56434. var xhrPrototype = XMLHttpRequest.prototype;
  56435. var xhr = new XMLHttpRequest();
  56436. if (!('overrideMimeType' in xhr)) {
  56437. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56438. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56439. }
  56440. });
  56441. }
  56442. if ('responseType' in xhr) {
  56443. return;
  56444. }
  56445. Object.defineProperty(xhrPrototype, 'responseType', {
  56446. get: function xmlHttpRequestGetResponseType() {
  56447. return this._responseType || 'text';
  56448. },
  56449. set: function xmlHttpRequestSetResponseType(value) {
  56450. if (value === 'text' || value === 'arraybuffer') {
  56451. this._responseType = value;
  56452. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56453. this.overrideMimeType('text/plain; charset=x-user-defined');
  56454. }
  56455. }
  56456. }
  56457. });
  56458. if (typeof VBArray !== 'undefined') {
  56459. Object.defineProperty(xhrPrototype, 'response', {
  56460. get: function xmlHttpRequestResponseGet() {
  56461. if (this.responseType === 'arraybuffer') {
  56462. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56463. }
  56464. return this.responseText;
  56465. }
  56466. });
  56467. return;
  56468. }
  56469. Object.defineProperty(xhrPrototype, 'response', {
  56470. get: function xmlHttpRequestResponseGet() {
  56471. if (this.responseType !== 'arraybuffer') {
  56472. return this.responseText;
  56473. }
  56474. var text = this.responseText;
  56475. var i, n = text.length;
  56476. var result = new Uint8Array(n);
  56477. for (i = 0; i < n; ++i) {
  56478. result[i] = text.charCodeAt(i) & 0xFF;
  56479. }
  56480. return result.buffer;
  56481. }
  56482. });
  56483. }());
  56484. (function checkWindowBtoaCompatibility() {
  56485. if ('btoa' in globalScope) {
  56486. return;
  56487. }
  56488. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56489. globalScope.btoa = function (chars) {
  56490. var buffer = '';
  56491. var i, n;
  56492. for (i = 0, n = chars.length; i < n; i += 3) {
  56493. var b1 = chars.charCodeAt(i) & 0xFF;
  56494. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56495. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56496. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56497. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56498. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56499. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56500. }
  56501. return buffer;
  56502. };
  56503. }());
  56504. (function checkWindowAtobCompatibility() {
  56505. if ('atob' in globalScope) {
  56506. return;
  56507. }
  56508. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56509. globalScope.atob = function (input) {
  56510. input = input.replace(/=+$/, '');
  56511. if (input.length % 4 === 1) {
  56512. throw new Error('bad atob input');
  56513. }
  56514. 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) {
  56515. buffer = digits.indexOf(buffer);
  56516. }
  56517. return output;
  56518. };
  56519. }());
  56520. (function checkFunctionPrototypeBindCompatibility() {
  56521. if (typeof Function.prototype.bind !== 'undefined') {
  56522. return;
  56523. }
  56524. Function.prototype.bind = function functionPrototypeBind(obj) {
  56525. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56526. var bound = function functionPrototypeBindBound() {
  56527. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56528. return fn.apply(obj, args);
  56529. };
  56530. return bound;
  56531. };
  56532. }());
  56533. (function checkDatasetProperty() {
  56534. if (!hasDOM) {
  56535. return;
  56536. }
  56537. var div = document.createElement('div');
  56538. if ('dataset' in div) {
  56539. return;
  56540. }
  56541. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56542. get: function () {
  56543. if (this._dataset) {
  56544. return this._dataset;
  56545. }
  56546. var dataset = {};
  56547. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56548. var attribute = this.attributes[j];
  56549. if (attribute.name.substring(0, 5) !== 'data-') {
  56550. continue;
  56551. }
  56552. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56553. return ch.toUpperCase();
  56554. });
  56555. dataset[key] = attribute.value;
  56556. }
  56557. Object.defineProperty(this, '_dataset', {
  56558. value: dataset,
  56559. writable: false,
  56560. enumerable: false
  56561. });
  56562. return dataset;
  56563. },
  56564. enumerable: true
  56565. });
  56566. }());
  56567. (function checkClassListProperty() {
  56568. function changeList(element, itemName, add, remove) {
  56569. var s = element.className || '';
  56570. var list = s.split(/\s+/g);
  56571. if (list[0] === '') {
  56572. list.shift();
  56573. }
  56574. var index = list.indexOf(itemName);
  56575. if (index < 0 && add) {
  56576. list.push(itemName);
  56577. }
  56578. if (index >= 0 && remove) {
  56579. list.splice(index, 1);
  56580. }
  56581. element.className = list.join(' ');
  56582. return index >= 0;
  56583. }
  56584. if (!hasDOM) {
  56585. return;
  56586. }
  56587. var div = document.createElement('div');
  56588. if ('classList' in div) {
  56589. return;
  56590. }
  56591. var classListPrototype = {
  56592. add: function (name) {
  56593. changeList(this.element, name, true, false);
  56594. },
  56595. contains: function (name) {
  56596. return changeList(this.element, name, false, false);
  56597. },
  56598. remove: function (name) {
  56599. changeList(this.element, name, false, true);
  56600. },
  56601. toggle: function (name) {
  56602. changeList(this.element, name, true, true);
  56603. }
  56604. };
  56605. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56606. get: function () {
  56607. if (this._classList) {
  56608. return this._classList;
  56609. }
  56610. var classList = Object.create(classListPrototype, {
  56611. element: {
  56612. value: this,
  56613. writable: false,
  56614. enumerable: true
  56615. }
  56616. });
  56617. Object.defineProperty(this, '_classList', {
  56618. value: classList,
  56619. writable: false,
  56620. enumerable: false
  56621. });
  56622. return classList;
  56623. },
  56624. enumerable: true
  56625. });
  56626. }());
  56627. (function checkWorkerConsoleCompatibility() {
  56628. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56629. return;
  56630. }
  56631. var consoleTimer = {};
  56632. var workerConsole = {
  56633. log: function log() {
  56634. var args = Array.prototype.slice.call(arguments);
  56635. globalScope.postMessage({
  56636. targetName: 'main',
  56637. action: 'console_log',
  56638. data: args
  56639. });
  56640. },
  56641. error: function error() {
  56642. var args = Array.prototype.slice.call(arguments);
  56643. globalScope.postMessage({
  56644. targetName: 'main',
  56645. action: 'console_error',
  56646. data: args
  56647. });
  56648. },
  56649. time: function time(name) {
  56650. consoleTimer[name] = Date.now();
  56651. },
  56652. timeEnd: function timeEnd(name) {
  56653. var time = consoleTimer[name];
  56654. if (!time) {
  56655. throw new Error('Unknown timer name ' + name);
  56656. }
  56657. this.log('Timer:', name, Date.now() - time);
  56658. }
  56659. };
  56660. globalScope.console = workerConsole;
  56661. }());
  56662. (function checkConsoleCompatibility() {
  56663. if (!hasDOM) {
  56664. return;
  56665. }
  56666. if (!('console' in window)) {
  56667. window.console = {
  56668. log: function () {
  56669. },
  56670. error: function () {
  56671. },
  56672. warn: function () {
  56673. }
  56674. };
  56675. return;
  56676. }
  56677. if (!('bind' in console.log)) {
  56678. console.log = function (fn) {
  56679. return function (msg) {
  56680. return fn(msg);
  56681. };
  56682. }(console.log);
  56683. console.error = function (fn) {
  56684. return function (msg) {
  56685. return fn(msg);
  56686. };
  56687. }(console.error);
  56688. console.warn = function (fn) {
  56689. return function (msg) {
  56690. return fn(msg);
  56691. };
  56692. }(console.warn);
  56693. return;
  56694. }
  56695. }());
  56696. (function checkOnClickCompatibility() {
  56697. function ignoreIfTargetDisabled(event) {
  56698. if (isDisabled(event.target)) {
  56699. event.stopPropagation();
  56700. }
  56701. }
  56702. function isDisabled(node) {
  56703. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56704. }
  56705. if (isOpera) {
  56706. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56707. }
  56708. }());
  56709. (function checkOnBlobSupport() {
  56710. if (isIE || isIOSChrome) {
  56711. PDFJS.disableCreateObjectURL = true;
  56712. }
  56713. }());
  56714. (function checkNavigatorLanguage() {
  56715. if (typeof navigator === 'undefined') {
  56716. return;
  56717. }
  56718. if ('language' in navigator) {
  56719. return;
  56720. }
  56721. PDFJS.locale = navigator.userLanguage || 'en-US';
  56722. }());
  56723. (function checkRangeRequests() {
  56724. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56725. PDFJS.disableRange = true;
  56726. PDFJS.disableStream = true;
  56727. }
  56728. }());
  56729. (function checkHistoryManipulation() {
  56730. if (!hasDOM) {
  56731. return;
  56732. }
  56733. if (!history.pushState || isAndroidPre3) {
  56734. PDFJS.disableHistory = true;
  56735. }
  56736. }());
  56737. (function checkSetPresenceInImageData() {
  56738. if (!hasDOM) {
  56739. return;
  56740. }
  56741. if (window.CanvasPixelArray) {
  56742. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56743. window.CanvasPixelArray.prototype.set = function (arr) {
  56744. for (var i = 0, ii = this.length; i < ii; i++) {
  56745. this[i] = arr[i];
  56746. }
  56747. };
  56748. }
  56749. } else {
  56750. var polyfill = false, versionMatch;
  56751. if (isChrome) {
  56752. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56753. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56754. } else if (isAndroid) {
  56755. polyfill = isAndroidPre5;
  56756. } else if (isSafari) {
  56757. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56758. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56759. }
  56760. if (polyfill) {
  56761. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56762. var createImageData = contextPrototype.createImageData;
  56763. contextPrototype.createImageData = function (w, h) {
  56764. var imageData = createImageData.call(this, w, h);
  56765. imageData.data.set = function (arr) {
  56766. for (var i = 0, ii = this.length; i < ii; i++) {
  56767. this[i] = arr[i];
  56768. }
  56769. };
  56770. return imageData;
  56771. };
  56772. contextPrototype = null;
  56773. }
  56774. }
  56775. }());
  56776. (function checkRequestAnimationFrame() {
  56777. function fakeRequestAnimationFrame(callback) {
  56778. window.setTimeout(callback, 20);
  56779. }
  56780. if (!hasDOM) {
  56781. return;
  56782. }
  56783. if (isIOS) {
  56784. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56785. return;
  56786. }
  56787. if ('requestAnimationFrame' in window) {
  56788. return;
  56789. }
  56790. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56791. }());
  56792. (function checkCanvasSizeLimitation() {
  56793. if (isIOS || isAndroid) {
  56794. PDFJS.maxCanvasPixels = 5242880;
  56795. }
  56796. }());
  56797. (function checkFullscreenSupport() {
  56798. if (!hasDOM) {
  56799. return;
  56800. }
  56801. if (isIE && window.parent !== window) {
  56802. PDFJS.disableFullscreen = true;
  56803. }
  56804. }());
  56805. (function checkCurrentScript() {
  56806. if (!hasDOM) {
  56807. return;
  56808. }
  56809. if ('currentScript' in document) {
  56810. return;
  56811. }
  56812. Object.defineProperty(document, 'currentScript', {
  56813. get: function () {
  56814. var scripts = document.getElementsByTagName('script');
  56815. return scripts[scripts.length - 1];
  56816. },
  56817. enumerable: true,
  56818. configurable: true
  56819. });
  56820. }());
  56821. (function checkInputTypeNumberAssign() {
  56822. if (!hasDOM) {
  56823. return;
  56824. }
  56825. var el = document.createElement('input');
  56826. try {
  56827. el.type = 'number';
  56828. } catch (ex) {
  56829. var inputProto = el.constructor.prototype;
  56830. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56831. Object.defineProperty(inputProto, 'type', {
  56832. get: function () {
  56833. return typeProperty.get.call(this);
  56834. },
  56835. set: function (value) {
  56836. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56837. },
  56838. enumerable: true,
  56839. configurable: true
  56840. });
  56841. }
  56842. }());
  56843. (function checkDocumentReadyState() {
  56844. if (!hasDOM) {
  56845. return;
  56846. }
  56847. if (!document.attachEvent) {
  56848. return;
  56849. }
  56850. var documentProto = document.constructor.prototype;
  56851. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56852. Object.defineProperty(documentProto, 'readyState', {
  56853. get: function () {
  56854. var value = readyStateProto.get.call(this);
  56855. return value === 'interactive' ? 'loading' : value;
  56856. },
  56857. set: function (value) {
  56858. readyStateProto.set.call(this, value);
  56859. },
  56860. enumerable: true,
  56861. configurable: true
  56862. });
  56863. }());
  56864. (function checkChildNodeRemove() {
  56865. if (!hasDOM) {
  56866. return;
  56867. }
  56868. if (typeof Element.prototype.remove !== 'undefined') {
  56869. return;
  56870. }
  56871. Element.prototype.remove = function () {
  56872. if (this.parentNode) {
  56873. this.parentNode.removeChild(this);
  56874. }
  56875. };
  56876. }());
  56877. (function checkPromise() {
  56878. if (globalScope.Promise) {
  56879. if (typeof globalScope.Promise.all !== 'function') {
  56880. globalScope.Promise.all = function (iterable) {
  56881. var count = 0, results = [], resolve, reject;
  56882. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56883. resolve = resolve_;
  56884. reject = reject_;
  56885. });
  56886. iterable.forEach(function (p, i) {
  56887. count++;
  56888. p.then(function (result) {
  56889. results[i] = result;
  56890. count--;
  56891. if (count === 0) {
  56892. resolve(results);
  56893. }
  56894. }, reject);
  56895. });
  56896. if (count === 0) {
  56897. resolve(results);
  56898. }
  56899. return promise;
  56900. };
  56901. }
  56902. if (typeof globalScope.Promise.resolve !== 'function') {
  56903. globalScope.Promise.resolve = function (value) {
  56904. return new globalScope.Promise(function (resolve) {
  56905. resolve(value);
  56906. });
  56907. };
  56908. }
  56909. if (typeof globalScope.Promise.reject !== 'function') {
  56910. globalScope.Promise.reject = function (reason) {
  56911. return new globalScope.Promise(function (resolve, reject) {
  56912. reject(reason);
  56913. });
  56914. };
  56915. }
  56916. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56917. globalScope.Promise.prototype.catch = function (onReject) {
  56918. return globalScope.Promise.prototype.then(undefined, onReject);
  56919. };
  56920. }
  56921. return;
  56922. }
  56923. var STATUS_PENDING = 0;
  56924. var STATUS_RESOLVED = 1;
  56925. var STATUS_REJECTED = 2;
  56926. var REJECTION_TIMEOUT = 500;
  56927. var HandlerManager = {
  56928. handlers: [],
  56929. running: false,
  56930. unhandledRejections: [],
  56931. pendingRejectionCheck: false,
  56932. scheduleHandlers: function scheduleHandlers(promise) {
  56933. if (promise._status === STATUS_PENDING) {
  56934. return;
  56935. }
  56936. this.handlers = this.handlers.concat(promise._handlers);
  56937. promise._handlers = [];
  56938. if (this.running) {
  56939. return;
  56940. }
  56941. this.running = true;
  56942. setTimeout(this.runHandlers.bind(this), 0);
  56943. },
  56944. runHandlers: function runHandlers() {
  56945. var RUN_TIMEOUT = 1;
  56946. var timeoutAt = Date.now() + RUN_TIMEOUT;
  56947. while (this.handlers.length > 0) {
  56948. var handler = this.handlers.shift();
  56949. var nextStatus = handler.thisPromise._status;
  56950. var nextValue = handler.thisPromise._value;
  56951. try {
  56952. if (nextStatus === STATUS_RESOLVED) {
  56953. if (typeof handler.onResolve === 'function') {
  56954. nextValue = handler.onResolve(nextValue);
  56955. }
  56956. } else if (typeof handler.onReject === 'function') {
  56957. nextValue = handler.onReject(nextValue);
  56958. nextStatus = STATUS_RESOLVED;
  56959. if (handler.thisPromise._unhandledRejection) {
  56960. this.removeUnhandeledRejection(handler.thisPromise);
  56961. }
  56962. }
  56963. } catch (ex) {
  56964. nextStatus = STATUS_REJECTED;
  56965. nextValue = ex;
  56966. }
  56967. handler.nextPromise._updateStatus(nextStatus, nextValue);
  56968. if (Date.now() >= timeoutAt) {
  56969. break;
  56970. }
  56971. }
  56972. if (this.handlers.length > 0) {
  56973. setTimeout(this.runHandlers.bind(this), 0);
  56974. return;
  56975. }
  56976. this.running = false;
  56977. },
  56978. addUnhandledRejection: function addUnhandledRejection(promise) {
  56979. this.unhandledRejections.push({
  56980. promise: promise,
  56981. time: Date.now()
  56982. });
  56983. this.scheduleRejectionCheck();
  56984. },
  56985. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  56986. promise._unhandledRejection = false;
  56987. for (var i = 0; i < this.unhandledRejections.length; i++) {
  56988. if (this.unhandledRejections[i].promise === promise) {
  56989. this.unhandledRejections.splice(i);
  56990. i--;
  56991. }
  56992. }
  56993. },
  56994. scheduleRejectionCheck: function scheduleRejectionCheck() {
  56995. if (this.pendingRejectionCheck) {
  56996. return;
  56997. }
  56998. this.pendingRejectionCheck = true;
  56999. setTimeout(function rejectionCheck() {
  57000. this.pendingRejectionCheck = false;
  57001. var now = Date.now();
  57002. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57003. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  57004. var unhandled = this.unhandledRejections[i].promise._value;
  57005. var msg = 'Unhandled rejection: ' + unhandled;
  57006. if (unhandled.stack) {
  57007. msg += '\n' + unhandled.stack;
  57008. }
  57009. try {
  57010. throw new Error(msg);
  57011. } catch (_) {
  57012. console.warn(msg);
  57013. }
  57014. this.unhandledRejections.splice(i);
  57015. i--;
  57016. }
  57017. }
  57018. if (this.unhandledRejections.length) {
  57019. this.scheduleRejectionCheck();
  57020. }
  57021. }.bind(this), REJECTION_TIMEOUT);
  57022. }
  57023. };
  57024. var Promise = function Promise(resolver) {
  57025. this._status = STATUS_PENDING;
  57026. this._handlers = [];
  57027. try {
  57028. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57029. } catch (e) {
  57030. this._reject(e);
  57031. }
  57032. };
  57033. Promise.all = function Promise_all(promises) {
  57034. var resolveAll, rejectAll;
  57035. var deferred = new Promise(function (resolve, reject) {
  57036. resolveAll = resolve;
  57037. rejectAll = reject;
  57038. });
  57039. var unresolved = promises.length;
  57040. var results = [];
  57041. if (unresolved === 0) {
  57042. resolveAll(results);
  57043. return deferred;
  57044. }
  57045. function reject(reason) {
  57046. if (deferred._status === STATUS_REJECTED) {
  57047. return;
  57048. }
  57049. results = [];
  57050. rejectAll(reason);
  57051. }
  57052. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57053. var promise = promises[i];
  57054. var resolve = function (i) {
  57055. return function (value) {
  57056. if (deferred._status === STATUS_REJECTED) {
  57057. return;
  57058. }
  57059. results[i] = value;
  57060. unresolved--;
  57061. if (unresolved === 0) {
  57062. resolveAll(results);
  57063. }
  57064. };
  57065. }(i);
  57066. if (Promise.isPromise(promise)) {
  57067. promise.then(resolve, reject);
  57068. } else {
  57069. resolve(promise);
  57070. }
  57071. }
  57072. return deferred;
  57073. };
  57074. Promise.isPromise = function Promise_isPromise(value) {
  57075. return value && typeof value.then === 'function';
  57076. };
  57077. Promise.resolve = function Promise_resolve(value) {
  57078. return new Promise(function (resolve) {
  57079. resolve(value);
  57080. });
  57081. };
  57082. Promise.reject = function Promise_reject(reason) {
  57083. return new Promise(function (resolve, reject) {
  57084. reject(reason);
  57085. });
  57086. };
  57087. Promise.prototype = {
  57088. _status: null,
  57089. _value: null,
  57090. _handlers: null,
  57091. _unhandledRejection: null,
  57092. _updateStatus: function Promise__updateStatus(status, value) {
  57093. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57094. return;
  57095. }
  57096. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57097. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57098. return;
  57099. }
  57100. this._status = status;
  57101. this._value = value;
  57102. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57103. this._unhandledRejection = true;
  57104. HandlerManager.addUnhandledRejection(this);
  57105. }
  57106. HandlerManager.scheduleHandlers(this);
  57107. },
  57108. _resolve: function Promise_resolve(value) {
  57109. this._updateStatus(STATUS_RESOLVED, value);
  57110. },
  57111. _reject: function Promise_reject(reason) {
  57112. this._updateStatus(STATUS_REJECTED, reason);
  57113. },
  57114. then: function Promise_then(onResolve, onReject) {
  57115. var nextPromise = new Promise(function (resolve, reject) {
  57116. this.resolve = resolve;
  57117. this.reject = reject;
  57118. });
  57119. this._handlers.push({
  57120. thisPromise: this,
  57121. onResolve: onResolve,
  57122. onReject: onReject,
  57123. nextPromise: nextPromise
  57124. });
  57125. HandlerManager.scheduleHandlers(this);
  57126. return nextPromise;
  57127. },
  57128. catch: function Promise_catch(onReject) {
  57129. return this.then(undefined, onReject);
  57130. }
  57131. };
  57132. globalScope.Promise = Promise;
  57133. }());
  57134. (function checkWeakMap() {
  57135. if (globalScope.WeakMap) {
  57136. return;
  57137. }
  57138. var id = 0;
  57139. function WeakMap() {
  57140. this.id = '$weakmap' + id++;
  57141. }
  57142. WeakMap.prototype = {
  57143. has: function (obj) {
  57144. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57145. },
  57146. get: function (obj, defaultValue) {
  57147. return this.has(obj) ? obj[this.id] : defaultValue;
  57148. },
  57149. set: function (obj, value) {
  57150. Object.defineProperty(obj, this.id, {
  57151. value: value,
  57152. enumerable: false,
  57153. configurable: true
  57154. });
  57155. },
  57156. delete: function (obj) {
  57157. delete obj[this.id];
  57158. }
  57159. };
  57160. globalScope.WeakMap = WeakMap;
  57161. }());
  57162. (function checkURLConstructor() {
  57163. var hasWorkingUrl = false;
  57164. try {
  57165. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57166. var u = new URL('b', 'http://a');
  57167. u.pathname = 'c%20d';
  57168. hasWorkingUrl = u.href === 'http://a/c%20d';
  57169. }
  57170. } catch (e) {
  57171. }
  57172. if (hasWorkingUrl) {
  57173. return;
  57174. }
  57175. var relative = Object.create(null);
  57176. relative['ftp'] = 21;
  57177. relative['file'] = 0;
  57178. relative['gopher'] = 70;
  57179. relative['http'] = 80;
  57180. relative['https'] = 443;
  57181. relative['ws'] = 80;
  57182. relative['wss'] = 443;
  57183. var relativePathDotMapping = Object.create(null);
  57184. relativePathDotMapping['%2e'] = '.';
  57185. relativePathDotMapping['.%2e'] = '..';
  57186. relativePathDotMapping['%2e.'] = '..';
  57187. relativePathDotMapping['%2e%2e'] = '..';
  57188. function isRelativeScheme(scheme) {
  57189. return relative[scheme] !== undefined;
  57190. }
  57191. function invalid() {
  57192. clear.call(this);
  57193. this._isInvalid = true;
  57194. }
  57195. function IDNAToASCII(h) {
  57196. if (h === '') {
  57197. invalid.call(this);
  57198. }
  57199. return h.toLowerCase();
  57200. }
  57201. function percentEscape(c) {
  57202. var unicode = c.charCodeAt(0);
  57203. if (unicode > 0x20 && unicode < 0x7F && [
  57204. 0x22,
  57205. 0x23,
  57206. 0x3C,
  57207. 0x3E,
  57208. 0x3F,
  57209. 0x60
  57210. ].indexOf(unicode) === -1) {
  57211. return c;
  57212. }
  57213. return encodeURIComponent(c);
  57214. }
  57215. function percentEscapeQuery(c) {
  57216. var unicode = c.charCodeAt(0);
  57217. if (unicode > 0x20 && unicode < 0x7F && [
  57218. 0x22,
  57219. 0x23,
  57220. 0x3C,
  57221. 0x3E,
  57222. 0x60
  57223. ].indexOf(unicode) === -1) {
  57224. return c;
  57225. }
  57226. return encodeURIComponent(c);
  57227. }
  57228. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57229. function parse(input, stateOverride, base) {
  57230. function err(message) {
  57231. errors.push(message);
  57232. }
  57233. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57234. loop:
  57235. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57236. var c = input[cursor];
  57237. switch (state) {
  57238. case 'scheme start':
  57239. if (c && ALPHA.test(c)) {
  57240. buffer += c.toLowerCase();
  57241. state = 'scheme';
  57242. } else if (!stateOverride) {
  57243. buffer = '';
  57244. state = 'no scheme';
  57245. continue;
  57246. } else {
  57247. err('Invalid scheme.');
  57248. break loop;
  57249. }
  57250. break;
  57251. case 'scheme':
  57252. if (c && ALPHANUMERIC.test(c)) {
  57253. buffer += c.toLowerCase();
  57254. } else if (c === ':') {
  57255. this._scheme = buffer;
  57256. buffer = '';
  57257. if (stateOverride) {
  57258. break loop;
  57259. }
  57260. if (isRelativeScheme(this._scheme)) {
  57261. this._isRelative = true;
  57262. }
  57263. if (this._scheme === 'file') {
  57264. state = 'relative';
  57265. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57266. state = 'relative or authority';
  57267. } else if (this._isRelative) {
  57268. state = 'authority first slash';
  57269. } else {
  57270. state = 'scheme data';
  57271. }
  57272. } else if (!stateOverride) {
  57273. buffer = '';
  57274. cursor = 0;
  57275. state = 'no scheme';
  57276. continue;
  57277. } else if (EOF === c) {
  57278. break loop;
  57279. } else {
  57280. err('Code point not allowed in scheme: ' + c);
  57281. break loop;
  57282. }
  57283. break;
  57284. case 'scheme data':
  57285. if (c === '?') {
  57286. this._query = '?';
  57287. state = 'query';
  57288. } else if (c === '#') {
  57289. this._fragment = '#';
  57290. state = 'fragment';
  57291. } else {
  57292. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57293. this._schemeData += percentEscape(c);
  57294. }
  57295. }
  57296. break;
  57297. case 'no scheme':
  57298. if (!base || !isRelativeScheme(base._scheme)) {
  57299. err('Missing scheme.');
  57300. invalid.call(this);
  57301. } else {
  57302. state = 'relative';
  57303. continue;
  57304. }
  57305. break;
  57306. case 'relative or authority':
  57307. if (c === '/' && input[cursor + 1] === '/') {
  57308. state = 'authority ignore slashes';
  57309. } else {
  57310. err('Expected /, got: ' + c);
  57311. state = 'relative';
  57312. continue;
  57313. }
  57314. break;
  57315. case 'relative':
  57316. this._isRelative = true;
  57317. if ('file' !== this._scheme) {
  57318. this._scheme = base._scheme;
  57319. }
  57320. if (EOF === c) {
  57321. this._host = base._host;
  57322. this._port = base._port;
  57323. this._path = base._path.slice();
  57324. this._query = base._query;
  57325. this._username = base._username;
  57326. this._password = base._password;
  57327. break loop;
  57328. } else if (c === '/' || c === '\\') {
  57329. if (c === '\\') {
  57330. err('\\ is an invalid code point.');
  57331. }
  57332. state = 'relative slash';
  57333. } else if (c === '?') {
  57334. this._host = base._host;
  57335. this._port = base._port;
  57336. this._path = base._path.slice();
  57337. this._query = '?';
  57338. this._username = base._username;
  57339. this._password = base._password;
  57340. state = 'query';
  57341. } else if (c === '#') {
  57342. this._host = base._host;
  57343. this._port = base._port;
  57344. this._path = base._path.slice();
  57345. this._query = base._query;
  57346. this._fragment = '#';
  57347. this._username = base._username;
  57348. this._password = base._password;
  57349. state = 'fragment';
  57350. } else {
  57351. var nextC = input[cursor + 1];
  57352. var nextNextC = input[cursor + 2];
  57353. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  57354. this._host = base._host;
  57355. this._port = base._port;
  57356. this._username = base._username;
  57357. this._password = base._password;
  57358. this._path = base._path.slice();
  57359. this._path.pop();
  57360. }
  57361. state = 'relative path';
  57362. continue;
  57363. }
  57364. break;
  57365. case 'relative slash':
  57366. if (c === '/' || c === '\\') {
  57367. if (c === '\\') {
  57368. err('\\ is an invalid code point.');
  57369. }
  57370. if (this._scheme === 'file') {
  57371. state = 'file host';
  57372. } else {
  57373. state = 'authority ignore slashes';
  57374. }
  57375. } else {
  57376. if ('file' !== this._scheme) {
  57377. this._host = base._host;
  57378. this._port = base._port;
  57379. this._username = base._username;
  57380. this._password = base._password;
  57381. }
  57382. state = 'relative path';
  57383. continue;
  57384. }
  57385. break;
  57386. case 'authority first slash':
  57387. if (c === '/') {
  57388. state = 'authority second slash';
  57389. } else {
  57390. err('Expected \'/\', got: ' + c);
  57391. state = 'authority ignore slashes';
  57392. continue;
  57393. }
  57394. break;
  57395. case 'authority second slash':
  57396. state = 'authority ignore slashes';
  57397. if ('/' !== c) {
  57398. err('Expected \'/\', got: ' + c);
  57399. continue;
  57400. }
  57401. break;
  57402. case 'authority ignore slashes':
  57403. if ('/' !== c && '\\' !== c) {
  57404. state = 'authority';
  57405. continue;
  57406. } else {
  57407. err('Expected authority, got: ' + c);
  57408. }
  57409. break;
  57410. case 'authority':
  57411. if (c === '@') {
  57412. if (seenAt) {
  57413. err('@ already seen.');
  57414. buffer += '%40';
  57415. }
  57416. seenAt = true;
  57417. for (var i = 0; i < buffer.length; i++) {
  57418. var cp = buffer[i];
  57419. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57420. err('Invalid whitespace in authority.');
  57421. continue;
  57422. }
  57423. if (cp === ':' && this._password === null) {
  57424. this._password = '';
  57425. continue;
  57426. }
  57427. var tempC = percentEscape(cp);
  57428. if (null !== this._password) {
  57429. this._password += tempC;
  57430. } else {
  57431. this._username += tempC;
  57432. }
  57433. }
  57434. buffer = '';
  57435. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57436. cursor -= buffer.length;
  57437. buffer = '';
  57438. state = 'host';
  57439. continue;
  57440. } else {
  57441. buffer += c;
  57442. }
  57443. break;
  57444. case 'file host':
  57445. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57446. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57447. state = 'relative path';
  57448. } else if (buffer.length === 0) {
  57449. state = 'relative path start';
  57450. } else {
  57451. this._host = IDNAToASCII.call(this, buffer);
  57452. buffer = '';
  57453. state = 'relative path start';
  57454. }
  57455. continue;
  57456. } else if (c === '\t' || c === '\n' || c === '\r') {
  57457. err('Invalid whitespace in file host.');
  57458. } else {
  57459. buffer += c;
  57460. }
  57461. break;
  57462. case 'host':
  57463. case 'hostname':
  57464. if (c === ':' && !seenBracket) {
  57465. this._host = IDNAToASCII.call(this, buffer);
  57466. buffer = '';
  57467. state = 'port';
  57468. if (stateOverride === 'hostname') {
  57469. break loop;
  57470. }
  57471. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57472. this._host = IDNAToASCII.call(this, buffer);
  57473. buffer = '';
  57474. state = 'relative path start';
  57475. if (stateOverride) {
  57476. break loop;
  57477. }
  57478. continue;
  57479. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57480. if (c === '[') {
  57481. seenBracket = true;
  57482. } else if (c === ']') {
  57483. seenBracket = false;
  57484. }
  57485. buffer += c;
  57486. } else {
  57487. err('Invalid code point in host/hostname: ' + c);
  57488. }
  57489. break;
  57490. case 'port':
  57491. if (/[0-9]/.test(c)) {
  57492. buffer += c;
  57493. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57494. if ('' !== buffer) {
  57495. var temp = parseInt(buffer, 10);
  57496. if (temp !== relative[this._scheme]) {
  57497. this._port = temp + '';
  57498. }
  57499. buffer = '';
  57500. }
  57501. if (stateOverride) {
  57502. break loop;
  57503. }
  57504. state = 'relative path start';
  57505. continue;
  57506. } else if (c === '\t' || c === '\n' || c === '\r') {
  57507. err('Invalid code point in port: ' + c);
  57508. } else {
  57509. invalid.call(this);
  57510. }
  57511. break;
  57512. case 'relative path start':
  57513. if (c === '\\') {
  57514. err('\'\\\' not allowed in path.');
  57515. }
  57516. state = 'relative path';
  57517. if ('/' !== c && '\\' !== c) {
  57518. continue;
  57519. }
  57520. break;
  57521. case 'relative path':
  57522. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57523. if (c === '\\') {
  57524. err('\\ not allowed in relative path.');
  57525. }
  57526. var tmp;
  57527. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57528. buffer = tmp;
  57529. }
  57530. if (buffer === '..') {
  57531. this._path.pop();
  57532. if ('/' !== c && '\\' !== c) {
  57533. this._path.push('');
  57534. }
  57535. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  57536. this._path.push('');
  57537. } else if ('.' !== buffer) {
  57538. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57539. buffer = buffer[0] + ':';
  57540. }
  57541. this._path.push(buffer);
  57542. }
  57543. buffer = '';
  57544. if (c === '?') {
  57545. this._query = '?';
  57546. state = 'query';
  57547. } else if (c === '#') {
  57548. this._fragment = '#';
  57549. state = 'fragment';
  57550. }
  57551. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57552. buffer += percentEscape(c);
  57553. }
  57554. break;
  57555. case 'query':
  57556. if (!stateOverride && c === '#') {
  57557. this._fragment = '#';
  57558. state = 'fragment';
  57559. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57560. this._query += percentEscapeQuery(c);
  57561. }
  57562. break;
  57563. case 'fragment':
  57564. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57565. this._fragment += c;
  57566. }
  57567. break;
  57568. }
  57569. cursor++;
  57570. }
  57571. }
  57572. function clear() {
  57573. this._scheme = '';
  57574. this._schemeData = '';
  57575. this._username = '';
  57576. this._password = null;
  57577. this._host = '';
  57578. this._port = '';
  57579. this._path = [];
  57580. this._query = '';
  57581. this._fragment = '';
  57582. this._isInvalid = false;
  57583. this._isRelative = false;
  57584. }
  57585. function JURL(url, base) {
  57586. if (base !== undefined && !(base instanceof JURL)) {
  57587. base = new JURL(String(base));
  57588. }
  57589. this._url = url;
  57590. clear.call(this);
  57591. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57592. parse.call(this, input, null, base);
  57593. }
  57594. JURL.prototype = {
  57595. toString: function () {
  57596. return this.href;
  57597. },
  57598. get href() {
  57599. if (this._isInvalid) {
  57600. return this._url;
  57601. }
  57602. var authority = '';
  57603. if ('' !== this._username || null !== this._password) {
  57604. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  57605. }
  57606. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57607. },
  57608. set href(href) {
  57609. clear.call(this);
  57610. parse.call(this, href);
  57611. },
  57612. get protocol() {
  57613. return this._scheme + ':';
  57614. },
  57615. set protocol(protocol) {
  57616. if (this._isInvalid) {
  57617. return;
  57618. }
  57619. parse.call(this, protocol + ':', 'scheme start');
  57620. },
  57621. get host() {
  57622. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57623. },
  57624. set host(host) {
  57625. if (this._isInvalid || !this._isRelative) {
  57626. return;
  57627. }
  57628. parse.call(this, host, 'host');
  57629. },
  57630. get hostname() {
  57631. return this._host;
  57632. },
  57633. set hostname(hostname) {
  57634. if (this._isInvalid || !this._isRelative) {
  57635. return;
  57636. }
  57637. parse.call(this, hostname, 'hostname');
  57638. },
  57639. get port() {
  57640. return this._port;
  57641. },
  57642. set port(port) {
  57643. if (this._isInvalid || !this._isRelative) {
  57644. return;
  57645. }
  57646. parse.call(this, port, 'port');
  57647. },
  57648. get pathname() {
  57649. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57650. },
  57651. set pathname(pathname) {
  57652. if (this._isInvalid || !this._isRelative) {
  57653. return;
  57654. }
  57655. this._path = [];
  57656. parse.call(this, pathname, 'relative path start');
  57657. },
  57658. get search() {
  57659. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57660. },
  57661. set search(search) {
  57662. if (this._isInvalid || !this._isRelative) {
  57663. return;
  57664. }
  57665. this._query = '?';
  57666. if (search[0] === '?') {
  57667. search = search.slice(1);
  57668. }
  57669. parse.call(this, search, 'query');
  57670. },
  57671. get hash() {
  57672. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57673. },
  57674. set hash(hash) {
  57675. if (this._isInvalid) {
  57676. return;
  57677. }
  57678. this._fragment = '#';
  57679. if (hash[0] === '#') {
  57680. hash = hash.slice(1);
  57681. }
  57682. parse.call(this, hash, 'fragment');
  57683. },
  57684. get origin() {
  57685. var host;
  57686. if (this._isInvalid || !this._scheme) {
  57687. return '';
  57688. }
  57689. switch (this._scheme) {
  57690. case 'data':
  57691. case 'file':
  57692. case 'javascript':
  57693. case 'mailto':
  57694. return 'null';
  57695. }
  57696. host = this.host;
  57697. if (!host) {
  57698. return '';
  57699. }
  57700. return this._scheme + '://' + host;
  57701. }
  57702. };
  57703. var OriginalURL = globalScope.URL;
  57704. if (OriginalURL) {
  57705. JURL.createObjectURL = function (blob) {
  57706. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57707. };
  57708. JURL.revokeObjectURL = function (url) {
  57709. OriginalURL.revokeObjectURL(url);
  57710. };
  57711. }
  57712. globalScope.URL = JURL;
  57713. }());
  57714. }
  57715. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57716. /***/ }),
  57717. /* 48 */
  57718. /***/ (function(module, exports, __w_pdfjs_require__) {
  57719. "use strict";
  57720. var pdfjsVersion = '1.7.331';
  57721. var pdfjsBuild = 'b75d53a7';
  57722. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57723. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57724. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57725. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57726. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57727. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57728. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57729. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57730. exports.build = pdfjsDisplayAPI.build;
  57731. exports.version = pdfjsDisplayAPI.version;
  57732. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57733. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57734. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57735. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57736. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57737. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57738. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57739. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57740. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57741. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57742. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57743. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57744. exports.OPS = pdfjsSharedUtil.OPS;
  57745. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57746. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57747. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57748. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57749. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57750. exports.shadow = pdfjsSharedUtil.shadow;
  57751. exports.createBlob = pdfjsSharedUtil.createBlob;
  57752. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57753. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57754. /***/ })
  57755. /******/ ]);
  57756. });