html2canvas.esm.js 346 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026
  1. /*!
  2. * html2canvas 1.0.0-rc.5 <https://html2canvas.hertzen.com>
  3. * Copyright (c) 2019 Niklas von Hertzen <https://hertzen.com>
  4. * Released under MIT License
  5. */
  6. /*! *****************************************************************************
  7. Copyright (c) Microsoft Corporation. All rights reserved.
  8. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  9. this file except in compliance with the License. You may obtain a copy of the
  10. License at http://www.apache.org/licenses/LICENSE-2.0
  11. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  13. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  14. MERCHANTABLITY OR NON-INFRINGEMENT.
  15. See the Apache Version 2.0 License for specific language governing permissions
  16. and limitations under the License.
  17. ***************************************************************************** */
  18. /* global Reflect, Promise */
  19. var extendStatics = function(d, b) {
  20. extendStatics = Object.setPrototypeOf ||
  21. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23. return extendStatics(d, b);
  24. };
  25. function __extends(d, b) {
  26. extendStatics(d, b);
  27. function __() { this.constructor = d; }
  28. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29. }
  30. var __assign = function() {
  31. __assign = Object.assign || function __assign(t) {
  32. for (var s, i = 1, n = arguments.length; i < n; i++) {
  33. s = arguments[i];
  34. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  35. }
  36. return t;
  37. };
  38. return __assign.apply(this, arguments);
  39. };
  40. function __awaiter(thisArg, _arguments, P, generator) {
  41. return new (P || (P = Promise))(function (resolve, reject) {
  42. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  43. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  44. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  45. step((generator = generator.apply(thisArg, _arguments || [])).next());
  46. });
  47. }
  48. function __generator(thisArg, body) {
  49. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  50. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  51. function verb(n) { return function (v) { return step([n, v]); }; }
  52. function step(op) {
  53. if (f) throw new TypeError("Generator is already executing.");
  54. while (_) try {
  55. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  56. if (y = 0, t) op = [op[0] & 2, t.value];
  57. switch (op[0]) {
  58. case 0: case 1: t = op; break;
  59. case 4: _.label++; return { value: op[1], done: false };
  60. case 5: _.label++; y = op[1]; op = [0]; continue;
  61. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  62. default:
  63. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  64. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  65. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  66. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  67. if (t[2]) _.ops.pop();
  68. _.trys.pop(); continue;
  69. }
  70. op = body.call(thisArg, _);
  71. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  72. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  73. }
  74. }
  75. var Bounds = /** @class */ (function () {
  76. function Bounds(x, y, w, h) {
  77. this.left = x;
  78. this.top = y;
  79. this.width = w;
  80. this.height = h;
  81. }
  82. Bounds.prototype.add = function (x, y, w, h) {
  83. return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);
  84. };
  85. Bounds.fromClientRect = function (clientRect) {
  86. return new Bounds(clientRect.left, clientRect.top, clientRect.width, clientRect.height);
  87. };
  88. return Bounds;
  89. }());
  90. var parseBounds = function (node) {
  91. return Bounds.fromClientRect(node.getBoundingClientRect());
  92. };
  93. var parseDocumentSize = function (document) {
  94. var body = document.body;
  95. var documentElement = document.documentElement;
  96. if (!body || !documentElement) {
  97. throw new Error("Unable to get document size");
  98. }
  99. var width = Math.max(Math.max(body.scrollWidth, documentElement.scrollWidth), Math.max(body.offsetWidth, documentElement.offsetWidth), Math.max(body.clientWidth, documentElement.clientWidth));
  100. var height = Math.max(Math.max(body.scrollHeight, documentElement.scrollHeight), Math.max(body.offsetHeight, documentElement.offsetHeight), Math.max(body.clientHeight, documentElement.clientHeight));
  101. return new Bounds(0, 0, width, height);
  102. };
  103. /*
  104. * css-line-break 1.1.1 <https://github.com/niklasvh/css-line-break#readme>
  105. * Copyright (c) 2019 Niklas von Hertzen <https://hertzen.com>
  106. * Released under MIT License
  107. */
  108. var toCodePoints = function (str) {
  109. var codePoints = [];
  110. var i = 0;
  111. var length = str.length;
  112. while (i < length) {
  113. var value = str.charCodeAt(i++);
  114. if (value >= 0xd800 && value <= 0xdbff && i < length) {
  115. var extra = str.charCodeAt(i++);
  116. if ((extra & 0xfc00) === 0xdc00) {
  117. codePoints.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
  118. }
  119. else {
  120. codePoints.push(value);
  121. i--;
  122. }
  123. }
  124. else {
  125. codePoints.push(value);
  126. }
  127. }
  128. return codePoints;
  129. };
  130. var fromCodePoint = function () {
  131. var codePoints = [];
  132. for (var _i = 0; _i < arguments.length; _i++) {
  133. codePoints[_i] = arguments[_i];
  134. }
  135. if (String.fromCodePoint) {
  136. return String.fromCodePoint.apply(String, codePoints);
  137. }
  138. var length = codePoints.length;
  139. if (!length) {
  140. return '';
  141. }
  142. var codeUnits = [];
  143. var index = -1;
  144. var result = '';
  145. while (++index < length) {
  146. var codePoint = codePoints[index];
  147. if (codePoint <= 0xffff) {
  148. codeUnits.push(codePoint);
  149. }
  150. else {
  151. codePoint -= 0x10000;
  152. codeUnits.push((codePoint >> 10) + 0xd800, codePoint % 0x400 + 0xdc00);
  153. }
  154. if (index + 1 === length || codeUnits.length > 0x4000) {
  155. result += String.fromCharCode.apply(String, codeUnits);
  156. codeUnits.length = 0;
  157. }
  158. }
  159. return result;
  160. };
  161. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  162. // Use a lookup table to find the index.
  163. var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  164. for (var i = 0; i < chars.length; i++) {
  165. lookup[chars.charCodeAt(i)] = i;
  166. }
  167. var decode = function (base64) {
  168. var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  169. if (base64[base64.length - 1] === '=') {
  170. bufferLength--;
  171. if (base64[base64.length - 2] === '=') {
  172. bufferLength--;
  173. }
  174. }
  175. var buffer = typeof ArrayBuffer !== 'undefined' &&
  176. typeof Uint8Array !== 'undefined' &&
  177. typeof Uint8Array.prototype.slice !== 'undefined'
  178. ? new ArrayBuffer(bufferLength)
  179. : new Array(bufferLength);
  180. var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);
  181. for (i = 0; i < len; i += 4) {
  182. encoded1 = lookup[base64.charCodeAt(i)];
  183. encoded2 = lookup[base64.charCodeAt(i + 1)];
  184. encoded3 = lookup[base64.charCodeAt(i + 2)];
  185. encoded4 = lookup[base64.charCodeAt(i + 3)];
  186. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  187. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  188. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  189. }
  190. return buffer;
  191. };
  192. var polyUint16Array = function (buffer) {
  193. var length = buffer.length;
  194. var bytes = [];
  195. for (var i = 0; i < length; i += 2) {
  196. bytes.push((buffer[i + 1] << 8) | buffer[i]);
  197. }
  198. return bytes;
  199. };
  200. var polyUint32Array = function (buffer) {
  201. var length = buffer.length;
  202. var bytes = [];
  203. for (var i = 0; i < length; i += 4) {
  204. bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);
  205. }
  206. return bytes;
  207. };
  208. /** Shift size for getting the index-2 table offset. */
  209. var UTRIE2_SHIFT_2 = 5;
  210. /** Shift size for getting the index-1 table offset. */
  211. var UTRIE2_SHIFT_1 = 6 + 5;
  212. /**
  213. * Shift size for shifting left the index array values.
  214. * Increases possible data size with 16-bit index values at the cost
  215. * of compactability.
  216. * This requires data blocks to be aligned by UTRIE2_DATA_GRANULARITY.
  217. */
  218. var UTRIE2_INDEX_SHIFT = 2;
  219. /**
  220. * Difference between the two shift sizes,
  221. * for getting an index-1 offset from an index-2 offset. 6=11-5
  222. */
  223. var UTRIE2_SHIFT_1_2 = UTRIE2_SHIFT_1 - UTRIE2_SHIFT_2;
  224. /**
  225. * The part of the index-2 table for U+D800..U+DBFF stores values for
  226. * lead surrogate code _units_ not code _points_.
  227. * Values for lead surrogate code _points_ are indexed with this portion of the table.
  228. * Length=32=0x20=0x400>>UTRIE2_SHIFT_2. (There are 1024=0x400 lead surrogates.)
  229. */
  230. var UTRIE2_LSCP_INDEX_2_OFFSET = 0x10000 >> UTRIE2_SHIFT_2;
  231. /** Number of entries in a data block. 32=0x20 */
  232. var UTRIE2_DATA_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_2;
  233. /** Mask for getting the lower bits for the in-data-block offset. */
  234. var UTRIE2_DATA_MASK = UTRIE2_DATA_BLOCK_LENGTH - 1;
  235. var UTRIE2_LSCP_INDEX_2_LENGTH = 0x400 >> UTRIE2_SHIFT_2;
  236. /** Count the lengths of both BMP pieces. 2080=0x820 */
  237. var UTRIE2_INDEX_2_BMP_LENGTH = UTRIE2_LSCP_INDEX_2_OFFSET + UTRIE2_LSCP_INDEX_2_LENGTH;
  238. /**
  239. * The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.
  240. * Length 32=0x20 for lead bytes C0..DF, regardless of UTRIE2_SHIFT_2.
  241. */
  242. var UTRIE2_UTF8_2B_INDEX_2_OFFSET = UTRIE2_INDEX_2_BMP_LENGTH;
  243. var UTRIE2_UTF8_2B_INDEX_2_LENGTH = 0x800 >> 6; /* U+0800 is the first code point after 2-byte UTF-8 */
  244. /**
  245. * The index-1 table, only used for supplementary code points, at offset 2112=0x840.
  246. * Variable length, for code points up to highStart, where the last single-value range starts.
  247. * Maximum length 512=0x200=0x100000>>UTRIE2_SHIFT_1.
  248. * (For 0x100000 supplementary code points U+10000..U+10ffff.)
  249. *
  250. * The part of the index-2 table for supplementary code points starts
  251. * after this index-1 table.
  252. *
  253. * Both the index-1 table and the following part of the index-2 table
  254. * are omitted completely if there is only BMP data.
  255. */
  256. var UTRIE2_INDEX_1_OFFSET = UTRIE2_UTF8_2B_INDEX_2_OFFSET + UTRIE2_UTF8_2B_INDEX_2_LENGTH;
  257. /**
  258. * Number of index-1 entries for the BMP. 32=0x20
  259. * This part of the index-1 table is omitted from the serialized form.
  260. */
  261. var UTRIE2_OMITTED_BMP_INDEX_1_LENGTH = 0x10000 >> UTRIE2_SHIFT_1;
  262. /** Number of entries in an index-2 block. 64=0x40 */
  263. var UTRIE2_INDEX_2_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_1_2;
  264. /** Mask for getting the lower bits for the in-index-2-block offset. */
  265. var UTRIE2_INDEX_2_MASK = UTRIE2_INDEX_2_BLOCK_LENGTH - 1;
  266. var slice16 = function (view, start, end) {
  267. if (view.slice) {
  268. return view.slice(start, end);
  269. }
  270. return new Uint16Array(Array.prototype.slice.call(view, start, end));
  271. };
  272. var slice32 = function (view, start, end) {
  273. if (view.slice) {
  274. return view.slice(start, end);
  275. }
  276. return new Uint32Array(Array.prototype.slice.call(view, start, end));
  277. };
  278. var createTrieFromBase64 = function (base64) {
  279. var buffer = decode(base64);
  280. var view32 = Array.isArray(buffer) ? polyUint32Array(buffer) : new Uint32Array(buffer);
  281. var view16 = Array.isArray(buffer) ? polyUint16Array(buffer) : new Uint16Array(buffer);
  282. var headerLength = 24;
  283. var index = slice16(view16, headerLength / 2, view32[4] / 2);
  284. var data = view32[5] === 2
  285. ? slice16(view16, (headerLength + view32[4]) / 2)
  286. : slice32(view32, Math.ceil((headerLength + view32[4]) / 4));
  287. return new Trie(view32[0], view32[1], view32[2], view32[3], index, data);
  288. };
  289. var Trie = /** @class */ (function () {
  290. function Trie(initialValue, errorValue, highStart, highValueIndex, index, data) {
  291. this.initialValue = initialValue;
  292. this.errorValue = errorValue;
  293. this.highStart = highStart;
  294. this.highValueIndex = highValueIndex;
  295. this.index = index;
  296. this.data = data;
  297. }
  298. /**
  299. * Get the value for a code point as stored in the Trie.
  300. *
  301. * @param codePoint the code point
  302. * @return the value
  303. */
  304. Trie.prototype.get = function (codePoint) {
  305. var ix;
  306. if (codePoint >= 0) {
  307. if (codePoint < 0x0d800 || (codePoint > 0x0dbff && codePoint <= 0x0ffff)) {
  308. // Ordinary BMP code point, excluding leading surrogates.
  309. // BMP uses a single level lookup. BMP index starts at offset 0 in the Trie2 index.
  310. // 16 bit data is stored in the index array itself.
  311. ix = this.index[codePoint >> UTRIE2_SHIFT_2];
  312. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  313. return this.data[ix];
  314. }
  315. if (codePoint <= 0xffff) {
  316. // Lead Surrogate Code Point. A Separate index section is stored for
  317. // lead surrogate code units and code points.
  318. // The main index has the code unit data.
  319. // For this function, we need the code point data.
  320. // Note: this expression could be refactored for slightly improved efficiency, but
  321. // surrogate code points will be so rare in practice that it's not worth it.
  322. ix = this.index[UTRIE2_LSCP_INDEX_2_OFFSET + ((codePoint - 0xd800) >> UTRIE2_SHIFT_2)];
  323. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  324. return this.data[ix];
  325. }
  326. if (codePoint < this.highStart) {
  327. // Supplemental code point, use two-level lookup.
  328. ix = UTRIE2_INDEX_1_OFFSET - UTRIE2_OMITTED_BMP_INDEX_1_LENGTH + (codePoint >> UTRIE2_SHIFT_1);
  329. ix = this.index[ix];
  330. ix += (codePoint >> UTRIE2_SHIFT_2) & UTRIE2_INDEX_2_MASK;
  331. ix = this.index[ix];
  332. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  333. return this.data[ix];
  334. }
  335. if (codePoint <= 0x10ffff) {
  336. return this.data[this.highValueIndex];
  337. }
  338. }
  339. // Fall through. The code point is outside of the legal range of 0..0x10ffff.
  340. return this.errorValue;
  341. };
  342. return Trie;
  343. }());
  344. var base64 = 'KwAAAAAAAAAACA4AIDoAAPAfAAACAAAAAAAIABAAGABAAEgAUABYAF4AZgBeAGYAYABoAHAAeABeAGYAfACEAIAAiACQAJgAoACoAK0AtQC9AMUAXgBmAF4AZgBeAGYAzQDVAF4AZgDRANkA3gDmAOwA9AD8AAQBDAEUARoBIgGAAIgAJwEvATcBPwFFAU0BTAFUAVwBZAFsAXMBewGDATAAiwGTAZsBogGkAawBtAG8AcIBygHSAdoB4AHoAfAB+AH+AQYCDgIWAv4BHgImAi4CNgI+AkUCTQJTAlsCYwJrAnECeQKBAk0CiQKRApkCoQKoArACuALAAsQCzAIwANQC3ALkAjAA7AL0AvwCAQMJAxADGAMwACADJgMuAzYDPgOAAEYDSgNSA1IDUgNaA1oDYANiA2IDgACAAGoDgAByA3YDfgOAAIQDgACKA5IDmgOAAIAAogOqA4AAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAK8DtwOAAIAAvwPHA88D1wPfAyAD5wPsA/QD/AOAAIAABAQMBBIEgAAWBB4EJgQuBDMEIAM7BEEEXgBJBCADUQRZBGEEaQQwADAAcQQ+AXkEgQSJBJEEgACYBIAAoASoBK8EtwQwAL8ExQSAAIAAgACAAIAAgACgAM0EXgBeAF4AXgBeAF4AXgBeANUEXgDZBOEEXgDpBPEE+QQBBQkFEQUZBSEFKQUxBTUFPQVFBUwFVAVcBV4AYwVeAGsFcwV7BYMFiwWSBV4AmgWgBacFXgBeAF4AXgBeAKsFXgCyBbEFugW7BcIFwgXIBcIFwgXQBdQF3AXkBesF8wX7BQMGCwYTBhsGIwYrBjMGOwZeAD8GRwZNBl4AVAZbBl4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAGMGXgBqBnEGXgBeAF4AXgBeAF4AXgBeAF4AXgB5BoAG4wSGBo4GkwaAAIADHgR5AF4AXgBeAJsGgABGA4AAowarBrMGswagALsGwwbLBjAA0wbaBtoG3QbaBtoG2gbaBtoG2gblBusG8wb7BgMHCwcTBxsHCwcjBysHMAc1BzUHOgdCB9oGSgdSB1oHYAfaBloHaAfaBlIH2gbaBtoG2gbaBtoG2gbaBjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHbQdeAF4ANQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQd1B30HNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B4MH2gaKB68EgACAAIAAgACAAIAAgACAAI8HlwdeAJ8HpweAAIAArwe3B14AXgC/B8UHygcwANAH2AfgB4AA6AfwBz4B+AcACFwBCAgPCBcIogEYAR8IJwiAAC8INwg/CCADRwhPCFcIXwhnCEoDGgSAAIAAgABvCHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIhAiLCI4IMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAANQc1BzUHNQc1BzUHNQc1BzUHNQc1B54INQc1B6II2gaqCLIIugiAAIAAvgjGCIAAgACAAIAAgACAAIAAgACAAIAAywiHAYAA0wiAANkI3QjlCO0I9Aj8CIAAgACAAAIJCgkSCRoJIgknCTYHLwk3CZYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiAAIAAAAFAAXgBeAGAAcABeAHwAQACQAKAArQC9AJ4AXgBeAE0A3gBRAN4A7AD8AMwBGgEAAKcBNwEFAUwBXAF4QkhCmEKnArcCgAHHAsABz4LAAcABwAHAAd+C6ABoAG+C/4LAAcABwAHAAc+DF4MAAcAB54M3gweDV4Nng3eDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEeDqABVg6WDqABoQ6gAaABoAHXDvcONw/3DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DncPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB7cPPwlGCU4JMACAAIAAgABWCV4JYQmAAGkJcAl4CXwJgAkwADAAMAAwAIgJgACLCZMJgACZCZ8JowmrCYAAswkwAF4AXgB8AIAAuwkABMMJyQmAAM4JgADVCTAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAqwYWBNkIMAAwADAAMADdCeAJ6AnuCR4E9gkwAP4JBQoNCjAAMACAABUK0wiAAB0KJAosCjQKgAAwADwKQwqAAEsKvQmdCVMKWwowADAAgACAALcEMACAAGMKgABrCjAAMAAwADAAMAAwADAAMAAwADAAMAAeBDAAMAAwADAAMAAwADAAMAAwADAAMAAwAIkEPQFzCnoKiQSCCooKkAqJBJgKoAqkCokEGAGsCrQKvArBCjAAMADJCtEKFQHZCuEK/gHpCvEKMAAwADAAMACAAIwE+QowAIAAPwEBCzAAMAAwADAAMACAAAkLEQswAIAAPwEZCyELgAAOCCkLMAAxCzkLMAAwADAAMAAwADAAXgBeAEELMAAwADAAMAAwADAAMAAwAEkLTQtVC4AAXAtkC4AAiQkwADAAMAAwADAAMAAwADAAbAtxC3kLgAuFC4sLMAAwAJMLlwufCzAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAApwswADAAMACAAIAAgACvC4AAgACAAIAAgACAALcLMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAvwuAAMcLgACAAIAAgACAAIAAyguAAIAAgACAAIAA0QswADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAANkLgACAAIAA4AswADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACJCR4E6AswADAAhwHwC4AA+AsADAgMEAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMACAAIAAGAwdDCUMMAAwAC0MNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQw1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHPQwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADUHNQc1BzUHNQc1BzUHNQc2BzAAMAA5DDUHNQc1BzUHNQc1BzUHNQc1BzUHNQdFDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAATQxSDFoMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAF4AXgBeAF4AXgBeAF4AYgxeAGoMXgBxDHkMfwxeAIUMXgBeAI0MMAAwADAAMAAwAF4AXgCVDJ0MMAAwADAAMABeAF4ApQxeAKsMswy7DF4Awgy9DMoMXgBeAF4AXgBeAF4AXgBeAF4AXgDRDNkMeQBqCeAM3Ax8AOYM7Az0DPgMXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgCgAAANoAAHDQ4NFg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAeDSYNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAC4NMABeAF4ANg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAD4NRg1ODVYNXg1mDTAAbQ0wADAAMAAwADAAMAAwADAA2gbaBtoG2gbaBtoG2gbaBnUNeg3CBYANwgWFDdoGjA3aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gaUDZwNpA2oDdoG2gawDbcNvw3HDdoG2gbPDdYN3A3fDeYN2gbsDfMN2gbaBvoN/g3aBgYODg7aBl4AXgBeABYOXgBeACUG2gYeDl4AJA5eACwO2w3aBtoGMQ45DtoG2gbaBtoGQQ7aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B1EO2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQdZDjUHNQc1BzUHNQc1B2EONQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHaA41BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B3AO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B2EO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBkkOeA6gAKAAoAAwADAAMAAwAKAAoACgAKAAoACgAKAAgA4wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAD//wQABAAEAAQABAAEAAQABAAEAA0AAwABAAEAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAKABMAFwAeABsAGgAeABcAFgASAB4AGwAYAA8AGAAcAEsASwBLAEsASwBLAEsASwBLAEsAGAAYAB4AHgAeABMAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAFgAbABIAHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYADQARAB4ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkAFgAaABsAGwAbAB4AHQAdAB4ATwAXAB4ADQAeAB4AGgAbAE8ATwAOAFAAHQAdAB0ATwBPABcATwBPAE8AFgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwArAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAAQABAANAA0ASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAUAArACsAKwArACsAKwArACsABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAGgAaAFAAUABQAFAAUABMAB4AGwBQAB4AKwArACsABAAEAAQAKwBQAFAAUABQAFAAUAArACsAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUAArAFAAUAArACsABAArAAQABAAEAAQABAArACsAKwArAAQABAArACsABAAEAAQAKwArACsABAArACsAKwArACsAKwArAFAAUABQAFAAKwBQACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwAEAAQAUABQAFAABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQAKwArAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeABsAKwArACsAKwArACsAKwBQAAQABAAEAAQABAAEACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAKwArACsAKwArACsAKwArAAQABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwAEAFAAKwBQAFAAUABQAFAAUAArACsAKwBQAFAAUAArAFAAUABQAFAAKwArACsAUABQACsAUAArAFAAUAArACsAKwBQAFAAKwArACsAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQAKwArACsABAAEAAQAKwAEAAQABAAEACsAKwBQACsAKwArACsAKwArAAQAKwArACsAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAB4AHgAeAB4AHgAeABsAHgArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArAFAAUABQACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAB4AUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArACsAKwArACsAKwArAFAAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwArAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAKwBcAFwAKwBcACsAKwBcACsAKwArACsAKwArAFwAXABcAFwAKwBcAFwAXABcAFwAXABcACsAXABcAFwAKwBcACsAXAArACsAXABcACsAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgArACoAKgBcACsAKwBcAFwAXABcAFwAKwBcACsAKgAqACoAKgAqACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAFwAXABcAFwAUAAOAA4ADgAOAB4ADgAOAAkADgAOAA0ACQATABMAEwATABMACQAeABMAHgAeAB4ABAAEAB4AHgAeAB4AHgAeAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUAANAAQAHgAEAB4ABAAWABEAFgARAAQABABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAAQABAAEAAQABAANAAQABABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsADQANAB4AHgAeAB4AHgAeAAQAHgAeAB4AHgAeAB4AKwAeAB4ADgAOAA0ADgAeAB4AHgAeAB4ACQAJACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgAeAB4AHgBcAFwAXABcAFwAXAAqACoAKgAqAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAKgAqACoAKgAqACoAKgBcAFwAXAAqACoAKgAqAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAXAAqAEsASwBLAEsASwBLAEsASwBLAEsAKgAqACoAKgAqACoAUABQAFAAUABQAFAAKwBQACsAKwArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQACsAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwAEAAQABAAeAA0AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAEQArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAADQANAA0AUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAA0ADQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoADQANABUAXAANAB4ADQAbAFwAKgArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAB4AHgATABMADQANAA4AHgATABMAHgAEAAQABAAJACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAUABQAFAAUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwAeACsAKwArABMAEwBLAEsASwBLAEsASwBLAEsASwBLAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwBcAFwAXABcAFwAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcACsAKwArACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwAeAB4AXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsABABLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKgAqACoAKgAqACoAKgBcACoAKgAqACoAKgAqACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAUABQAFAAUABQAFAAUAArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4ADQANAA0ADQAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAHgAeAB4AHgBQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwANAA0ADQANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwBQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsABAAEAAQAHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAABABQAFAAUABQAAQABAAEAFAAUAAEAAQABAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAKwBQACsAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAKwArAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAKwAeAB4AHgAeAB4AHgAeAA4AHgArAA0ADQANAA0ADQANAA0ACQANAA0ADQAIAAQACwAEAAQADQAJAA0ADQAMAB0AHQAeABcAFwAWABcAFwAXABYAFwAdAB0AHgAeABQAFAAUAA0AAQABAAQABAAEAAQABAAJABoAGgAaABoAGgAaABoAGgAeABcAFwAdABUAFQAeAB4AHgAeAB4AHgAYABYAEQAVABUAFQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgANAB4ADQANAA0ADQAeAA0ADQANAAcAHgAeAB4AHgArAAQABAAEAAQABAAEAAQABAAEAAQAUABQACsAKwBPAFAAUABQAFAAUAAeAB4AHgAWABEATwBQAE8ATwBPAE8AUABQAFAAUABQAB4AHgAeABYAEQArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGgAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgBQABoAHgAdAB4AUAAeABoAHgAeAB4AHgAeAB4AHgAeAB4ATwAeAFAAGwAeAB4AUABQAFAAUABQAB4AHgAeAB0AHQAeAFAAHgBQAB4AUAAeAFAATwBQAFAAHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AUABQAFAAUABPAE8AUABQAFAAUABQAE8AUABQAE8AUABPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAE8ATwBPAE8ATwBPAE8ATwBPAE8AUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAATwAeAB4AKwArACsAKwAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB0AHQAeAB4AHgAdAB0AHgAeAB0AHgAeAB4AHQAeAB0AGwAbAB4AHQAeAB4AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB0AHgAdAB4AHQAdAB0AHQAdAB0AHgAdAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAdAB0AHQAdAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAlACUAHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB0AHQAeAB4AHgAeAB0AHQAdAB4AHgAdAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB0AHQAeAB4AHQAeAB4AHgAeAB0AHQAeAB4AHgAeACUAJQAdAB0AJQAeACUAJQAlACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHQAdAB0AHgAdACUAHQAdAB4AHQAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHQAdAB0AHQAlAB4AJQAlACUAHQAlACUAHQAdAB0AJQAlAB0AHQAlAB0AHQAlACUAJQAeAB0AHgAeAB4AHgAdAB0AJQAdAB0AHQAdAB0AHQAlACUAJQAlACUAHQAlACUAIAAlAB0AHQAlACUAJQAlACUAJQAlACUAHgAeAB4AJQAlACAAIAAgACAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeABcAFwAXABcAFwAXAB4AEwATACUAHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACUAJQBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwArACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAE8ATwBPAE8ATwBPAE8ATwAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeACsAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUAArACsAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQBQAFAAUABQACsAKwArACsAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAABAAEAAQAKwAEAAQAKwArACsAKwArAAQABAAEAAQAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsABAAEAAQAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsADQANAA0ADQANAA0ADQANAB4AKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAUABQAFAAUABQAA0ADQANAA0ADQANABQAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwANAA0ADQANAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAeAAQABAAEAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLACsADQArAB4AKwArAAQABAAEAAQAUABQAB4AUAArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwAEAAQABAAEAAQABAAEAAQABAAOAA0ADQATABMAHgAeAB4ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0AUABQAFAAUAAEAAQAKwArAAQADQANAB4AUAArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXABcAA0ADQANACoASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUAArACsAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANACsADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEcARwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwAeAAQABAANAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAEAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUAArACsAUAArACsAUABQACsAKwBQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAeAB4ADQANAA0ADQAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAArAAQABAArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAEAAQABAAEAAQABAAEACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAFgAWAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAKwBQACsAKwArACsAKwArAFAAKwArACsAKwBQACsAUAArAFAAKwBQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQACsAUAArAFAAKwBQACsAUABQACsAUAArACsAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAUABQAFAAUAArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUAArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAlACUAJQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeACUAJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeACUAJQAlACUAJQAeACUAJQAlACUAJQAgACAAIAAlACUAIAAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIQAhACEAIQAhACUAJQAgACAAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAIAAlACUAJQAlACAAJQAgACAAIAAgACAAIAAgACAAIAAlACUAJQAgACUAJQAlACUAIAAgACAAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeACUAHgAlAB4AJQAlACUAJQAlACAAJQAlACUAJQAeACUAHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAIAAgACAAIAAgAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFwAXABcAFQAVABUAHgAeAB4AHgAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAlACAAIAAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsA';
  345. /* @flow */
  346. var LETTER_NUMBER_MODIFIER = 50;
  347. // Non-tailorable Line Breaking Classes
  348. var BK = 1; // Cause a line break (after)
  349. var CR = 2; // Cause a line break (after), except between CR and LF
  350. var LF = 3; // Cause a line break (after)
  351. var CM = 4; // Prohibit a line break between the character and the preceding character
  352. var NL = 5; // Cause a line break (after)
  353. var WJ = 7; // Prohibit line breaks before and after
  354. var ZW = 8; // Provide a break opportunity
  355. var GL = 9; // Prohibit line breaks before and after
  356. var SP = 10; // Enable indirect line breaks
  357. var ZWJ = 11; // Prohibit line breaks within joiner sequences
  358. // Break Opportunities
  359. var B2 = 12; // Provide a line break opportunity before and after the character
  360. var BA = 13; // Generally provide a line break opportunity after the character
  361. var BB = 14; // Generally provide a line break opportunity before the character
  362. var HY = 15; // Provide a line break opportunity after the character, except in numeric context
  363. var CB = 16; // Provide a line break opportunity contingent on additional information
  364. // Characters Prohibiting Certain Breaks
  365. var CL = 17; // Prohibit line breaks before
  366. var CP = 18; // Prohibit line breaks before
  367. var EX = 19; // Prohibit line breaks before
  368. var IN = 20; // Allow only indirect line breaks between pairs
  369. var NS = 21; // Allow only indirect line breaks before
  370. var OP = 22; // Prohibit line breaks after
  371. var QU = 23; // Act like they are both opening and closing
  372. // Numeric Context
  373. var IS = 24; // Prevent breaks after any and before numeric
  374. var NU = 25; // Form numeric expressions for line breaking purposes
  375. var PO = 26; // Do not break following a numeric expression
  376. var PR = 27; // Do not break in front of a numeric expression
  377. var SY = 28; // Prevent a break before; and allow a break after
  378. // Other Characters
  379. var AI = 29; // Act like AL when the resolvedEAW is N; otherwise; act as ID
  380. var AL = 30; // Are alphabetic characters or symbols that are used with alphabetic characters
  381. var CJ = 31; // Treat as NS or ID for strict or normal breaking.
  382. var EB = 32; // Do not break from following Emoji Modifier
  383. var EM = 33; // Do not break from preceding Emoji Base
  384. var H2 = 34; // Form Korean syllable blocks
  385. var H3 = 35; // Form Korean syllable blocks
  386. var HL = 36; // Do not break around a following hyphen; otherwise act as Alphabetic
  387. var ID = 37; // Break before or after; except in some numeric context
  388. var JL = 38; // Form Korean syllable blocks
  389. var JV = 39; // Form Korean syllable blocks
  390. var JT = 40; // Form Korean syllable blocks
  391. var RI = 41; // Keep pairs together. For pairs; break before and after other classes
  392. var SA = 42; // Provide a line break opportunity contingent on additional, language-specific context analysis
  393. var XX = 43; // Have as yet unknown line breaking behavior or unassigned code positions
  394. var BREAK_MANDATORY = '!';
  395. var BREAK_NOT_ALLOWED = '×';
  396. var BREAK_ALLOWED = '÷';
  397. var UnicodeTrie = createTrieFromBase64(base64);
  398. var ALPHABETICS = [AL, HL];
  399. var HARD_LINE_BREAKS = [BK, CR, LF, NL];
  400. var SPACE = [SP, ZW];
  401. var PREFIX_POSTFIX = [PR, PO];
  402. var LINE_BREAKS = HARD_LINE_BREAKS.concat(SPACE);
  403. var KOREAN_SYLLABLE_BLOCK = [JL, JV, JT, H2, H3];
  404. var HYPHEN = [HY, BA];
  405. var codePointsToCharacterClasses = function (codePoints, lineBreak) {
  406. if (lineBreak === void 0) { lineBreak = 'strict'; }
  407. var types = [];
  408. var indicies = [];
  409. var categories = [];
  410. codePoints.forEach(function (codePoint, index) {
  411. var classType = UnicodeTrie.get(codePoint);
  412. if (classType > LETTER_NUMBER_MODIFIER) {
  413. categories.push(true);
  414. classType -= LETTER_NUMBER_MODIFIER;
  415. }
  416. else {
  417. categories.push(false);
  418. }
  419. if (['normal', 'auto', 'loose'].indexOf(lineBreak) !== -1) {
  420. // U+2010, – U+2013, 〜 U+301C, ゠ U+30A0
  421. if ([0x2010, 0x2013, 0x301c, 0x30a0].indexOf(codePoint) !== -1) {
  422. indicies.push(index);
  423. return types.push(CB);
  424. }
  425. }
  426. if (classType === CM || classType === ZWJ) {
  427. // LB10 Treat any remaining combining mark or ZWJ as AL.
  428. if (index === 0) {
  429. indicies.push(index);
  430. return types.push(AL);
  431. }
  432. // LB9 Do not break a combining character sequence; treat it as if it has the line breaking class of
  433. // the base character in all of the following rules. Treat ZWJ as if it were CM.
  434. var prev = types[index - 1];
  435. if (LINE_BREAKS.indexOf(prev) === -1) {
  436. indicies.push(indicies[index - 1]);
  437. return types.push(prev);
  438. }
  439. indicies.push(index);
  440. return types.push(AL);
  441. }
  442. indicies.push(index);
  443. if (classType === CJ) {
  444. return types.push(lineBreak === 'strict' ? NS : ID);
  445. }
  446. if (classType === SA) {
  447. return types.push(AL);
  448. }
  449. if (classType === AI) {
  450. return types.push(AL);
  451. }
  452. // For supplementary characters, a useful default is to treat characters in the range 10000..1FFFD as AL
  453. // and characters in the ranges 20000..2FFFD and 30000..3FFFD as ID, until the implementation can be revised
  454. // to take into account the actual line breaking properties for these characters.
  455. if (classType === XX) {
  456. if ((codePoint >= 0x20000 && codePoint <= 0x2fffd) || (codePoint >= 0x30000 && codePoint <= 0x3fffd)) {
  457. return types.push(ID);
  458. }
  459. else {
  460. return types.push(AL);
  461. }
  462. }
  463. types.push(classType);
  464. });
  465. return [indicies, types, categories];
  466. };
  467. var isAdjacentWithSpaceIgnored = function (a, b, currentIndex, classTypes) {
  468. var current = classTypes[currentIndex];
  469. if (Array.isArray(a) ? a.indexOf(current) !== -1 : a === current) {
  470. var i = currentIndex;
  471. while (i <= classTypes.length) {
  472. i++;
  473. var next = classTypes[i];
  474. if (next === b) {
  475. return true;
  476. }
  477. if (next !== SP) {
  478. break;
  479. }
  480. }
  481. }
  482. if (current === SP) {
  483. var i = currentIndex;
  484. while (i > 0) {
  485. i--;
  486. var prev = classTypes[i];
  487. if (Array.isArray(a) ? a.indexOf(prev) !== -1 : a === prev) {
  488. var n = currentIndex;
  489. while (n <= classTypes.length) {
  490. n++;
  491. var next = classTypes[n];
  492. if (next === b) {
  493. return true;
  494. }
  495. if (next !== SP) {
  496. break;
  497. }
  498. }
  499. }
  500. if (prev !== SP) {
  501. break;
  502. }
  503. }
  504. }
  505. return false;
  506. };
  507. var previousNonSpaceClassType = function (currentIndex, classTypes) {
  508. var i = currentIndex;
  509. while (i >= 0) {
  510. var type = classTypes[i];
  511. if (type === SP) {
  512. i--;
  513. }
  514. else {
  515. return type;
  516. }
  517. }
  518. return 0;
  519. };
  520. var _lineBreakAtIndex = function (codePoints, classTypes, indicies, index, forbiddenBreaks) {
  521. if (indicies[index] === 0) {
  522. return BREAK_NOT_ALLOWED;
  523. }
  524. var currentIndex = index - 1;
  525. if (Array.isArray(forbiddenBreaks) && forbiddenBreaks[currentIndex] === true) {
  526. return BREAK_NOT_ALLOWED;
  527. }
  528. var beforeIndex = currentIndex - 1;
  529. var afterIndex = currentIndex + 1;
  530. var current = classTypes[currentIndex];
  531. // LB4 Always break after hard line breaks.
  532. // LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.
  533. var before = beforeIndex >= 0 ? classTypes[beforeIndex] : 0;
  534. var next = classTypes[afterIndex];
  535. if (current === CR && next === LF) {
  536. return BREAK_NOT_ALLOWED;
  537. }
  538. if (HARD_LINE_BREAKS.indexOf(current) !== -1) {
  539. return BREAK_MANDATORY;
  540. }
  541. // LB6 Do not break before hard line breaks.
  542. if (HARD_LINE_BREAKS.indexOf(next) !== -1) {
  543. return BREAK_NOT_ALLOWED;
  544. }
  545. // LB7 Do not break before spaces or zero width space.
  546. if (SPACE.indexOf(next) !== -1) {
  547. return BREAK_NOT_ALLOWED;
  548. }
  549. // LB8 Break before any character following a zero-width space, even if one or more spaces intervene.
  550. if (previousNonSpaceClassType(currentIndex, classTypes) === ZW) {
  551. return BREAK_ALLOWED;
  552. }
  553. // LB8a Do not break between a zero width joiner and an ideograph, emoji base or emoji modifier.
  554. if (UnicodeTrie.get(codePoints[currentIndex]) === ZWJ && (next === ID || next === EB || next === EM)) {
  555. return BREAK_NOT_ALLOWED;
  556. }
  557. // LB11 Do not break before or after Word joiner and related characters.
  558. if (current === WJ || next === WJ) {
  559. return BREAK_NOT_ALLOWED;
  560. }
  561. // LB12 Do not break after NBSP and related characters.
  562. if (current === GL) {
  563. return BREAK_NOT_ALLOWED;
  564. }
  565. // LB12a Do not break before NBSP and related characters, except after spaces and hyphens.
  566. if ([SP, BA, HY].indexOf(current) === -1 && next === GL) {
  567. return BREAK_NOT_ALLOWED;
  568. }
  569. // LB13 Do not break before ‘]’ or ‘!’ or ‘;’ or ‘/’, even after spaces.
  570. if ([CL, CP, EX, IS, SY].indexOf(next) !== -1) {
  571. return BREAK_NOT_ALLOWED;
  572. }
  573. // LB14 Do not break after ‘[’, even after spaces.
  574. if (previousNonSpaceClassType(currentIndex, classTypes) === OP) {
  575. return BREAK_NOT_ALLOWED;
  576. }
  577. // LB15 Do not break within ‘”[’, even with intervening spaces.
  578. if (isAdjacentWithSpaceIgnored(QU, OP, currentIndex, classTypes)) {
  579. return BREAK_NOT_ALLOWED;
  580. }
  581. // LB16 Do not break between closing punctuation and a nonstarter (lb=NS), even with intervening spaces.
  582. if (isAdjacentWithSpaceIgnored([CL, CP], NS, currentIndex, classTypes)) {
  583. return BREAK_NOT_ALLOWED;
  584. }
  585. // LB17 Do not break within ‘——’, even with intervening spaces.
  586. if (isAdjacentWithSpaceIgnored(B2, B2, currentIndex, classTypes)) {
  587. return BREAK_NOT_ALLOWED;
  588. }
  589. // LB18 Break after spaces.
  590. if (current === SP) {
  591. return BREAK_ALLOWED;
  592. }
  593. // LB19 Do not break before or after quotation marks, such as ‘ ” ’.
  594. if (current === QU || next === QU) {
  595. return BREAK_NOT_ALLOWED;
  596. }
  597. // LB20 Break before and after unresolved CB.
  598. if (next === CB || current === CB) {
  599. return BREAK_ALLOWED;
  600. }
  601. // LB21 Do not break before hyphen-minus, other hyphens, fixed-width spaces, small kana, and other non-starters, or after acute accents.
  602. if ([BA, HY, NS].indexOf(next) !== -1 || current === BB) {
  603. return BREAK_NOT_ALLOWED;
  604. }
  605. // LB21a Don't break after Hebrew + Hyphen.
  606. if (before === HL && HYPHEN.indexOf(current) !== -1) {
  607. return BREAK_NOT_ALLOWED;
  608. }
  609. // LB21b Don’t break between Solidus and Hebrew letters.
  610. if (current === SY && next === HL) {
  611. return BREAK_NOT_ALLOWED;
  612. }
  613. // LB22 Do not break between two ellipses, or between letters, numbers or exclamations and ellipsis.
  614. if (next === IN && ALPHABETICS.concat(IN, EX, NU, ID, EB, EM).indexOf(current) !== -1) {
  615. return BREAK_NOT_ALLOWED;
  616. }
  617. // LB23 Do not break between digits and letters.
  618. if ((ALPHABETICS.indexOf(next) !== -1 && current === NU) || (ALPHABETICS.indexOf(current) !== -1 && next === NU)) {
  619. return BREAK_NOT_ALLOWED;
  620. }
  621. // LB23a Do not break between numeric prefixes and ideographs, or between ideographs and numeric postfixes.
  622. if ((current === PR && [ID, EB, EM].indexOf(next) !== -1) ||
  623. ([ID, EB, EM].indexOf(current) !== -1 && next === PO)) {
  624. return BREAK_NOT_ALLOWED;
  625. }
  626. // LB24 Do not break between numeric prefix/postfix and letters, or between letters and prefix/postfix.
  627. if ((ALPHABETICS.indexOf(current) !== -1 && PREFIX_POSTFIX.indexOf(next) !== -1) ||
  628. (PREFIX_POSTFIX.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1)) {
  629. return BREAK_NOT_ALLOWED;
  630. }
  631. // LB25 Do not break between the following pairs of classes relevant to numbers:
  632. if (
  633. // (PR | PO) × ( OP | HY )? NU
  634. ([PR, PO].indexOf(current) !== -1 &&
  635. (next === NU || ([OP, HY].indexOf(next) !== -1 && classTypes[afterIndex + 1] === NU))) ||
  636. // ( OP | HY ) × NU
  637. ([OP, HY].indexOf(current) !== -1 && next === NU) ||
  638. // NU × (NU | SY | IS)
  639. (current === NU && [NU, SY, IS].indexOf(next) !== -1)) {
  640. return BREAK_NOT_ALLOWED;
  641. }
  642. // NU (NU | SY | IS)* × (NU | SY | IS | CL | CP)
  643. if ([NU, SY, IS, CL, CP].indexOf(next) !== -1) {
  644. var prevIndex = currentIndex;
  645. while (prevIndex >= 0) {
  646. var type = classTypes[prevIndex];
  647. if (type === NU) {
  648. return BREAK_NOT_ALLOWED;
  649. }
  650. else if ([SY, IS].indexOf(type) !== -1) {
  651. prevIndex--;
  652. }
  653. else {
  654. break;
  655. }
  656. }
  657. }
  658. // NU (NU | SY | IS)* (CL | CP)? × (PO | PR))
  659. if ([PR, PO].indexOf(next) !== -1) {
  660. var prevIndex = [CL, CP].indexOf(current) !== -1 ? beforeIndex : currentIndex;
  661. while (prevIndex >= 0) {
  662. var type = classTypes[prevIndex];
  663. if (type === NU) {
  664. return BREAK_NOT_ALLOWED;
  665. }
  666. else if ([SY, IS].indexOf(type) !== -1) {
  667. prevIndex--;
  668. }
  669. else {
  670. break;
  671. }
  672. }
  673. }
  674. // LB26 Do not break a Korean syllable.
  675. if ((JL === current && [JL, JV, H2, H3].indexOf(next) !== -1) ||
  676. ([JV, H2].indexOf(current) !== -1 && [JV, JT].indexOf(next) !== -1) ||
  677. ([JT, H3].indexOf(current) !== -1 && next === JT)) {
  678. return BREAK_NOT_ALLOWED;
  679. }
  680. // LB27 Treat a Korean Syllable Block the same as ID.
  681. if ((KOREAN_SYLLABLE_BLOCK.indexOf(current) !== -1 && [IN, PO].indexOf(next) !== -1) ||
  682. (KOREAN_SYLLABLE_BLOCK.indexOf(next) !== -1 && current === PR)) {
  683. return BREAK_NOT_ALLOWED;
  684. }
  685. // LB28 Do not break between alphabetics (“at”).
  686. if (ALPHABETICS.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1) {
  687. return BREAK_NOT_ALLOWED;
  688. }
  689. // LB29 Do not break between numeric punctuation and alphabetics (“e.g.”).
  690. if (current === IS && ALPHABETICS.indexOf(next) !== -1) {
  691. return BREAK_NOT_ALLOWED;
  692. }
  693. // LB30 Do not break between letters, numbers, or ordinary symbols and opening or closing parentheses.
  694. if ((ALPHABETICS.concat(NU).indexOf(current) !== -1 && next === OP) ||
  695. (ALPHABETICS.concat(NU).indexOf(next) !== -1 && current === CP)) {
  696. return BREAK_NOT_ALLOWED;
  697. }
  698. // LB30a Break between two regional indicator symbols if and only if there are an even number of regional
  699. // indicators preceding the position of the break.
  700. if (current === RI && next === RI) {
  701. var i = indicies[currentIndex];
  702. var count = 1;
  703. while (i > 0) {
  704. i--;
  705. if (classTypes[i] === RI) {
  706. count++;
  707. }
  708. else {
  709. break;
  710. }
  711. }
  712. if (count % 2 !== 0) {
  713. return BREAK_NOT_ALLOWED;
  714. }
  715. }
  716. // LB30b Do not break between an emoji base and an emoji modifier.
  717. if (current === EB && next === EM) {
  718. return BREAK_NOT_ALLOWED;
  719. }
  720. return BREAK_ALLOWED;
  721. };
  722. var cssFormattedClasses = function (codePoints, options) {
  723. if (!options) {
  724. options = { lineBreak: 'normal', wordBreak: 'normal' };
  725. }
  726. var _a = codePointsToCharacterClasses(codePoints, options.lineBreak), indicies = _a[0], classTypes = _a[1], isLetterNumber = _a[2];
  727. if (options.wordBreak === 'break-all' || options.wordBreak === 'break-word') {
  728. classTypes = classTypes.map(function (type) { return ([NU, AL, SA].indexOf(type) !== -1 ? ID : type); });
  729. }
  730. var forbiddenBreakpoints = options.wordBreak === 'keep-all'
  731. ? isLetterNumber.map(function (letterNumber, i) {
  732. return letterNumber && codePoints[i] >= 0x4e00 && codePoints[i] <= 0x9fff;
  733. })
  734. : undefined;
  735. return [indicies, classTypes, forbiddenBreakpoints];
  736. };
  737. var Break = /** @class */ (function () {
  738. function Break(codePoints, lineBreak, start, end) {
  739. this.codePoints = codePoints;
  740. this.required = lineBreak === BREAK_MANDATORY;
  741. this.start = start;
  742. this.end = end;
  743. }
  744. Break.prototype.slice = function () {
  745. return fromCodePoint.apply(void 0, this.codePoints.slice(this.start, this.end));
  746. };
  747. return Break;
  748. }());
  749. var LineBreaker = function (str, options) {
  750. var codePoints = toCodePoints(str);
  751. var _a = cssFormattedClasses(codePoints, options), indicies = _a[0], classTypes = _a[1], forbiddenBreakpoints = _a[2];
  752. var length = codePoints.length;
  753. var lastEnd = 0;
  754. var nextIndex = 0;
  755. return {
  756. next: function () {
  757. if (nextIndex >= length) {
  758. return { done: true, value: null };
  759. }
  760. var lineBreak = BREAK_NOT_ALLOWED;
  761. while (nextIndex < length &&
  762. (lineBreak = _lineBreakAtIndex(codePoints, classTypes, indicies, ++nextIndex, forbiddenBreakpoints)) ===
  763. BREAK_NOT_ALLOWED) { }
  764. if (lineBreak !== BREAK_NOT_ALLOWED || nextIndex === length) {
  765. var value = new Break(codePoints, lineBreak, lastEnd, nextIndex);
  766. lastEnd = nextIndex;
  767. return { value: value, done: false };
  768. }
  769. return { done: true, value: null };
  770. },
  771. };
  772. };
  773. // https://www.w3.org/TR/css-syntax-3
  774. var TokenType;
  775. (function (TokenType) {
  776. TokenType[TokenType["STRING_TOKEN"] = 0] = "STRING_TOKEN";
  777. TokenType[TokenType["BAD_STRING_TOKEN"] = 1] = "BAD_STRING_TOKEN";
  778. TokenType[TokenType["LEFT_PARENTHESIS_TOKEN"] = 2] = "LEFT_PARENTHESIS_TOKEN";
  779. TokenType[TokenType["RIGHT_PARENTHESIS_TOKEN"] = 3] = "RIGHT_PARENTHESIS_TOKEN";
  780. TokenType[TokenType["COMMA_TOKEN"] = 4] = "COMMA_TOKEN";
  781. TokenType[TokenType["HASH_TOKEN"] = 5] = "HASH_TOKEN";
  782. TokenType[TokenType["DELIM_TOKEN"] = 6] = "DELIM_TOKEN";
  783. TokenType[TokenType["AT_KEYWORD_TOKEN"] = 7] = "AT_KEYWORD_TOKEN";
  784. TokenType[TokenType["PREFIX_MATCH_TOKEN"] = 8] = "PREFIX_MATCH_TOKEN";
  785. TokenType[TokenType["DASH_MATCH_TOKEN"] = 9] = "DASH_MATCH_TOKEN";
  786. TokenType[TokenType["INCLUDE_MATCH_TOKEN"] = 10] = "INCLUDE_MATCH_TOKEN";
  787. TokenType[TokenType["LEFT_CURLY_BRACKET_TOKEN"] = 11] = "LEFT_CURLY_BRACKET_TOKEN";
  788. TokenType[TokenType["RIGHT_CURLY_BRACKET_TOKEN"] = 12] = "RIGHT_CURLY_BRACKET_TOKEN";
  789. TokenType[TokenType["SUFFIX_MATCH_TOKEN"] = 13] = "SUFFIX_MATCH_TOKEN";
  790. TokenType[TokenType["SUBSTRING_MATCH_TOKEN"] = 14] = "SUBSTRING_MATCH_TOKEN";
  791. TokenType[TokenType["DIMENSION_TOKEN"] = 15] = "DIMENSION_TOKEN";
  792. TokenType[TokenType["PERCENTAGE_TOKEN"] = 16] = "PERCENTAGE_TOKEN";
  793. TokenType[TokenType["NUMBER_TOKEN"] = 17] = "NUMBER_TOKEN";
  794. TokenType[TokenType["FUNCTION"] = 18] = "FUNCTION";
  795. TokenType[TokenType["FUNCTION_TOKEN"] = 19] = "FUNCTION_TOKEN";
  796. TokenType[TokenType["IDENT_TOKEN"] = 20] = "IDENT_TOKEN";
  797. TokenType[TokenType["COLUMN_TOKEN"] = 21] = "COLUMN_TOKEN";
  798. TokenType[TokenType["URL_TOKEN"] = 22] = "URL_TOKEN";
  799. TokenType[TokenType["BAD_URL_TOKEN"] = 23] = "BAD_URL_TOKEN";
  800. TokenType[TokenType["CDC_TOKEN"] = 24] = "CDC_TOKEN";
  801. TokenType[TokenType["CDO_TOKEN"] = 25] = "CDO_TOKEN";
  802. TokenType[TokenType["COLON_TOKEN"] = 26] = "COLON_TOKEN";
  803. TokenType[TokenType["SEMICOLON_TOKEN"] = 27] = "SEMICOLON_TOKEN";
  804. TokenType[TokenType["LEFT_SQUARE_BRACKET_TOKEN"] = 28] = "LEFT_SQUARE_BRACKET_TOKEN";
  805. TokenType[TokenType["RIGHT_SQUARE_BRACKET_TOKEN"] = 29] = "RIGHT_SQUARE_BRACKET_TOKEN";
  806. TokenType[TokenType["UNICODE_RANGE_TOKEN"] = 30] = "UNICODE_RANGE_TOKEN";
  807. TokenType[TokenType["WHITESPACE_TOKEN"] = 31] = "WHITESPACE_TOKEN";
  808. TokenType[TokenType["EOF_TOKEN"] = 32] = "EOF_TOKEN";
  809. })(TokenType || (TokenType = {}));
  810. var FLAG_UNRESTRICTED = 1 << 0;
  811. var FLAG_ID = 1 << 1;
  812. var FLAG_INTEGER = 1 << 2;
  813. var FLAG_NUMBER = 1 << 3;
  814. var LINE_FEED = 0x000a;
  815. var SOLIDUS = 0x002f;
  816. var REVERSE_SOLIDUS = 0x005c;
  817. var CHARACTER_TABULATION = 0x0009;
  818. var SPACE$1 = 0x0020;
  819. var QUOTATION_MARK = 0x0022;
  820. var EQUALS_SIGN = 0x003d;
  821. var NUMBER_SIGN = 0x0023;
  822. var DOLLAR_SIGN = 0x0024;
  823. var PERCENTAGE_SIGN = 0x0025;
  824. var APOSTROPHE = 0x0027;
  825. var LEFT_PARENTHESIS = 0x0028;
  826. var RIGHT_PARENTHESIS = 0x0029;
  827. var LOW_LINE = 0x005f;
  828. var HYPHEN_MINUS = 0x002d;
  829. var EXCLAMATION_MARK = 0x0021;
  830. var LESS_THAN_SIGN = 0x003c;
  831. var GREATER_THAN_SIGN = 0x003e;
  832. var COMMERCIAL_AT = 0x0040;
  833. var LEFT_SQUARE_BRACKET = 0x005b;
  834. var RIGHT_SQUARE_BRACKET = 0x005d;
  835. var CIRCUMFLEX_ACCENT = 0x003d;
  836. var LEFT_CURLY_BRACKET = 0x007b;
  837. var QUESTION_MARK = 0x003f;
  838. var RIGHT_CURLY_BRACKET = 0x007d;
  839. var VERTICAL_LINE = 0x007c;
  840. var TILDE = 0x007e;
  841. var CONTROL = 0x0080;
  842. var REPLACEMENT_CHARACTER = 0xfffd;
  843. var ASTERISK = 0x002a;
  844. var PLUS_SIGN = 0x002b;
  845. var COMMA = 0x002c;
  846. var COLON = 0x003a;
  847. var SEMICOLON = 0x003b;
  848. var FULL_STOP = 0x002e;
  849. var NULL = 0x0000;
  850. var BACKSPACE = 0x0008;
  851. var LINE_TABULATION = 0x000b;
  852. var SHIFT_OUT = 0x000e;
  853. var INFORMATION_SEPARATOR_ONE = 0x001f;
  854. var DELETE = 0x007f;
  855. var EOF = -1;
  856. var ZERO = 0x0030;
  857. var a = 0x0061;
  858. var e = 0x0065;
  859. var f = 0x0066;
  860. var u = 0x0075;
  861. var z = 0x007a;
  862. var A = 0x0041;
  863. var E = 0x0045;
  864. var F = 0x0046;
  865. var U = 0x0055;
  866. var Z = 0x005a;
  867. var isDigit = function (codePoint) { return codePoint >= ZERO && codePoint <= 0x0039; };
  868. var isSurrogateCodePoint = function (codePoint) { return codePoint >= 0xd800 && codePoint <= 0xdfff; };
  869. var isHex = function (codePoint) {
  870. return isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a && codePoint <= f);
  871. };
  872. var isLowerCaseLetter = function (codePoint) { return codePoint >= a && codePoint <= z; };
  873. var isUpperCaseLetter = function (codePoint) { return codePoint >= A && codePoint <= Z; };
  874. var isLetter = function (codePoint) { return isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint); };
  875. var isNonASCIICodePoint = function (codePoint) { return codePoint >= CONTROL; };
  876. var isWhiteSpace = function (codePoint) {
  877. return codePoint === LINE_FEED || codePoint === CHARACTER_TABULATION || codePoint === SPACE$1;
  878. };
  879. var isNameStartCodePoint = function (codePoint) {
  880. return isLetter(codePoint) || isNonASCIICodePoint(codePoint) || codePoint === LOW_LINE;
  881. };
  882. var isNameCodePoint = function (codePoint) {
  883. return isNameStartCodePoint(codePoint) || isDigit(codePoint) || codePoint === HYPHEN_MINUS;
  884. };
  885. var isNonPrintableCodePoint = function (codePoint) {
  886. return ((codePoint >= NULL && codePoint <= BACKSPACE) ||
  887. codePoint === LINE_TABULATION ||
  888. (codePoint >= SHIFT_OUT && codePoint <= INFORMATION_SEPARATOR_ONE) ||
  889. codePoint === DELETE);
  890. };
  891. var isValidEscape = function (c1, c2) {
  892. if (c1 !== REVERSE_SOLIDUS) {
  893. return false;
  894. }
  895. return c2 !== LINE_FEED;
  896. };
  897. var isIdentifierStart = function (c1, c2, c3) {
  898. if (c1 === HYPHEN_MINUS) {
  899. return isNameStartCodePoint(c2) || isValidEscape(c2, c3);
  900. }
  901. else if (isNameStartCodePoint(c1)) {
  902. return true;
  903. }
  904. else if (c1 === REVERSE_SOLIDUS && isValidEscape(c1, c2)) {
  905. return true;
  906. }
  907. return false;
  908. };
  909. var isNumberStart = function (c1, c2, c3) {
  910. if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
  911. if (isDigit(c2)) {
  912. return true;
  913. }
  914. return c2 === FULL_STOP && isDigit(c3);
  915. }
  916. if (c1 === FULL_STOP) {
  917. return isDigit(c2);
  918. }
  919. return isDigit(c1);
  920. };
  921. var stringToNumber = function (codePoints) {
  922. var c = 0;
  923. var sign = 1;
  924. if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
  925. if (codePoints[c] === HYPHEN_MINUS) {
  926. sign = -1;
  927. }
  928. c++;
  929. }
  930. var integers = [];
  931. while (isDigit(codePoints[c])) {
  932. integers.push(codePoints[c++]);
  933. }
  934. var int = integers.length ? parseInt(fromCodePoint.apply(void 0, integers), 10) : 0;
  935. if (codePoints[c] === FULL_STOP) {
  936. c++;
  937. }
  938. var fraction = [];
  939. while (isDigit(codePoints[c])) {
  940. fraction.push(codePoints[c++]);
  941. }
  942. var fracd = fraction.length;
  943. var frac = fracd ? parseInt(fromCodePoint.apply(void 0, fraction), 10) : 0;
  944. if (codePoints[c] === E || codePoints[c] === e) {
  945. c++;
  946. }
  947. var expsign = 1;
  948. if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
  949. if (codePoints[c] === HYPHEN_MINUS) {
  950. expsign = -1;
  951. }
  952. c++;
  953. }
  954. var exponent = [];
  955. while (isDigit(codePoints[c])) {
  956. exponent.push(codePoints[c++]);
  957. }
  958. var exp = exponent.length ? parseInt(fromCodePoint.apply(void 0, exponent), 10) : 0;
  959. return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
  960. };
  961. var LEFT_PARENTHESIS_TOKEN = {
  962. type: TokenType.LEFT_PARENTHESIS_TOKEN
  963. };
  964. var RIGHT_PARENTHESIS_TOKEN = {
  965. type: TokenType.RIGHT_PARENTHESIS_TOKEN
  966. };
  967. var COMMA_TOKEN = { type: TokenType.COMMA_TOKEN };
  968. var SUFFIX_MATCH_TOKEN = { type: TokenType.SUFFIX_MATCH_TOKEN };
  969. var PREFIX_MATCH_TOKEN = { type: TokenType.PREFIX_MATCH_TOKEN };
  970. var COLUMN_TOKEN = { type: TokenType.COLUMN_TOKEN };
  971. var DASH_MATCH_TOKEN = { type: TokenType.DASH_MATCH_TOKEN };
  972. var INCLUDE_MATCH_TOKEN = { type: TokenType.INCLUDE_MATCH_TOKEN };
  973. var LEFT_CURLY_BRACKET_TOKEN = {
  974. type: TokenType.LEFT_CURLY_BRACKET_TOKEN
  975. };
  976. var RIGHT_CURLY_BRACKET_TOKEN = {
  977. type: TokenType.RIGHT_CURLY_BRACKET_TOKEN
  978. };
  979. var SUBSTRING_MATCH_TOKEN = { type: TokenType.SUBSTRING_MATCH_TOKEN };
  980. var BAD_URL_TOKEN = { type: TokenType.BAD_URL_TOKEN };
  981. var BAD_STRING_TOKEN = { type: TokenType.BAD_STRING_TOKEN };
  982. var CDO_TOKEN = { type: TokenType.CDO_TOKEN };
  983. var CDC_TOKEN = { type: TokenType.CDC_TOKEN };
  984. var COLON_TOKEN = { type: TokenType.COLON_TOKEN };
  985. var SEMICOLON_TOKEN = { type: TokenType.SEMICOLON_TOKEN };
  986. var LEFT_SQUARE_BRACKET_TOKEN = {
  987. type: TokenType.LEFT_SQUARE_BRACKET_TOKEN
  988. };
  989. var RIGHT_SQUARE_BRACKET_TOKEN = {
  990. type: TokenType.RIGHT_SQUARE_BRACKET_TOKEN
  991. };
  992. var WHITESPACE_TOKEN = { type: TokenType.WHITESPACE_TOKEN };
  993. var EOF_TOKEN = { type: TokenType.EOF_TOKEN };
  994. var Tokenizer = /** @class */ (function () {
  995. function Tokenizer() {
  996. this._value = [];
  997. }
  998. Tokenizer.prototype.write = function (chunk) {
  999. this._value = this._value.concat(toCodePoints(chunk));
  1000. };
  1001. Tokenizer.prototype.read = function () {
  1002. var tokens = [];
  1003. var token = this.consumeToken();
  1004. while (token !== EOF_TOKEN) {
  1005. tokens.push(token);
  1006. token = this.consumeToken();
  1007. }
  1008. return tokens;
  1009. };
  1010. Tokenizer.prototype.consumeToken = function () {
  1011. var codePoint = this.consumeCodePoint();
  1012. switch (codePoint) {
  1013. case QUOTATION_MARK:
  1014. return this.consumeStringToken(QUOTATION_MARK);
  1015. case NUMBER_SIGN:
  1016. var c1 = this.peekCodePoint(0);
  1017. var c2 = this.peekCodePoint(1);
  1018. var c3 = this.peekCodePoint(2);
  1019. if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
  1020. var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;
  1021. var value = this.consumeName();
  1022. return { type: TokenType.HASH_TOKEN, value: value, flags: flags };
  1023. }
  1024. break;
  1025. case DOLLAR_SIGN:
  1026. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  1027. this.consumeCodePoint();
  1028. return SUFFIX_MATCH_TOKEN;
  1029. }
  1030. break;
  1031. case APOSTROPHE:
  1032. return this.consumeStringToken(APOSTROPHE);
  1033. case LEFT_PARENTHESIS:
  1034. return LEFT_PARENTHESIS_TOKEN;
  1035. case RIGHT_PARENTHESIS:
  1036. return RIGHT_PARENTHESIS_TOKEN;
  1037. case ASTERISK:
  1038. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  1039. this.consumeCodePoint();
  1040. return SUBSTRING_MATCH_TOKEN;
  1041. }
  1042. break;
  1043. case PLUS_SIGN:
  1044. if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
  1045. this.reconsumeCodePoint(codePoint);
  1046. return this.consumeNumericToken();
  1047. }
  1048. break;
  1049. case COMMA:
  1050. return COMMA_TOKEN;
  1051. case HYPHEN_MINUS:
  1052. var e1 = codePoint;
  1053. var e2 = this.peekCodePoint(0);
  1054. var e3 = this.peekCodePoint(1);
  1055. if (isNumberStart(e1, e2, e3)) {
  1056. this.reconsumeCodePoint(codePoint);
  1057. return this.consumeNumericToken();
  1058. }
  1059. if (isIdentifierStart(e1, e2, e3)) {
  1060. this.reconsumeCodePoint(codePoint);
  1061. return this.consumeIdentLikeToken();
  1062. }
  1063. if (e2 === HYPHEN_MINUS && e3 === GREATER_THAN_SIGN) {
  1064. this.consumeCodePoint();
  1065. this.consumeCodePoint();
  1066. return CDC_TOKEN;
  1067. }
  1068. break;
  1069. case FULL_STOP:
  1070. if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
  1071. this.reconsumeCodePoint(codePoint);
  1072. return this.consumeNumericToken();
  1073. }
  1074. break;
  1075. case SOLIDUS:
  1076. if (this.peekCodePoint(0) === ASTERISK) {
  1077. this.consumeCodePoint();
  1078. while (true) {
  1079. var c = this.consumeCodePoint();
  1080. if (c === ASTERISK) {
  1081. c = this.consumeCodePoint();
  1082. if (c === SOLIDUS) {
  1083. return this.consumeToken();
  1084. }
  1085. }
  1086. if (c === EOF) {
  1087. return this.consumeToken();
  1088. }
  1089. }
  1090. }
  1091. break;
  1092. case COLON:
  1093. return COLON_TOKEN;
  1094. case SEMICOLON:
  1095. return SEMICOLON_TOKEN;
  1096. case LESS_THAN_SIGN:
  1097. if (this.peekCodePoint(0) === EXCLAMATION_MARK &&
  1098. this.peekCodePoint(1) === HYPHEN_MINUS &&
  1099. this.peekCodePoint(2) === HYPHEN_MINUS) {
  1100. this.consumeCodePoint();
  1101. this.consumeCodePoint();
  1102. return CDO_TOKEN;
  1103. }
  1104. break;
  1105. case COMMERCIAL_AT:
  1106. var a1 = this.peekCodePoint(0);
  1107. var a2 = this.peekCodePoint(1);
  1108. var a3 = this.peekCodePoint(2);
  1109. if (isIdentifierStart(a1, a2, a3)) {
  1110. var value = this.consumeName();
  1111. return { type: TokenType.AT_KEYWORD_TOKEN, value: value };
  1112. }
  1113. break;
  1114. case LEFT_SQUARE_BRACKET:
  1115. return LEFT_SQUARE_BRACKET_TOKEN;
  1116. case REVERSE_SOLIDUS:
  1117. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  1118. this.reconsumeCodePoint(codePoint);
  1119. return this.consumeIdentLikeToken();
  1120. }
  1121. break;
  1122. case RIGHT_SQUARE_BRACKET:
  1123. return RIGHT_SQUARE_BRACKET_TOKEN;
  1124. case CIRCUMFLEX_ACCENT:
  1125. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  1126. this.consumeCodePoint();
  1127. return PREFIX_MATCH_TOKEN;
  1128. }
  1129. break;
  1130. case LEFT_CURLY_BRACKET:
  1131. return LEFT_CURLY_BRACKET_TOKEN;
  1132. case RIGHT_CURLY_BRACKET:
  1133. return RIGHT_CURLY_BRACKET_TOKEN;
  1134. case u:
  1135. case U:
  1136. var u1 = this.peekCodePoint(0);
  1137. var u2 = this.peekCodePoint(1);
  1138. if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {
  1139. this.consumeCodePoint();
  1140. this.consumeUnicodeRangeToken();
  1141. }
  1142. this.reconsumeCodePoint(codePoint);
  1143. return this.consumeIdentLikeToken();
  1144. case VERTICAL_LINE:
  1145. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  1146. this.consumeCodePoint();
  1147. return DASH_MATCH_TOKEN;
  1148. }
  1149. if (this.peekCodePoint(0) === VERTICAL_LINE) {
  1150. this.consumeCodePoint();
  1151. return COLUMN_TOKEN;
  1152. }
  1153. break;
  1154. case TILDE:
  1155. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  1156. this.consumeCodePoint();
  1157. return INCLUDE_MATCH_TOKEN;
  1158. }
  1159. break;
  1160. case EOF:
  1161. return EOF_TOKEN;
  1162. }
  1163. if (isWhiteSpace(codePoint)) {
  1164. this.consumeWhiteSpace();
  1165. return WHITESPACE_TOKEN;
  1166. }
  1167. if (isDigit(codePoint)) {
  1168. this.reconsumeCodePoint(codePoint);
  1169. return this.consumeNumericToken();
  1170. }
  1171. if (isNameStartCodePoint(codePoint)) {
  1172. this.reconsumeCodePoint(codePoint);
  1173. return this.consumeIdentLikeToken();
  1174. }
  1175. return { type: TokenType.DELIM_TOKEN, value: fromCodePoint(codePoint) };
  1176. };
  1177. Tokenizer.prototype.consumeCodePoint = function () {
  1178. var value = this._value.shift();
  1179. return typeof value === 'undefined' ? -1 : value;
  1180. };
  1181. Tokenizer.prototype.reconsumeCodePoint = function (codePoint) {
  1182. this._value.unshift(codePoint);
  1183. };
  1184. Tokenizer.prototype.peekCodePoint = function (delta) {
  1185. if (delta >= this._value.length) {
  1186. return -1;
  1187. }
  1188. return this._value[delta];
  1189. };
  1190. Tokenizer.prototype.consumeUnicodeRangeToken = function () {
  1191. var digits = [];
  1192. var codePoint = this.consumeCodePoint();
  1193. while (isHex(codePoint) && digits.length < 6) {
  1194. digits.push(codePoint);
  1195. codePoint = this.consumeCodePoint();
  1196. }
  1197. var questionMarks = false;
  1198. while (codePoint === QUESTION_MARK && digits.length < 6) {
  1199. digits.push(codePoint);
  1200. codePoint = this.consumeCodePoint();
  1201. questionMarks = true;
  1202. }
  1203. if (questionMarks) {
  1204. var start_1 = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
  1205. var end = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
  1206. return { type: TokenType.UNICODE_RANGE_TOKEN, start: start_1, end: end };
  1207. }
  1208. var start = parseInt(fromCodePoint.apply(void 0, digits), 16);
  1209. if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
  1210. this.consumeCodePoint();
  1211. codePoint = this.consumeCodePoint();
  1212. var endDigits = [];
  1213. while (isHex(codePoint) && endDigits.length < 6) {
  1214. endDigits.push(codePoint);
  1215. codePoint = this.consumeCodePoint();
  1216. }
  1217. var end = parseInt(fromCodePoint.apply(void 0, endDigits), 16);
  1218. return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: end };
  1219. }
  1220. else {
  1221. return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: start };
  1222. }
  1223. };
  1224. Tokenizer.prototype.consumeIdentLikeToken = function () {
  1225. var value = this.consumeName();
  1226. if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === LEFT_PARENTHESIS) {
  1227. this.consumeCodePoint();
  1228. return this.consumeUrlToken();
  1229. }
  1230. else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
  1231. this.consumeCodePoint();
  1232. return { type: TokenType.FUNCTION_TOKEN, value: value };
  1233. }
  1234. return { type: TokenType.IDENT_TOKEN, value: value };
  1235. };
  1236. Tokenizer.prototype.consumeUrlToken = function () {
  1237. var value = [];
  1238. this.consumeWhiteSpace();
  1239. if (this.peekCodePoint(0) === EOF) {
  1240. return { type: TokenType.URL_TOKEN, value: '' };
  1241. }
  1242. var next = this.peekCodePoint(0);
  1243. if (next === APOSTROPHE || next === QUOTATION_MARK) {
  1244. var stringToken = this.consumeStringToken(this.consumeCodePoint());
  1245. if (stringToken.type === TokenType.STRING_TOKEN) {
  1246. this.consumeWhiteSpace();
  1247. if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
  1248. this.consumeCodePoint();
  1249. return { type: TokenType.URL_TOKEN, value: stringToken.value };
  1250. }
  1251. }
  1252. this.consumeBadUrlRemnants();
  1253. return BAD_URL_TOKEN;
  1254. }
  1255. while (true) {
  1256. var codePoint = this.consumeCodePoint();
  1257. if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
  1258. return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };
  1259. }
  1260. else if (isWhiteSpace(codePoint)) {
  1261. this.consumeWhiteSpace();
  1262. if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
  1263. this.consumeCodePoint();
  1264. return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };
  1265. }
  1266. this.consumeBadUrlRemnants();
  1267. return BAD_URL_TOKEN;
  1268. }
  1269. else if (codePoint === QUOTATION_MARK ||
  1270. codePoint === APOSTROPHE ||
  1271. codePoint === LEFT_PARENTHESIS ||
  1272. isNonPrintableCodePoint(codePoint)) {
  1273. this.consumeBadUrlRemnants();
  1274. return BAD_URL_TOKEN;
  1275. }
  1276. else if (codePoint === REVERSE_SOLIDUS) {
  1277. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  1278. value.push(this.consumeEscapedCodePoint());
  1279. }
  1280. else {
  1281. this.consumeBadUrlRemnants();
  1282. return BAD_URL_TOKEN;
  1283. }
  1284. }
  1285. else {
  1286. value.push(codePoint);
  1287. }
  1288. }
  1289. };
  1290. Tokenizer.prototype.consumeWhiteSpace = function () {
  1291. while (isWhiteSpace(this.peekCodePoint(0))) {
  1292. this.consumeCodePoint();
  1293. }
  1294. };
  1295. Tokenizer.prototype.consumeBadUrlRemnants = function () {
  1296. while (true) {
  1297. var codePoint = this.consumeCodePoint();
  1298. if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {
  1299. return;
  1300. }
  1301. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  1302. this.consumeEscapedCodePoint();
  1303. }
  1304. }
  1305. };
  1306. Tokenizer.prototype.consumeStringSlice = function (count) {
  1307. var SLICE_STACK_SIZE = 60000;
  1308. var value = '';
  1309. while (count > 0) {
  1310. var amount = Math.min(SLICE_STACK_SIZE, count);
  1311. value += fromCodePoint.apply(void 0, this._value.splice(0, amount));
  1312. count -= amount;
  1313. }
  1314. this._value.shift();
  1315. return value;
  1316. };
  1317. Tokenizer.prototype.consumeStringToken = function (endingCodePoint) {
  1318. var value = '';
  1319. var i = 0;
  1320. do {
  1321. var codePoint = this._value[i];
  1322. if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
  1323. value += this.consumeStringSlice(i);
  1324. return { type: TokenType.STRING_TOKEN, value: value };
  1325. }
  1326. if (codePoint === LINE_FEED) {
  1327. this._value.splice(0, i);
  1328. return BAD_STRING_TOKEN;
  1329. }
  1330. if (codePoint === REVERSE_SOLIDUS) {
  1331. var next = this._value[i + 1];
  1332. if (next !== EOF && next !== undefined) {
  1333. if (next === LINE_FEED) {
  1334. value += this.consumeStringSlice(i);
  1335. i = -1;
  1336. this._value.shift();
  1337. }
  1338. else if (isValidEscape(codePoint, next)) {
  1339. value += this.consumeStringSlice(i);
  1340. value += fromCodePoint(this.consumeEscapedCodePoint());
  1341. i = -1;
  1342. }
  1343. }
  1344. }
  1345. i++;
  1346. } while (true);
  1347. };
  1348. Tokenizer.prototype.consumeNumber = function () {
  1349. var repr = [];
  1350. var type = FLAG_INTEGER;
  1351. var c1 = this.peekCodePoint(0);
  1352. if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
  1353. repr.push(this.consumeCodePoint());
  1354. }
  1355. while (isDigit(this.peekCodePoint(0))) {
  1356. repr.push(this.consumeCodePoint());
  1357. }
  1358. c1 = this.peekCodePoint(0);
  1359. var c2 = this.peekCodePoint(1);
  1360. if (c1 === FULL_STOP && isDigit(c2)) {
  1361. repr.push(this.consumeCodePoint(), this.consumeCodePoint());
  1362. type = FLAG_NUMBER;
  1363. while (isDigit(this.peekCodePoint(0))) {
  1364. repr.push(this.consumeCodePoint());
  1365. }
  1366. }
  1367. c1 = this.peekCodePoint(0);
  1368. c2 = this.peekCodePoint(1);
  1369. var c3 = this.peekCodePoint(2);
  1370. if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
  1371. repr.push(this.consumeCodePoint(), this.consumeCodePoint());
  1372. type = FLAG_NUMBER;
  1373. while (isDigit(this.peekCodePoint(0))) {
  1374. repr.push(this.consumeCodePoint());
  1375. }
  1376. }
  1377. return [stringToNumber(repr), type];
  1378. };
  1379. Tokenizer.prototype.consumeNumericToken = function () {
  1380. var _a = this.consumeNumber(), number = _a[0], flags = _a[1];
  1381. var c1 = this.peekCodePoint(0);
  1382. var c2 = this.peekCodePoint(1);
  1383. var c3 = this.peekCodePoint(2);
  1384. if (isIdentifierStart(c1, c2, c3)) {
  1385. var unit = this.consumeName();
  1386. return { type: TokenType.DIMENSION_TOKEN, number: number, flags: flags, unit: unit };
  1387. }
  1388. if (c1 === PERCENTAGE_SIGN) {
  1389. this.consumeCodePoint();
  1390. return { type: TokenType.PERCENTAGE_TOKEN, number: number, flags: flags };
  1391. }
  1392. return { type: TokenType.NUMBER_TOKEN, number: number, flags: flags };
  1393. };
  1394. Tokenizer.prototype.consumeEscapedCodePoint = function () {
  1395. var codePoint = this.consumeCodePoint();
  1396. if (isHex(codePoint)) {
  1397. var hex = fromCodePoint(codePoint);
  1398. while (isHex(this.peekCodePoint(0)) && hex.length < 6) {
  1399. hex += fromCodePoint(this.consumeCodePoint());
  1400. }
  1401. if (isWhiteSpace(this.peekCodePoint(0))) {
  1402. this.consumeCodePoint();
  1403. }
  1404. var hexCodePoint = parseInt(hex, 16);
  1405. if (hexCodePoint === 0 || isSurrogateCodePoint(hexCodePoint) || hexCodePoint > 0x10ffff) {
  1406. return REPLACEMENT_CHARACTER;
  1407. }
  1408. return hexCodePoint;
  1409. }
  1410. if (codePoint === EOF) {
  1411. return REPLACEMENT_CHARACTER;
  1412. }
  1413. return codePoint;
  1414. };
  1415. Tokenizer.prototype.consumeName = function () {
  1416. var result = '';
  1417. while (true) {
  1418. var codePoint = this.consumeCodePoint();
  1419. if (isNameCodePoint(codePoint)) {
  1420. result += fromCodePoint(codePoint);
  1421. }
  1422. else if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  1423. result += fromCodePoint(this.consumeEscapedCodePoint());
  1424. }
  1425. else {
  1426. this.reconsumeCodePoint(codePoint);
  1427. return result;
  1428. }
  1429. }
  1430. };
  1431. return Tokenizer;
  1432. }());
  1433. var Parser = /** @class */ (function () {
  1434. function Parser(tokens) {
  1435. this._tokens = tokens;
  1436. }
  1437. Parser.create = function (value) {
  1438. var tokenizer = new Tokenizer();
  1439. tokenizer.write(value);
  1440. return new Parser(tokenizer.read());
  1441. };
  1442. Parser.parseValue = function (value) {
  1443. return Parser.create(value).parseComponentValue();
  1444. };
  1445. Parser.parseValues = function (value) {
  1446. return Parser.create(value).parseComponentValues();
  1447. };
  1448. Parser.prototype.parseComponentValue = function () {
  1449. var token = this.consumeToken();
  1450. while (token.type === TokenType.WHITESPACE_TOKEN) {
  1451. token = this.consumeToken();
  1452. }
  1453. if (token.type === TokenType.EOF_TOKEN) {
  1454. throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
  1455. }
  1456. this.reconsumeToken(token);
  1457. var value = this.consumeComponentValue();
  1458. do {
  1459. token = this.consumeToken();
  1460. } while (token.type === TokenType.WHITESPACE_TOKEN);
  1461. if (token.type === TokenType.EOF_TOKEN) {
  1462. return value;
  1463. }
  1464. throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
  1465. };
  1466. Parser.prototype.parseComponentValues = function () {
  1467. var values = [];
  1468. while (true) {
  1469. var value = this.consumeComponentValue();
  1470. if (value.type === TokenType.EOF_TOKEN) {
  1471. return values;
  1472. }
  1473. values.push(value);
  1474. values.push();
  1475. }
  1476. };
  1477. Parser.prototype.consumeComponentValue = function () {
  1478. var token = this.consumeToken();
  1479. switch (token.type) {
  1480. case TokenType.LEFT_CURLY_BRACKET_TOKEN:
  1481. case TokenType.LEFT_SQUARE_BRACKET_TOKEN:
  1482. case TokenType.LEFT_PARENTHESIS_TOKEN:
  1483. return this.consumeSimpleBlock(token.type);
  1484. case TokenType.FUNCTION_TOKEN:
  1485. return this.consumeFunction(token);
  1486. }
  1487. return token;
  1488. };
  1489. Parser.prototype.consumeSimpleBlock = function (type) {
  1490. var block = { type: type, values: [] };
  1491. var token = this.consumeToken();
  1492. while (true) {
  1493. if (token.type === TokenType.EOF_TOKEN || isEndingTokenFor(token, type)) {
  1494. return block;
  1495. }
  1496. this.reconsumeToken(token);
  1497. block.values.push(this.consumeComponentValue());
  1498. token = this.consumeToken();
  1499. }
  1500. };
  1501. Parser.prototype.consumeFunction = function (functionToken) {
  1502. var cssFunction = {
  1503. name: functionToken.value,
  1504. values: [],
  1505. type: TokenType.FUNCTION
  1506. };
  1507. while (true) {
  1508. var token = this.consumeToken();
  1509. if (token.type === TokenType.EOF_TOKEN || token.type === TokenType.RIGHT_PARENTHESIS_TOKEN) {
  1510. return cssFunction;
  1511. }
  1512. this.reconsumeToken(token);
  1513. cssFunction.values.push(this.consumeComponentValue());
  1514. }
  1515. };
  1516. Parser.prototype.consumeToken = function () {
  1517. var token = this._tokens.shift();
  1518. return typeof token === 'undefined' ? EOF_TOKEN : token;
  1519. };
  1520. Parser.prototype.reconsumeToken = function (token) {
  1521. this._tokens.unshift(token);
  1522. };
  1523. return Parser;
  1524. }());
  1525. var isDimensionToken = function (token) { return token.type === TokenType.DIMENSION_TOKEN; };
  1526. var isNumberToken = function (token) { return token.type === TokenType.NUMBER_TOKEN; };
  1527. var isIdentToken = function (token) { return token.type === TokenType.IDENT_TOKEN; };
  1528. var isStringToken = function (token) { return token.type === TokenType.STRING_TOKEN; };
  1529. var isIdentWithValue = function (token, value) {
  1530. return isIdentToken(token) && token.value === value;
  1531. };
  1532. var nonWhiteSpace = function (token) { return token.type !== TokenType.WHITESPACE_TOKEN; };
  1533. var nonFunctionArgSeparator = function (token) {
  1534. return token.type !== TokenType.WHITESPACE_TOKEN && token.type !== TokenType.COMMA_TOKEN;
  1535. };
  1536. var parseFunctionArgs = function (tokens) {
  1537. var args = [];
  1538. var arg = [];
  1539. tokens.forEach(function (token) {
  1540. if (token.type === TokenType.COMMA_TOKEN) {
  1541. if (arg.length === 0) {
  1542. throw new Error("Error parsing function args, zero tokens for arg");
  1543. }
  1544. args.push(arg);
  1545. arg = [];
  1546. return;
  1547. }
  1548. if (token.type !== TokenType.WHITESPACE_TOKEN) {
  1549. arg.push(token);
  1550. }
  1551. });
  1552. if (arg.length) {
  1553. args.push(arg);
  1554. }
  1555. return args;
  1556. };
  1557. var isEndingTokenFor = function (token, type) {
  1558. if (type === TokenType.LEFT_CURLY_BRACKET_TOKEN && token.type === TokenType.RIGHT_CURLY_BRACKET_TOKEN) {
  1559. return true;
  1560. }
  1561. if (type === TokenType.LEFT_SQUARE_BRACKET_TOKEN && token.type === TokenType.RIGHT_SQUARE_BRACKET_TOKEN) {
  1562. return true;
  1563. }
  1564. return type === TokenType.LEFT_PARENTHESIS_TOKEN && token.type === TokenType.RIGHT_PARENTHESIS_TOKEN;
  1565. };
  1566. var isLength = function (token) {
  1567. return token.type === TokenType.NUMBER_TOKEN || token.type === TokenType.DIMENSION_TOKEN;
  1568. };
  1569. var isLengthPercentage = function (token) {
  1570. return token.type === TokenType.PERCENTAGE_TOKEN || isLength(token);
  1571. };
  1572. var parseLengthPercentageTuple = function (tokens) {
  1573. return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];
  1574. };
  1575. var ZERO_LENGTH = {
  1576. type: TokenType.NUMBER_TOKEN,
  1577. number: 0,
  1578. flags: FLAG_INTEGER
  1579. };
  1580. var FIFTY_PERCENT = {
  1581. type: TokenType.PERCENTAGE_TOKEN,
  1582. number: 50,
  1583. flags: FLAG_INTEGER
  1584. };
  1585. var HUNDRED_PERCENT = {
  1586. type: TokenType.PERCENTAGE_TOKEN,
  1587. number: 100,
  1588. flags: FLAG_INTEGER
  1589. };
  1590. var getAbsoluteValueForTuple = function (tuple, width, height) {
  1591. var x = tuple[0], y = tuple[1];
  1592. return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
  1593. };
  1594. var getAbsoluteValue = function (token, parent) {
  1595. if (token.type === TokenType.PERCENTAGE_TOKEN) {
  1596. return (token.number / 100) * parent;
  1597. }
  1598. if (isDimensionToken(token)) {
  1599. switch (token.unit) {
  1600. case 'rem':
  1601. case 'em':
  1602. return 16 * token.number; // TODO use correct font-size
  1603. case 'px':
  1604. default:
  1605. return token.number;
  1606. }
  1607. }
  1608. return token.number;
  1609. };
  1610. var DEG = 'deg';
  1611. var GRAD = 'grad';
  1612. var RAD = 'rad';
  1613. var TURN = 'turn';
  1614. var angle = {
  1615. name: 'angle',
  1616. parse: function (value) {
  1617. if (value.type === TokenType.DIMENSION_TOKEN) {
  1618. switch (value.unit) {
  1619. case DEG:
  1620. return (Math.PI * value.number) / 180;
  1621. case GRAD:
  1622. return (Math.PI / 200) * value.number;
  1623. case RAD:
  1624. return value.number;
  1625. case TURN:
  1626. return Math.PI * 2 * value.number;
  1627. }
  1628. }
  1629. throw new Error("Unsupported angle type");
  1630. }
  1631. };
  1632. var isAngle = function (value) {
  1633. if (value.type === TokenType.DIMENSION_TOKEN) {
  1634. if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
  1635. return true;
  1636. }
  1637. }
  1638. return false;
  1639. };
  1640. var parseNamedSide = function (tokens) {
  1641. var sideOrCorner = tokens
  1642. .filter(isIdentToken)
  1643. .map(function (ident) { return ident.value; })
  1644. .join(' ');
  1645. switch (sideOrCorner) {
  1646. case 'to bottom right':
  1647. case 'to right bottom':
  1648. case 'left top':
  1649. case 'top left':
  1650. return [ZERO_LENGTH, ZERO_LENGTH];
  1651. case 'to top':
  1652. case 'bottom':
  1653. return deg(0);
  1654. case 'to bottom left':
  1655. case 'to left bottom':
  1656. case 'right top':
  1657. case 'top right':
  1658. return [ZERO_LENGTH, HUNDRED_PERCENT];
  1659. case 'to right':
  1660. case 'left':
  1661. return deg(90);
  1662. case 'to top left':
  1663. case 'to left top':
  1664. case 'right bottom':
  1665. case 'bottom right':
  1666. return [HUNDRED_PERCENT, HUNDRED_PERCENT];
  1667. case 'to bottom':
  1668. case 'top':
  1669. return deg(180);
  1670. case 'to top right':
  1671. case 'to right top':
  1672. case 'left bottom':
  1673. case 'bottom left':
  1674. return [HUNDRED_PERCENT, ZERO_LENGTH];
  1675. case 'to left':
  1676. case 'right':
  1677. return deg(270);
  1678. }
  1679. return 0;
  1680. };
  1681. var deg = function (deg) { return (Math.PI * deg) / 180; };
  1682. var color = {
  1683. name: 'color',
  1684. parse: function (value) {
  1685. if (value.type === TokenType.FUNCTION) {
  1686. var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
  1687. if (typeof colorFunction === 'undefined') {
  1688. throw new Error("Attempting to parse an unsupported color function \"" + value.name + "\"");
  1689. }
  1690. return colorFunction(value.values);
  1691. }
  1692. if (value.type === TokenType.HASH_TOKEN) {
  1693. if (value.value.length === 3) {
  1694. var r = value.value.substring(0, 1);
  1695. var g = value.value.substring(1, 2);
  1696. var b = value.value.substring(2, 3);
  1697. return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);
  1698. }
  1699. if (value.value.length === 4) {
  1700. var r = value.value.substring(0, 1);
  1701. var g = value.value.substring(1, 2);
  1702. var b = value.value.substring(2, 3);
  1703. var a = value.value.substring(3, 4);
  1704. return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);
  1705. }
  1706. if (value.value.length === 6) {
  1707. var r = value.value.substring(0, 2);
  1708. var g = value.value.substring(2, 4);
  1709. var b = value.value.substring(4, 6);
  1710. return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
  1711. }
  1712. if (value.value.length === 8) {
  1713. var r = value.value.substring(0, 2);
  1714. var g = value.value.substring(2, 4);
  1715. var b = value.value.substring(4, 6);
  1716. var a = value.value.substring(6, 8);
  1717. return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);
  1718. }
  1719. }
  1720. if (value.type === TokenType.IDENT_TOKEN) {
  1721. var namedColor = COLORS[value.value.toUpperCase()];
  1722. if (typeof namedColor !== 'undefined') {
  1723. return namedColor;
  1724. }
  1725. }
  1726. return COLORS.TRANSPARENT;
  1727. }
  1728. };
  1729. var isTransparent = function (color) { return (0xff & color) === 0; };
  1730. var asString = function (color) {
  1731. var alpha = 0xff & color;
  1732. var blue = 0xff & (color >> 8);
  1733. var green = 0xff & (color >> 16);
  1734. var red = 0xff & (color >> 24);
  1735. return alpha < 255 ? "rgba(" + red + "," + green + "," + blue + "," + alpha / 255 + ")" : "rgb(" + red + "," + green + "," + blue + ")";
  1736. };
  1737. var pack = function (r, g, b, a) {
  1738. return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;
  1739. };
  1740. var getTokenColorValue = function (token, i) {
  1741. if (token.type === TokenType.NUMBER_TOKEN) {
  1742. return token.number;
  1743. }
  1744. if (token.type === TokenType.PERCENTAGE_TOKEN) {
  1745. var max = i === 3 ? 1 : 255;
  1746. return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);
  1747. }
  1748. return 0;
  1749. };
  1750. var rgb = function (args) {
  1751. var tokens = args.filter(nonFunctionArgSeparator);
  1752. if (tokens.length === 3) {
  1753. var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
  1754. return pack(r, g, b, 1);
  1755. }
  1756. if (tokens.length === 4) {
  1757. var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
  1758. return pack(r, g, b, a);
  1759. }
  1760. return 0;
  1761. };
  1762. function hue2rgb(t1, t2, hue) {
  1763. if (hue < 0) {
  1764. hue += 1;
  1765. }
  1766. if (hue >= 1) {
  1767. hue -= 1;
  1768. }
  1769. if (hue < 1 / 6) {
  1770. return (t2 - t1) * hue * 6 + t1;
  1771. }
  1772. else if (hue < 1 / 2) {
  1773. return t2;
  1774. }
  1775. else if (hue < 2 / 3) {
  1776. return (t2 - t1) * 6 * (2 / 3 - hue) + t1;
  1777. }
  1778. else {
  1779. return t1;
  1780. }
  1781. }
  1782. var hsl = function (args) {
  1783. var tokens = args.filter(nonFunctionArgSeparator);
  1784. var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];
  1785. var h = (hue.type === TokenType.NUMBER_TOKEN ? deg(hue.number) : angle.parse(hue)) / (Math.PI * 2);
  1786. var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;
  1787. var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;
  1788. var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
  1789. if (s === 0) {
  1790. return pack(l * 255, l * 255, l * 255, 1);
  1791. }
  1792. var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  1793. var t1 = l * 2 - t2;
  1794. var r = hue2rgb(t1, t2, h + 1 / 3);
  1795. var g = hue2rgb(t1, t2, h);
  1796. var b = hue2rgb(t1, t2, h - 1 / 3);
  1797. return pack(r * 255, g * 255, b * 255, a);
  1798. };
  1799. var SUPPORTED_COLOR_FUNCTIONS = {
  1800. hsl: hsl,
  1801. hsla: hsl,
  1802. rgb: rgb,
  1803. rgba: rgb
  1804. };
  1805. var COLORS = {
  1806. ALICEBLUE: 0xf0f8ffff,
  1807. ANTIQUEWHITE: 0xfaebd7ff,
  1808. AQUA: 0x00ffffff,
  1809. AQUAMARINE: 0x7fffd4ff,
  1810. AZURE: 0xf0ffffff,
  1811. BEIGE: 0xf5f5dcff,
  1812. BISQUE: 0xffe4c4ff,
  1813. BLACK: 0x000000ff,
  1814. BLANCHEDALMOND: 0xffebcdff,
  1815. BLUE: 0x0000ffff,
  1816. BLUEVIOLET: 0x8a2be2ff,
  1817. BROWN: 0xa52a2aff,
  1818. BURLYWOOD: 0xdeb887ff,
  1819. CADETBLUE: 0x5f9ea0ff,
  1820. CHARTREUSE: 0x7fff00ff,
  1821. CHOCOLATE: 0xd2691eff,
  1822. CORAL: 0xff7f50ff,
  1823. CORNFLOWERBLUE: 0x6495edff,
  1824. CORNSILK: 0xfff8dcff,
  1825. CRIMSON: 0xdc143cff,
  1826. CYAN: 0x00ffffff,
  1827. DARKBLUE: 0x00008bff,
  1828. DARKCYAN: 0x008b8bff,
  1829. DARKGOLDENROD: 0xb886bbff,
  1830. DARKGRAY: 0xa9a9a9ff,
  1831. DARKGREEN: 0x006400ff,
  1832. DARKGREY: 0xa9a9a9ff,
  1833. DARKKHAKI: 0xbdb76bff,
  1834. DARKMAGENTA: 0x8b008bff,
  1835. DARKOLIVEGREEN: 0x556b2fff,
  1836. DARKORANGE: 0xff8c00ff,
  1837. DARKORCHID: 0x9932ccff,
  1838. DARKRED: 0x8b0000ff,
  1839. DARKSALMON: 0xe9967aff,
  1840. DARKSEAGREEN: 0x8fbc8fff,
  1841. DARKSLATEBLUE: 0x483d8bff,
  1842. DARKSLATEGRAY: 0x2f4f4fff,
  1843. DARKSLATEGREY: 0x2f4f4fff,
  1844. DARKTURQUOISE: 0x00ced1ff,
  1845. DARKVIOLET: 0x9400d3ff,
  1846. DEEPPINK: 0xff1493ff,
  1847. DEEPSKYBLUE: 0x00bfffff,
  1848. DIMGRAY: 0x696969ff,
  1849. DIMGREY: 0x696969ff,
  1850. DODGERBLUE: 0x1e90ffff,
  1851. FIREBRICK: 0xb22222ff,
  1852. FLORALWHITE: 0xfffaf0ff,
  1853. FORESTGREEN: 0x228b22ff,
  1854. FUCHSIA: 0xff00ffff,
  1855. GAINSBORO: 0xdcdcdcff,
  1856. GHOSTWHITE: 0xf8f8ffff,
  1857. GOLD: 0xffd700ff,
  1858. GOLDENROD: 0xdaa520ff,
  1859. GRAY: 0x808080ff,
  1860. GREEN: 0x008000ff,
  1861. GREENYELLOW: 0xadff2fff,
  1862. GREY: 0x808080ff,
  1863. HONEYDEW: 0xf0fff0ff,
  1864. HOTPINK: 0xff69b4ff,
  1865. INDIANRED: 0xcd5c5cff,
  1866. INDIGO: 0x4b0082ff,
  1867. IVORY: 0xfffff0ff,
  1868. KHAKI: 0xf0e68cff,
  1869. LAVENDER: 0xe6e6faff,
  1870. LAVENDERBLUSH: 0xfff0f5ff,
  1871. LAWNGREEN: 0x7cfc00ff,
  1872. LEMONCHIFFON: 0xfffacdff,
  1873. LIGHTBLUE: 0xadd8e6ff,
  1874. LIGHTCORAL: 0xf08080ff,
  1875. LIGHTCYAN: 0xe0ffffff,
  1876. LIGHTGOLDENRODYELLOW: 0xfafad2ff,
  1877. LIGHTGRAY: 0xd3d3d3ff,
  1878. LIGHTGREEN: 0x90ee90ff,
  1879. LIGHTGREY: 0xd3d3d3ff,
  1880. LIGHTPINK: 0xffb6c1ff,
  1881. LIGHTSALMON: 0xffa07aff,
  1882. LIGHTSEAGREEN: 0x20b2aaff,
  1883. LIGHTSKYBLUE: 0x87cefaff,
  1884. LIGHTSLATEGRAY: 0x778899ff,
  1885. LIGHTSLATEGREY: 0x778899ff,
  1886. LIGHTSTEELBLUE: 0xb0c4deff,
  1887. LIGHTYELLOW: 0xffffe0ff,
  1888. LIME: 0x00ff00ff,
  1889. LIMEGREEN: 0x32cd32ff,
  1890. LINEN: 0xfaf0e6ff,
  1891. MAGENTA: 0xff00ffff,
  1892. MAROON: 0x800000ff,
  1893. MEDIUMAQUAMARINE: 0x66cdaaff,
  1894. MEDIUMBLUE: 0x0000cdff,
  1895. MEDIUMORCHID: 0xba55d3ff,
  1896. MEDIUMPURPLE: 0x9370dbff,
  1897. MEDIUMSEAGREEN: 0x3cb371ff,
  1898. MEDIUMSLATEBLUE: 0x7b68eeff,
  1899. MEDIUMSPRINGGREEN: 0x00fa9aff,
  1900. MEDIUMTURQUOISE: 0x48d1ccff,
  1901. MEDIUMVIOLETRED: 0xc71585ff,
  1902. MIDNIGHTBLUE: 0x191970ff,
  1903. MINTCREAM: 0xf5fffaff,
  1904. MISTYROSE: 0xffe4e1ff,
  1905. MOCCASIN: 0xffe4b5ff,
  1906. NAVAJOWHITE: 0xffdeadff,
  1907. NAVY: 0x000080ff,
  1908. OLDLACE: 0xfdf5e6ff,
  1909. OLIVE: 0x808000ff,
  1910. OLIVEDRAB: 0x6b8e23ff,
  1911. ORANGE: 0xffa500ff,
  1912. ORANGERED: 0xff4500ff,
  1913. ORCHID: 0xda70d6ff,
  1914. PALEGOLDENROD: 0xeee8aaff,
  1915. PALEGREEN: 0x98fb98ff,
  1916. PALETURQUOISE: 0xafeeeeff,
  1917. PALEVIOLETRED: 0xdb7093ff,
  1918. PAPAYAWHIP: 0xffefd5ff,
  1919. PEACHPUFF: 0xffdab9ff,
  1920. PERU: 0xcd853fff,
  1921. PINK: 0xffc0cbff,
  1922. PLUM: 0xdda0ddff,
  1923. POWDERBLUE: 0xb0e0e6ff,
  1924. PURPLE: 0x800080ff,
  1925. REBECCAPURPLE: 0x663399ff,
  1926. RED: 0xff0000ff,
  1927. ROSYBROWN: 0xbc8f8fff,
  1928. ROYALBLUE: 0x4169e1ff,
  1929. SADDLEBROWN: 0x8b4513ff,
  1930. SALMON: 0xfa8072ff,
  1931. SANDYBROWN: 0xf4a460ff,
  1932. SEAGREEN: 0x2e8b57ff,
  1933. SEASHELL: 0xfff5eeff,
  1934. SIENNA: 0xa0522dff,
  1935. SILVER: 0xc0c0c0ff,
  1936. SKYBLUE: 0x87ceebff,
  1937. SLATEBLUE: 0x6a5acdff,
  1938. SLATEGRAY: 0x708090ff,
  1939. SLATEGREY: 0x708090ff,
  1940. SNOW: 0xfffafaff,
  1941. SPRINGGREEN: 0x00ff7fff,
  1942. STEELBLUE: 0x4682b4ff,
  1943. TAN: 0xd2b48cff,
  1944. TEAL: 0x008080ff,
  1945. THISTLE: 0xd8bfd8ff,
  1946. TOMATO: 0xff6347ff,
  1947. TRANSPARENT: 0x00000000,
  1948. TURQUOISE: 0x40e0d0ff,
  1949. VIOLET: 0xee82eeff,
  1950. WHEAT: 0xf5deb3ff,
  1951. WHITE: 0xffffffff,
  1952. WHITESMOKE: 0xf5f5f5ff,
  1953. YELLOW: 0xffff00ff,
  1954. YELLOWGREEN: 0x9acd32ff
  1955. };
  1956. var PropertyDescriptorParsingType;
  1957. (function (PropertyDescriptorParsingType) {
  1958. PropertyDescriptorParsingType[PropertyDescriptorParsingType["VALUE"] = 0] = "VALUE";
  1959. PropertyDescriptorParsingType[PropertyDescriptorParsingType["LIST"] = 1] = "LIST";
  1960. PropertyDescriptorParsingType[PropertyDescriptorParsingType["IDENT_VALUE"] = 2] = "IDENT_VALUE";
  1961. PropertyDescriptorParsingType[PropertyDescriptorParsingType["TYPE_VALUE"] = 3] = "TYPE_VALUE";
  1962. PropertyDescriptorParsingType[PropertyDescriptorParsingType["TOKEN_VALUE"] = 4] = "TOKEN_VALUE";
  1963. })(PropertyDescriptorParsingType || (PropertyDescriptorParsingType = {}));
  1964. var BACKGROUND_CLIP;
  1965. (function (BACKGROUND_CLIP) {
  1966. BACKGROUND_CLIP[BACKGROUND_CLIP["BORDER_BOX"] = 0] = "BORDER_BOX";
  1967. BACKGROUND_CLIP[BACKGROUND_CLIP["PADDING_BOX"] = 1] = "PADDING_BOX";
  1968. BACKGROUND_CLIP[BACKGROUND_CLIP["CONTENT_BOX"] = 2] = "CONTENT_BOX";
  1969. })(BACKGROUND_CLIP || (BACKGROUND_CLIP = {}));
  1970. var backgroundClip = {
  1971. name: 'background-clip',
  1972. initialValue: 'border-box',
  1973. prefix: false,
  1974. type: PropertyDescriptorParsingType.LIST,
  1975. parse: function (tokens) {
  1976. return tokens.map(function (token) {
  1977. if (isIdentToken(token)) {
  1978. switch (token.value) {
  1979. case 'padding-box':
  1980. return BACKGROUND_CLIP.PADDING_BOX;
  1981. case 'content-box':
  1982. return BACKGROUND_CLIP.CONTENT_BOX;
  1983. }
  1984. }
  1985. return BACKGROUND_CLIP.BORDER_BOX;
  1986. });
  1987. }
  1988. };
  1989. var backgroundColor = {
  1990. name: "background-color",
  1991. initialValue: 'transparent',
  1992. prefix: false,
  1993. type: PropertyDescriptorParsingType.TYPE_VALUE,
  1994. format: 'color'
  1995. };
  1996. var parseColorStop = function (args) {
  1997. var color$1 = color.parse(args[0]);
  1998. var stop = args[1];
  1999. return stop && isLengthPercentage(stop) ? { color: color$1, stop: stop } : { color: color$1, stop: null };
  2000. };
  2001. var processColorStops = function (stops, lineLength) {
  2002. var first = stops[0];
  2003. var last = stops[stops.length - 1];
  2004. if (first.stop === null) {
  2005. first.stop = ZERO_LENGTH;
  2006. }
  2007. if (last.stop === null) {
  2008. last.stop = HUNDRED_PERCENT;
  2009. }
  2010. var processStops = [];
  2011. var previous = 0;
  2012. for (var i = 0; i < stops.length; i++) {
  2013. var stop_1 = stops[i].stop;
  2014. if (stop_1 !== null) {
  2015. var absoluteValue = getAbsoluteValue(stop_1, lineLength);
  2016. if (absoluteValue > previous) {
  2017. processStops.push(absoluteValue);
  2018. }
  2019. else {
  2020. processStops.push(previous);
  2021. }
  2022. previous = absoluteValue;
  2023. }
  2024. else {
  2025. processStops.push(null);
  2026. }
  2027. }
  2028. var gapBegin = null;
  2029. for (var i = 0; i < processStops.length; i++) {
  2030. var stop_2 = processStops[i];
  2031. if (stop_2 === null) {
  2032. if (gapBegin === null) {
  2033. gapBegin = i;
  2034. }
  2035. }
  2036. else if (gapBegin !== null) {
  2037. var gapLength = i - gapBegin;
  2038. var beforeGap = processStops[gapBegin - 1];
  2039. var gapValue = (stop_2 - beforeGap) / (gapLength + 1);
  2040. for (var g = 1; g <= gapLength; g++) {
  2041. processStops[gapBegin + g - 1] = gapValue * g;
  2042. }
  2043. gapBegin = null;
  2044. }
  2045. }
  2046. return stops.map(function (_a, i) {
  2047. var color = _a.color;
  2048. return { color: color, stop: Math.max(Math.min(1, processStops[i] / lineLength), 0) };
  2049. });
  2050. };
  2051. var getAngleFromCorner = function (corner, width, height) {
  2052. var centerX = width / 2;
  2053. var centerY = height / 2;
  2054. var x = getAbsoluteValue(corner[0], width) - centerX;
  2055. var y = centerY - getAbsoluteValue(corner[1], height);
  2056. return (Math.atan2(y, x) + Math.PI * 2) % (Math.PI * 2);
  2057. };
  2058. var calculateGradientDirection = function (angle, width, height) {
  2059. var radian = typeof angle === 'number' ? angle : getAngleFromCorner(angle, width, height);
  2060. var lineLength = Math.abs(width * Math.sin(radian)) + Math.abs(height * Math.cos(radian));
  2061. var halfWidth = width / 2;
  2062. var halfHeight = height / 2;
  2063. var halfLineLength = lineLength / 2;
  2064. var yDiff = Math.sin(radian - Math.PI / 2) * halfLineLength;
  2065. var xDiff = Math.cos(radian - Math.PI / 2) * halfLineLength;
  2066. return [lineLength, halfWidth - xDiff, halfWidth + xDiff, halfHeight - yDiff, halfHeight + yDiff];
  2067. };
  2068. var distance = function (a, b) { return Math.sqrt(a * a + b * b); };
  2069. var findCorner = function (width, height, x, y, closest) {
  2070. var corners = [[0, 0], [0, height], [width, 0], [width, height]];
  2071. return corners.reduce(function (stat, corner) {
  2072. var cx = corner[0], cy = corner[1];
  2073. var d = distance(x - cx, y - cy);
  2074. if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {
  2075. return {
  2076. optimumCorner: corner,
  2077. optimumDistance: d
  2078. };
  2079. }
  2080. return stat;
  2081. }, {
  2082. optimumDistance: closest ? Infinity : -Infinity,
  2083. optimumCorner: null
  2084. }).optimumCorner;
  2085. };
  2086. var calculateRadius = function (gradient, x, y, width, height) {
  2087. var rx = 0;
  2088. var ry = 0;
  2089. switch (gradient.size) {
  2090. case CSSRadialExtent.CLOSEST_SIDE:
  2091. // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.
  2092. // If the shape is an ellipse, it exactly meets the closest side in each dimension.
  2093. if (gradient.shape === CSSRadialShape.CIRCLE) {
  2094. rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
  2095. }
  2096. else if (gradient.shape === CSSRadialShape.ELLIPSE) {
  2097. rx = Math.min(Math.abs(x), Math.abs(x - width));
  2098. ry = Math.min(Math.abs(y), Math.abs(y - height));
  2099. }
  2100. break;
  2101. case CSSRadialExtent.CLOSEST_CORNER:
  2102. // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.
  2103. // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.
  2104. if (gradient.shape === CSSRadialShape.CIRCLE) {
  2105. rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
  2106. }
  2107. else if (gradient.shape === CSSRadialShape.ELLIPSE) {
  2108. // Compute the ratio ry/rx (which is to be the same as for "closest-side")
  2109. var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));
  2110. var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];
  2111. rx = distance(cx - x, (cy - y) / c);
  2112. ry = c * rx;
  2113. }
  2114. break;
  2115. case CSSRadialExtent.FARTHEST_SIDE:
  2116. // Same as closest-side, except the ending shape is sized based on the farthest side(s)
  2117. if (gradient.shape === CSSRadialShape.CIRCLE) {
  2118. rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
  2119. }
  2120. else if (gradient.shape === CSSRadialShape.ELLIPSE) {
  2121. rx = Math.max(Math.abs(x), Math.abs(x - width));
  2122. ry = Math.max(Math.abs(y), Math.abs(y - height));
  2123. }
  2124. break;
  2125. case CSSRadialExtent.FARTHEST_CORNER:
  2126. // Same as closest-corner, except the ending shape is sized based on the farthest corner.
  2127. // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.
  2128. if (gradient.shape === CSSRadialShape.CIRCLE) {
  2129. rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
  2130. }
  2131. else if (gradient.shape === CSSRadialShape.ELLIPSE) {
  2132. // Compute the ratio ry/rx (which is to be the same as for "farthest-side")
  2133. var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));
  2134. var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];
  2135. rx = distance(cx - x, (cy - y) / c);
  2136. ry = c * rx;
  2137. }
  2138. break;
  2139. }
  2140. if (Array.isArray(gradient.size)) {
  2141. rx = getAbsoluteValue(gradient.size[0], width);
  2142. ry = gradient.size.length === 2 ? getAbsoluteValue(gradient.size[1], height) : rx;
  2143. }
  2144. return [rx, ry];
  2145. };
  2146. var linearGradient = function (tokens) {
  2147. var angle$1 = deg(180);
  2148. var stops = [];
  2149. parseFunctionArgs(tokens).forEach(function (arg, i) {
  2150. if (i === 0) {
  2151. var firstToken = arg[0];
  2152. if (firstToken.type === TokenType.IDENT_TOKEN && firstToken.value === 'to') {
  2153. angle$1 = parseNamedSide(arg);
  2154. return;
  2155. }
  2156. else if (isAngle(firstToken)) {
  2157. angle$1 = angle.parse(firstToken);
  2158. return;
  2159. }
  2160. }
  2161. var colorStop = parseColorStop(arg);
  2162. stops.push(colorStop);
  2163. });
  2164. return { angle: angle$1, stops: stops, type: CSSImageType.LINEAR_GRADIENT };
  2165. };
  2166. var prefixLinearGradient = function (tokens) {
  2167. var angle$1 = deg(180);
  2168. var stops = [];
  2169. parseFunctionArgs(tokens).forEach(function (arg, i) {
  2170. if (i === 0) {
  2171. var firstToken = arg[0];
  2172. if (firstToken.type === TokenType.IDENT_TOKEN &&
  2173. ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
  2174. angle$1 = parseNamedSide(arg);
  2175. return;
  2176. }
  2177. else if (isAngle(firstToken)) {
  2178. angle$1 = (angle.parse(firstToken) + deg(270)) % deg(360);
  2179. return;
  2180. }
  2181. }
  2182. var colorStop = parseColorStop(arg);
  2183. stops.push(colorStop);
  2184. });
  2185. return {
  2186. angle: angle$1,
  2187. stops: stops,
  2188. type: CSSImageType.LINEAR_GRADIENT
  2189. };
  2190. };
  2191. var testRangeBounds = function (document) {
  2192. var TEST_HEIGHT = 123;
  2193. if (document.createRange) {
  2194. var range = document.createRange();
  2195. if (range.getBoundingClientRect) {
  2196. var testElement = document.createElement('boundtest');
  2197. testElement.style.height = TEST_HEIGHT + "px";
  2198. testElement.style.display = 'block';
  2199. document.body.appendChild(testElement);
  2200. range.selectNode(testElement);
  2201. var rangeBounds = range.getBoundingClientRect();
  2202. var rangeHeight = Math.round(rangeBounds.height);
  2203. document.body.removeChild(testElement);
  2204. if (rangeHeight === TEST_HEIGHT) {
  2205. return true;
  2206. }
  2207. }
  2208. }
  2209. return false;
  2210. };
  2211. var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };
  2212. var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };
  2213. var testSVG = function (document) {
  2214. var img = new Image();
  2215. var canvas = document.createElement('canvas');
  2216. var ctx = canvas.getContext('2d');
  2217. if (!ctx) {
  2218. return false;
  2219. }
  2220. img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  2221. try {
  2222. ctx.drawImage(img, 0, 0);
  2223. canvas.toDataURL();
  2224. }
  2225. catch (e) {
  2226. return false;
  2227. }
  2228. return true;
  2229. };
  2230. var isGreenPixel = function (data) {
  2231. return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255;
  2232. };
  2233. var testForeignObject = function (document) {
  2234. var canvas = document.createElement('canvas');
  2235. var size = 100;
  2236. canvas.width = size;
  2237. canvas.height = size;
  2238. var ctx = canvas.getContext('2d');
  2239. if (!ctx) {
  2240. return Promise.reject(false);
  2241. }
  2242. ctx.fillStyle = 'rgb(0, 255, 0)';
  2243. ctx.fillRect(0, 0, size, size);
  2244. var img = new Image();
  2245. var greenImageSrc = canvas.toDataURL();
  2246. img.src = greenImageSrc;
  2247. var svg = createForeignObjectSVG(size, size, 0, 0, img);
  2248. ctx.fillStyle = 'red';
  2249. ctx.fillRect(0, 0, size, size);
  2250. return loadSerializedSVG(svg)
  2251. .then(function (img) {
  2252. ctx.drawImage(img, 0, 0);
  2253. var data = ctx.getImageData(0, 0, size, size).data;
  2254. ctx.fillStyle = 'red';
  2255. ctx.fillRect(0, 0, size, size);
  2256. var node = document.createElement('div');
  2257. node.style.backgroundImage = "url(" + greenImageSrc + ")";
  2258. node.style.height = size + "px";
  2259. // Firefox 55 does not render inline <img /> tags
  2260. return isGreenPixel(data)
  2261. ? loadSerializedSVG(createForeignObjectSVG(size, size, 0, 0, node))
  2262. : Promise.reject(false);
  2263. })
  2264. .then(function (img) {
  2265. ctx.drawImage(img, 0, 0);
  2266. // Edge does not render background-images
  2267. return isGreenPixel(ctx.getImageData(0, 0, size, size).data);
  2268. })
  2269. .catch(function () { return false; });
  2270. };
  2271. var createForeignObjectSVG = function (width, height, x, y, node) {
  2272. var xmlns = 'http://www.w3.org/2000/svg';
  2273. var svg = document.createElementNS(xmlns, 'svg');
  2274. var foreignObject = document.createElementNS(xmlns, 'foreignObject');
  2275. svg.setAttributeNS(null, 'width', width.toString());
  2276. svg.setAttributeNS(null, 'height', height.toString());
  2277. foreignObject.setAttributeNS(null, 'width', '100%');
  2278. foreignObject.setAttributeNS(null, 'height', '100%');
  2279. foreignObject.setAttributeNS(null, 'x', x.toString());
  2280. foreignObject.setAttributeNS(null, 'y', y.toString());
  2281. foreignObject.setAttributeNS(null, 'externalResourcesRequired', 'true');
  2282. svg.appendChild(foreignObject);
  2283. foreignObject.appendChild(node);
  2284. return svg;
  2285. };
  2286. var loadSerializedSVG = function (svg) {
  2287. return new Promise(function (resolve, reject) {
  2288. var img = new Image();
  2289. img.onload = function () { return resolve(img); };
  2290. img.onerror = reject;
  2291. img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
  2292. });
  2293. };
  2294. var FEATURES = {
  2295. get SUPPORT_RANGE_BOUNDS() {
  2296. var value = testRangeBounds(document);
  2297. Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', { value: value });
  2298. return value;
  2299. },
  2300. get SUPPORT_SVG_DRAWING() {
  2301. var value = testSVG(document);
  2302. Object.defineProperty(FEATURES, 'SUPPORT_SVG_DRAWING', { value: value });
  2303. return value;
  2304. },
  2305. get SUPPORT_FOREIGNOBJECT_DRAWING() {
  2306. var value = typeof Array.from === 'function' && typeof window.fetch === 'function'
  2307. ? testForeignObject(document)
  2308. : Promise.resolve(false);
  2309. Object.defineProperty(FEATURES, 'SUPPORT_FOREIGNOBJECT_DRAWING', { value: value });
  2310. return value;
  2311. },
  2312. get SUPPORT_CORS_IMAGES() {
  2313. var value = testCORS();
  2314. Object.defineProperty(FEATURES, 'SUPPORT_CORS_IMAGES', { value: value });
  2315. return value;
  2316. },
  2317. get SUPPORT_RESPONSE_TYPE() {
  2318. var value = testResponseType();
  2319. Object.defineProperty(FEATURES, 'SUPPORT_RESPONSE_TYPE', { value: value });
  2320. return value;
  2321. },
  2322. get SUPPORT_CORS_XHR() {
  2323. var value = 'withCredentials' in new XMLHttpRequest();
  2324. Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', { value: value });
  2325. return value;
  2326. }
  2327. };
  2328. var Logger = /** @class */ (function () {
  2329. function Logger(_a) {
  2330. var id = _a.id, enabled = _a.enabled;
  2331. this.id = id;
  2332. this.enabled = enabled;
  2333. this.start = Date.now();
  2334. }
  2335. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  2336. Logger.prototype.debug = function () {
  2337. var args = [];
  2338. for (var _i = 0; _i < arguments.length; _i++) {
  2339. args[_i] = arguments[_i];
  2340. }
  2341. if (this.enabled) {
  2342. // eslint-disable-next-line no-console
  2343. if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
  2344. // eslint-disable-next-line no-console
  2345. console.debug.apply(console, [this.id, this.getTime() + "ms"].concat(args));
  2346. }
  2347. else {
  2348. this.info.apply(this, args);
  2349. }
  2350. }
  2351. };
  2352. Logger.prototype.getTime = function () {
  2353. return Date.now() - this.start;
  2354. };
  2355. Logger.create = function (options) {
  2356. Logger.instances[options.id] = new Logger(options);
  2357. };
  2358. Logger.destroy = function (id) {
  2359. delete Logger.instances[id];
  2360. };
  2361. Logger.getInstance = function (id) {
  2362. var instance = Logger.instances[id];
  2363. if (typeof instance === 'undefined') {
  2364. throw new Error("No logger instance found with id " + id);
  2365. }
  2366. return instance;
  2367. };
  2368. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  2369. Logger.prototype.info = function () {
  2370. var args = [];
  2371. for (var _i = 0; _i < arguments.length; _i++) {
  2372. args[_i] = arguments[_i];
  2373. }
  2374. if (this.enabled) {
  2375. // eslint-disable-next-line no-console
  2376. if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
  2377. // eslint-disable-next-line no-console
  2378. console.info.apply(console, [this.id, this.getTime() + "ms"].concat(args));
  2379. }
  2380. }
  2381. };
  2382. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  2383. Logger.prototype.error = function () {
  2384. var args = [];
  2385. for (var _i = 0; _i < arguments.length; _i++) {
  2386. args[_i] = arguments[_i];
  2387. }
  2388. if (this.enabled) {
  2389. // eslint-disable-next-line no-console
  2390. if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
  2391. // eslint-disable-next-line no-console
  2392. console.error.apply(console, [this.id, this.getTime() + "ms"].concat(args));
  2393. }
  2394. else {
  2395. this.info.apply(this, args);
  2396. }
  2397. }
  2398. };
  2399. Logger.instances = {};
  2400. return Logger;
  2401. }());
  2402. var CacheStorage = /** @class */ (function () {
  2403. function CacheStorage() {
  2404. }
  2405. CacheStorage.create = function (name, options) {
  2406. return (CacheStorage._caches[name] = new Cache(name, options));
  2407. };
  2408. CacheStorage.destroy = function (name) {
  2409. delete CacheStorage._caches[name];
  2410. };
  2411. CacheStorage.open = function (name) {
  2412. var cache = CacheStorage._caches[name];
  2413. if (typeof cache !== 'undefined') {
  2414. return cache;
  2415. }
  2416. throw new Error("Cache with key \"" + name + "\" not found");
  2417. };
  2418. CacheStorage.getOrigin = function (url) {
  2419. var link = CacheStorage._link;
  2420. if (!link) {
  2421. return 'about:blank';
  2422. }
  2423. link.href = url;
  2424. link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/
  2425. return link.protocol + link.hostname + link.port;
  2426. };
  2427. CacheStorage.isSameOrigin = function (src) {
  2428. return CacheStorage.getOrigin(src) === CacheStorage._origin;
  2429. };
  2430. CacheStorage.setContext = function (window) {
  2431. CacheStorage._link = window.document.createElement('a');
  2432. CacheStorage._origin = CacheStorage.getOrigin(window.location.href);
  2433. };
  2434. CacheStorage.getInstance = function () {
  2435. var current = CacheStorage._current;
  2436. if (current === null) {
  2437. throw new Error("No cache instance attached");
  2438. }
  2439. return current;
  2440. };
  2441. CacheStorage.attachInstance = function (cache) {
  2442. CacheStorage._current = cache;
  2443. };
  2444. CacheStorage.detachInstance = function () {
  2445. CacheStorage._current = null;
  2446. };
  2447. CacheStorage._caches = {};
  2448. CacheStorage._origin = 'about:blank';
  2449. CacheStorage._current = null;
  2450. return CacheStorage;
  2451. }());
  2452. var Cache = /** @class */ (function () {
  2453. function Cache(id, options) {
  2454. this.id = id;
  2455. this._options = options;
  2456. this._cache = {};
  2457. }
  2458. Cache.prototype.addImage = function (src) {
  2459. var result = Promise.resolve();
  2460. if (this.has(src)) {
  2461. return result;
  2462. }
  2463. if (isBlobImage(src) || isRenderable(src)) {
  2464. this._cache[src] = this.loadImage(src);
  2465. return result;
  2466. }
  2467. return result;
  2468. };
  2469. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  2470. Cache.prototype.match = function (src) {
  2471. return this._cache[src];
  2472. };
  2473. Cache.prototype.loadImage = function (key) {
  2474. return __awaiter(this, void 0, void 0, function () {
  2475. var isSameOrigin, useCORS, useProxy, src;
  2476. var _this = this;
  2477. return __generator(this, function (_a) {
  2478. switch (_a.label) {
  2479. case 0:
  2480. isSameOrigin = CacheStorage.isSameOrigin(key);
  2481. useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
  2482. useProxy = !isInlineImage(key) &&
  2483. !isSameOrigin &&
  2484. typeof this._options.proxy === 'string' &&
  2485. FEATURES.SUPPORT_CORS_XHR &&
  2486. !useCORS;
  2487. if (!isSameOrigin && this._options.allowTaint === false && !isInlineImage(key) && !useProxy && !useCORS) {
  2488. return [2 /*return*/];
  2489. }
  2490. src = key;
  2491. if (!useProxy) return [3 /*break*/, 2];
  2492. return [4 /*yield*/, this.proxy(src)];
  2493. case 1:
  2494. src = _a.sent();
  2495. _a.label = 2;
  2496. case 2:
  2497. Logger.getInstance(this.id).debug("Added image " + key.substring(0, 256));
  2498. return [4 /*yield*/, new Promise(function (resolve, reject) {
  2499. var img = new Image();
  2500. img.onload = function () { return resolve(img); };
  2501. img.onerror = reject;
  2502. //ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous
  2503. if (isInlineBase64Image(src) || useCORS) {
  2504. img.crossOrigin = 'anonymous';
  2505. }
  2506. img.src = src;
  2507. if (img.complete === true) {
  2508. // Inline XML images may fail to parse, throwing an Error later on
  2509. setTimeout(function () { return resolve(img); }, 500);
  2510. }
  2511. if (_this._options.imageTimeout > 0) {
  2512. setTimeout(function () { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout);
  2513. }
  2514. })];
  2515. case 3: return [2 /*return*/, _a.sent()];
  2516. }
  2517. });
  2518. });
  2519. };
  2520. Cache.prototype.has = function (key) {
  2521. return typeof this._cache[key] !== 'undefined';
  2522. };
  2523. Cache.prototype.keys = function () {
  2524. return Promise.resolve(Object.keys(this._cache));
  2525. };
  2526. Cache.prototype.proxy = function (src) {
  2527. var _this = this;
  2528. var proxy = this._options.proxy;
  2529. if (!proxy) {
  2530. throw new Error('No proxy defined');
  2531. }
  2532. var key = src.substring(0, 256);
  2533. return new Promise(function (resolve, reject) {
  2534. var responseType = FEATURES.SUPPORT_RESPONSE_TYPE ? 'blob' : 'text';
  2535. var xhr = new XMLHttpRequest();
  2536. xhr.onload = function () {
  2537. if (xhr.status === 200) {
  2538. if (responseType === 'text') {
  2539. resolve(xhr.response);
  2540. }
  2541. else {
  2542. var reader_1 = new FileReader();
  2543. reader_1.addEventListener('load', function () { return resolve(reader_1.result); }, false);
  2544. reader_1.addEventListener('error', function (e) { return reject(e); }, false);
  2545. reader_1.readAsDataURL(xhr.response);
  2546. }
  2547. }
  2548. else {
  2549. reject("Failed to proxy resource " + key + " with status code " + xhr.status);
  2550. }
  2551. };
  2552. xhr.onerror = reject;
  2553. xhr.open('GET', proxy + "?url=" + encodeURIComponent(src) + "&responseType=" + responseType);
  2554. if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
  2555. xhr.responseType = responseType;
  2556. }
  2557. if (_this._options.imageTimeout) {
  2558. var timeout_1 = _this._options.imageTimeout;
  2559. xhr.timeout = timeout_1;
  2560. xhr.ontimeout = function () { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); };
  2561. }
  2562. xhr.send();
  2563. });
  2564. };
  2565. return Cache;
  2566. }());
  2567. var INLINE_SVG = /^data:image\/svg\+xml/i;
  2568. var INLINE_BASE64 = /^data:image\/.*;base64,/i;
  2569. var INLINE_IMG = /^data:image\/.*/i;
  2570. var isRenderable = function (src) { return FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); };
  2571. var isInlineImage = function (src) { return INLINE_IMG.test(src); };
  2572. var isInlineBase64Image = function (src) { return INLINE_BASE64.test(src); };
  2573. var isBlobImage = function (src) { return src.substr(0, 4) === 'blob'; };
  2574. var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); };
  2575. var webkitGradient = function (tokens) {
  2576. var angle = deg(180);
  2577. var stops = [];
  2578. var type = CSSImageType.LINEAR_GRADIENT;
  2579. var shape = CSSRadialShape.CIRCLE;
  2580. var size = CSSRadialExtent.FARTHEST_CORNER;
  2581. var position = [];
  2582. parseFunctionArgs(tokens).forEach(function (arg, i) {
  2583. var firstToken = arg[0];
  2584. if (i === 0) {
  2585. if (isIdentToken(firstToken) && firstToken.value === 'linear') {
  2586. type = CSSImageType.LINEAR_GRADIENT;
  2587. return;
  2588. }
  2589. else if (isIdentToken(firstToken) && firstToken.value === 'radial') {
  2590. type = CSSImageType.RADIAL_GRADIENT;
  2591. return;
  2592. }
  2593. }
  2594. if (firstToken.type === TokenType.FUNCTION) {
  2595. if (firstToken.name === 'from') {
  2596. var color$1 = color.parse(firstToken.values[0]);
  2597. stops.push({ stop: ZERO_LENGTH, color: color$1 });
  2598. }
  2599. else if (firstToken.name === 'to') {
  2600. var color$1 = color.parse(firstToken.values[0]);
  2601. stops.push({ stop: HUNDRED_PERCENT, color: color$1 });
  2602. }
  2603. else if (firstToken.name === 'color-stop') {
  2604. var values = firstToken.values.filter(nonFunctionArgSeparator);
  2605. if (values.length === 2) {
  2606. var color$1 = color.parse(values[1]);
  2607. var stop_1 = values[0];
  2608. if (isNumberToken(stop_1)) {
  2609. stops.push({
  2610. stop: { type: TokenType.PERCENTAGE_TOKEN, number: stop_1.number * 100, flags: stop_1.flags },
  2611. color: color$1
  2612. });
  2613. }
  2614. }
  2615. }
  2616. }
  2617. });
  2618. return type === CSSImageType.LINEAR_GRADIENT
  2619. ? {
  2620. angle: (angle + deg(180)) % deg(360),
  2621. stops: stops,
  2622. type: type
  2623. }
  2624. : { size: size, shape: shape, stops: stops, position: position, type: type };
  2625. };
  2626. var CLOSEST_SIDE = 'closest-side';
  2627. var FARTHEST_SIDE = 'farthest-side';
  2628. var CLOSEST_CORNER = 'closest-corner';
  2629. var FARTHEST_CORNER = 'farthest-corner';
  2630. var CIRCLE = 'circle';
  2631. var ELLIPSE = 'ellipse';
  2632. var COVER = 'cover';
  2633. var CONTAIN = 'contain';
  2634. var radialGradient = function (tokens) {
  2635. var shape = CSSRadialShape.CIRCLE;
  2636. var size = CSSRadialExtent.FARTHEST_CORNER;
  2637. var stops = [];
  2638. var position = [];
  2639. parseFunctionArgs(tokens).forEach(function (arg, i) {
  2640. var isColorStop = true;
  2641. if (i === 0) {
  2642. var isAtPosition_1 = false;
  2643. isColorStop = arg.reduce(function (acc, token) {
  2644. if (isAtPosition_1) {
  2645. if (isIdentToken(token)) {
  2646. switch (token.value) {
  2647. case 'center':
  2648. position.push(FIFTY_PERCENT);
  2649. return acc;
  2650. case 'top':
  2651. case 'left':
  2652. position.push(ZERO_LENGTH);
  2653. return acc;
  2654. case 'right':
  2655. case 'bottom':
  2656. position.push(HUNDRED_PERCENT);
  2657. return acc;
  2658. }
  2659. }
  2660. else if (isLengthPercentage(token) || isLength(token)) {
  2661. position.push(token);
  2662. }
  2663. }
  2664. else if (isIdentToken(token)) {
  2665. switch (token.value) {
  2666. case CIRCLE:
  2667. shape = CSSRadialShape.CIRCLE;
  2668. return false;
  2669. case ELLIPSE:
  2670. shape = CSSRadialShape.ELLIPSE;
  2671. return false;
  2672. case 'at':
  2673. isAtPosition_1 = true;
  2674. return false;
  2675. case CLOSEST_SIDE:
  2676. size = CSSRadialExtent.CLOSEST_SIDE;
  2677. return false;
  2678. case COVER:
  2679. case FARTHEST_SIDE:
  2680. size = CSSRadialExtent.FARTHEST_SIDE;
  2681. return false;
  2682. case CONTAIN:
  2683. case CLOSEST_CORNER:
  2684. size = CSSRadialExtent.CLOSEST_CORNER;
  2685. return false;
  2686. case FARTHEST_CORNER:
  2687. size = CSSRadialExtent.FARTHEST_CORNER;
  2688. return false;
  2689. }
  2690. }
  2691. else if (isLength(token) || isLengthPercentage(token)) {
  2692. if (!Array.isArray(size)) {
  2693. size = [];
  2694. }
  2695. size.push(token);
  2696. return false;
  2697. }
  2698. return acc;
  2699. }, isColorStop);
  2700. }
  2701. if (isColorStop) {
  2702. var colorStop = parseColorStop(arg);
  2703. stops.push(colorStop);
  2704. }
  2705. });
  2706. return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };
  2707. };
  2708. var prefixRadialGradient = function (tokens) {
  2709. var shape = CSSRadialShape.CIRCLE;
  2710. var size = CSSRadialExtent.FARTHEST_CORNER;
  2711. var stops = [];
  2712. var position = [];
  2713. parseFunctionArgs(tokens).forEach(function (arg, i) {
  2714. var isColorStop = true;
  2715. if (i === 0) {
  2716. isColorStop = arg.reduce(function (acc, token) {
  2717. if (isIdentToken(token)) {
  2718. switch (token.value) {
  2719. case 'center':
  2720. position.push(FIFTY_PERCENT);
  2721. return false;
  2722. case 'top':
  2723. case 'left':
  2724. position.push(ZERO_LENGTH);
  2725. return false;
  2726. case 'right':
  2727. case 'bottom':
  2728. position.push(HUNDRED_PERCENT);
  2729. return false;
  2730. }
  2731. }
  2732. else if (isLengthPercentage(token) || isLength(token)) {
  2733. position.push(token);
  2734. return false;
  2735. }
  2736. return acc;
  2737. }, isColorStop);
  2738. }
  2739. else if (i === 1) {
  2740. isColorStop = arg.reduce(function (acc, token) {
  2741. if (isIdentToken(token)) {
  2742. switch (token.value) {
  2743. case CIRCLE:
  2744. shape = CSSRadialShape.CIRCLE;
  2745. return false;
  2746. case ELLIPSE:
  2747. shape = CSSRadialShape.ELLIPSE;
  2748. return false;
  2749. case CONTAIN:
  2750. case CLOSEST_SIDE:
  2751. size = CSSRadialExtent.CLOSEST_SIDE;
  2752. return false;
  2753. case FARTHEST_SIDE:
  2754. size = CSSRadialExtent.FARTHEST_SIDE;
  2755. return false;
  2756. case CLOSEST_CORNER:
  2757. size = CSSRadialExtent.CLOSEST_CORNER;
  2758. return false;
  2759. case COVER:
  2760. case FARTHEST_CORNER:
  2761. size = CSSRadialExtent.FARTHEST_CORNER;
  2762. return false;
  2763. }
  2764. }
  2765. else if (isLength(token) || isLengthPercentage(token)) {
  2766. if (!Array.isArray(size)) {
  2767. size = [];
  2768. }
  2769. size.push(token);
  2770. return false;
  2771. }
  2772. return acc;
  2773. }, isColorStop);
  2774. }
  2775. if (isColorStop) {
  2776. var colorStop = parseColorStop(arg);
  2777. stops.push(colorStop);
  2778. }
  2779. });
  2780. return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };
  2781. };
  2782. var CSSImageType;
  2783. (function (CSSImageType) {
  2784. CSSImageType[CSSImageType["URL"] = 0] = "URL";
  2785. CSSImageType[CSSImageType["LINEAR_GRADIENT"] = 1] = "LINEAR_GRADIENT";
  2786. CSSImageType[CSSImageType["RADIAL_GRADIENT"] = 2] = "RADIAL_GRADIENT";
  2787. })(CSSImageType || (CSSImageType = {}));
  2788. var isLinearGradient = function (background) {
  2789. return background.type === CSSImageType.LINEAR_GRADIENT;
  2790. };
  2791. var isRadialGradient = function (background) {
  2792. return background.type === CSSImageType.RADIAL_GRADIENT;
  2793. };
  2794. var CSSRadialShape;
  2795. (function (CSSRadialShape) {
  2796. CSSRadialShape[CSSRadialShape["CIRCLE"] = 0] = "CIRCLE";
  2797. CSSRadialShape[CSSRadialShape["ELLIPSE"] = 1] = "ELLIPSE";
  2798. })(CSSRadialShape || (CSSRadialShape = {}));
  2799. var CSSRadialExtent;
  2800. (function (CSSRadialExtent) {
  2801. CSSRadialExtent[CSSRadialExtent["CLOSEST_SIDE"] = 0] = "CLOSEST_SIDE";
  2802. CSSRadialExtent[CSSRadialExtent["FARTHEST_SIDE"] = 1] = "FARTHEST_SIDE";
  2803. CSSRadialExtent[CSSRadialExtent["CLOSEST_CORNER"] = 2] = "CLOSEST_CORNER";
  2804. CSSRadialExtent[CSSRadialExtent["FARTHEST_CORNER"] = 3] = "FARTHEST_CORNER";
  2805. })(CSSRadialExtent || (CSSRadialExtent = {}));
  2806. var image = {
  2807. name: 'image',
  2808. parse: function (value) {
  2809. if (value.type === TokenType.URL_TOKEN) {
  2810. var image_1 = { url: value.value, type: CSSImageType.URL };
  2811. CacheStorage.getInstance().addImage(value.value);
  2812. return image_1;
  2813. }
  2814. if (value.type === TokenType.FUNCTION) {
  2815. var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];
  2816. if (typeof imageFunction === 'undefined') {
  2817. throw new Error("Attempting to parse an unsupported image function \"" + value.name + "\"");
  2818. }
  2819. return imageFunction(value.values);
  2820. }
  2821. throw new Error("Unsupported image type");
  2822. }
  2823. };
  2824. function isSupportedImage(value) {
  2825. return value.type !== TokenType.FUNCTION || SUPPORTED_IMAGE_FUNCTIONS[value.name];
  2826. }
  2827. var SUPPORTED_IMAGE_FUNCTIONS = {
  2828. 'linear-gradient': linearGradient,
  2829. '-moz-linear-gradient': prefixLinearGradient,
  2830. '-ms-linear-gradient': prefixLinearGradient,
  2831. '-o-linear-gradient': prefixLinearGradient,
  2832. '-webkit-linear-gradient': prefixLinearGradient,
  2833. 'radial-gradient': radialGradient,
  2834. '-moz-radial-gradient': prefixRadialGradient,
  2835. '-ms-radial-gradient': prefixRadialGradient,
  2836. '-o-radial-gradient': prefixRadialGradient,
  2837. '-webkit-radial-gradient': prefixRadialGradient,
  2838. '-webkit-gradient': webkitGradient
  2839. };
  2840. var backgroundImage = {
  2841. name: 'background-image',
  2842. initialValue: 'none',
  2843. type: PropertyDescriptorParsingType.LIST,
  2844. prefix: false,
  2845. parse: function (tokens) {
  2846. if (tokens.length === 0) {
  2847. return [];
  2848. }
  2849. var first = tokens[0];
  2850. if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
  2851. return [];
  2852. }
  2853. return tokens.filter(function (value) { return nonFunctionArgSeparator(value) && isSupportedImage(value); }).map(image.parse);
  2854. }
  2855. };
  2856. var backgroundOrigin = {
  2857. name: 'background-origin',
  2858. initialValue: 'border-box',
  2859. prefix: false,
  2860. type: PropertyDescriptorParsingType.LIST,
  2861. parse: function (tokens) {
  2862. return tokens.map(function (token) {
  2863. if (isIdentToken(token)) {
  2864. switch (token.value) {
  2865. case 'padding-box':
  2866. return 1 /* PADDING_BOX */;
  2867. case 'content-box':
  2868. return 2 /* CONTENT_BOX */;
  2869. }
  2870. }
  2871. return 0 /* BORDER_BOX */;
  2872. });
  2873. }
  2874. };
  2875. var backgroundPosition = {
  2876. name: 'background-position',
  2877. initialValue: '0% 0%',
  2878. type: PropertyDescriptorParsingType.LIST,
  2879. prefix: false,
  2880. parse: function (tokens) {
  2881. return parseFunctionArgs(tokens)
  2882. .map(function (values) { return values.filter(isLengthPercentage); })
  2883. .map(parseLengthPercentageTuple);
  2884. }
  2885. };
  2886. var BACKGROUND_REPEAT;
  2887. (function (BACKGROUND_REPEAT) {
  2888. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT"] = 0] = "REPEAT";
  2889. BACKGROUND_REPEAT[BACKGROUND_REPEAT["NO_REPEAT"] = 1] = "NO_REPEAT";
  2890. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT_X"] = 2] = "REPEAT_X";
  2891. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT_Y"] = 3] = "REPEAT_Y";
  2892. })(BACKGROUND_REPEAT || (BACKGROUND_REPEAT = {}));
  2893. var backgroundRepeat = {
  2894. name: 'background-repeat',
  2895. initialValue: 'repeat',
  2896. prefix: false,
  2897. type: PropertyDescriptorParsingType.LIST,
  2898. parse: function (tokens) {
  2899. return parseFunctionArgs(tokens)
  2900. .map(function (values) {
  2901. return values
  2902. .filter(isIdentToken)
  2903. .map(function (token) { return token.value; })
  2904. .join(' ');
  2905. })
  2906. .map(parseBackgroundRepeat);
  2907. }
  2908. };
  2909. var parseBackgroundRepeat = function (value) {
  2910. switch (value) {
  2911. case 'no-repeat':
  2912. return BACKGROUND_REPEAT.NO_REPEAT;
  2913. case 'repeat-x':
  2914. case 'repeat no-repeat':
  2915. return BACKGROUND_REPEAT.REPEAT_X;
  2916. case 'repeat-y':
  2917. case 'no-repeat repeat':
  2918. return BACKGROUND_REPEAT.REPEAT_Y;
  2919. case 'repeat':
  2920. default:
  2921. return BACKGROUND_REPEAT.REPEAT;
  2922. }
  2923. };
  2924. var BACKGROUND_SIZE;
  2925. (function (BACKGROUND_SIZE) {
  2926. BACKGROUND_SIZE["AUTO"] = "auto";
  2927. BACKGROUND_SIZE["CONTAIN"] = "contain";
  2928. BACKGROUND_SIZE["COVER"] = "cover";
  2929. })(BACKGROUND_SIZE || (BACKGROUND_SIZE = {}));
  2930. var backgroundSize = {
  2931. name: 'background-size',
  2932. initialValue: '0',
  2933. prefix: false,
  2934. type: PropertyDescriptorParsingType.LIST,
  2935. parse: function (tokens) {
  2936. return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
  2937. }
  2938. };
  2939. var isBackgroundSizeInfoToken = function (value) {
  2940. return isIdentToken(value) || isLengthPercentage(value);
  2941. };
  2942. var borderColorForSide = function (side) { return ({
  2943. name: "border-" + side + "-color",
  2944. initialValue: 'transparent',
  2945. prefix: false,
  2946. type: PropertyDescriptorParsingType.TYPE_VALUE,
  2947. format: 'color'
  2948. }); };
  2949. var borderTopColor = borderColorForSide('top');
  2950. var borderRightColor = borderColorForSide('right');
  2951. var borderBottomColor = borderColorForSide('bottom');
  2952. var borderLeftColor = borderColorForSide('left');
  2953. var borderRadiusForSide = function (side) { return ({
  2954. name: "border-radius-" + side,
  2955. initialValue: '0 0',
  2956. prefix: false,
  2957. type: PropertyDescriptorParsingType.LIST,
  2958. parse: function (tokens) { return parseLengthPercentageTuple(tokens.filter(isLengthPercentage)); }
  2959. }); };
  2960. var borderTopLeftRadius = borderRadiusForSide('top-left');
  2961. var borderTopRightRadius = borderRadiusForSide('top-right');
  2962. var borderBottomRightRadius = borderRadiusForSide('bottom-right');
  2963. var borderBottomLeftRadius = borderRadiusForSide('bottom-left');
  2964. var BORDER_STYLE;
  2965. (function (BORDER_STYLE) {
  2966. BORDER_STYLE[BORDER_STYLE["NONE"] = 0] = "NONE";
  2967. BORDER_STYLE[BORDER_STYLE["SOLID"] = 1] = "SOLID";
  2968. })(BORDER_STYLE || (BORDER_STYLE = {}));
  2969. var borderStyleForSide = function (side) { return ({
  2970. name: "border-" + side + "-style",
  2971. initialValue: 'solid',
  2972. prefix: false,
  2973. type: PropertyDescriptorParsingType.IDENT_VALUE,
  2974. parse: function (style) {
  2975. switch (style) {
  2976. case 'none':
  2977. return BORDER_STYLE.NONE;
  2978. }
  2979. return BORDER_STYLE.SOLID;
  2980. }
  2981. }); };
  2982. var borderTopStyle = borderStyleForSide('top');
  2983. var borderRightStyle = borderStyleForSide('right');
  2984. var borderBottomStyle = borderStyleForSide('bottom');
  2985. var borderLeftStyle = borderStyleForSide('left');
  2986. var borderWidthForSide = function (side) { return ({
  2987. name: "border-" + side + "-width",
  2988. initialValue: '0',
  2989. type: PropertyDescriptorParsingType.VALUE,
  2990. prefix: false,
  2991. parse: function (token) {
  2992. if (isDimensionToken(token)) {
  2993. return token.number;
  2994. }
  2995. return 0;
  2996. }
  2997. }); };
  2998. var borderTopWidth = borderWidthForSide('top');
  2999. var borderRightWidth = borderWidthForSide('right');
  3000. var borderBottomWidth = borderWidthForSide('bottom');
  3001. var borderLeftWidth = borderWidthForSide('left');
  3002. var color$1 = {
  3003. name: "color",
  3004. initialValue: 'transparent',
  3005. prefix: false,
  3006. type: PropertyDescriptorParsingType.TYPE_VALUE,
  3007. format: 'color'
  3008. };
  3009. var display = {
  3010. name: 'display',
  3011. initialValue: 'inline-block',
  3012. prefix: false,
  3013. type: PropertyDescriptorParsingType.LIST,
  3014. parse: function (tokens) {
  3015. return tokens.filter(isIdentToken).reduce(function (bit, token) {
  3016. return bit | parseDisplayValue(token.value);
  3017. }, 0 /* NONE */);
  3018. }
  3019. };
  3020. var parseDisplayValue = function (display) {
  3021. switch (display) {
  3022. case 'block':
  3023. return 2 /* BLOCK */;
  3024. case 'inline':
  3025. return 4 /* INLINE */;
  3026. case 'run-in':
  3027. return 8 /* RUN_IN */;
  3028. case 'flow':
  3029. return 16 /* FLOW */;
  3030. case 'flow-root':
  3031. return 32 /* FLOW_ROOT */;
  3032. case 'table':
  3033. return 64 /* TABLE */;
  3034. case 'flex':
  3035. case '-webkit-flex':
  3036. return 128 /* FLEX */;
  3037. case 'grid':
  3038. case '-ms-grid':
  3039. return 256 /* GRID */;
  3040. case 'ruby':
  3041. return 512 /* RUBY */;
  3042. case 'subgrid':
  3043. return 1024 /* SUBGRID */;
  3044. case 'list-item':
  3045. return 2048 /* LIST_ITEM */;
  3046. case 'table-row-group':
  3047. return 4096 /* TABLE_ROW_GROUP */;
  3048. case 'table-header-group':
  3049. return 8192 /* TABLE_HEADER_GROUP */;
  3050. case 'table-footer-group':
  3051. return 16384 /* TABLE_FOOTER_GROUP */;
  3052. case 'table-row':
  3053. return 32768 /* TABLE_ROW */;
  3054. case 'table-cell':
  3055. return 65536 /* TABLE_CELL */;
  3056. case 'table-column-group':
  3057. return 131072 /* TABLE_COLUMN_GROUP */;
  3058. case 'table-column':
  3059. return 262144 /* TABLE_COLUMN */;
  3060. case 'table-caption':
  3061. return 524288 /* TABLE_CAPTION */;
  3062. case 'ruby-base':
  3063. return 1048576 /* RUBY_BASE */;
  3064. case 'ruby-text':
  3065. return 2097152 /* RUBY_TEXT */;
  3066. case 'ruby-base-container':
  3067. return 4194304 /* RUBY_BASE_CONTAINER */;
  3068. case 'ruby-text-container':
  3069. return 8388608 /* RUBY_TEXT_CONTAINER */;
  3070. case 'contents':
  3071. return 16777216 /* CONTENTS */;
  3072. case 'inline-block':
  3073. return 33554432 /* INLINE_BLOCK */;
  3074. case 'inline-list-item':
  3075. return 67108864 /* INLINE_LIST_ITEM */;
  3076. case 'inline-table':
  3077. return 134217728 /* INLINE_TABLE */;
  3078. case 'inline-flex':
  3079. return 268435456 /* INLINE_FLEX */;
  3080. case 'inline-grid':
  3081. return 536870912 /* INLINE_GRID */;
  3082. }
  3083. return 0 /* NONE */;
  3084. };
  3085. var FLOAT;
  3086. (function (FLOAT) {
  3087. FLOAT[FLOAT["NONE"] = 0] = "NONE";
  3088. FLOAT[FLOAT["LEFT"] = 1] = "LEFT";
  3089. FLOAT[FLOAT["RIGHT"] = 2] = "RIGHT";
  3090. FLOAT[FLOAT["INLINE_START"] = 3] = "INLINE_START";
  3091. FLOAT[FLOAT["INLINE_END"] = 4] = "INLINE_END";
  3092. })(FLOAT || (FLOAT = {}));
  3093. var float = {
  3094. name: 'float',
  3095. initialValue: 'none',
  3096. prefix: false,
  3097. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3098. parse: function (float) {
  3099. switch (float) {
  3100. case 'left':
  3101. return FLOAT.LEFT;
  3102. case 'right':
  3103. return FLOAT.RIGHT;
  3104. case 'inline-start':
  3105. return FLOAT.INLINE_START;
  3106. case 'inline-end':
  3107. return FLOAT.INLINE_END;
  3108. }
  3109. return FLOAT.NONE;
  3110. }
  3111. };
  3112. var letterSpacing = {
  3113. name: 'letter-spacing',
  3114. initialValue: '0',
  3115. prefix: false,
  3116. type: PropertyDescriptorParsingType.VALUE,
  3117. parse: function (token) {
  3118. if (token.type === TokenType.IDENT_TOKEN && token.value === 'normal') {
  3119. return 0;
  3120. }
  3121. if (token.type === TokenType.NUMBER_TOKEN) {
  3122. return token.number;
  3123. }
  3124. if (token.type === TokenType.DIMENSION_TOKEN) {
  3125. return token.number;
  3126. }
  3127. return 0;
  3128. }
  3129. };
  3130. var LINE_BREAK;
  3131. (function (LINE_BREAK) {
  3132. LINE_BREAK["NORMAL"] = "normal";
  3133. LINE_BREAK["STRICT"] = "strict";
  3134. })(LINE_BREAK || (LINE_BREAK = {}));
  3135. var lineBreak = {
  3136. name: 'line-break',
  3137. initialValue: 'normal',
  3138. prefix: false,
  3139. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3140. parse: function (lineBreak) {
  3141. switch (lineBreak) {
  3142. case 'strict':
  3143. return LINE_BREAK.STRICT;
  3144. case 'normal':
  3145. default:
  3146. return LINE_BREAK.NORMAL;
  3147. }
  3148. }
  3149. };
  3150. var lineHeight = {
  3151. name: 'line-height',
  3152. initialValue: 'normal',
  3153. prefix: false,
  3154. type: PropertyDescriptorParsingType.TOKEN_VALUE
  3155. };
  3156. var computeLineHeight = function (token, fontSize) {
  3157. if (isIdentToken(token) && token.value === 'normal') {
  3158. return 1.2 * fontSize;
  3159. }
  3160. else if (token.type === TokenType.NUMBER_TOKEN) {
  3161. return fontSize * token.number;
  3162. }
  3163. else if (isLengthPercentage(token)) {
  3164. return getAbsoluteValue(token, fontSize);
  3165. }
  3166. return fontSize;
  3167. };
  3168. var listStyleImage = {
  3169. name: 'list-style-image',
  3170. initialValue: 'none',
  3171. type: PropertyDescriptorParsingType.VALUE,
  3172. prefix: false,
  3173. parse: function (token) {
  3174. if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {
  3175. return null;
  3176. }
  3177. return image.parse(token);
  3178. }
  3179. };
  3180. var LIST_STYLE_POSITION;
  3181. (function (LIST_STYLE_POSITION) {
  3182. LIST_STYLE_POSITION[LIST_STYLE_POSITION["INSIDE"] = 0] = "INSIDE";
  3183. LIST_STYLE_POSITION[LIST_STYLE_POSITION["OUTSIDE"] = 1] = "OUTSIDE";
  3184. })(LIST_STYLE_POSITION || (LIST_STYLE_POSITION = {}));
  3185. var listStylePosition = {
  3186. name: 'list-style-position',
  3187. initialValue: 'outside',
  3188. prefix: false,
  3189. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3190. parse: function (position) {
  3191. switch (position) {
  3192. case 'inside':
  3193. return LIST_STYLE_POSITION.INSIDE;
  3194. case 'outside':
  3195. default:
  3196. return LIST_STYLE_POSITION.OUTSIDE;
  3197. }
  3198. }
  3199. };
  3200. var LIST_STYLE_TYPE;
  3201. (function (LIST_STYLE_TYPE) {
  3202. LIST_STYLE_TYPE[LIST_STYLE_TYPE["NONE"] = -1] = "NONE";
  3203. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DISC"] = 0] = "DISC";
  3204. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CIRCLE"] = 1] = "CIRCLE";
  3205. LIST_STYLE_TYPE[LIST_STYLE_TYPE["SQUARE"] = 2] = "SQUARE";
  3206. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DECIMAL"] = 3] = "DECIMAL";
  3207. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CJK_DECIMAL"] = 4] = "CJK_DECIMAL";
  3208. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DECIMAL_LEADING_ZERO"] = 5] = "DECIMAL_LEADING_ZERO";
  3209. LIST_STYLE_TYPE[LIST_STYLE_TYPE["LOWER_ROMAN"] = 6] = "LOWER_ROMAN";
  3210. LIST_STYLE_TYPE[LIST_STYLE_TYPE["UPPER_ROMAN"] = 7] = "UPPER_ROMAN";
  3211. LIST_STYLE_TYPE[LIST_STYLE_TYPE["LOWER_GREEK"] = 8] = "LOWER_GREEK";
  3212. LIST_STYLE_TYPE[LIST_STYLE_TYPE["LOWER_ALPHA"] = 9] = "LOWER_ALPHA";
  3213. LIST_STYLE_TYPE[LIST_STYLE_TYPE["UPPER_ALPHA"] = 10] = "UPPER_ALPHA";
  3214. LIST_STYLE_TYPE[LIST_STYLE_TYPE["ARABIC_INDIC"] = 11] = "ARABIC_INDIC";
  3215. LIST_STYLE_TYPE[LIST_STYLE_TYPE["ARMENIAN"] = 12] = "ARMENIAN";
  3216. LIST_STYLE_TYPE[LIST_STYLE_TYPE["BENGALI"] = 13] = "BENGALI";
  3217. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CAMBODIAN"] = 14] = "CAMBODIAN";
  3218. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CJK_EARTHLY_BRANCH"] = 15] = "CJK_EARTHLY_BRANCH";
  3219. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CJK_HEAVENLY_STEM"] = 16] = "CJK_HEAVENLY_STEM";
  3220. LIST_STYLE_TYPE[LIST_STYLE_TYPE["CJK_IDEOGRAPHIC"] = 17] = "CJK_IDEOGRAPHIC";
  3221. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DEVANAGARI"] = 18] = "DEVANAGARI";
  3222. LIST_STYLE_TYPE[LIST_STYLE_TYPE["ETHIOPIC_NUMERIC"] = 19] = "ETHIOPIC_NUMERIC";
  3223. LIST_STYLE_TYPE[LIST_STYLE_TYPE["GEORGIAN"] = 20] = "GEORGIAN";
  3224. LIST_STYLE_TYPE[LIST_STYLE_TYPE["GUJARATI"] = 21] = "GUJARATI";
  3225. LIST_STYLE_TYPE[LIST_STYLE_TYPE["GURMUKHI"] = 22] = "GURMUKHI";
  3226. LIST_STYLE_TYPE[LIST_STYLE_TYPE["HEBREW"] = 22] = "HEBREW";
  3227. LIST_STYLE_TYPE[LIST_STYLE_TYPE["HIRAGANA"] = 23] = "HIRAGANA";
  3228. LIST_STYLE_TYPE[LIST_STYLE_TYPE["HIRAGANA_IROHA"] = 24] = "HIRAGANA_IROHA";
  3229. LIST_STYLE_TYPE[LIST_STYLE_TYPE["JAPANESE_FORMAL"] = 25] = "JAPANESE_FORMAL";
  3230. LIST_STYLE_TYPE[LIST_STYLE_TYPE["JAPANESE_INFORMAL"] = 26] = "JAPANESE_INFORMAL";
  3231. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KANNADA"] = 27] = "KANNADA";
  3232. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KATAKANA"] = 28] = "KATAKANA";
  3233. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KATAKANA_IROHA"] = 29] = "KATAKANA_IROHA";
  3234. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KHMER"] = 30] = "KHMER";
  3235. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KOREAN_HANGUL_FORMAL"] = 31] = "KOREAN_HANGUL_FORMAL";
  3236. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KOREAN_HANJA_FORMAL"] = 32] = "KOREAN_HANJA_FORMAL";
  3237. LIST_STYLE_TYPE[LIST_STYLE_TYPE["KOREAN_HANJA_INFORMAL"] = 33] = "KOREAN_HANJA_INFORMAL";
  3238. LIST_STYLE_TYPE[LIST_STYLE_TYPE["LAO"] = 34] = "LAO";
  3239. LIST_STYLE_TYPE[LIST_STYLE_TYPE["LOWER_ARMENIAN"] = 35] = "LOWER_ARMENIAN";
  3240. LIST_STYLE_TYPE[LIST_STYLE_TYPE["MALAYALAM"] = 36] = "MALAYALAM";
  3241. LIST_STYLE_TYPE[LIST_STYLE_TYPE["MONGOLIAN"] = 37] = "MONGOLIAN";
  3242. LIST_STYLE_TYPE[LIST_STYLE_TYPE["MYANMAR"] = 38] = "MYANMAR";
  3243. LIST_STYLE_TYPE[LIST_STYLE_TYPE["ORIYA"] = 39] = "ORIYA";
  3244. LIST_STYLE_TYPE[LIST_STYLE_TYPE["PERSIAN"] = 40] = "PERSIAN";
  3245. LIST_STYLE_TYPE[LIST_STYLE_TYPE["SIMP_CHINESE_FORMAL"] = 41] = "SIMP_CHINESE_FORMAL";
  3246. LIST_STYLE_TYPE[LIST_STYLE_TYPE["SIMP_CHINESE_INFORMAL"] = 42] = "SIMP_CHINESE_INFORMAL";
  3247. LIST_STYLE_TYPE[LIST_STYLE_TYPE["TAMIL"] = 43] = "TAMIL";
  3248. LIST_STYLE_TYPE[LIST_STYLE_TYPE["TELUGU"] = 44] = "TELUGU";
  3249. LIST_STYLE_TYPE[LIST_STYLE_TYPE["THAI"] = 45] = "THAI";
  3250. LIST_STYLE_TYPE[LIST_STYLE_TYPE["TIBETAN"] = 46] = "TIBETAN";
  3251. LIST_STYLE_TYPE[LIST_STYLE_TYPE["TRAD_CHINESE_FORMAL"] = 47] = "TRAD_CHINESE_FORMAL";
  3252. LIST_STYLE_TYPE[LIST_STYLE_TYPE["TRAD_CHINESE_INFORMAL"] = 48] = "TRAD_CHINESE_INFORMAL";
  3253. LIST_STYLE_TYPE[LIST_STYLE_TYPE["UPPER_ARMENIAN"] = 49] = "UPPER_ARMENIAN";
  3254. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DISCLOSURE_OPEN"] = 50] = "DISCLOSURE_OPEN";
  3255. LIST_STYLE_TYPE[LIST_STYLE_TYPE["DISCLOSURE_CLOSED"] = 51] = "DISCLOSURE_CLOSED";
  3256. })(LIST_STYLE_TYPE || (LIST_STYLE_TYPE = {}));
  3257. var listStyleType = {
  3258. name: 'list-style-type',
  3259. initialValue: 'none',
  3260. prefix: false,
  3261. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3262. parse: function (type) {
  3263. switch (type) {
  3264. case 'disc':
  3265. return LIST_STYLE_TYPE.DISC;
  3266. case 'circle':
  3267. return LIST_STYLE_TYPE.CIRCLE;
  3268. case 'square':
  3269. return LIST_STYLE_TYPE.SQUARE;
  3270. case 'decimal':
  3271. return LIST_STYLE_TYPE.DECIMAL;
  3272. case 'cjk-decimal':
  3273. return LIST_STYLE_TYPE.CJK_DECIMAL;
  3274. case 'decimal-leading-zero':
  3275. return LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO;
  3276. case 'lower-roman':
  3277. return LIST_STYLE_TYPE.LOWER_ROMAN;
  3278. case 'upper-roman':
  3279. return LIST_STYLE_TYPE.UPPER_ROMAN;
  3280. case 'lower-greek':
  3281. return LIST_STYLE_TYPE.LOWER_GREEK;
  3282. case 'lower-alpha':
  3283. return LIST_STYLE_TYPE.LOWER_ALPHA;
  3284. case 'upper-alpha':
  3285. return LIST_STYLE_TYPE.UPPER_ALPHA;
  3286. case 'arabic-indic':
  3287. return LIST_STYLE_TYPE.ARABIC_INDIC;
  3288. case 'armenian':
  3289. return LIST_STYLE_TYPE.ARMENIAN;
  3290. case 'bengali':
  3291. return LIST_STYLE_TYPE.BENGALI;
  3292. case 'cambodian':
  3293. return LIST_STYLE_TYPE.CAMBODIAN;
  3294. case 'cjk-earthly-branch':
  3295. return LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH;
  3296. case 'cjk-heavenly-stem':
  3297. return LIST_STYLE_TYPE.CJK_HEAVENLY_STEM;
  3298. case 'cjk-ideographic':
  3299. return LIST_STYLE_TYPE.CJK_IDEOGRAPHIC;
  3300. case 'devanagari':
  3301. return LIST_STYLE_TYPE.DEVANAGARI;
  3302. case 'ethiopic-numeric':
  3303. return LIST_STYLE_TYPE.ETHIOPIC_NUMERIC;
  3304. case 'georgian':
  3305. return LIST_STYLE_TYPE.GEORGIAN;
  3306. case 'gujarati':
  3307. return LIST_STYLE_TYPE.GUJARATI;
  3308. case 'gurmukhi':
  3309. return LIST_STYLE_TYPE.GURMUKHI;
  3310. case 'hebrew':
  3311. return LIST_STYLE_TYPE.HEBREW;
  3312. case 'hiragana':
  3313. return LIST_STYLE_TYPE.HIRAGANA;
  3314. case 'hiragana-iroha':
  3315. return LIST_STYLE_TYPE.HIRAGANA_IROHA;
  3316. case 'japanese-formal':
  3317. return LIST_STYLE_TYPE.JAPANESE_FORMAL;
  3318. case 'japanese-informal':
  3319. return LIST_STYLE_TYPE.JAPANESE_INFORMAL;
  3320. case 'kannada':
  3321. return LIST_STYLE_TYPE.KANNADA;
  3322. case 'katakana':
  3323. return LIST_STYLE_TYPE.KATAKANA;
  3324. case 'katakana-iroha':
  3325. return LIST_STYLE_TYPE.KATAKANA_IROHA;
  3326. case 'khmer':
  3327. return LIST_STYLE_TYPE.KHMER;
  3328. case 'korean-hangul-formal':
  3329. return LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL;
  3330. case 'korean-hanja-formal':
  3331. return LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL;
  3332. case 'korean-hanja-informal':
  3333. return LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL;
  3334. case 'lao':
  3335. return LIST_STYLE_TYPE.LAO;
  3336. case 'lower-armenian':
  3337. return LIST_STYLE_TYPE.LOWER_ARMENIAN;
  3338. case 'malayalam':
  3339. return LIST_STYLE_TYPE.MALAYALAM;
  3340. case 'mongolian':
  3341. return LIST_STYLE_TYPE.MONGOLIAN;
  3342. case 'myanmar':
  3343. return LIST_STYLE_TYPE.MYANMAR;
  3344. case 'oriya':
  3345. return LIST_STYLE_TYPE.ORIYA;
  3346. case 'persian':
  3347. return LIST_STYLE_TYPE.PERSIAN;
  3348. case 'simp-chinese-formal':
  3349. return LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL;
  3350. case 'simp-chinese-informal':
  3351. return LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL;
  3352. case 'tamil':
  3353. return LIST_STYLE_TYPE.TAMIL;
  3354. case 'telugu':
  3355. return LIST_STYLE_TYPE.TELUGU;
  3356. case 'thai':
  3357. return LIST_STYLE_TYPE.THAI;
  3358. case 'tibetan':
  3359. return LIST_STYLE_TYPE.TIBETAN;
  3360. case 'trad-chinese-formal':
  3361. return LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL;
  3362. case 'trad-chinese-informal':
  3363. return LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL;
  3364. case 'upper-armenian':
  3365. return LIST_STYLE_TYPE.UPPER_ARMENIAN;
  3366. case 'disclosure-open':
  3367. return LIST_STYLE_TYPE.DISCLOSURE_OPEN;
  3368. case 'disclosure-closed':
  3369. return LIST_STYLE_TYPE.DISCLOSURE_CLOSED;
  3370. case 'none':
  3371. default:
  3372. return LIST_STYLE_TYPE.NONE;
  3373. }
  3374. }
  3375. };
  3376. var marginForSide = function (side) { return ({
  3377. name: "margin-" + side,
  3378. initialValue: '0',
  3379. prefix: false,
  3380. type: PropertyDescriptorParsingType.TOKEN_VALUE
  3381. }); };
  3382. var marginTop = marginForSide('top');
  3383. var marginRight = marginForSide('right');
  3384. var marginBottom = marginForSide('bottom');
  3385. var marginLeft = marginForSide('left');
  3386. var OVERFLOW;
  3387. (function (OVERFLOW) {
  3388. OVERFLOW[OVERFLOW["VISIBLE"] = 0] = "VISIBLE";
  3389. OVERFLOW[OVERFLOW["HIDDEN"] = 1] = "HIDDEN";
  3390. OVERFLOW[OVERFLOW["SCROLL"] = 2] = "SCROLL";
  3391. OVERFLOW[OVERFLOW["AUTO"] = 3] = "AUTO";
  3392. })(OVERFLOW || (OVERFLOW = {}));
  3393. var overflow = {
  3394. name: 'overflow',
  3395. initialValue: 'visible',
  3396. prefix: false,
  3397. type: PropertyDescriptorParsingType.LIST,
  3398. parse: function (tokens) {
  3399. return tokens.filter(isIdentToken).map(function (overflow) {
  3400. switch (overflow.value) {
  3401. case 'hidden':
  3402. return OVERFLOW.HIDDEN;
  3403. case 'scroll':
  3404. return OVERFLOW.SCROLL;
  3405. case 'auto':
  3406. return OVERFLOW.AUTO;
  3407. case 'visible':
  3408. default:
  3409. return OVERFLOW.VISIBLE;
  3410. }
  3411. });
  3412. }
  3413. };
  3414. var OVERFLOW_WRAP;
  3415. (function (OVERFLOW_WRAP) {
  3416. OVERFLOW_WRAP["NORMAL"] = "normal";
  3417. OVERFLOW_WRAP["BREAK_WORD"] = "break-word";
  3418. })(OVERFLOW_WRAP || (OVERFLOW_WRAP = {}));
  3419. var overflowWrap = {
  3420. name: 'overflow-wrap',
  3421. initialValue: 'normal',
  3422. prefix: false,
  3423. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3424. parse: function (overflow) {
  3425. switch (overflow) {
  3426. case 'break-word':
  3427. return OVERFLOW_WRAP.BREAK_WORD;
  3428. case 'normal':
  3429. default:
  3430. return OVERFLOW_WRAP.NORMAL;
  3431. }
  3432. }
  3433. };
  3434. var paddingForSide = function (side) { return ({
  3435. name: "padding-" + side,
  3436. initialValue: '0',
  3437. prefix: false,
  3438. type: PropertyDescriptorParsingType.TYPE_VALUE,
  3439. format: 'length-percentage'
  3440. }); };
  3441. var paddingTop = paddingForSide('top');
  3442. var paddingRight = paddingForSide('right');
  3443. var paddingBottom = paddingForSide('bottom');
  3444. var paddingLeft = paddingForSide('left');
  3445. var TEXT_ALIGN;
  3446. (function (TEXT_ALIGN) {
  3447. TEXT_ALIGN[TEXT_ALIGN["LEFT"] = 0] = "LEFT";
  3448. TEXT_ALIGN[TEXT_ALIGN["CENTER"] = 1] = "CENTER";
  3449. TEXT_ALIGN[TEXT_ALIGN["RIGHT"] = 2] = "RIGHT";
  3450. })(TEXT_ALIGN || (TEXT_ALIGN = {}));
  3451. var textAlign = {
  3452. name: 'text-align',
  3453. initialValue: 'left',
  3454. prefix: false,
  3455. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3456. parse: function (textAlign) {
  3457. switch (textAlign) {
  3458. case 'right':
  3459. return TEXT_ALIGN.RIGHT;
  3460. case 'center':
  3461. case 'justify':
  3462. return TEXT_ALIGN.CENTER;
  3463. case 'left':
  3464. default:
  3465. return TEXT_ALIGN.LEFT;
  3466. }
  3467. }
  3468. };
  3469. var POSITION;
  3470. (function (POSITION) {
  3471. POSITION[POSITION["STATIC"] = 0] = "STATIC";
  3472. POSITION[POSITION["RELATIVE"] = 1] = "RELATIVE";
  3473. POSITION[POSITION["ABSOLUTE"] = 2] = "ABSOLUTE";
  3474. POSITION[POSITION["FIXED"] = 3] = "FIXED";
  3475. POSITION[POSITION["STICKY"] = 4] = "STICKY";
  3476. })(POSITION || (POSITION = {}));
  3477. var position = {
  3478. name: 'position',
  3479. initialValue: 'static',
  3480. prefix: false,
  3481. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3482. parse: function (position) {
  3483. switch (position) {
  3484. case 'relative':
  3485. return POSITION.RELATIVE;
  3486. case 'absolute':
  3487. return POSITION.ABSOLUTE;
  3488. case 'fixed':
  3489. return POSITION.FIXED;
  3490. case 'sticky':
  3491. return POSITION.STICKY;
  3492. }
  3493. return POSITION.STATIC;
  3494. }
  3495. };
  3496. var textShadow = {
  3497. name: 'text-shadow',
  3498. initialValue: 'none',
  3499. type: PropertyDescriptorParsingType.LIST,
  3500. prefix: false,
  3501. parse: function (tokens) {
  3502. if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
  3503. return [];
  3504. }
  3505. return parseFunctionArgs(tokens).map(function (values) {
  3506. var shadow = {
  3507. color: COLORS.TRANSPARENT,
  3508. offsetX: ZERO_LENGTH,
  3509. offsetY: ZERO_LENGTH,
  3510. blur: ZERO_LENGTH
  3511. };
  3512. var c = 0;
  3513. for (var i = 0; i < values.length; i++) {
  3514. var token = values[i];
  3515. if (isLength(token)) {
  3516. if (c === 0) {
  3517. shadow.offsetX = token;
  3518. }
  3519. else if (c === 1) {
  3520. shadow.offsetY = token;
  3521. }
  3522. else {
  3523. shadow.blur = token;
  3524. }
  3525. c++;
  3526. }
  3527. else {
  3528. shadow.color = color.parse(token);
  3529. }
  3530. }
  3531. return shadow;
  3532. });
  3533. }
  3534. };
  3535. var TEXT_TRANSFORM;
  3536. (function (TEXT_TRANSFORM) {
  3537. TEXT_TRANSFORM[TEXT_TRANSFORM["NONE"] = 0] = "NONE";
  3538. TEXT_TRANSFORM[TEXT_TRANSFORM["LOWERCASE"] = 1] = "LOWERCASE";
  3539. TEXT_TRANSFORM[TEXT_TRANSFORM["UPPERCASE"] = 2] = "UPPERCASE";
  3540. TEXT_TRANSFORM[TEXT_TRANSFORM["CAPITALIZE"] = 3] = "CAPITALIZE";
  3541. })(TEXT_TRANSFORM || (TEXT_TRANSFORM = {}));
  3542. var textTransform = {
  3543. name: 'text-transform',
  3544. initialValue: 'none',
  3545. prefix: false,
  3546. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3547. parse: function (textTransform) {
  3548. switch (textTransform) {
  3549. case 'uppercase':
  3550. return TEXT_TRANSFORM.UPPERCASE;
  3551. case 'lowercase':
  3552. return TEXT_TRANSFORM.LOWERCASE;
  3553. case 'capitalize':
  3554. return TEXT_TRANSFORM.CAPITALIZE;
  3555. }
  3556. return TEXT_TRANSFORM.NONE;
  3557. }
  3558. };
  3559. var transform = {
  3560. name: 'transform',
  3561. initialValue: 'none',
  3562. prefix: true,
  3563. type: PropertyDescriptorParsingType.VALUE,
  3564. parse: function (token) {
  3565. if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {
  3566. return null;
  3567. }
  3568. if (token.type === TokenType.FUNCTION) {
  3569. var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
  3570. if (typeof transformFunction === 'undefined') {
  3571. throw new Error("Attempting to parse an unsupported transform function \"" + token.name + "\"");
  3572. }
  3573. return transformFunction(token.values);
  3574. }
  3575. return null;
  3576. }
  3577. };
  3578. var matrix = function (args) {
  3579. var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });
  3580. return values.length === 6 ? values : null;
  3581. };
  3582. // doesn't support 3D transforms at the moment
  3583. var matrix3d = function (args) {
  3584. var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });
  3585. var a1 = values[0], b1 = values[1], _a = values[2], _b = values[3], a2 = values[4], b2 = values[5], _c = values[6], _d = values[7], _e = values[8], _f = values[9], _g = values[10], _h = values[11], a4 = values[12], b4 = values[13], _j = values[14], _k = values[15];
  3586. return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
  3587. };
  3588. var SUPPORTED_TRANSFORM_FUNCTIONS = {
  3589. matrix: matrix,
  3590. matrix3d: matrix3d
  3591. };
  3592. var DEFAULT_VALUE = {
  3593. type: TokenType.PERCENTAGE_TOKEN,
  3594. number: 50,
  3595. flags: FLAG_INTEGER
  3596. };
  3597. var DEFAULT = [DEFAULT_VALUE, DEFAULT_VALUE];
  3598. var transformOrigin = {
  3599. name: 'transform-origin',
  3600. initialValue: '50% 50%',
  3601. prefix: true,
  3602. type: PropertyDescriptorParsingType.LIST,
  3603. parse: function (tokens) {
  3604. var origins = tokens.filter(isLengthPercentage);
  3605. if (origins.length !== 2) {
  3606. return DEFAULT;
  3607. }
  3608. return [origins[0], origins[1]];
  3609. }
  3610. };
  3611. var VISIBILITY;
  3612. (function (VISIBILITY) {
  3613. VISIBILITY[VISIBILITY["VISIBLE"] = 0] = "VISIBLE";
  3614. VISIBILITY[VISIBILITY["HIDDEN"] = 1] = "HIDDEN";
  3615. VISIBILITY[VISIBILITY["COLLAPSE"] = 2] = "COLLAPSE";
  3616. })(VISIBILITY || (VISIBILITY = {}));
  3617. var visibility = {
  3618. name: 'visible',
  3619. initialValue: 'none',
  3620. prefix: false,
  3621. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3622. parse: function (visibility) {
  3623. switch (visibility) {
  3624. case 'hidden':
  3625. return VISIBILITY.HIDDEN;
  3626. case 'collapse':
  3627. return VISIBILITY.COLLAPSE;
  3628. case 'visible':
  3629. default:
  3630. return VISIBILITY.VISIBLE;
  3631. }
  3632. }
  3633. };
  3634. var WORD_BREAK;
  3635. (function (WORD_BREAK) {
  3636. WORD_BREAK["NORMAL"] = "normal";
  3637. WORD_BREAK["BREAK_ALL"] = "break-all";
  3638. WORD_BREAK["KEEP_ALL"] = "keep-all";
  3639. })(WORD_BREAK || (WORD_BREAK = {}));
  3640. var wordBreak = {
  3641. name: 'word-break',
  3642. initialValue: 'normal',
  3643. prefix: false,
  3644. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3645. parse: function (wordBreak) {
  3646. switch (wordBreak) {
  3647. case 'break-all':
  3648. return WORD_BREAK.BREAK_ALL;
  3649. case 'keep-all':
  3650. return WORD_BREAK.KEEP_ALL;
  3651. case 'normal':
  3652. default:
  3653. return WORD_BREAK.NORMAL;
  3654. }
  3655. }
  3656. };
  3657. var zIndex = {
  3658. name: 'z-index',
  3659. initialValue: 'auto',
  3660. prefix: false,
  3661. type: PropertyDescriptorParsingType.VALUE,
  3662. parse: function (token) {
  3663. if (token.type === TokenType.IDENT_TOKEN) {
  3664. return { auto: true, order: 0 };
  3665. }
  3666. if (isNumberToken(token)) {
  3667. return { auto: false, order: token.number };
  3668. }
  3669. throw new Error("Invalid z-index number parsed");
  3670. }
  3671. };
  3672. var opacity = {
  3673. name: 'opacity',
  3674. initialValue: '1',
  3675. type: PropertyDescriptorParsingType.VALUE,
  3676. prefix: false,
  3677. parse: function (token) {
  3678. if (isNumberToken(token)) {
  3679. return token.number;
  3680. }
  3681. return 1;
  3682. }
  3683. };
  3684. var textDecorationColor = {
  3685. name: "text-decoration-color",
  3686. initialValue: 'transparent',
  3687. prefix: false,
  3688. type: PropertyDescriptorParsingType.TYPE_VALUE,
  3689. format: 'color'
  3690. };
  3691. var textDecorationLine = {
  3692. name: 'text-decoration-line',
  3693. initialValue: 'none',
  3694. prefix: false,
  3695. type: PropertyDescriptorParsingType.LIST,
  3696. parse: function (tokens) {
  3697. return tokens
  3698. .filter(isIdentToken)
  3699. .map(function (token) {
  3700. switch (token.value) {
  3701. case 'underline':
  3702. return 1 /* UNDERLINE */;
  3703. case 'overline':
  3704. return 2 /* OVERLINE */;
  3705. case 'line-through':
  3706. return 3 /* LINE_THROUGH */;
  3707. case 'none':
  3708. return 4 /* BLINK */;
  3709. }
  3710. return 0 /* NONE */;
  3711. })
  3712. .filter(function (line) { return line !== 0 /* NONE */; });
  3713. }
  3714. };
  3715. var fontFamily = {
  3716. name: "font-family",
  3717. initialValue: '',
  3718. prefix: false,
  3719. type: PropertyDescriptorParsingType.LIST,
  3720. parse: function (tokens) {
  3721. return tokens.filter(isStringToken$1).map(function (token) { return token.value; });
  3722. }
  3723. };
  3724. var isStringToken$1 = function (token) {
  3725. return token.type === TokenType.STRING_TOKEN || token.type === TokenType.IDENT_TOKEN;
  3726. };
  3727. var fontSize = {
  3728. name: "font-size",
  3729. initialValue: '0',
  3730. prefix: false,
  3731. type: PropertyDescriptorParsingType.TYPE_VALUE,
  3732. format: 'length'
  3733. };
  3734. var fontWeight = {
  3735. name: 'font-weight',
  3736. initialValue: 'normal',
  3737. type: PropertyDescriptorParsingType.VALUE,
  3738. prefix: false,
  3739. parse: function (token) {
  3740. if (isNumberToken(token)) {
  3741. return token.number;
  3742. }
  3743. if (isIdentToken(token)) {
  3744. switch (token.value) {
  3745. case 'bold':
  3746. return 700;
  3747. case 'normal':
  3748. default:
  3749. return 400;
  3750. }
  3751. }
  3752. return 400;
  3753. }
  3754. };
  3755. var fontVariant = {
  3756. name: 'font-variant',
  3757. initialValue: 'none',
  3758. type: PropertyDescriptorParsingType.LIST,
  3759. prefix: false,
  3760. parse: function (tokens) {
  3761. return tokens.filter(isIdentToken).map(function (token) { return token.value; });
  3762. }
  3763. };
  3764. var FONT_STYLE;
  3765. (function (FONT_STYLE) {
  3766. FONT_STYLE["NORMAL"] = "normal";
  3767. FONT_STYLE["ITALIC"] = "italic";
  3768. FONT_STYLE["OBLIQUE"] = "oblique";
  3769. })(FONT_STYLE || (FONT_STYLE = {}));
  3770. var fontStyle = {
  3771. name: 'font-style',
  3772. initialValue: 'normal',
  3773. prefix: false,
  3774. type: PropertyDescriptorParsingType.IDENT_VALUE,
  3775. parse: function (overflow) {
  3776. switch (overflow) {
  3777. case 'oblique':
  3778. return FONT_STYLE.OBLIQUE;
  3779. case 'italic':
  3780. return FONT_STYLE.ITALIC;
  3781. case 'normal':
  3782. default:
  3783. return FONT_STYLE.NORMAL;
  3784. }
  3785. }
  3786. };
  3787. var contains = function (bit, value) { return (bit & value) !== 0; };
  3788. var content = {
  3789. name: 'content',
  3790. initialValue: 'none',
  3791. type: PropertyDescriptorParsingType.LIST,
  3792. prefix: false,
  3793. parse: function (tokens) {
  3794. if (tokens.length === 0) {
  3795. return [];
  3796. }
  3797. var first = tokens[0];
  3798. if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
  3799. return [];
  3800. }
  3801. return tokens;
  3802. }
  3803. };
  3804. var counterIncrement = {
  3805. name: 'counter-increment',
  3806. initialValue: 'none',
  3807. prefix: true,
  3808. type: PropertyDescriptorParsingType.LIST,
  3809. parse: function (tokens) {
  3810. if (tokens.length === 0) {
  3811. return null;
  3812. }
  3813. var first = tokens[0];
  3814. if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
  3815. return null;
  3816. }
  3817. var increments = [];
  3818. var filtered = tokens.filter(nonWhiteSpace);
  3819. for (var i = 0; i < filtered.length; i++) {
  3820. var counter = filtered[i];
  3821. var next = filtered[i + 1];
  3822. if (counter.type === TokenType.IDENT_TOKEN) {
  3823. var increment = next && isNumberToken(next) ? next.number : 1;
  3824. increments.push({ counter: counter.value, increment: increment });
  3825. }
  3826. }
  3827. return increments;
  3828. }
  3829. };
  3830. var counterReset = {
  3831. name: 'counter-reset',
  3832. initialValue: 'none',
  3833. prefix: true,
  3834. type: PropertyDescriptorParsingType.LIST,
  3835. parse: function (tokens) {
  3836. if (tokens.length === 0) {
  3837. return [];
  3838. }
  3839. var resets = [];
  3840. var filtered = tokens.filter(nonWhiteSpace);
  3841. for (var i = 0; i < filtered.length; i++) {
  3842. var counter = filtered[i];
  3843. var next = filtered[i + 1];
  3844. if (isIdentToken(counter) && counter.value !== 'none') {
  3845. var reset = next && isNumberToken(next) ? next.number : 0;
  3846. resets.push({ counter: counter.value, reset: reset });
  3847. }
  3848. }
  3849. return resets;
  3850. }
  3851. };
  3852. var quotes = {
  3853. name: 'quotes',
  3854. initialValue: 'none',
  3855. prefix: true,
  3856. type: PropertyDescriptorParsingType.LIST,
  3857. parse: function (tokens) {
  3858. if (tokens.length === 0) {
  3859. return null;
  3860. }
  3861. var first = tokens[0];
  3862. if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
  3863. return null;
  3864. }
  3865. var quotes = [];
  3866. var filtered = tokens.filter(isStringToken);
  3867. if (filtered.length % 2 !== 0) {
  3868. return null;
  3869. }
  3870. for (var i = 0; i < filtered.length; i += 2) {
  3871. var open_1 = filtered[i].value;
  3872. var close_1 = filtered[i + 1].value;
  3873. quotes.push({ open: open_1, close: close_1 });
  3874. }
  3875. return quotes;
  3876. }
  3877. };
  3878. var getQuote = function (quotes, depth, open) {
  3879. if (!quotes) {
  3880. return '';
  3881. }
  3882. var quote = quotes[Math.min(depth, quotes.length - 1)];
  3883. if (!quote) {
  3884. return '';
  3885. }
  3886. return open ? quote.open : quote.close;
  3887. };
  3888. var boxShadow = {
  3889. name: 'box-shadow',
  3890. initialValue: 'none',
  3891. type: PropertyDescriptorParsingType.LIST,
  3892. prefix: false,
  3893. parse: function (tokens) {
  3894. if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
  3895. return [];
  3896. }
  3897. return parseFunctionArgs(tokens).map(function (values) {
  3898. var shadow = {
  3899. color: 0x000000ff,
  3900. offsetX: ZERO_LENGTH,
  3901. offsetY: ZERO_LENGTH,
  3902. blur: ZERO_LENGTH,
  3903. spread: ZERO_LENGTH,
  3904. inset: false
  3905. };
  3906. var c = 0;
  3907. for (var i = 0; i < values.length; i++) {
  3908. var token = values[i];
  3909. if (isIdentWithValue(token, 'inset')) {
  3910. shadow.inset = true;
  3911. }
  3912. else if (isLength(token)) {
  3913. if (c === 0) {
  3914. shadow.offsetX = token;
  3915. }
  3916. else if (c === 1) {
  3917. shadow.offsetY = token;
  3918. }
  3919. else if (c === 2) {
  3920. shadow.blur = token;
  3921. }
  3922. else {
  3923. shadow.spread = token;
  3924. }
  3925. c++;
  3926. }
  3927. else {
  3928. shadow.color = color.parse(token);
  3929. }
  3930. }
  3931. return shadow;
  3932. });
  3933. }
  3934. };
  3935. var CSSParsedDeclaration = /** @class */ (function () {
  3936. function CSSParsedDeclaration(declaration) {
  3937. this.backgroundClip = parse(backgroundClip, declaration.backgroundClip);
  3938. this.backgroundColor = parse(backgroundColor, declaration.backgroundColor);
  3939. this.backgroundImage = parse(backgroundImage, declaration.backgroundImage);
  3940. this.backgroundOrigin = parse(backgroundOrigin, declaration.backgroundOrigin);
  3941. this.backgroundPosition = parse(backgroundPosition, declaration.backgroundPosition);
  3942. this.backgroundRepeat = parse(backgroundRepeat, declaration.backgroundRepeat);
  3943. this.backgroundSize = parse(backgroundSize, declaration.backgroundSize);
  3944. this.borderTopColor = parse(borderTopColor, declaration.borderTopColor);
  3945. this.borderRightColor = parse(borderRightColor, declaration.borderRightColor);
  3946. this.borderBottomColor = parse(borderBottomColor, declaration.borderBottomColor);
  3947. this.borderLeftColor = parse(borderLeftColor, declaration.borderLeftColor);
  3948. this.borderTopLeftRadius = parse(borderTopLeftRadius, declaration.borderTopLeftRadius);
  3949. this.borderTopRightRadius = parse(borderTopRightRadius, declaration.borderTopRightRadius);
  3950. this.borderBottomRightRadius = parse(borderBottomRightRadius, declaration.borderBottomRightRadius);
  3951. this.borderBottomLeftRadius = parse(borderBottomLeftRadius, declaration.borderBottomLeftRadius);
  3952. this.borderTopStyle = parse(borderTopStyle, declaration.borderTopStyle);
  3953. this.borderRightStyle = parse(borderRightStyle, declaration.borderRightStyle);
  3954. this.borderBottomStyle = parse(borderBottomStyle, declaration.borderBottomStyle);
  3955. this.borderLeftStyle = parse(borderLeftStyle, declaration.borderLeftStyle);
  3956. this.borderTopWidth = parse(borderTopWidth, declaration.borderTopWidth);
  3957. this.borderRightWidth = parse(borderRightWidth, declaration.borderRightWidth);
  3958. this.borderBottomWidth = parse(borderBottomWidth, declaration.borderBottomWidth);
  3959. this.borderLeftWidth = parse(borderLeftWidth, declaration.borderLeftWidth);
  3960. this.boxShadow = parse(boxShadow, declaration.boxShadow);
  3961. this.color = parse(color$1, declaration.color);
  3962. this.display = parse(display, declaration.display);
  3963. this.float = parse(float, declaration.cssFloat);
  3964. this.fontFamily = parse(fontFamily, declaration.fontFamily);
  3965. this.fontSize = parse(fontSize, declaration.fontSize);
  3966. this.fontStyle = parse(fontStyle, declaration.fontStyle);
  3967. this.fontVariant = parse(fontVariant, declaration.fontVariant);
  3968. this.fontWeight = parse(fontWeight, declaration.fontWeight);
  3969. this.letterSpacing = parse(letterSpacing, declaration.letterSpacing);
  3970. this.lineBreak = parse(lineBreak, declaration.lineBreak);
  3971. this.lineHeight = parse(lineHeight, declaration.lineHeight);
  3972. this.listStyleImage = parse(listStyleImage, declaration.listStyleImage);
  3973. this.listStylePosition = parse(listStylePosition, declaration.listStylePosition);
  3974. this.listStyleType = parse(listStyleType, declaration.listStyleType);
  3975. this.marginTop = parse(marginTop, declaration.marginTop);
  3976. this.marginRight = parse(marginRight, declaration.marginRight);
  3977. this.marginBottom = parse(marginBottom, declaration.marginBottom);
  3978. this.marginLeft = parse(marginLeft, declaration.marginLeft);
  3979. this.opacity = parse(opacity, declaration.opacity);
  3980. var overflowTuple = parse(overflow, declaration.overflow);
  3981. this.overflowX = overflowTuple[0];
  3982. this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
  3983. this.overflowWrap = parse(overflowWrap, declaration.overflowWrap);
  3984. this.paddingTop = parse(paddingTop, declaration.paddingTop);
  3985. this.paddingRight = parse(paddingRight, declaration.paddingRight);
  3986. this.paddingBottom = parse(paddingBottom, declaration.paddingBottom);
  3987. this.paddingLeft = parse(paddingLeft, declaration.paddingLeft);
  3988. this.position = parse(position, declaration.position);
  3989. this.textAlign = parse(textAlign, declaration.textAlign);
  3990. this.textDecorationColor = parse(textDecorationColor, declaration.textDecorationColor || declaration.color);
  3991. this.textDecorationLine = parse(textDecorationLine, declaration.textDecorationLine);
  3992. this.textShadow = parse(textShadow, declaration.textShadow);
  3993. this.textTransform = parse(textTransform, declaration.textTransform);
  3994. this.transform = parse(transform, declaration.transform);
  3995. this.transformOrigin = parse(transformOrigin, declaration.transformOrigin);
  3996. this.visibility = parse(visibility, declaration.visibility);
  3997. this.wordBreak = parse(wordBreak, declaration.wordBreak);
  3998. this.zIndex = parse(zIndex, declaration.zIndex);
  3999. }
  4000. CSSParsedDeclaration.prototype.isVisible = function () {
  4001. return this.display > 0 && this.opacity > 0 && this.visibility === VISIBILITY.VISIBLE;
  4002. };
  4003. CSSParsedDeclaration.prototype.isTransparent = function () {
  4004. return isTransparent(this.backgroundColor);
  4005. };
  4006. CSSParsedDeclaration.prototype.isTransformed = function () {
  4007. return this.transform !== null;
  4008. };
  4009. CSSParsedDeclaration.prototype.isPositioned = function () {
  4010. return this.position !== POSITION.STATIC;
  4011. };
  4012. CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
  4013. return this.isPositioned() && !this.zIndex.auto;
  4014. };
  4015. CSSParsedDeclaration.prototype.isFloating = function () {
  4016. return this.float !== FLOAT.NONE;
  4017. };
  4018. CSSParsedDeclaration.prototype.isInlineLevel = function () {
  4019. return (contains(this.display, 4 /* INLINE */) ||
  4020. contains(this.display, 33554432 /* INLINE_BLOCK */) ||
  4021. contains(this.display, 268435456 /* INLINE_FLEX */) ||
  4022. contains(this.display, 536870912 /* INLINE_GRID */) ||
  4023. contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
  4024. contains(this.display, 134217728 /* INLINE_TABLE */));
  4025. };
  4026. return CSSParsedDeclaration;
  4027. }());
  4028. var CSSParsedPseudoDeclaration = /** @class */ (function () {
  4029. function CSSParsedPseudoDeclaration(declaration) {
  4030. this.content = parse(content, declaration.content);
  4031. this.quotes = parse(quotes, declaration.quotes);
  4032. }
  4033. return CSSParsedPseudoDeclaration;
  4034. }());
  4035. var CSSParsedCounterDeclaration = /** @class */ (function () {
  4036. function CSSParsedCounterDeclaration(declaration) {
  4037. this.counterIncrement = parse(counterIncrement, declaration.counterIncrement);
  4038. this.counterReset = parse(counterReset, declaration.counterReset);
  4039. }
  4040. return CSSParsedCounterDeclaration;
  4041. }());
  4042. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  4043. var parse = function (descriptor, style) {
  4044. var tokenizer = new Tokenizer();
  4045. var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
  4046. tokenizer.write(value);
  4047. var parser = new Parser(tokenizer.read());
  4048. switch (descriptor.type) {
  4049. case PropertyDescriptorParsingType.IDENT_VALUE:
  4050. var token = parser.parseComponentValue();
  4051. return descriptor.parse(isIdentToken(token) ? token.value : descriptor.initialValue);
  4052. case PropertyDescriptorParsingType.VALUE:
  4053. return descriptor.parse(parser.parseComponentValue());
  4054. case PropertyDescriptorParsingType.LIST:
  4055. return descriptor.parse(parser.parseComponentValues());
  4056. case PropertyDescriptorParsingType.TOKEN_VALUE:
  4057. return parser.parseComponentValue();
  4058. case PropertyDescriptorParsingType.TYPE_VALUE:
  4059. switch (descriptor.format) {
  4060. case 'angle':
  4061. return angle.parse(parser.parseComponentValue());
  4062. case 'color':
  4063. return color.parse(parser.parseComponentValue());
  4064. case 'image':
  4065. return image.parse(parser.parseComponentValue());
  4066. case 'length':
  4067. var length_1 = parser.parseComponentValue();
  4068. return isLength(length_1) ? length_1 : ZERO_LENGTH;
  4069. case 'length-percentage':
  4070. var value_1 = parser.parseComponentValue();
  4071. return isLengthPercentage(value_1) ? value_1 : ZERO_LENGTH;
  4072. }
  4073. }
  4074. throw new Error("Attempting to parse unsupported css format type " + descriptor.format);
  4075. };
  4076. var ElementContainer = /** @class */ (function () {
  4077. function ElementContainer(element) {
  4078. this.styles = new CSSParsedDeclaration(window.getComputedStyle(element, null));
  4079. this.textNodes = [];
  4080. this.elements = [];
  4081. if (this.styles.transform !== null && isHTMLElementNode(element)) {
  4082. // getBoundingClientRect takes transforms into account
  4083. element.style.transform = 'none';
  4084. }
  4085. this.bounds = parseBounds(element);
  4086. this.flags = 0;
  4087. }
  4088. return ElementContainer;
  4089. }());
  4090. var TextBounds = /** @class */ (function () {
  4091. function TextBounds(text, bounds) {
  4092. this.text = text;
  4093. this.bounds = bounds;
  4094. }
  4095. return TextBounds;
  4096. }());
  4097. var parseTextBounds = function (value, styles, node) {
  4098. var textList = breakText(value, styles);
  4099. var textBounds = [];
  4100. var offset = 0;
  4101. textList.forEach(function (text) {
  4102. if (styles.textDecorationLine.length || text.trim().length > 0) {
  4103. if (FEATURES.SUPPORT_RANGE_BOUNDS) {
  4104. textBounds.push(new TextBounds(text, getRangeBounds(node, offset, text.length)));
  4105. }
  4106. else {
  4107. var replacementNode = node.splitText(text.length);
  4108. textBounds.push(new TextBounds(text, getWrapperBounds(node)));
  4109. node = replacementNode;
  4110. }
  4111. }
  4112. else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {
  4113. node = node.splitText(text.length);
  4114. }
  4115. offset += text.length;
  4116. });
  4117. return textBounds;
  4118. };
  4119. var getWrapperBounds = function (node) {
  4120. var ownerDocument = node.ownerDocument;
  4121. if (ownerDocument) {
  4122. var wrapper = ownerDocument.createElement('html2canvaswrapper');
  4123. wrapper.appendChild(node.cloneNode(true));
  4124. var parentNode = node.parentNode;
  4125. if (parentNode) {
  4126. parentNode.replaceChild(wrapper, node);
  4127. var bounds = parseBounds(wrapper);
  4128. if (wrapper.firstChild) {
  4129. parentNode.replaceChild(wrapper.firstChild, wrapper);
  4130. }
  4131. return bounds;
  4132. }
  4133. }
  4134. return new Bounds(0, 0, 0, 0);
  4135. };
  4136. var getRangeBounds = function (node, offset, length) {
  4137. var ownerDocument = node.ownerDocument;
  4138. if (!ownerDocument) {
  4139. throw new Error('Node has no owner document');
  4140. }
  4141. var range = ownerDocument.createRange();
  4142. range.setStart(node, offset);
  4143. range.setEnd(node, offset + length);
  4144. return Bounds.fromClientRect(range.getBoundingClientRect());
  4145. };
  4146. var breakText = function (value, styles) {
  4147. return styles.letterSpacing !== 0 ? toCodePoints(value).map(function (i) { return fromCodePoint(i); }) : breakWords(value, styles);
  4148. };
  4149. var breakWords = function (str, styles) {
  4150. var breaker = LineBreaker(str, {
  4151. lineBreak: styles.lineBreak,
  4152. wordBreak: styles.overflowWrap === OVERFLOW_WRAP.BREAK_WORD ? 'break-word' : styles.wordBreak
  4153. });
  4154. var words = [];
  4155. var bk;
  4156. while (!(bk = breaker.next()).done) {
  4157. if (bk.value) {
  4158. words.push(bk.value.slice());
  4159. }
  4160. }
  4161. return words;
  4162. };
  4163. var TextContainer = /** @class */ (function () {
  4164. function TextContainer(node, styles) {
  4165. this.text = transform$1(node.data, styles.textTransform);
  4166. this.textBounds = parseTextBounds(this.text, styles, node);
  4167. }
  4168. return TextContainer;
  4169. }());
  4170. var transform$1 = function (text, transform) {
  4171. switch (transform) {
  4172. case TEXT_TRANSFORM.LOWERCASE:
  4173. return text.toLowerCase();
  4174. case TEXT_TRANSFORM.CAPITALIZE:
  4175. return text.replace(CAPITALIZE, capitalize);
  4176. case TEXT_TRANSFORM.UPPERCASE:
  4177. return text.toUpperCase();
  4178. default:
  4179. return text;
  4180. }
  4181. };
  4182. var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
  4183. var capitalize = function (m, p1, p2) {
  4184. if (m.length > 0) {
  4185. return p1 + p2.toUpperCase();
  4186. }
  4187. return m;
  4188. };
  4189. var ImageElementContainer = /** @class */ (function (_super) {
  4190. __extends(ImageElementContainer, _super);
  4191. function ImageElementContainer(img) {
  4192. var _this = _super.call(this, img) || this;
  4193. _this.src = img.currentSrc || img.src;
  4194. _this.intrinsicWidth = img.naturalWidth;
  4195. _this.intrinsicHeight = img.naturalHeight;
  4196. CacheStorage.getInstance().addImage(_this.src);
  4197. return _this;
  4198. }
  4199. return ImageElementContainer;
  4200. }(ElementContainer));
  4201. var CanvasElementContainer = /** @class */ (function (_super) {
  4202. __extends(CanvasElementContainer, _super);
  4203. function CanvasElementContainer(canvas) {
  4204. var _this = _super.call(this, canvas) || this;
  4205. _this.canvas = canvas;
  4206. _this.intrinsicWidth = canvas.width;
  4207. _this.intrinsicHeight = canvas.height;
  4208. return _this;
  4209. }
  4210. return CanvasElementContainer;
  4211. }(ElementContainer));
  4212. var SVGElementContainer = /** @class */ (function (_super) {
  4213. __extends(SVGElementContainer, _super);
  4214. function SVGElementContainer(img) {
  4215. var _this = _super.call(this, img) || this;
  4216. var s = new XMLSerializer();
  4217. _this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
  4218. _this.intrinsicWidth = img.width.baseVal.value;
  4219. _this.intrinsicHeight = img.height.baseVal.value;
  4220. CacheStorage.getInstance().addImage(_this.svg);
  4221. return _this;
  4222. }
  4223. return SVGElementContainer;
  4224. }(ElementContainer));
  4225. var LIElementContainer = /** @class */ (function (_super) {
  4226. __extends(LIElementContainer, _super);
  4227. function LIElementContainer(element) {
  4228. var _this = _super.call(this, element) || this;
  4229. _this.value = element.value;
  4230. return _this;
  4231. }
  4232. return LIElementContainer;
  4233. }(ElementContainer));
  4234. var OLElementContainer = /** @class */ (function (_super) {
  4235. __extends(OLElementContainer, _super);
  4236. function OLElementContainer(element) {
  4237. var _this = _super.call(this, element) || this;
  4238. _this.start = element.start;
  4239. _this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;
  4240. return _this;
  4241. }
  4242. return OLElementContainer;
  4243. }(ElementContainer));
  4244. var CHECKBOX_BORDER_RADIUS = [
  4245. {
  4246. type: TokenType.DIMENSION_TOKEN,
  4247. flags: 0,
  4248. unit: 'px',
  4249. number: 3
  4250. }
  4251. ];
  4252. var RADIO_BORDER_RADIUS = [
  4253. {
  4254. type: TokenType.PERCENTAGE_TOKEN,
  4255. flags: 0,
  4256. number: 50
  4257. }
  4258. ];
  4259. var reformatInputBounds = function (bounds) {
  4260. if (bounds.width > bounds.height) {
  4261. return new Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);
  4262. }
  4263. else if (bounds.width < bounds.height) {
  4264. return new Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);
  4265. }
  4266. return bounds;
  4267. };
  4268. var getInputValue = function (node) {
  4269. var value = node.type === PASSWORD ? new Array(node.value.length + 1).join('\u2022') : node.value;
  4270. return value.length === 0 ? node.placeholder || '' : value;
  4271. };
  4272. var CHECKBOX = 'checkbox';
  4273. var RADIO = 'radio';
  4274. var PASSWORD = 'password';
  4275. var INPUT_COLOR = 0x2a2a2aff;
  4276. var InputElementContainer = /** @class */ (function (_super) {
  4277. __extends(InputElementContainer, _super);
  4278. function InputElementContainer(input) {
  4279. var _this = _super.call(this, input) || this;
  4280. _this.type = input.type.toLowerCase();
  4281. _this.checked = input.checked;
  4282. _this.value = getInputValue(input);
  4283. if (_this.type === CHECKBOX || _this.type === RADIO) {
  4284. _this.styles.backgroundColor = 0xdededeff;
  4285. _this.styles.borderTopColor = _this.styles.borderRightColor = _this.styles.borderBottomColor = _this.styles.borderLeftColor = 0xa5a5a5ff;
  4286. _this.styles.borderTopWidth = _this.styles.borderRightWidth = _this.styles.borderBottomWidth = _this.styles.borderLeftWidth = 1;
  4287. _this.styles.borderTopStyle = _this.styles.borderRightStyle = _this.styles.borderBottomStyle = _this.styles.borderLeftStyle =
  4288. BORDER_STYLE.SOLID;
  4289. _this.styles.backgroundClip = [BACKGROUND_CLIP.BORDER_BOX];
  4290. _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
  4291. _this.bounds = reformatInputBounds(_this.bounds);
  4292. }
  4293. switch (_this.type) {
  4294. case CHECKBOX:
  4295. _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = CHECKBOX_BORDER_RADIUS;
  4296. break;
  4297. case RADIO:
  4298. _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = RADIO_BORDER_RADIUS;
  4299. break;
  4300. }
  4301. return _this;
  4302. }
  4303. return InputElementContainer;
  4304. }(ElementContainer));
  4305. var SelectElementContainer = /** @class */ (function (_super) {
  4306. __extends(SelectElementContainer, _super);
  4307. function SelectElementContainer(element) {
  4308. var _this = _super.call(this, element) || this;
  4309. var option = element.options[element.selectedIndex || 0];
  4310. _this.value = option ? option.text || '' : '';
  4311. return _this;
  4312. }
  4313. return SelectElementContainer;
  4314. }(ElementContainer));
  4315. var TextareaElementContainer = /** @class */ (function (_super) {
  4316. __extends(TextareaElementContainer, _super);
  4317. function TextareaElementContainer(element) {
  4318. var _this = _super.call(this, element) || this;
  4319. _this.value = element.value;
  4320. return _this;
  4321. }
  4322. return TextareaElementContainer;
  4323. }(ElementContainer));
  4324. var parseColor = function (value) { return color.parse(Parser.create(value).parseComponentValue()); };
  4325. var IFrameElementContainer = /** @class */ (function (_super) {
  4326. __extends(IFrameElementContainer, _super);
  4327. function IFrameElementContainer(iframe) {
  4328. var _this = _super.call(this, iframe) || this;
  4329. _this.src = iframe.src;
  4330. _this.width = parseInt(iframe.width, 10) || 0;
  4331. _this.height = parseInt(iframe.height, 10) || 0;
  4332. _this.backgroundColor = _this.styles.backgroundColor;
  4333. try {
  4334. if (iframe.contentWindow &&
  4335. iframe.contentWindow.document &&
  4336. iframe.contentWindow.document.documentElement) {
  4337. _this.tree = parseTree(iframe.contentWindow.document.documentElement);
  4338. // http://www.w3.org/TR/css3-background/#special-backgrounds
  4339. var documentBackgroundColor = iframe.contentWindow.document.documentElement
  4340. ? parseColor(getComputedStyle(iframe.contentWindow.document.documentElement)
  4341. .backgroundColor)
  4342. : COLORS.TRANSPARENT;
  4343. var bodyBackgroundColor = iframe.contentWindow.document.body
  4344. ? parseColor(getComputedStyle(iframe.contentWindow.document.body).backgroundColor)
  4345. : COLORS.TRANSPARENT;
  4346. _this.backgroundColor = isTransparent(documentBackgroundColor)
  4347. ? isTransparent(bodyBackgroundColor)
  4348. ? _this.styles.backgroundColor
  4349. : bodyBackgroundColor
  4350. : documentBackgroundColor;
  4351. }
  4352. }
  4353. catch (e) { }
  4354. return _this;
  4355. }
  4356. return IFrameElementContainer;
  4357. }(ElementContainer));
  4358. var LIST_OWNERS = ['OL', 'UL', 'MENU'];
  4359. var parseNodeTree = function (node, parent, root) {
  4360. for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
  4361. nextNode = childNode.nextSibling;
  4362. if (isTextNode(childNode) && childNode.data.trim().length > 0) {
  4363. parent.textNodes.push(new TextContainer(childNode, parent.styles));
  4364. }
  4365. else if (isElementNode(childNode)) {
  4366. var container = createContainer(childNode);
  4367. if (container.styles.isVisible()) {
  4368. if (createsRealStackingContext(childNode, container, root)) {
  4369. container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
  4370. }
  4371. else if (createsStackingContext(container.styles)) {
  4372. container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
  4373. }
  4374. if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
  4375. container.flags |= 8 /* IS_LIST_OWNER */;
  4376. }
  4377. parent.elements.push(container);
  4378. if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) {
  4379. parseNodeTree(childNode, container, root);
  4380. }
  4381. }
  4382. }
  4383. }
  4384. };
  4385. var createContainer = function (element) {
  4386. if (isImageElement(element)) {
  4387. return new ImageElementContainer(element);
  4388. }
  4389. if (isCanvasElement(element)) {
  4390. return new CanvasElementContainer(element);
  4391. }
  4392. if (isSVGElement(element)) {
  4393. return new SVGElementContainer(element);
  4394. }
  4395. if (isLIElement(element)) {
  4396. return new LIElementContainer(element);
  4397. }
  4398. if (isOLElement(element)) {
  4399. return new OLElementContainer(element);
  4400. }
  4401. if (isInputElement(element)) {
  4402. return new InputElementContainer(element);
  4403. }
  4404. if (isSelectElement(element)) {
  4405. return new SelectElementContainer(element);
  4406. }
  4407. if (isTextareaElement(element)) {
  4408. return new TextareaElementContainer(element);
  4409. }
  4410. if (isIFrameElement(element)) {
  4411. return new IFrameElementContainer(element);
  4412. }
  4413. return new ElementContainer(element);
  4414. };
  4415. var parseTree = function (element) {
  4416. var container = createContainer(element);
  4417. container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
  4418. parseNodeTree(element, container, container);
  4419. return container;
  4420. };
  4421. var createsRealStackingContext = function (node, container, root) {
  4422. return (container.styles.isPositionedWithZIndex() ||
  4423. container.styles.opacity < 1 ||
  4424. container.styles.isTransformed() ||
  4425. (isBodyElement(node) && root.styles.isTransparent()));
  4426. };
  4427. var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };
  4428. var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
  4429. var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  4430. var isHTMLElementNode = function (node) {
  4431. return typeof node.style !== 'undefined';
  4432. };
  4433. var isLIElement = function (node) { return node.tagName === 'LI'; };
  4434. var isOLElement = function (node) { return node.tagName === 'OL'; };
  4435. var isInputElement = function (node) { return node.tagName === 'INPUT'; };
  4436. var isHTMLElement = function (node) { return node.tagName === 'HTML'; };
  4437. var isSVGElement = function (node) { return node.tagName === 'svg'; };
  4438. var isBodyElement = function (node) { return node.tagName === 'BODY'; };
  4439. var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };
  4440. var isImageElement = function (node) { return node.tagName === 'IMG'; };
  4441. var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };
  4442. var isStyleElement = function (node) { return node.tagName === 'STYLE'; };
  4443. var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };
  4444. var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };
  4445. var isSelectElement = function (node) { return node.tagName === 'SELECT'; };
  4446. var CounterState = /** @class */ (function () {
  4447. function CounterState() {
  4448. this.counters = {};
  4449. }
  4450. CounterState.prototype.getCounterValue = function (name) {
  4451. var counter = this.counters[name];
  4452. if (counter && counter.length) {
  4453. return counter[counter.length - 1];
  4454. }
  4455. return 1;
  4456. };
  4457. CounterState.prototype.getCounterValues = function (name) {
  4458. var counter = this.counters[name];
  4459. return counter ? counter : [];
  4460. };
  4461. CounterState.prototype.pop = function (counters) {
  4462. var _this = this;
  4463. counters.forEach(function (counter) { return _this.counters[counter].pop(); });
  4464. };
  4465. CounterState.prototype.parse = function (style) {
  4466. var _this = this;
  4467. var counterIncrement = style.counterIncrement;
  4468. var counterReset = style.counterReset;
  4469. var canReset = true;
  4470. if (counterIncrement !== null) {
  4471. counterIncrement.forEach(function (entry) {
  4472. var counter = _this.counters[entry.counter];
  4473. if (counter && entry.increment !== 0) {
  4474. canReset = false;
  4475. counter[Math.max(0, counter.length - 1)] += entry.increment;
  4476. }
  4477. });
  4478. }
  4479. var counterNames = [];
  4480. if (canReset) {
  4481. counterReset.forEach(function (entry) {
  4482. var counter = _this.counters[entry.counter];
  4483. counterNames.push(entry.counter);
  4484. if (!counter) {
  4485. counter = _this.counters[entry.counter] = [];
  4486. }
  4487. counter.push(entry.reset);
  4488. });
  4489. }
  4490. return counterNames;
  4491. };
  4492. return CounterState;
  4493. }());
  4494. var ROMAN_UPPER = {
  4495. integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
  4496. values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
  4497. };
  4498. var ARMENIAN = {
  4499. integers: [
  4500. 9000,
  4501. 8000,
  4502. 7000,
  4503. 6000,
  4504. 5000,
  4505. 4000,
  4506. 3000,
  4507. 2000,
  4508. 1000,
  4509. 900,
  4510. 800,
  4511. 700,
  4512. 600,
  4513. 500,
  4514. 400,
  4515. 300,
  4516. 200,
  4517. 100,
  4518. 90,
  4519. 80,
  4520. 70,
  4521. 60,
  4522. 50,
  4523. 40,
  4524. 30,
  4525. 20,
  4526. 10,
  4527. 9,
  4528. 8,
  4529. 7,
  4530. 6,
  4531. 5,
  4532. 4,
  4533. 3,
  4534. 2,
  4535. 1
  4536. ],
  4537. values: [
  4538. 'Ք',
  4539. 'Փ',
  4540. 'Ւ',
  4541. 'Ց',
  4542. 'Ր',
  4543. 'Տ',
  4544. 'Վ',
  4545. 'Ս',
  4546. 'Ռ',
  4547. 'Ջ',
  4548. 'Պ',
  4549. 'Չ',
  4550. 'Ո',
  4551. 'Շ',
  4552. 'Ն',
  4553. 'Յ',
  4554. 'Մ',
  4555. 'Ճ',
  4556. 'Ղ',
  4557. 'Ձ',
  4558. 'Հ',
  4559. 'Կ',
  4560. 'Ծ',
  4561. 'Խ',
  4562. 'Լ',
  4563. 'Ի',
  4564. 'Ժ',
  4565. 'Թ',
  4566. 'Ը',
  4567. 'Է',
  4568. 'Զ',
  4569. 'Ե',
  4570. 'Դ',
  4571. 'Գ',
  4572. 'Բ',
  4573. 'Ա'
  4574. ]
  4575. };
  4576. var HEBREW = {
  4577. integers: [
  4578. 10000,
  4579. 9000,
  4580. 8000,
  4581. 7000,
  4582. 6000,
  4583. 5000,
  4584. 4000,
  4585. 3000,
  4586. 2000,
  4587. 1000,
  4588. 400,
  4589. 300,
  4590. 200,
  4591. 100,
  4592. 90,
  4593. 80,
  4594. 70,
  4595. 60,
  4596. 50,
  4597. 40,
  4598. 30,
  4599. 20,
  4600. 19,
  4601. 18,
  4602. 17,
  4603. 16,
  4604. 15,
  4605. 10,
  4606. 9,
  4607. 8,
  4608. 7,
  4609. 6,
  4610. 5,
  4611. 4,
  4612. 3,
  4613. 2,
  4614. 1
  4615. ],
  4616. values: [
  4617. 'י׳',
  4618. 'ט׳',
  4619. 'ח׳',
  4620. 'ז׳',
  4621. 'ו׳',
  4622. 'ה׳',
  4623. 'ד׳',
  4624. 'ג׳',
  4625. 'ב׳',
  4626. 'א׳',
  4627. 'ת',
  4628. 'ש',
  4629. 'ר',
  4630. 'ק',
  4631. 'צ',
  4632. 'פ',
  4633. 'ע',
  4634. 'ס',
  4635. 'נ',
  4636. 'מ',
  4637. 'ל',
  4638. 'כ',
  4639. 'יט',
  4640. 'יח',
  4641. 'יז',
  4642. 'טז',
  4643. 'טו',
  4644. 'י',
  4645. 'ט',
  4646. 'ח',
  4647. 'ז',
  4648. 'ו',
  4649. 'ה',
  4650. 'ד',
  4651. 'ג',
  4652. 'ב',
  4653. 'א'
  4654. ]
  4655. };
  4656. var GEORGIAN = {
  4657. integers: [
  4658. 10000,
  4659. 9000,
  4660. 8000,
  4661. 7000,
  4662. 6000,
  4663. 5000,
  4664. 4000,
  4665. 3000,
  4666. 2000,
  4667. 1000,
  4668. 900,
  4669. 800,
  4670. 700,
  4671. 600,
  4672. 500,
  4673. 400,
  4674. 300,
  4675. 200,
  4676. 100,
  4677. 90,
  4678. 80,
  4679. 70,
  4680. 60,
  4681. 50,
  4682. 40,
  4683. 30,
  4684. 20,
  4685. 10,
  4686. 9,
  4687. 8,
  4688. 7,
  4689. 6,
  4690. 5,
  4691. 4,
  4692. 3,
  4693. 2,
  4694. 1
  4695. ],
  4696. values: [
  4697. 'ჵ',
  4698. 'ჰ',
  4699. 'ჯ',
  4700. 'ჴ',
  4701. 'ხ',
  4702. 'ჭ',
  4703. 'წ',
  4704. 'ძ',
  4705. 'ც',
  4706. 'ჩ',
  4707. 'შ',
  4708. 'ყ',
  4709. 'ღ',
  4710. 'ქ',
  4711. 'ფ',
  4712. 'ჳ',
  4713. 'ტ',
  4714. 'ს',
  4715. 'რ',
  4716. 'ჟ',
  4717. 'პ',
  4718. 'ო',
  4719. 'ჲ',
  4720. 'ნ',
  4721. 'მ',
  4722. 'ლ',
  4723. 'კ',
  4724. 'ი',
  4725. 'თ',
  4726. 'ჱ',
  4727. 'ზ',
  4728. 'ვ',
  4729. 'ე',
  4730. 'დ',
  4731. 'გ',
  4732. 'ბ',
  4733. 'ა'
  4734. ]
  4735. };
  4736. var createAdditiveCounter = function (value, min, max, symbols, fallback, suffix) {
  4737. if (value < min || value > max) {
  4738. return createCounterText(value, fallback, suffix.length > 0);
  4739. }
  4740. return (symbols.integers.reduce(function (string, integer, index) {
  4741. while (value >= integer) {
  4742. value -= integer;
  4743. string += symbols.values[index];
  4744. }
  4745. return string;
  4746. }, '') + suffix);
  4747. };
  4748. var createCounterStyleWithSymbolResolver = function (value, codePointRangeLength, isNumeric, resolver) {
  4749. var string = '';
  4750. do {
  4751. if (!isNumeric) {
  4752. value--;
  4753. }
  4754. string = resolver(value) + string;
  4755. value /= codePointRangeLength;
  4756. } while (value * codePointRangeLength >= codePointRangeLength);
  4757. return string;
  4758. };
  4759. var createCounterStyleFromRange = function (value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) {
  4760. var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1;
  4761. return ((value < 0 ? '-' : '') +
  4762. (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function (codePoint) {
  4763. return fromCodePoint(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart);
  4764. }) +
  4765. suffix));
  4766. };
  4767. var createCounterStyleFromSymbols = function (value, symbols, suffix) {
  4768. if (suffix === void 0) { suffix = '. '; }
  4769. var codePointRangeLength = symbols.length;
  4770. return (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function (codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix);
  4771. };
  4772. var CJK_ZEROS = 1 << 0;
  4773. var CJK_TEN_COEFFICIENTS = 1 << 1;
  4774. var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;
  4775. var CJK_HUNDRED_COEFFICIENTS = 1 << 3;
  4776. var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {
  4777. if (value < -9999 || value > 9999) {
  4778. return createCounterText(value, LIST_STYLE_TYPE.CJK_DECIMAL, suffix.length > 0);
  4779. }
  4780. var tmp = Math.abs(value);
  4781. var string = suffix;
  4782. if (tmp === 0) {
  4783. return numbers[0] + string;
  4784. }
  4785. for (var digit = 0; tmp > 0 && digit <= 4; digit++) {
  4786. var coefficient = tmp % 10;
  4787. if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {
  4788. string = numbers[coefficient] + string;
  4789. }
  4790. else if (coefficient > 1 ||
  4791. (coefficient === 1 && digit === 0) ||
  4792. (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS)) ||
  4793. (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100) ||
  4794. (coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS))) {
  4795. string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string;
  4796. }
  4797. else if (coefficient === 1 && digit > 0) {
  4798. string = multipliers[digit - 1] + string;
  4799. }
  4800. tmp = Math.floor(tmp / 10);
  4801. }
  4802. return (value < 0 ? negativeSign : '') + string;
  4803. };
  4804. var CHINESE_INFORMAL_MULTIPLIERS = '十百千萬';
  4805. var CHINESE_FORMAL_MULTIPLIERS = '拾佰仟萬';
  4806. var JAPANESE_NEGATIVE = 'マイナス';
  4807. var KOREAN_NEGATIVE = '마이너스';
  4808. var createCounterText = function (value, type, appendSuffix) {
  4809. var defaultSuffix = appendSuffix ? '. ' : '';
  4810. var cjkSuffix = appendSuffix ? '、' : '';
  4811. var koreanSuffix = appendSuffix ? ', ' : '';
  4812. var spaceSuffix = appendSuffix ? ' ' : '';
  4813. switch (type) {
  4814. case LIST_STYLE_TYPE.DISC:
  4815. return '•' + spaceSuffix;
  4816. case LIST_STYLE_TYPE.CIRCLE:
  4817. return '◦' + spaceSuffix;
  4818. case LIST_STYLE_TYPE.SQUARE:
  4819. return '◾' + spaceSuffix;
  4820. case LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO:
  4821. var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
  4822. return string.length < 4 ? "0" + string : string;
  4823. case LIST_STYLE_TYPE.CJK_DECIMAL:
  4824. return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);
  4825. case LIST_STYLE_TYPE.LOWER_ROMAN:
  4826. return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();
  4827. case LIST_STYLE_TYPE.UPPER_ROMAN:
  4828. return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);
  4829. case LIST_STYLE_TYPE.LOWER_GREEK:
  4830. return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);
  4831. case LIST_STYLE_TYPE.LOWER_ALPHA:
  4832. return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);
  4833. case LIST_STYLE_TYPE.UPPER_ALPHA:
  4834. return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);
  4835. case LIST_STYLE_TYPE.ARABIC_INDIC:
  4836. return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);
  4837. case LIST_STYLE_TYPE.ARMENIAN:
  4838. case LIST_STYLE_TYPE.UPPER_ARMENIAN:
  4839. return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);
  4840. case LIST_STYLE_TYPE.LOWER_ARMENIAN:
  4841. return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();
  4842. case LIST_STYLE_TYPE.BENGALI:
  4843. return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);
  4844. case LIST_STYLE_TYPE.CAMBODIAN:
  4845. case LIST_STYLE_TYPE.KHMER:
  4846. return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);
  4847. case LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH:
  4848. return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);
  4849. case LIST_STYLE_TYPE.CJK_HEAVENLY_STEM:
  4850. return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);
  4851. case LIST_STYLE_TYPE.CJK_IDEOGRAPHIC:
  4852. case LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL:
  4853. return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  4854. case LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL:
  4855. return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  4856. case LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL:
  4857. return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  4858. case LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL:
  4859. return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  4860. case LIST_STYLE_TYPE.JAPANESE_INFORMAL:
  4861. return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);
  4862. case LIST_STYLE_TYPE.JAPANESE_FORMAL:
  4863. return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  4864. case LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL:
  4865. return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  4866. case LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL:
  4867. return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);
  4868. case LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL:
  4869. return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  4870. case LIST_STYLE_TYPE.DEVANAGARI:
  4871. return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);
  4872. case LIST_STYLE_TYPE.GEORGIAN:
  4873. return createAdditiveCounter(value, 1, 19999, GEORGIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);
  4874. case LIST_STYLE_TYPE.GUJARATI:
  4875. return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);
  4876. case LIST_STYLE_TYPE.GURMUKHI:
  4877. return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);
  4878. case LIST_STYLE_TYPE.HEBREW:
  4879. return createAdditiveCounter(value, 1, 10999, HEBREW, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);
  4880. case LIST_STYLE_TYPE.HIRAGANA:
  4881. return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');
  4882. case LIST_STYLE_TYPE.HIRAGANA_IROHA:
  4883. return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');
  4884. case LIST_STYLE_TYPE.KANNADA:
  4885. return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);
  4886. case LIST_STYLE_TYPE.KATAKANA:
  4887. return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);
  4888. case LIST_STYLE_TYPE.KATAKANA_IROHA:
  4889. return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);
  4890. case LIST_STYLE_TYPE.LAO:
  4891. return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);
  4892. case LIST_STYLE_TYPE.MONGOLIAN:
  4893. return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);
  4894. case LIST_STYLE_TYPE.MYANMAR:
  4895. return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);
  4896. case LIST_STYLE_TYPE.ORIYA:
  4897. return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);
  4898. case LIST_STYLE_TYPE.PERSIAN:
  4899. return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);
  4900. case LIST_STYLE_TYPE.TAMIL:
  4901. return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);
  4902. case LIST_STYLE_TYPE.TELUGU:
  4903. return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);
  4904. case LIST_STYLE_TYPE.THAI:
  4905. return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);
  4906. case LIST_STYLE_TYPE.TIBETAN:
  4907. return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);
  4908. case LIST_STYLE_TYPE.DECIMAL:
  4909. default:
  4910. return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
  4911. }
  4912. };
  4913. var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
  4914. var DocumentCloner = /** @class */ (function () {
  4915. function DocumentCloner(element, options) {
  4916. this.options = options;
  4917. this.scrolledElements = [];
  4918. this.referenceElement = element;
  4919. this.counters = new CounterState();
  4920. this.quoteDepth = 0;
  4921. if (!element.ownerDocument) {
  4922. throw new Error('Cloned element does not have an owner document');
  4923. }
  4924. this.documentElement = this.cloneNode(element.ownerDocument.documentElement);
  4925. }
  4926. DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {
  4927. var _this = this;
  4928. var iframe = createIFrameContainer(ownerDocument, windowSize);
  4929. if (!iframe.contentWindow) {
  4930. return Promise.reject("Unable to find iframe window");
  4931. }
  4932. var scrollX = ownerDocument.defaultView.pageXOffset;
  4933. var scrollY = ownerDocument.defaultView.pageYOffset;
  4934. var cloneWindow = iframe.contentWindow;
  4935. var documentClone = cloneWindow.document;
  4936. /* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
  4937. if window url is about:blank, we can assign the url to current by writing onto the document
  4938. */
  4939. var iframeLoad = iframeLoader(iframe).then(function () { return __awaiter(_this, void 0, void 0, function () {
  4940. var onclone;
  4941. return __generator(this, function (_a) {
  4942. switch (_a.label) {
  4943. case 0:
  4944. this.scrolledElements.forEach(restoreNodeScroll);
  4945. if (cloneWindow) {
  4946. cloneWindow.scrollTo(windowSize.left, windowSize.top);
  4947. if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
  4948. (cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) {
  4949. documentClone.documentElement.style.top = -windowSize.top + 'px';
  4950. documentClone.documentElement.style.left = -windowSize.left + 'px';
  4951. documentClone.documentElement.style.position = 'absolute';
  4952. }
  4953. }
  4954. onclone = this.options.onclone;
  4955. if (typeof this.clonedReferenceElement === 'undefined') {
  4956. return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
  4957. }
  4958. if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
  4959. return [4 /*yield*/, documentClone.fonts.ready];
  4960. case 1:
  4961. _a.sent();
  4962. _a.label = 2;
  4963. case 2:
  4964. if (typeof onclone === 'function') {
  4965. return [2 /*return*/, Promise.resolve()
  4966. .then(function () { return onclone(documentClone); })
  4967. .then(function () { return iframe; })];
  4968. }
  4969. return [2 /*return*/, iframe];
  4970. }
  4971. });
  4972. }); });
  4973. documentClone.open();
  4974. documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
  4975. // Chrome scrolls the parent document for some reason after the write to the cloned window???
  4976. restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
  4977. documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
  4978. documentClone.close();
  4979. return iframeLoad;
  4980. };
  4981. DocumentCloner.prototype.createElementClone = function (node) {
  4982. if (isCanvasElement(node)) {
  4983. return this.createCanvasClone(node);
  4984. }
  4985. /*
  4986. if (isIFrameElement(node)) {
  4987. return this.createIFrameClone(node);
  4988. }
  4989. */
  4990. if (isStyleElement(node)) {
  4991. return this.createStyleClone(node);
  4992. }
  4993. return node.cloneNode(false);
  4994. };
  4995. DocumentCloner.prototype.createStyleClone = function (node) {
  4996. try {
  4997. var sheet = node.sheet;
  4998. if (sheet && sheet.cssRules) {
  4999. var css = [].slice.call(sheet.cssRules, 0).reduce(function (css, rule) {
  5000. if (rule && typeof rule.cssText === 'string') {
  5001. return css + rule.cssText;
  5002. }
  5003. return css;
  5004. }, '');
  5005. var style = node.cloneNode(false);
  5006. style.textContent = css;
  5007. return style;
  5008. }
  5009. }
  5010. catch (e) {
  5011. // accessing node.sheet.cssRules throws a DOMException
  5012. Logger.getInstance(this.options.id).error('Unable to access cssRules property', e);
  5013. if (e.name !== 'SecurityError') {
  5014. throw e;
  5015. }
  5016. }
  5017. return node.cloneNode(false);
  5018. };
  5019. DocumentCloner.prototype.createCanvasClone = function (canvas) {
  5020. if (this.options.inlineImages && canvas.ownerDocument) {
  5021. var img = canvas.ownerDocument.createElement('img');
  5022. try {
  5023. img.src = canvas.toDataURL();
  5024. return img;
  5025. }
  5026. catch (e) {
  5027. Logger.getInstance(this.options.id).info("Unable to clone canvas contents, canvas is tainted");
  5028. }
  5029. }
  5030. var clonedCanvas = canvas.cloneNode(false);
  5031. try {
  5032. clonedCanvas.width = canvas.width;
  5033. clonedCanvas.height = canvas.height;
  5034. var ctx = canvas.getContext('2d');
  5035. var clonedCtx = clonedCanvas.getContext('2d');
  5036. if (clonedCtx) {
  5037. if (ctx) {
  5038. clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
  5039. }
  5040. else {
  5041. clonedCtx.drawImage(canvas, 0, 0);
  5042. }
  5043. }
  5044. return clonedCanvas;
  5045. }
  5046. catch (e) { }
  5047. return clonedCanvas;
  5048. };
  5049. /*
  5050. createIFrameClone(iframe: HTMLIFrameElement) {
  5051. const tempIframe = <HTMLIFrameElement>iframe.cloneNode(false);
  5052. const iframeKey = generateIframeKey();
  5053. tempIframe.setAttribute('data-html2canvas-internal-iframe-key', iframeKey);
  5054. const {width, height} = parseBounds(iframe);
  5055. this.resourceLoader.cache[iframeKey] = getIframeDocumentElement(iframe, this.options)
  5056. .then(documentElement => {
  5057. return this.renderer(
  5058. documentElement,
  5059. {
  5060. allowTaint: this.options.allowTaint,
  5061. backgroundColor: '#ffffff',
  5062. canvas: null,
  5063. imageTimeout: this.options.imageTimeout,
  5064. logging: this.options.logging,
  5065. proxy: this.options.proxy,
  5066. removeContainer: this.options.removeContainer,
  5067. scale: this.options.scale,
  5068. foreignObjectRendering: this.options.foreignObjectRendering,
  5069. useCORS: this.options.useCORS,
  5070. target: new CanvasRenderer(),
  5071. width,
  5072. height,
  5073. x: 0,
  5074. y: 0,
  5075. windowWidth: documentElement.ownerDocument.defaultView.innerWidth,
  5076. windowHeight: documentElement.ownerDocument.defaultView.innerHeight,
  5077. scrollX: documentElement.ownerDocument.defaultView.pageXOffset,
  5078. scrollY: documentElement.ownerDocument.defaultView.pageYOffset
  5079. },
  5080. );
  5081. })
  5082. .then(
  5083. (canvas: HTMLCanvasElement) =>
  5084. new Promise((resolve, reject) => {
  5085. const iframeCanvas = document.createElement('img');
  5086. iframeCanvas.onload = () => resolve(canvas);
  5087. iframeCanvas.onerror = (event) => {
  5088. // Empty iframes may result in empty "data:," URLs, which are invalid from the <img>'s point of view
  5089. // and instead of `onload` cause `onerror` and unhandled rejection warnings
  5090. // https://github.com/niklasvh/html2canvas/issues/1502
  5091. iframeCanvas.src == 'data:,' ? resolve(canvas) : reject(event);
  5092. };
  5093. iframeCanvas.src = canvas.toDataURL();
  5094. if (tempIframe.parentNode && iframe.ownerDocument && iframe.ownerDocument.defaultView) {
  5095. tempIframe.parentNode.replaceChild(
  5096. copyCSSStyles(
  5097. iframe.ownerDocument.defaultView.getComputedStyle(iframe),
  5098. iframeCanvas
  5099. ),
  5100. tempIframe
  5101. );
  5102. }
  5103. })
  5104. );
  5105. return tempIframe;
  5106. }
  5107. */
  5108. DocumentCloner.prototype.cloneNode = function (node) {
  5109. if (isTextNode(node)) {
  5110. return document.createTextNode(node.data);
  5111. }
  5112. if (!node.ownerDocument) {
  5113. return node.cloneNode(false);
  5114. }
  5115. var window = node.ownerDocument.defaultView;
  5116. if (isHTMLElementNode(node) && window) {
  5117. var clone = this.createElementClone(node);
  5118. var style = window.getComputedStyle(node);
  5119. var styleBefore = window.getComputedStyle(node, ':before');
  5120. var styleAfter = window.getComputedStyle(node, ':after');
  5121. if (this.referenceElement === node) {
  5122. this.clonedReferenceElement = clone;
  5123. }
  5124. if (isBodyElement(clone)) {
  5125. createPseudoHideStyles(clone);
  5126. }
  5127. var counters = this.counters.parse(new CSSParsedCounterDeclaration(style));
  5128. var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE);
  5129. for (var child = node.firstChild; child; child = child.nextSibling) {
  5130. if (!isElementNode(child) ||
  5131. (!isScriptElement(child) &&
  5132. !child.hasAttribute(IGNORE_ATTRIBUTE) &&
  5133. (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child)))) {
  5134. if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) {
  5135. clone.appendChild(this.cloneNode(child));
  5136. }
  5137. }
  5138. }
  5139. if (before) {
  5140. clone.insertBefore(before, clone.firstChild);
  5141. }
  5142. var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER);
  5143. if (after) {
  5144. clone.appendChild(after);
  5145. }
  5146. this.counters.pop(counters);
  5147. if (style && this.options.copyStyles && !isIFrameElement(node)) {
  5148. copyCSSStyles(style, clone);
  5149. }
  5150. //this.inlineAllImages(clone);
  5151. if (node.scrollTop !== 0 || node.scrollLeft !== 0) {
  5152. this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]);
  5153. }
  5154. if ((isTextareaElement(node) || isSelectElement(node)) &&
  5155. (isTextareaElement(clone) || isSelectElement(clone))) {
  5156. clone.value = node.value;
  5157. }
  5158. return clone;
  5159. }
  5160. return node.cloneNode(false);
  5161. };
  5162. DocumentCloner.prototype.resolvePseudoContent = function (node, clone, style, pseudoElt) {
  5163. var _this = this;
  5164. if (!style) {
  5165. return;
  5166. }
  5167. var value = style.content;
  5168. var document = clone.ownerDocument;
  5169. if (!document || !value || value === 'none' || value === '-moz-alt-content' || style.display === 'none') {
  5170. return;
  5171. }
  5172. this.counters.parse(new CSSParsedCounterDeclaration(style));
  5173. var declaration = new CSSParsedPseudoDeclaration(style);
  5174. var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
  5175. copyCSSStyles(style, anonymousReplacedElement);
  5176. declaration.content.forEach(function (token) {
  5177. if (token.type === TokenType.STRING_TOKEN) {
  5178. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  5179. }
  5180. else if (token.type === TokenType.URL_TOKEN) {
  5181. var img = document.createElement('img');
  5182. img.src = token.value;
  5183. img.style.opacity = '1';
  5184. anonymousReplacedElement.appendChild(img);
  5185. }
  5186. else if (token.type === TokenType.FUNCTION) {
  5187. if (token.name === 'attr') {
  5188. var attr = token.values.filter(isIdentToken);
  5189. if (attr.length) {
  5190. anonymousReplacedElement.appendChild(document.createTextNode(node.getAttribute(attr[0].value) || ''));
  5191. }
  5192. }
  5193. else if (token.name === 'counter') {
  5194. var _a = token.values.filter(nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1];
  5195. if (counter && isIdentToken(counter)) {
  5196. var counterState = _this.counters.getCounterValue(counter.value);
  5197. var counterType = counterStyle && isIdentToken(counterStyle)
  5198. ? listStyleType.parse(counterStyle.value)
  5199. : LIST_STYLE_TYPE.DECIMAL;
  5200. anonymousReplacedElement.appendChild(document.createTextNode(createCounterText(counterState, counterType, false)));
  5201. }
  5202. }
  5203. else if (token.name === 'counters') {
  5204. var _b = token.values.filter(nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2];
  5205. if (counter && isIdentToken(counter)) {
  5206. var counterStates = _this.counters.getCounterValues(counter.value);
  5207. var counterType_1 = counterStyle && isIdentToken(counterStyle)
  5208. ? listStyleType.parse(counterStyle.value)
  5209. : LIST_STYLE_TYPE.DECIMAL;
  5210. var separator = delim && delim.type === TokenType.STRING_TOKEN ? delim.value : '';
  5211. var text = counterStates
  5212. .map(function (value) { return createCounterText(value, counterType_1, false); })
  5213. .join(separator);
  5214. anonymousReplacedElement.appendChild(document.createTextNode(text));
  5215. }
  5216. }
  5217. }
  5218. else if (token.type === TokenType.IDENT_TOKEN) {
  5219. switch (token.value) {
  5220. case 'open-quote':
  5221. anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true)));
  5222. break;
  5223. case 'close-quote':
  5224. anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, --_this.quoteDepth, false)));
  5225. break;
  5226. default:
  5227. // safari doesn't parse string tokens correctly because of lack of quotes
  5228. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  5229. }
  5230. }
  5231. });
  5232. anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  5233. clone.className +=
  5234. pseudoElt === PseudoElementType.BEFORE
  5235. ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
  5236. : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  5237. return anonymousReplacedElement;
  5238. };
  5239. DocumentCloner.destroy = function (container) {
  5240. if (container.parentNode) {
  5241. container.parentNode.removeChild(container);
  5242. return true;
  5243. }
  5244. return false;
  5245. };
  5246. return DocumentCloner;
  5247. }());
  5248. var PseudoElementType;
  5249. (function (PseudoElementType) {
  5250. PseudoElementType[PseudoElementType["BEFORE"] = 0] = "BEFORE";
  5251. PseudoElementType[PseudoElementType["AFTER"] = 1] = "AFTER";
  5252. })(PseudoElementType || (PseudoElementType = {}));
  5253. var createIFrameContainer = function (ownerDocument, bounds) {
  5254. var cloneIframeContainer = ownerDocument.createElement('iframe');
  5255. cloneIframeContainer.className = 'html2canvas-container';
  5256. cloneIframeContainer.style.visibility = 'hidden';
  5257. cloneIframeContainer.style.position = 'fixed';
  5258. cloneIframeContainer.style.left = '-10000px';
  5259. cloneIframeContainer.style.top = '0px';
  5260. cloneIframeContainer.style.border = '0';
  5261. cloneIframeContainer.width = bounds.width.toString();
  5262. cloneIframeContainer.height = bounds.height.toString();
  5263. cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it
  5264. cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true');
  5265. ownerDocument.body.appendChild(cloneIframeContainer);
  5266. return cloneIframeContainer;
  5267. };
  5268. var iframeLoader = function (iframe) {
  5269. return new Promise(function (resolve, reject) {
  5270. var cloneWindow = iframe.contentWindow;
  5271. if (!cloneWindow) {
  5272. return reject("No window assigned for iframe");
  5273. }
  5274. var documentClone = cloneWindow.document;
  5275. cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = function () {
  5276. cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = null;
  5277. var interval = setInterval(function () {
  5278. if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
  5279. clearInterval(interval);
  5280. resolve(iframe);
  5281. }
  5282. }, 50);
  5283. };
  5284. });
  5285. };
  5286. var copyCSSStyles = function (style, target) {
  5287. // Edge does not provide value for cssText
  5288. for (var i = style.length - 1; i >= 0; i--) {
  5289. var property = style.item(i);
  5290. // Safari shows pseudoelements if content is set
  5291. if (property !== 'content') {
  5292. target.style.setProperty(property, style.getPropertyValue(property));
  5293. }
  5294. }
  5295. return target;
  5296. };
  5297. var serializeDoctype = function (doctype) {
  5298. var str = '';
  5299. if (doctype) {
  5300. str += '<!DOCTYPE ';
  5301. if (doctype.name) {
  5302. str += doctype.name;
  5303. }
  5304. if (doctype.internalSubset) {
  5305. str += doctype.internalSubset;
  5306. }
  5307. if (doctype.publicId) {
  5308. str += "\"" + doctype.publicId + "\"";
  5309. }
  5310. if (doctype.systemId) {
  5311. str += "\"" + doctype.systemId + "\"";
  5312. }
  5313. str += '>';
  5314. }
  5315. return str;
  5316. };
  5317. var restoreOwnerScroll = function (ownerDocument, x, y) {
  5318. if (ownerDocument &&
  5319. ownerDocument.defaultView &&
  5320. (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
  5321. ownerDocument.defaultView.scrollTo(x, y);
  5322. }
  5323. };
  5324. var restoreNodeScroll = function (_a) {
  5325. var element = _a[0], x = _a[1], y = _a[2];
  5326. element.scrollLeft = x;
  5327. element.scrollTop = y;
  5328. };
  5329. var PSEUDO_BEFORE = ':before';
  5330. var PSEUDO_AFTER = ':after';
  5331. var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
  5332. var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
  5333. var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
  5334. var createPseudoHideStyles = function (body) {
  5335. createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
  5336. };
  5337. var createStyles = function (body, styles) {
  5338. var document = body.ownerDocument;
  5339. if (document) {
  5340. var style = document.createElement('style');
  5341. style.textContent = styles;
  5342. body.appendChild(style);
  5343. }
  5344. };
  5345. var PathType;
  5346. (function (PathType) {
  5347. PathType[PathType["VECTOR"] = 0] = "VECTOR";
  5348. PathType[PathType["BEZIER_CURVE"] = 1] = "BEZIER_CURVE";
  5349. })(PathType || (PathType = {}));
  5350. var equalPath = function (a, b) {
  5351. if (a.length === b.length) {
  5352. return a.some(function (v, i) { return v === b[i]; });
  5353. }
  5354. return false;
  5355. };
  5356. var transformPath = function (path, deltaX, deltaY, deltaW, deltaH) {
  5357. return path.map(function (point, index) {
  5358. switch (index) {
  5359. case 0:
  5360. return point.add(deltaX, deltaY);
  5361. case 1:
  5362. return point.add(deltaX + deltaW, deltaY);
  5363. case 2:
  5364. return point.add(deltaX + deltaW, deltaY + deltaH);
  5365. case 3:
  5366. return point.add(deltaX, deltaY + deltaH);
  5367. }
  5368. return point;
  5369. });
  5370. };
  5371. var Vector = /** @class */ (function () {
  5372. function Vector(x, y) {
  5373. this.type = PathType.VECTOR;
  5374. this.x = x;
  5375. this.y = y;
  5376. }
  5377. Vector.prototype.add = function (deltaX, deltaY) {
  5378. return new Vector(this.x + deltaX, this.y + deltaY);
  5379. };
  5380. return Vector;
  5381. }());
  5382. var lerp = function (a, b, t) {
  5383. return new Vector(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
  5384. };
  5385. var BezierCurve = /** @class */ (function () {
  5386. function BezierCurve(start, startControl, endControl, end) {
  5387. this.type = PathType.BEZIER_CURVE;
  5388. this.start = start;
  5389. this.startControl = startControl;
  5390. this.endControl = endControl;
  5391. this.end = end;
  5392. }
  5393. BezierCurve.prototype.subdivide = function (t, firstHalf) {
  5394. var ab = lerp(this.start, this.startControl, t);
  5395. var bc = lerp(this.startControl, this.endControl, t);
  5396. var cd = lerp(this.endControl, this.end, t);
  5397. var abbc = lerp(ab, bc, t);
  5398. var bccd = lerp(bc, cd, t);
  5399. var dest = lerp(abbc, bccd, t);
  5400. return firstHalf ? new BezierCurve(this.start, ab, abbc, dest) : new BezierCurve(dest, bccd, cd, this.end);
  5401. };
  5402. BezierCurve.prototype.add = function (deltaX, deltaY) {
  5403. return new BezierCurve(this.start.add(deltaX, deltaY), this.startControl.add(deltaX, deltaY), this.endControl.add(deltaX, deltaY), this.end.add(deltaX, deltaY));
  5404. };
  5405. BezierCurve.prototype.reverse = function () {
  5406. return new BezierCurve(this.end, this.endControl, this.startControl, this.start);
  5407. };
  5408. return BezierCurve;
  5409. }());
  5410. var isBezierCurve = function (path) { return path.type === PathType.BEZIER_CURVE; };
  5411. var BoundCurves = /** @class */ (function () {
  5412. function BoundCurves(element) {
  5413. var styles = element.styles;
  5414. var bounds = element.bounds;
  5415. var _a = getAbsoluteValueForTuple(styles.borderTopLeftRadius, bounds.width, bounds.height), tlh = _a[0], tlv = _a[1];
  5416. var _b = getAbsoluteValueForTuple(styles.borderTopRightRadius, bounds.width, bounds.height), trh = _b[0], trv = _b[1];
  5417. var _c = getAbsoluteValueForTuple(styles.borderBottomRightRadius, bounds.width, bounds.height), brh = _c[0], brv = _c[1];
  5418. var _d = getAbsoluteValueForTuple(styles.borderBottomLeftRadius, bounds.width, bounds.height), blh = _d[0], blv = _d[1];
  5419. var factors = [];
  5420. factors.push((tlh + trh) / bounds.width);
  5421. factors.push((blh + brh) / bounds.width);
  5422. factors.push((tlv + blv) / bounds.height);
  5423. factors.push((trv + brv) / bounds.height);
  5424. var maxFactor = Math.max.apply(Math, factors);
  5425. if (maxFactor > 1) {
  5426. tlh /= maxFactor;
  5427. tlv /= maxFactor;
  5428. trh /= maxFactor;
  5429. trv /= maxFactor;
  5430. brh /= maxFactor;
  5431. brv /= maxFactor;
  5432. blh /= maxFactor;
  5433. blv /= maxFactor;
  5434. }
  5435. var topWidth = bounds.width - trh;
  5436. var rightHeight = bounds.height - brv;
  5437. var bottomWidth = bounds.width - brh;
  5438. var leftHeight = bounds.height - blv;
  5439. var borderTopWidth = styles.borderTopWidth;
  5440. var borderRightWidth = styles.borderRightWidth;
  5441. var borderBottomWidth = styles.borderBottomWidth;
  5442. var borderLeftWidth = styles.borderLeftWidth;
  5443. var paddingTop = getAbsoluteValue(styles.paddingTop, element.bounds.width);
  5444. var paddingRight = getAbsoluteValue(styles.paddingRight, element.bounds.width);
  5445. var paddingBottom = getAbsoluteValue(styles.paddingBottom, element.bounds.width);
  5446. var paddingLeft = getAbsoluteValue(styles.paddingLeft, element.bounds.width);
  5447. this.topLeftBorderBox =
  5448. tlh > 0 || tlv > 0
  5449. ? getCurvePoints(bounds.left, bounds.top, tlh, tlv, CORNER.TOP_LEFT)
  5450. : new Vector(bounds.left, bounds.top);
  5451. this.topRightBorderBox =
  5452. trh > 0 || trv > 0
  5453. ? getCurvePoints(bounds.left + topWidth, bounds.top, trh, trv, CORNER.TOP_RIGHT)
  5454. : new Vector(bounds.left + bounds.width, bounds.top);
  5455. this.bottomRightBorderBox =
  5456. brh > 0 || brv > 0
  5457. ? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh, brv, CORNER.BOTTOM_RIGHT)
  5458. : new Vector(bounds.left + bounds.width, bounds.top + bounds.height);
  5459. this.bottomLeftBorderBox =
  5460. blh > 0 || blv > 0
  5461. ? getCurvePoints(bounds.left, bounds.top + leftHeight, blh, blv, CORNER.BOTTOM_LEFT)
  5462. : new Vector(bounds.left, bounds.top + bounds.height);
  5463. this.topLeftPaddingBox =
  5464. tlh > 0 || tlv > 0
  5465. ? getCurvePoints(bounds.left + borderLeftWidth, bounds.top + borderTopWidth, Math.max(0, tlh - borderLeftWidth), Math.max(0, tlv - borderTopWidth), CORNER.TOP_LEFT)
  5466. : new Vector(bounds.left + borderLeftWidth, bounds.top + borderTopWidth);
  5467. this.topRightPaddingBox =
  5468. trh > 0 || trv > 0
  5469. ? getCurvePoints(bounds.left + Math.min(topWidth, bounds.width + borderLeftWidth), bounds.top + borderTopWidth, topWidth > bounds.width + borderLeftWidth ? 0 : trh - borderLeftWidth, trv - borderTopWidth, CORNER.TOP_RIGHT)
  5470. : new Vector(bounds.left + bounds.width - borderRightWidth, bounds.top + borderTopWidth);
  5471. this.bottomRightPaddingBox =
  5472. brh > 0 || brv > 0
  5473. ? getCurvePoints(bounds.left + Math.min(bottomWidth, bounds.width - borderLeftWidth), bounds.top + Math.min(rightHeight, bounds.height + borderTopWidth), Math.max(0, brh - borderRightWidth), brv - borderBottomWidth, CORNER.BOTTOM_RIGHT)
  5474. : new Vector(bounds.left + bounds.width - borderRightWidth, bounds.top + bounds.height - borderBottomWidth);
  5475. this.bottomLeftPaddingBox =
  5476. blh > 0 || blv > 0
  5477. ? getCurvePoints(bounds.left + borderLeftWidth, bounds.top + leftHeight, Math.max(0, blh - borderLeftWidth), blv - borderBottomWidth, CORNER.BOTTOM_LEFT)
  5478. : new Vector(bounds.left + borderLeftWidth, bounds.top + bounds.height - borderBottomWidth);
  5479. this.topLeftContentBox =
  5480. tlh > 0 || tlv > 0
  5481. ? getCurvePoints(bounds.left + borderLeftWidth + paddingLeft, bounds.top + borderTopWidth + paddingTop, Math.max(0, tlh - (borderLeftWidth + paddingLeft)), Math.max(0, tlv - (borderTopWidth + paddingTop)), CORNER.TOP_LEFT)
  5482. : new Vector(bounds.left + borderLeftWidth + paddingLeft, bounds.top + borderTopWidth + paddingTop);
  5483. this.topRightContentBox =
  5484. trh > 0 || trv > 0
  5485. ? getCurvePoints(bounds.left + Math.min(topWidth, bounds.width + borderLeftWidth + paddingLeft), bounds.top + borderTopWidth + paddingTop, topWidth > bounds.width + borderLeftWidth + paddingLeft ? 0 : trh - borderLeftWidth + paddingLeft, trv - (borderTopWidth + paddingTop), CORNER.TOP_RIGHT)
  5486. : new Vector(bounds.left + bounds.width - (borderRightWidth + paddingRight), bounds.top + borderTopWidth + paddingTop);
  5487. this.bottomRightContentBox =
  5488. brh > 0 || brv > 0
  5489. ? getCurvePoints(bounds.left + Math.min(bottomWidth, bounds.width - (borderLeftWidth + paddingLeft)), bounds.top + Math.min(rightHeight, bounds.height + borderTopWidth + paddingTop), Math.max(0, brh - (borderRightWidth + paddingRight)), brv - (borderBottomWidth + paddingBottom), CORNER.BOTTOM_RIGHT)
  5490. : new Vector(bounds.left + bounds.width - (borderRightWidth + paddingRight), bounds.top + bounds.height - (borderBottomWidth + paddingBottom));
  5491. this.bottomLeftContentBox =
  5492. blh > 0 || blv > 0
  5493. ? getCurvePoints(bounds.left + borderLeftWidth + paddingLeft, bounds.top + leftHeight, Math.max(0, blh - (borderLeftWidth + paddingLeft)), blv - (borderBottomWidth + paddingBottom), CORNER.BOTTOM_LEFT)
  5494. : new Vector(bounds.left + borderLeftWidth + paddingLeft, bounds.top + bounds.height - (borderBottomWidth + paddingBottom));
  5495. }
  5496. return BoundCurves;
  5497. }());
  5498. var CORNER;
  5499. (function (CORNER) {
  5500. CORNER[CORNER["TOP_LEFT"] = 0] = "TOP_LEFT";
  5501. CORNER[CORNER["TOP_RIGHT"] = 1] = "TOP_RIGHT";
  5502. CORNER[CORNER["BOTTOM_RIGHT"] = 2] = "BOTTOM_RIGHT";
  5503. CORNER[CORNER["BOTTOM_LEFT"] = 3] = "BOTTOM_LEFT";
  5504. })(CORNER || (CORNER = {}));
  5505. var getCurvePoints = function (x, y, r1, r2, position) {
  5506. var kappa = 4 * ((Math.sqrt(2) - 1) / 3);
  5507. var ox = r1 * kappa; // control point offset horizontal
  5508. var oy = r2 * kappa; // control point offset vertical
  5509. var xm = x + r1; // x-middle
  5510. var ym = y + r2; // y-middle
  5511. switch (position) {
  5512. case CORNER.TOP_LEFT:
  5513. return new BezierCurve(new Vector(x, ym), new Vector(x, ym - oy), new Vector(xm - ox, y), new Vector(xm, y));
  5514. case CORNER.TOP_RIGHT:
  5515. return new BezierCurve(new Vector(x, y), new Vector(x + ox, y), new Vector(xm, ym - oy), new Vector(xm, ym));
  5516. case CORNER.BOTTOM_RIGHT:
  5517. return new BezierCurve(new Vector(xm, y), new Vector(xm, y + oy), new Vector(x + ox, ym), new Vector(x, ym));
  5518. case CORNER.BOTTOM_LEFT:
  5519. default:
  5520. return new BezierCurve(new Vector(xm, ym), new Vector(xm - ox, ym), new Vector(x, y + oy), new Vector(x, y));
  5521. }
  5522. };
  5523. var calculateBorderBoxPath = function (curves) {
  5524. return [curves.topLeftBorderBox, curves.topRightBorderBox, curves.bottomRightBorderBox, curves.bottomLeftBorderBox];
  5525. };
  5526. var calculateContentBoxPath = function (curves) {
  5527. return [
  5528. curves.topLeftContentBox,
  5529. curves.topRightContentBox,
  5530. curves.bottomRightContentBox,
  5531. curves.bottomLeftContentBox
  5532. ];
  5533. };
  5534. var calculatePaddingBoxPath = function (curves) {
  5535. return [
  5536. curves.topLeftPaddingBox,
  5537. curves.topRightPaddingBox,
  5538. curves.bottomRightPaddingBox,
  5539. curves.bottomLeftPaddingBox
  5540. ];
  5541. };
  5542. var TransformEffect = /** @class */ (function () {
  5543. function TransformEffect(offsetX, offsetY, matrix) {
  5544. this.type = 0 /* TRANSFORM */;
  5545. this.offsetX = offsetX;
  5546. this.offsetY = offsetY;
  5547. this.matrix = matrix;
  5548. this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
  5549. }
  5550. return TransformEffect;
  5551. }());
  5552. var ClipEffect = /** @class */ (function () {
  5553. function ClipEffect(path, target) {
  5554. this.type = 1 /* CLIP */;
  5555. this.target = target;
  5556. this.path = path;
  5557. }
  5558. return ClipEffect;
  5559. }());
  5560. var isTransformEffect = function (effect) {
  5561. return effect.type === 0 /* TRANSFORM */;
  5562. };
  5563. var isClipEffect = function (effect) { return effect.type === 1 /* CLIP */; };
  5564. var StackingContext = /** @class */ (function () {
  5565. function StackingContext(container) {
  5566. this.element = container;
  5567. this.inlineLevel = [];
  5568. this.nonInlineLevel = [];
  5569. this.negativeZIndex = [];
  5570. this.zeroOrAutoZIndexOrTransformedOrOpacity = [];
  5571. this.positiveZIndex = [];
  5572. this.nonPositionedFloats = [];
  5573. this.nonPositionedInlineLevel = [];
  5574. }
  5575. return StackingContext;
  5576. }());
  5577. var ElementPaint = /** @class */ (function () {
  5578. function ElementPaint(element, parentStack) {
  5579. this.container = element;
  5580. this.effects = parentStack.slice(0);
  5581. this.curves = new BoundCurves(element);
  5582. if (element.styles.transform !== null) {
  5583. var offsetX = element.bounds.left + element.styles.transformOrigin[0].number;
  5584. var offsetY = element.bounds.top + element.styles.transformOrigin[1].number;
  5585. var matrix = element.styles.transform;
  5586. this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
  5587. }
  5588. if (element.styles.overflowX !== OVERFLOW.VISIBLE) {
  5589. var borderBox = calculateBorderBoxPath(this.curves);
  5590. var paddingBox = calculatePaddingBoxPath(this.curves);
  5591. if (equalPath(borderBox, paddingBox)) {
  5592. this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
  5593. }
  5594. else {
  5595. this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */));
  5596. this.effects.push(new ClipEffect(paddingBox, 4 /* CONTENT */));
  5597. }
  5598. }
  5599. }
  5600. ElementPaint.prototype.getParentEffects = function () {
  5601. var effects = this.effects.slice(0);
  5602. if (this.container.styles.overflowX !== OVERFLOW.VISIBLE) {
  5603. var borderBox = calculateBorderBoxPath(this.curves);
  5604. var paddingBox = calculatePaddingBoxPath(this.curves);
  5605. if (!equalPath(borderBox, paddingBox)) {
  5606. effects.push(new ClipEffect(paddingBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
  5607. }
  5608. }
  5609. return effects;
  5610. };
  5611. return ElementPaint;
  5612. }());
  5613. var parseStackTree = function (parent, stackingContext, realStackingContext, listItems) {
  5614. parent.container.elements.forEach(function (child) {
  5615. var treatAsRealStackingContext = contains(child.flags, 4 /* CREATES_REAL_STACKING_CONTEXT */);
  5616. var createsStackingContext = contains(child.flags, 2 /* CREATES_STACKING_CONTEXT */);
  5617. var paintContainer = new ElementPaint(child, parent.getParentEffects());
  5618. if (contains(child.styles.display, 2048 /* LIST_ITEM */)) {
  5619. listItems.push(paintContainer);
  5620. }
  5621. var listOwnerItems = contains(child.flags, 8 /* IS_LIST_OWNER */) ? [] : listItems;
  5622. if (treatAsRealStackingContext || createsStackingContext) {
  5623. var parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
  5624. var stack = new StackingContext(paintContainer);
  5625. if (child.styles.isPositioned() || child.styles.opacity < 1 || child.styles.isTransformed()) {
  5626. var order_1 = child.styles.zIndex.order;
  5627. if (order_1 < 0) {
  5628. var index_1 = 0;
  5629. parentStack.negativeZIndex.some(function (current, i) {
  5630. if (order_1 > current.element.container.styles.zIndex.order) {
  5631. index_1 = i;
  5632. return false;
  5633. }
  5634. else if (index_1 > 0) {
  5635. return true;
  5636. }
  5637. return false;
  5638. });
  5639. parentStack.negativeZIndex.splice(index_1, 0, stack);
  5640. }
  5641. else if (order_1 > 0) {
  5642. var index_2 = 0;
  5643. parentStack.positiveZIndex.some(function (current, i) {
  5644. if (order_1 > current.element.container.styles.zIndex.order) {
  5645. index_2 = i + 1;
  5646. return false;
  5647. }
  5648. else if (index_2 > 0) {
  5649. return true;
  5650. }
  5651. return false;
  5652. });
  5653. parentStack.positiveZIndex.splice(index_2, 0, stack);
  5654. }
  5655. else {
  5656. parentStack.zeroOrAutoZIndexOrTransformedOrOpacity.push(stack);
  5657. }
  5658. }
  5659. else {
  5660. if (child.styles.isFloating()) {
  5661. parentStack.nonPositionedFloats.push(stack);
  5662. }
  5663. else {
  5664. parentStack.nonPositionedInlineLevel.push(stack);
  5665. }
  5666. }
  5667. parseStackTree(paintContainer, stack, treatAsRealStackingContext ? stack : realStackingContext, listOwnerItems);
  5668. }
  5669. else {
  5670. if (child.styles.isInlineLevel()) {
  5671. stackingContext.inlineLevel.push(paintContainer);
  5672. }
  5673. else {
  5674. stackingContext.nonInlineLevel.push(paintContainer);
  5675. }
  5676. parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
  5677. }
  5678. if (contains(child.flags, 8 /* IS_LIST_OWNER */)) {
  5679. processListItems(child, listOwnerItems);
  5680. }
  5681. });
  5682. };
  5683. var processListItems = function (owner, elements) {
  5684. var numbering = owner instanceof OLElementContainer ? owner.start : 1;
  5685. var reversed = owner instanceof OLElementContainer ? owner.reversed : false;
  5686. for (var i = 0; i < elements.length; i++) {
  5687. var item = elements[i];
  5688. if (item.container instanceof LIElementContainer &&
  5689. typeof item.container.value === 'number' &&
  5690. item.container.value !== 0) {
  5691. numbering = item.container.value;
  5692. }
  5693. item.listValue = createCounterText(numbering, item.container.styles.listStyleType, true);
  5694. numbering += reversed ? -1 : 1;
  5695. }
  5696. };
  5697. var parseStackingContexts = function (container) {
  5698. var paintContainer = new ElementPaint(container, []);
  5699. var root = new StackingContext(paintContainer);
  5700. var listItems = [];
  5701. parseStackTree(paintContainer, root, root, listItems);
  5702. processListItems(paintContainer.container, listItems);
  5703. return root;
  5704. };
  5705. var parsePathForBorder = function (curves, borderSide) {
  5706. switch (borderSide) {
  5707. case 0:
  5708. return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftPaddingBox, curves.topRightBorderBox, curves.topRightPaddingBox);
  5709. case 1:
  5710. return createPathFromCurves(curves.topRightBorderBox, curves.topRightPaddingBox, curves.bottomRightBorderBox, curves.bottomRightPaddingBox);
  5711. case 2:
  5712. return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox);
  5713. case 3:
  5714. default:
  5715. return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox, curves.topLeftBorderBox, curves.topLeftPaddingBox);
  5716. }
  5717. };
  5718. var createPathFromCurves = function (outer1, inner1, outer2, inner2) {
  5719. var path = [];
  5720. if (isBezierCurve(outer1)) {
  5721. path.push(outer1.subdivide(0.5, false));
  5722. }
  5723. else {
  5724. path.push(outer1);
  5725. }
  5726. if (isBezierCurve(outer2)) {
  5727. path.push(outer2.subdivide(0.5, true));
  5728. }
  5729. else {
  5730. path.push(outer2);
  5731. }
  5732. if (isBezierCurve(inner2)) {
  5733. path.push(inner2.subdivide(0.5, true).reverse());
  5734. }
  5735. else {
  5736. path.push(inner2);
  5737. }
  5738. if (isBezierCurve(inner1)) {
  5739. path.push(inner1.subdivide(0.5, false).reverse());
  5740. }
  5741. else {
  5742. path.push(inner1);
  5743. }
  5744. return path;
  5745. };
  5746. var paddingBox = function (element) {
  5747. var bounds = element.bounds;
  5748. var styles = element.styles;
  5749. return bounds.add(styles.borderLeftWidth, styles.borderTopWidth, -(styles.borderRightWidth + styles.borderLeftWidth), -(styles.borderTopWidth + styles.borderBottomWidth));
  5750. };
  5751. var contentBox = function (element) {
  5752. var styles = element.styles;
  5753. var bounds = element.bounds;
  5754. var paddingLeft = getAbsoluteValue(styles.paddingLeft, bounds.width);
  5755. var paddingRight = getAbsoluteValue(styles.paddingRight, bounds.width);
  5756. var paddingTop = getAbsoluteValue(styles.paddingTop, bounds.width);
  5757. var paddingBottom = getAbsoluteValue(styles.paddingBottom, bounds.width);
  5758. return bounds.add(paddingLeft + styles.borderLeftWidth, paddingTop + styles.borderTopWidth, -(styles.borderRightWidth + styles.borderLeftWidth + paddingLeft + paddingRight), -(styles.borderTopWidth + styles.borderBottomWidth + paddingTop + paddingBottom));
  5759. };
  5760. var calculateBackgroundPositioningArea = function (backgroundOrigin, element) {
  5761. if (backgroundOrigin === 0 /* BORDER_BOX */) {
  5762. return element.bounds;
  5763. }
  5764. if (backgroundOrigin === 2 /* CONTENT_BOX */) {
  5765. return contentBox(element);
  5766. }
  5767. return paddingBox(element);
  5768. };
  5769. var calculateBackgroundPaintingArea = function (backgroundClip, element) {
  5770. if (backgroundClip === BACKGROUND_CLIP.BORDER_BOX) {
  5771. return element.bounds;
  5772. }
  5773. if (backgroundClip === BACKGROUND_CLIP.CONTENT_BOX) {
  5774. return contentBox(element);
  5775. }
  5776. return paddingBox(element);
  5777. };
  5778. var calculateBackgroundRendering = function (container, index, intrinsicSize) {
  5779. var backgroundPositioningArea = calculateBackgroundPositioningArea(getBackgroundValueForIndex(container.styles.backgroundOrigin, index), container);
  5780. var backgroundPaintingArea = calculateBackgroundPaintingArea(getBackgroundValueForIndex(container.styles.backgroundClip, index), container);
  5781. var backgroundImageSize = calculateBackgroundSize(getBackgroundValueForIndex(container.styles.backgroundSize, index), intrinsicSize, backgroundPositioningArea);
  5782. var sizeWidth = backgroundImageSize[0], sizeHeight = backgroundImageSize[1];
  5783. var position = getAbsoluteValueForTuple(getBackgroundValueForIndex(container.styles.backgroundPosition, index), backgroundPositioningArea.width - sizeWidth, backgroundPositioningArea.height - sizeHeight);
  5784. var path = calculateBackgroundRepeatPath(getBackgroundValueForIndex(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
  5785. var offsetX = Math.round(backgroundPositioningArea.left + position[0]);
  5786. var offsetY = Math.round(backgroundPositioningArea.top + position[1]);
  5787. return [path, offsetX, offsetY, sizeWidth, sizeHeight];
  5788. };
  5789. var isAuto = function (token) { return isIdentToken(token) && token.value === BACKGROUND_SIZE.AUTO; };
  5790. var hasIntrinsicValue = function (value) { return typeof value === 'number'; };
  5791. var calculateBackgroundSize = function (size, _a, bounds) {
  5792. var intrinsicWidth = _a[0], intrinsicHeight = _a[1], intrinsicProportion = _a[2];
  5793. var first = size[0], second = size[1];
  5794. if (isLengthPercentage(first) && second && isLengthPercentage(second)) {
  5795. return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)];
  5796. }
  5797. var hasIntrinsicProportion = hasIntrinsicValue(intrinsicProportion);
  5798. if (isIdentToken(first) && (first.value === BACKGROUND_SIZE.CONTAIN || first.value === BACKGROUND_SIZE.COVER)) {
  5799. if (hasIntrinsicValue(intrinsicProportion)) {
  5800. var targetRatio = bounds.width / bounds.height;
  5801. return targetRatio < intrinsicProportion !== (first.value === BACKGROUND_SIZE.COVER)
  5802. ? [bounds.width, bounds.width / intrinsicProportion]
  5803. : [bounds.height * intrinsicProportion, bounds.height];
  5804. }
  5805. return [bounds.width, bounds.height];
  5806. }
  5807. var hasIntrinsicWidth = hasIntrinsicValue(intrinsicWidth);
  5808. var hasIntrinsicHeight = hasIntrinsicValue(intrinsicHeight);
  5809. var hasIntrinsicDimensions = hasIntrinsicWidth || hasIntrinsicHeight;
  5810. // If the background-size is auto or auto auto:
  5811. if (isAuto(first) && (!second || isAuto(second))) {
  5812. // If the image has both horizontal and vertical intrinsic dimensions, it's rendered at that size.
  5813. if (hasIntrinsicWidth && hasIntrinsicHeight) {
  5814. return [intrinsicWidth, intrinsicHeight];
  5815. }
  5816. // If the image has no intrinsic dimensions and has no intrinsic proportions,
  5817. // it's rendered at the size of the background positioning area.
  5818. if (!hasIntrinsicProportion && !hasIntrinsicDimensions) {
  5819. return [bounds.width, bounds.height];
  5820. }
  5821. // TODO If the image has no intrinsic dimensions but has intrinsic proportions, it's rendered as if contain had been specified instead.
  5822. // If the image has only one intrinsic dimension and has intrinsic proportions, it's rendered at the size corresponding to that one dimension.
  5823. // The other dimension is computed using the specified dimension and the intrinsic proportions.
  5824. if (hasIntrinsicDimensions && hasIntrinsicProportion) {
  5825. var width_1 = hasIntrinsicWidth
  5826. ? intrinsicWidth
  5827. : intrinsicHeight * intrinsicProportion;
  5828. var height_1 = hasIntrinsicHeight
  5829. ? intrinsicHeight
  5830. : intrinsicWidth / intrinsicProportion;
  5831. return [width_1, height_1];
  5832. }
  5833. // If the image has only one intrinsic dimension but has no intrinsic proportions,
  5834. // it's rendered using the specified dimension and the other dimension of the background positioning area.
  5835. var width_2 = hasIntrinsicWidth ? intrinsicWidth : bounds.width;
  5836. var height_2 = hasIntrinsicHeight ? intrinsicHeight : bounds.height;
  5837. return [width_2, height_2];
  5838. }
  5839. // If the image has intrinsic proportions, it's stretched to the specified dimension.
  5840. // The unspecified dimension is computed using the specified dimension and the intrinsic proportions.
  5841. if (hasIntrinsicProportion) {
  5842. var width_3 = 0;
  5843. var height_3 = 0;
  5844. if (isLengthPercentage(first)) {
  5845. width_3 = getAbsoluteValue(first, bounds.width);
  5846. }
  5847. else if (isLengthPercentage(second)) {
  5848. height_3 = getAbsoluteValue(second, bounds.height);
  5849. }
  5850. if (isAuto(first)) {
  5851. width_3 = height_3 * intrinsicProportion;
  5852. }
  5853. else if (!second || isAuto(second)) {
  5854. height_3 = width_3 / intrinsicProportion;
  5855. }
  5856. return [width_3, height_3];
  5857. }
  5858. // If the image has no intrinsic proportions, it's stretched to the specified dimension.
  5859. // The unspecified dimension is computed using the image's corresponding intrinsic dimension,
  5860. // if there is one. If there is no such intrinsic dimension,
  5861. // it becomes the corresponding dimension of the background positioning area.
  5862. var width = null;
  5863. var height = null;
  5864. if (isLengthPercentage(first)) {
  5865. width = getAbsoluteValue(first, bounds.width);
  5866. }
  5867. else if (second && isLengthPercentage(second)) {
  5868. height = getAbsoluteValue(second, bounds.height);
  5869. }
  5870. if (width !== null && (!second || isAuto(second))) {
  5871. height =
  5872. hasIntrinsicWidth && hasIntrinsicHeight
  5873. ? (width / intrinsicWidth) * intrinsicHeight
  5874. : bounds.height;
  5875. }
  5876. if (height !== null && isAuto(first)) {
  5877. width =
  5878. hasIntrinsicWidth && hasIntrinsicHeight
  5879. ? (height / intrinsicHeight) * intrinsicWidth
  5880. : bounds.width;
  5881. }
  5882. if (width !== null && height !== null) {
  5883. return [width, height];
  5884. }
  5885. throw new Error("Unable to calculate background-size for element");
  5886. };
  5887. var getBackgroundValueForIndex = function (values, index) {
  5888. var value = values[index];
  5889. if (typeof value === 'undefined') {
  5890. return values[0];
  5891. }
  5892. return value;
  5893. };
  5894. var calculateBackgroundRepeatPath = function (repeat, _a, _b, backgroundPositioningArea, backgroundPaintingArea) {
  5895. var x = _a[0], y = _a[1];
  5896. var width = _b[0], height = _b[1];
  5897. switch (repeat) {
  5898. case BACKGROUND_REPEAT.REPEAT_X:
  5899. return [
  5900. new Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
  5901. new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
  5902. new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
  5903. new Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
  5904. ];
  5905. case BACKGROUND_REPEAT.REPEAT_Y:
  5906. return [
  5907. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
  5908. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
  5909. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
  5910. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
  5911. ];
  5912. case BACKGROUND_REPEAT.NO_REPEAT:
  5913. return [
  5914. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
  5915. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
  5916. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y + height)),
  5917. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y + height))
  5918. ];
  5919. default:
  5920. return [
  5921. new Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.top)),
  5922. new Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.top)),
  5923. new Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top)),
  5924. new Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top))
  5925. ];
  5926. }
  5927. };
  5928. var SMALL_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
  5929. var SAMPLE_TEXT = 'Hidden Text';
  5930. var FontMetrics = /** @class */ (function () {
  5931. function FontMetrics(document) {
  5932. this._data = {};
  5933. this._document = document;
  5934. }
  5935. FontMetrics.prototype.parseMetrics = function (fontFamily, fontSize) {
  5936. var container = this._document.createElement('div');
  5937. var img = this._document.createElement('img');
  5938. var span = this._document.createElement('span');
  5939. var body = this._document.body;
  5940. container.style.visibility = 'hidden';
  5941. container.style.fontFamily = fontFamily;
  5942. container.style.fontSize = fontSize;
  5943. container.style.margin = '0';
  5944. container.style.padding = '0';
  5945. body.appendChild(container);
  5946. img.src = SMALL_IMAGE;
  5947. img.width = 1;
  5948. img.height = 1;
  5949. img.style.margin = '0';
  5950. img.style.padding = '0';
  5951. img.style.verticalAlign = 'baseline';
  5952. span.style.fontFamily = fontFamily;
  5953. span.style.fontSize = fontSize;
  5954. span.style.margin = '0';
  5955. span.style.padding = '0';
  5956. span.appendChild(this._document.createTextNode(SAMPLE_TEXT));
  5957. container.appendChild(span);
  5958. container.appendChild(img);
  5959. var baseline = img.offsetTop - span.offsetTop + 2;
  5960. container.removeChild(span);
  5961. container.appendChild(this._document.createTextNode(SAMPLE_TEXT));
  5962. container.style.lineHeight = 'normal';
  5963. img.style.verticalAlign = 'super';
  5964. var middle = img.offsetTop - container.offsetTop + 2;
  5965. body.removeChild(container);
  5966. return { baseline: baseline, middle: middle };
  5967. };
  5968. FontMetrics.prototype.getMetrics = function (fontFamily, fontSize) {
  5969. var key = fontFamily + " " + fontSize;
  5970. if (typeof this._data[key] === 'undefined') {
  5971. this._data[key] = this.parseMetrics(fontFamily, fontSize);
  5972. }
  5973. return this._data[key];
  5974. };
  5975. return FontMetrics;
  5976. }());
  5977. var MASK_OFFSET = 10000;
  5978. var CanvasRenderer = /** @class */ (function () {
  5979. function CanvasRenderer(options) {
  5980. this._activeEffects = [];
  5981. this.canvas = options.canvas ? options.canvas : document.createElement('canvas');
  5982. this.ctx = this.canvas.getContext('2d');
  5983. this.options = options;
  5984. if (!options.canvas) {
  5985. this.canvas.width = Math.floor(options.width * options.scale);
  5986. this.canvas.height = Math.floor(options.height * options.scale);
  5987. this.canvas.style.width = options.width + "px";
  5988. this.canvas.style.height = options.height + "px";
  5989. }
  5990. this.fontMetrics = new FontMetrics(document);
  5991. this.ctx.scale(this.options.scale, this.options.scale);
  5992. this.ctx.translate(-options.x + options.scrollX, -options.y + options.scrollY);
  5993. this.ctx.textBaseline = 'bottom';
  5994. this._activeEffects = [];
  5995. Logger.getInstance(options.id).debug("Canvas renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale);
  5996. }
  5997. CanvasRenderer.prototype.applyEffects = function (effects, target) {
  5998. var _this = this;
  5999. while (this._activeEffects.length) {
  6000. this.popEffect();
  6001. }
  6002. effects.filter(function (effect) { return contains(effect.target, target); }).forEach(function (effect) { return _this.applyEffect(effect); });
  6003. };
  6004. CanvasRenderer.prototype.applyEffect = function (effect) {
  6005. this.ctx.save();
  6006. if (isTransformEffect(effect)) {
  6007. this.ctx.translate(effect.offsetX, effect.offsetY);
  6008. this.ctx.transform(effect.matrix[0], effect.matrix[1], effect.matrix[2], effect.matrix[3], effect.matrix[4], effect.matrix[5]);
  6009. this.ctx.translate(-effect.offsetX, -effect.offsetY);
  6010. }
  6011. if (isClipEffect(effect)) {
  6012. this.path(effect.path);
  6013. this.ctx.clip();
  6014. }
  6015. this._activeEffects.push(effect);
  6016. };
  6017. CanvasRenderer.prototype.popEffect = function () {
  6018. this._activeEffects.pop();
  6019. this.ctx.restore();
  6020. };
  6021. CanvasRenderer.prototype.renderStack = function (stack) {
  6022. return __awaiter(this, void 0, void 0, function () {
  6023. var styles;
  6024. return __generator(this, function (_a) {
  6025. switch (_a.label) {
  6026. case 0:
  6027. styles = stack.element.container.styles;
  6028. if (!styles.isVisible()) return [3 /*break*/, 2];
  6029. this.ctx.globalAlpha = styles.opacity;
  6030. return [4 /*yield*/, this.renderStackContent(stack)];
  6031. case 1:
  6032. _a.sent();
  6033. _a.label = 2;
  6034. case 2: return [2 /*return*/];
  6035. }
  6036. });
  6037. });
  6038. };
  6039. CanvasRenderer.prototype.renderNode = function (paint) {
  6040. return __awaiter(this, void 0, void 0, function () {
  6041. return __generator(this, function (_a) {
  6042. switch (_a.label) {
  6043. case 0:
  6044. if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
  6045. return [4 /*yield*/, this.renderNodeBackgroundAndBorders(paint)];
  6046. case 1:
  6047. _a.sent();
  6048. return [4 /*yield*/, this.renderNodeContent(paint)];
  6049. case 2:
  6050. _a.sent();
  6051. _a.label = 3;
  6052. case 3: return [2 /*return*/];
  6053. }
  6054. });
  6055. });
  6056. };
  6057. CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing) {
  6058. var _this = this;
  6059. if (letterSpacing === 0) {
  6060. this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
  6061. }
  6062. else {
  6063. var letters = toCodePoints(text.text).map(function (i) { return fromCodePoint(i); });
  6064. letters.reduce(function (left, letter) {
  6065. _this.ctx.fillText(letter, left, text.bounds.top + text.bounds.height);
  6066. return left + _this.ctx.measureText(letter).width;
  6067. }, text.bounds.left);
  6068. }
  6069. };
  6070. CanvasRenderer.prototype.createFontStyle = function (styles) {
  6071. var fontVariant = styles.fontVariant
  6072. .filter(function (variant) { return variant === 'normal' || variant === 'small-caps'; })
  6073. .join('');
  6074. var fontFamily = styles.fontFamily.join(', ');
  6075. var fontSize = isDimensionToken(styles.fontSize)
  6076. ? "" + styles.fontSize.number + styles.fontSize.unit
  6077. : styles.fontSize.number + "px";
  6078. return [
  6079. [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
  6080. fontFamily,
  6081. fontSize
  6082. ];
  6083. };
  6084. CanvasRenderer.prototype.renderTextNode = function (text, styles) {
  6085. return __awaiter(this, void 0, void 0, function () {
  6086. var _a, font, fontFamily, fontSize;
  6087. var _this = this;
  6088. return __generator(this, function (_b) {
  6089. _a = this.createFontStyle(styles), font = _a[0], fontFamily = _a[1], fontSize = _a[2];
  6090. this.ctx.font = font;
  6091. text.textBounds.forEach(function (text) {
  6092. _this.ctx.fillStyle = asString(styles.color);
  6093. _this.renderTextWithLetterSpacing(text, styles.letterSpacing);
  6094. var textShadows = styles.textShadow;
  6095. if (textShadows.length && text.text.trim().length) {
  6096. textShadows
  6097. .slice(0)
  6098. .reverse()
  6099. .forEach(function (textShadow) {
  6100. _this.ctx.shadowColor = asString(textShadow.color);
  6101. _this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
  6102. _this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
  6103. _this.ctx.shadowBlur = textShadow.blur.number;
  6104. _this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
  6105. });
  6106. _this.ctx.shadowColor = '';
  6107. _this.ctx.shadowOffsetX = 0;
  6108. _this.ctx.shadowOffsetY = 0;
  6109. _this.ctx.shadowBlur = 0;
  6110. }
  6111. if (styles.textDecorationLine.length) {
  6112. _this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
  6113. styles.textDecorationLine.forEach(function (textDecorationLine) {
  6114. switch (textDecorationLine) {
  6115. case 1 /* UNDERLINE */:
  6116. // Draws a line at the baseline of the font
  6117. // TODO As some browsers display the line as more than 1px if the font-size is big,
  6118. // need to take that into account both in position and size
  6119. var baseline = _this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
  6120. _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
  6121. break;
  6122. case 2 /* OVERLINE */:
  6123. _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top), text.bounds.width, 1);
  6124. break;
  6125. case 3 /* LINE_THROUGH */:
  6126. // TODO try and find exact position for line-through
  6127. var middle = _this.fontMetrics.getMetrics(fontFamily, fontSize).middle;
  6128. _this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
  6129. break;
  6130. }
  6131. });
  6132. }
  6133. });
  6134. return [2 /*return*/];
  6135. });
  6136. });
  6137. };
  6138. CanvasRenderer.prototype.renderReplacedElement = function (container, curves, image) {
  6139. if (image && container.intrinsicWidth > 0 && container.intrinsicHeight > 0) {
  6140. var box = contentBox(container);
  6141. var path = calculatePaddingBoxPath(curves);
  6142. this.path(path);
  6143. this.ctx.save();
  6144. this.ctx.clip();
  6145. this.ctx.drawImage(image, 0, 0, container.intrinsicWidth, container.intrinsicHeight, box.left, box.top, box.width, box.height);
  6146. this.ctx.restore();
  6147. }
  6148. };
  6149. CanvasRenderer.prototype.renderNodeContent = function (paint) {
  6150. return __awaiter(this, void 0, void 0, function () {
  6151. var container, curves, styles, _i, _a, child, image, e_1, image, e_2, iframeRenderer, canvas, size, bounds, x, textBounds, img, image, url, e_3, bounds;
  6152. return __generator(this, function (_b) {
  6153. switch (_b.label) {
  6154. case 0:
  6155. this.applyEffects(paint.effects, 4 /* CONTENT */);
  6156. container = paint.container;
  6157. curves = paint.curves;
  6158. styles = container.styles;
  6159. _i = 0, _a = container.textNodes;
  6160. _b.label = 1;
  6161. case 1:
  6162. if (!(_i < _a.length)) return [3 /*break*/, 4];
  6163. child = _a[_i];
  6164. return [4 /*yield*/, this.renderTextNode(child, styles)];
  6165. case 2:
  6166. _b.sent();
  6167. _b.label = 3;
  6168. case 3:
  6169. _i++;
  6170. return [3 /*break*/, 1];
  6171. case 4:
  6172. if (!(container instanceof ImageElementContainer)) return [3 /*break*/, 8];
  6173. _b.label = 5;
  6174. case 5:
  6175. _b.trys.push([5, 7, , 8]);
  6176. return [4 /*yield*/, this.options.cache.match(container.src)];
  6177. case 6:
  6178. image = _b.sent();
  6179. this.renderReplacedElement(container, curves, image);
  6180. return [3 /*break*/, 8];
  6181. case 7:
  6182. e_1 = _b.sent();
  6183. Logger.getInstance(this.options.id).error("Error loading image " + container.src);
  6184. return [3 /*break*/, 8];
  6185. case 8:
  6186. if (container instanceof CanvasElementContainer) {
  6187. this.renderReplacedElement(container, curves, container.canvas);
  6188. }
  6189. if (!(container instanceof SVGElementContainer)) return [3 /*break*/, 12];
  6190. _b.label = 9;
  6191. case 9:
  6192. _b.trys.push([9, 11, , 12]);
  6193. return [4 /*yield*/, this.options.cache.match(container.svg)];
  6194. case 10:
  6195. image = _b.sent();
  6196. this.renderReplacedElement(container, curves, image);
  6197. return [3 /*break*/, 12];
  6198. case 11:
  6199. e_2 = _b.sent();
  6200. Logger.getInstance(this.options.id).error("Error loading svg " + container.svg.substring(0, 255));
  6201. return [3 /*break*/, 12];
  6202. case 12:
  6203. if (!(container instanceof IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
  6204. iframeRenderer = new CanvasRenderer({
  6205. id: this.options.id,
  6206. scale: this.options.scale,
  6207. backgroundColor: container.backgroundColor,
  6208. x: 0,
  6209. y: 0,
  6210. scrollX: 0,
  6211. scrollY: 0,
  6212. width: container.width,
  6213. height: container.height,
  6214. cache: this.options.cache,
  6215. windowWidth: container.width,
  6216. windowHeight: container.height
  6217. });
  6218. return [4 /*yield*/, iframeRenderer.render(container.tree)];
  6219. case 13:
  6220. canvas = _b.sent();
  6221. if (container.width && container.height) {
  6222. this.ctx.drawImage(canvas, 0, 0, container.width, container.height, container.bounds.left, container.bounds.top, container.bounds.width, container.bounds.height);
  6223. }
  6224. _b.label = 14;
  6225. case 14:
  6226. if (container instanceof InputElementContainer) {
  6227. size = Math.min(container.bounds.width, container.bounds.height);
  6228. if (container.type === CHECKBOX) {
  6229. if (container.checked) {
  6230. this.ctx.save();
  6231. this.path([
  6232. new Vector(container.bounds.left + size * 0.39363, container.bounds.top + size * 0.79),
  6233. new Vector(container.bounds.left + size * 0.16, container.bounds.top + size * 0.5549),
  6234. new Vector(container.bounds.left + size * 0.27347, container.bounds.top + size * 0.44071),
  6235. new Vector(container.bounds.left + size * 0.39694, container.bounds.top + size * 0.5649),
  6236. new Vector(container.bounds.left + size * 0.72983, container.bounds.top + size * 0.23),
  6237. new Vector(container.bounds.left + size * 0.84, container.bounds.top + size * 0.34085),
  6238. new Vector(container.bounds.left + size * 0.39363, container.bounds.top + size * 0.79)
  6239. ]);
  6240. this.ctx.fillStyle = asString(INPUT_COLOR);
  6241. this.ctx.fill();
  6242. this.ctx.restore();
  6243. }
  6244. }
  6245. else if (container.type === RADIO) {
  6246. if (container.checked) {
  6247. this.ctx.save();
  6248. this.ctx.beginPath();
  6249. this.ctx.arc(container.bounds.left + size / 2, container.bounds.top + size / 2, size / 4, 0, Math.PI * 2, true);
  6250. this.ctx.fillStyle = asString(INPUT_COLOR);
  6251. this.ctx.fill();
  6252. this.ctx.restore();
  6253. }
  6254. }
  6255. }
  6256. if (isTextInputElement(container) && container.value.length) {
  6257. this.ctx.font = this.createFontStyle(styles)[0];
  6258. this.ctx.fillStyle = asString(styles.color);
  6259. this.ctx.textBaseline = 'middle';
  6260. this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
  6261. bounds = contentBox(container);
  6262. x = 0;
  6263. switch (container.styles.textAlign) {
  6264. case TEXT_ALIGN.CENTER:
  6265. x += bounds.width / 2;
  6266. break;
  6267. case TEXT_ALIGN.RIGHT:
  6268. x += bounds.width;
  6269. break;
  6270. }
  6271. textBounds = bounds.add(x, 0, 0, -bounds.height / 2 + 1);
  6272. this.ctx.save();
  6273. this.path([
  6274. new Vector(bounds.left, bounds.top),
  6275. new Vector(bounds.left + bounds.width, bounds.top),
  6276. new Vector(bounds.left + bounds.width, bounds.top + bounds.height),
  6277. new Vector(bounds.left, bounds.top + bounds.height)
  6278. ]);
  6279. this.ctx.clip();
  6280. this.renderTextWithLetterSpacing(new TextBounds(container.value, textBounds), styles.letterSpacing);
  6281. this.ctx.restore();
  6282. this.ctx.textBaseline = 'bottom';
  6283. this.ctx.textAlign = 'left';
  6284. }
  6285. if (!contains(container.styles.display, 2048 /* LIST_ITEM */)) return [3 /*break*/, 20];
  6286. if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
  6287. img = container.styles.listStyleImage;
  6288. if (!(img.type === CSSImageType.URL)) return [3 /*break*/, 18];
  6289. image = void 0;
  6290. url = img.url;
  6291. _b.label = 15;
  6292. case 15:
  6293. _b.trys.push([15, 17, , 18]);
  6294. return [4 /*yield*/, this.options.cache.match(url)];
  6295. case 16:
  6296. image = _b.sent();
  6297. this.ctx.drawImage(image, container.bounds.left - (image.width + 10), container.bounds.top);
  6298. return [3 /*break*/, 18];
  6299. case 17:
  6300. e_3 = _b.sent();
  6301. Logger.getInstance(this.options.id).error("Error loading list-style-image " + url);
  6302. return [3 /*break*/, 18];
  6303. case 18: return [3 /*break*/, 20];
  6304. case 19:
  6305. if (paint.listValue && container.styles.listStyleType !== LIST_STYLE_TYPE.NONE) {
  6306. this.ctx.font = this.createFontStyle(styles)[0];
  6307. this.ctx.fillStyle = asString(styles.color);
  6308. this.ctx.textBaseline = 'middle';
  6309. this.ctx.textAlign = 'right';
  6310. bounds = new Bounds(container.bounds.left, container.bounds.top + getAbsoluteValue(container.styles.paddingTop, container.bounds.width), container.bounds.width, computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1);
  6311. this.renderTextWithLetterSpacing(new TextBounds(paint.listValue, bounds), styles.letterSpacing);
  6312. this.ctx.textBaseline = 'bottom';
  6313. this.ctx.textAlign = 'left';
  6314. }
  6315. _b.label = 20;
  6316. case 20: return [2 /*return*/];
  6317. }
  6318. });
  6319. });
  6320. };
  6321. CanvasRenderer.prototype.renderStackContent = function (stack) {
  6322. return __awaiter(this, void 0, void 0, function () {
  6323. var _i, _a, child, _b, _c, child, _d, _e, child, _f, _g, child, _h, _j, child, _k, _l, child, _m, _o, child;
  6324. return __generator(this, function (_p) {
  6325. switch (_p.label) {
  6326. case 0:
  6327. // https://www.w3.org/TR/css-position-3/#painting-order
  6328. // 1. the background and borders of the element forming the stacking context.
  6329. return [4 /*yield*/, this.renderNodeBackgroundAndBorders(stack.element)];
  6330. case 1:
  6331. // https://www.w3.org/TR/css-position-3/#painting-order
  6332. // 1. the background and borders of the element forming the stacking context.
  6333. _p.sent();
  6334. _i = 0, _a = stack.negativeZIndex;
  6335. _p.label = 2;
  6336. case 2:
  6337. if (!(_i < _a.length)) return [3 /*break*/, 5];
  6338. child = _a[_i];
  6339. return [4 /*yield*/, this.renderStack(child)];
  6340. case 3:
  6341. _p.sent();
  6342. _p.label = 4;
  6343. case 4:
  6344. _i++;
  6345. return [3 /*break*/, 2];
  6346. case 5:
  6347. // 3. For all its in-flow, non-positioned, block-level descendants in tree order:
  6348. return [4 /*yield*/, this.renderNodeContent(stack.element)];
  6349. case 6:
  6350. // 3. For all its in-flow, non-positioned, block-level descendants in tree order:
  6351. _p.sent();
  6352. _b = 0, _c = stack.nonInlineLevel;
  6353. _p.label = 7;
  6354. case 7:
  6355. if (!(_b < _c.length)) return [3 /*break*/, 10];
  6356. child = _c[_b];
  6357. return [4 /*yield*/, this.renderNode(child)];
  6358. case 8:
  6359. _p.sent();
  6360. _p.label = 9;
  6361. case 9:
  6362. _b++;
  6363. return [3 /*break*/, 7];
  6364. case 10:
  6365. _d = 0, _e = stack.nonPositionedFloats;
  6366. _p.label = 11;
  6367. case 11:
  6368. if (!(_d < _e.length)) return [3 /*break*/, 14];
  6369. child = _e[_d];
  6370. return [4 /*yield*/, this.renderStack(child)];
  6371. case 12:
  6372. _p.sent();
  6373. _p.label = 13;
  6374. case 13:
  6375. _d++;
  6376. return [3 /*break*/, 11];
  6377. case 14:
  6378. _f = 0, _g = stack.nonPositionedInlineLevel;
  6379. _p.label = 15;
  6380. case 15:
  6381. if (!(_f < _g.length)) return [3 /*break*/, 18];
  6382. child = _g[_f];
  6383. return [4 /*yield*/, this.renderStack(child)];
  6384. case 16:
  6385. _p.sent();
  6386. _p.label = 17;
  6387. case 17:
  6388. _f++;
  6389. return [3 /*break*/, 15];
  6390. case 18:
  6391. _h = 0, _j = stack.inlineLevel;
  6392. _p.label = 19;
  6393. case 19:
  6394. if (!(_h < _j.length)) return [3 /*break*/, 22];
  6395. child = _j[_h];
  6396. return [4 /*yield*/, this.renderNode(child)];
  6397. case 20:
  6398. _p.sent();
  6399. _p.label = 21;
  6400. case 21:
  6401. _h++;
  6402. return [3 /*break*/, 19];
  6403. case 22:
  6404. _k = 0, _l = stack.zeroOrAutoZIndexOrTransformedOrOpacity;
  6405. _p.label = 23;
  6406. case 23:
  6407. if (!(_k < _l.length)) return [3 /*break*/, 26];
  6408. child = _l[_k];
  6409. return [4 /*yield*/, this.renderStack(child)];
  6410. case 24:
  6411. _p.sent();
  6412. _p.label = 25;
  6413. case 25:
  6414. _k++;
  6415. return [3 /*break*/, 23];
  6416. case 26:
  6417. _m = 0, _o = stack.positiveZIndex;
  6418. _p.label = 27;
  6419. case 27:
  6420. if (!(_m < _o.length)) return [3 /*break*/, 30];
  6421. child = _o[_m];
  6422. return [4 /*yield*/, this.renderStack(child)];
  6423. case 28:
  6424. _p.sent();
  6425. _p.label = 29;
  6426. case 29:
  6427. _m++;
  6428. return [3 /*break*/, 27];
  6429. case 30: return [2 /*return*/];
  6430. }
  6431. });
  6432. });
  6433. };
  6434. CanvasRenderer.prototype.mask = function (paths) {
  6435. this.ctx.beginPath();
  6436. this.ctx.moveTo(0, 0);
  6437. this.ctx.lineTo(this.canvas.width, 0);
  6438. this.ctx.lineTo(this.canvas.width, this.canvas.height);
  6439. this.ctx.lineTo(0, this.canvas.height);
  6440. this.ctx.lineTo(0, 0);
  6441. this.formatPath(paths.slice(0).reverse());
  6442. this.ctx.closePath();
  6443. };
  6444. CanvasRenderer.prototype.path = function (paths) {
  6445. this.ctx.beginPath();
  6446. this.formatPath(paths);
  6447. this.ctx.closePath();
  6448. };
  6449. CanvasRenderer.prototype.formatPath = function (paths) {
  6450. var _this = this;
  6451. paths.forEach(function (point, index) {
  6452. var start = isBezierCurve(point) ? point.start : point;
  6453. if (index === 0) {
  6454. _this.ctx.moveTo(start.x, start.y);
  6455. }
  6456. else {
  6457. _this.ctx.lineTo(start.x, start.y);
  6458. }
  6459. if (isBezierCurve(point)) {
  6460. _this.ctx.bezierCurveTo(point.startControl.x, point.startControl.y, point.endControl.x, point.endControl.y, point.end.x, point.end.y);
  6461. }
  6462. });
  6463. };
  6464. CanvasRenderer.prototype.renderRepeat = function (path, pattern, offsetX, offsetY) {
  6465. this.path(path);
  6466. this.ctx.fillStyle = pattern;
  6467. this.ctx.translate(offsetX, offsetY);
  6468. this.ctx.fill();
  6469. this.ctx.translate(-offsetX, -offsetY);
  6470. };
  6471. CanvasRenderer.prototype.resizeImage = function (image, width, height) {
  6472. if (image.width === width && image.height === height) {
  6473. return image;
  6474. }
  6475. var canvas = this.canvas.ownerDocument.createElement('canvas');
  6476. canvas.width = width;
  6477. canvas.height = height;
  6478. var ctx = canvas.getContext('2d');
  6479. ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, width, height);
  6480. return canvas;
  6481. };
  6482. CanvasRenderer.prototype.renderBackgroundImage = function (container) {
  6483. return __awaiter(this, void 0, void 0, function () {
  6484. var index, _loop_1, this_1, _i, _a, backgroundImage;
  6485. return __generator(this, function (_b) {
  6486. switch (_b.label) {
  6487. case 0:
  6488. index = container.styles.backgroundImage.length - 1;
  6489. _loop_1 = function (backgroundImage) {
  6490. var image, url, e_4, _a, path, x, y, width, height, pattern, _b, path, x, y, width, height, _c, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _d, path, left, top_1, width, height, position, x, y, _e, rx, ry, radialGradient_1, midX, midY, f, invF;
  6491. return __generator(this, function (_f) {
  6492. switch (_f.label) {
  6493. case 0:
  6494. if (!(backgroundImage.type === CSSImageType.URL)) return [3 /*break*/, 5];
  6495. image = void 0;
  6496. url = backgroundImage.url;
  6497. _f.label = 1;
  6498. case 1:
  6499. _f.trys.push([1, 3, , 4]);
  6500. return [4 /*yield*/, this_1.options.cache.match(url)];
  6501. case 2:
  6502. image = _f.sent();
  6503. return [3 /*break*/, 4];
  6504. case 3:
  6505. e_4 = _f.sent();
  6506. Logger.getInstance(this_1.options.id).error("Error loading background-image " + url);
  6507. return [3 /*break*/, 4];
  6508. case 4:
  6509. if (image) {
  6510. _a = calculateBackgroundRendering(container, index, [
  6511. image.width,
  6512. image.height,
  6513. image.width / image.height
  6514. ]), path = _a[0], x = _a[1], y = _a[2], width = _a[3], height = _a[4];
  6515. pattern = this_1.ctx.createPattern(this_1.resizeImage(image, width, height), 'repeat');
  6516. this_1.renderRepeat(path, pattern, x, y);
  6517. }
  6518. return [3 /*break*/, 6];
  6519. case 5:
  6520. if (isLinearGradient(backgroundImage)) {
  6521. _b = calculateBackgroundRendering(container, index, [null, null, null]), path = _b[0], x = _b[1], y = _b[2], width = _b[3], height = _b[4];
  6522. _c = calculateGradientDirection(backgroundImage.angle, width, height), lineLength = _c[0], x0 = _c[1], x1 = _c[2], y0 = _c[3], y1 = _c[4];
  6523. canvas = document.createElement('canvas');
  6524. canvas.width = width;
  6525. canvas.height = height;
  6526. ctx = canvas.getContext('2d');
  6527. gradient_1 = ctx.createLinearGradient(x0, y0, x1, y1);
  6528. processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
  6529. return gradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
  6530. });
  6531. ctx.fillStyle = gradient_1;
  6532. ctx.fillRect(0, 0, width, height);
  6533. if (width > 0 && height > 0) {
  6534. pattern = this_1.ctx.createPattern(canvas, 'repeat');
  6535. this_1.renderRepeat(path, pattern, x, y);
  6536. }
  6537. }
  6538. else if (isRadialGradient(backgroundImage)) {
  6539. _d = calculateBackgroundRendering(container, index, [
  6540. null,
  6541. null,
  6542. null
  6543. ]), path = _d[0], left = _d[1], top_1 = _d[2], width = _d[3], height = _d[4];
  6544. position = backgroundImage.position.length === 0 ? [FIFTY_PERCENT] : backgroundImage.position;
  6545. x = getAbsoluteValue(position[0], width);
  6546. y = getAbsoluteValue(position[position.length - 1], height);
  6547. _e = calculateRadius(backgroundImage, x, y, width, height), rx = _e[0], ry = _e[1];
  6548. if (rx > 0 && rx > 0) {
  6549. radialGradient_1 = this_1.ctx.createRadialGradient(left + x, top_1 + y, 0, left + x, top_1 + y, rx);
  6550. processColorStops(backgroundImage.stops, rx * 2).forEach(function (colorStop) {
  6551. return radialGradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
  6552. });
  6553. this_1.path(path);
  6554. this_1.ctx.fillStyle = radialGradient_1;
  6555. if (rx !== ry) {
  6556. midX = container.bounds.left + 0.5 * container.bounds.width;
  6557. midY = container.bounds.top + 0.5 * container.bounds.height;
  6558. f = ry / rx;
  6559. invF = 1 / f;
  6560. this_1.ctx.save();
  6561. this_1.ctx.translate(midX, midY);
  6562. this_1.ctx.transform(1, 0, 0, f, 0, 0);
  6563. this_1.ctx.translate(-midX, -midY);
  6564. this_1.ctx.fillRect(left, invF * (top_1 - midY) + midY, width, height * invF);
  6565. this_1.ctx.restore();
  6566. }
  6567. else {
  6568. this_1.ctx.fill();
  6569. }
  6570. }
  6571. }
  6572. _f.label = 6;
  6573. case 6:
  6574. index--;
  6575. return [2 /*return*/];
  6576. }
  6577. });
  6578. };
  6579. this_1 = this;
  6580. _i = 0, _a = container.styles.backgroundImage.slice(0).reverse();
  6581. _b.label = 1;
  6582. case 1:
  6583. if (!(_i < _a.length)) return [3 /*break*/, 4];
  6584. backgroundImage = _a[_i];
  6585. return [5 /*yield**/, _loop_1(backgroundImage)];
  6586. case 2:
  6587. _b.sent();
  6588. _b.label = 3;
  6589. case 3:
  6590. _i++;
  6591. return [3 /*break*/, 1];
  6592. case 4: return [2 /*return*/];
  6593. }
  6594. });
  6595. });
  6596. };
  6597. CanvasRenderer.prototype.renderBorder = function (color, side, curvePoints) {
  6598. return __awaiter(this, void 0, void 0, function () {
  6599. return __generator(this, function (_a) {
  6600. this.path(parsePathForBorder(curvePoints, side));
  6601. this.ctx.fillStyle = asString(color);
  6602. this.ctx.fill();
  6603. return [2 /*return*/];
  6604. });
  6605. });
  6606. };
  6607. CanvasRenderer.prototype.renderNodeBackgroundAndBorders = function (paint) {
  6608. return __awaiter(this, void 0, void 0, function () {
  6609. var styles, hasBackground, borders, backgroundPaintingArea, side, _i, borders_1, border;
  6610. var _this = this;
  6611. return __generator(this, function (_a) {
  6612. switch (_a.label) {
  6613. case 0:
  6614. this.applyEffects(paint.effects, 2 /* BACKGROUND_BORDERS */);
  6615. styles = paint.container.styles;
  6616. hasBackground = !isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
  6617. borders = [
  6618. { style: styles.borderTopStyle, color: styles.borderTopColor },
  6619. { style: styles.borderRightStyle, color: styles.borderRightColor },
  6620. { style: styles.borderBottomStyle, color: styles.borderBottomColor },
  6621. { style: styles.borderLeftStyle, color: styles.borderLeftColor }
  6622. ];
  6623. backgroundPaintingArea = calculateBackgroundCurvedPaintingArea(getBackgroundValueForIndex(styles.backgroundClip, 0), paint.curves);
  6624. if (!(hasBackground || styles.boxShadow.length)) return [3 /*break*/, 2];
  6625. this.ctx.save();
  6626. this.path(backgroundPaintingArea);
  6627. this.ctx.clip();
  6628. if (!isTransparent(styles.backgroundColor)) {
  6629. this.ctx.fillStyle = asString(styles.backgroundColor);
  6630. this.ctx.fill();
  6631. }
  6632. return [4 /*yield*/, this.renderBackgroundImage(paint.container)];
  6633. case 1:
  6634. _a.sent();
  6635. this.ctx.restore();
  6636. styles.boxShadow
  6637. .slice(0)
  6638. .reverse()
  6639. .forEach(function (shadow) {
  6640. _this.ctx.save();
  6641. var borderBoxArea = calculateBorderBoxPath(paint.curves);
  6642. var maskOffset = shadow.inset ? 0 : MASK_OFFSET;
  6643. var shadowPaintingArea = transformPath(borderBoxArea, -maskOffset + (shadow.inset ? 1 : -1) * shadow.spread.number, (shadow.inset ? 1 : -1) * shadow.spread.number, shadow.spread.number * (shadow.inset ? -2 : 2), shadow.spread.number * (shadow.inset ? -2 : 2));
  6644. if (shadow.inset) {
  6645. _this.path(borderBoxArea);
  6646. _this.ctx.clip();
  6647. _this.mask(shadowPaintingArea);
  6648. }
  6649. else {
  6650. _this.mask(borderBoxArea);
  6651. _this.ctx.clip();
  6652. _this.path(shadowPaintingArea);
  6653. }
  6654. _this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset;
  6655. _this.ctx.shadowOffsetY = shadow.offsetY.number;
  6656. _this.ctx.shadowColor = asString(shadow.color);
  6657. _this.ctx.shadowBlur = shadow.blur.number;
  6658. _this.ctx.fillStyle = shadow.inset ? asString(shadow.color) : 'rgba(0,0,0,1)';
  6659. _this.ctx.fill();
  6660. _this.ctx.restore();
  6661. });
  6662. _a.label = 2;
  6663. case 2:
  6664. side = 0;
  6665. _i = 0, borders_1 = borders;
  6666. _a.label = 3;
  6667. case 3:
  6668. if (!(_i < borders_1.length)) return [3 /*break*/, 7];
  6669. border = borders_1[_i];
  6670. if (!(border.style !== BORDER_STYLE.NONE && !isTransparent(border.color))) return [3 /*break*/, 5];
  6671. return [4 /*yield*/, this.renderBorder(border.color, side, paint.curves)];
  6672. case 4:
  6673. _a.sent();
  6674. _a.label = 5;
  6675. case 5:
  6676. side++;
  6677. _a.label = 6;
  6678. case 6:
  6679. _i++;
  6680. return [3 /*break*/, 3];
  6681. case 7: return [2 /*return*/];
  6682. }
  6683. });
  6684. });
  6685. };
  6686. CanvasRenderer.prototype.render = function (element) {
  6687. return __awaiter(this, void 0, void 0, function () {
  6688. var stack;
  6689. return __generator(this, function (_a) {
  6690. switch (_a.label) {
  6691. case 0:
  6692. if (this.options.backgroundColor) {
  6693. this.ctx.fillStyle = asString(this.options.backgroundColor);
  6694. this.ctx.fillRect(this.options.x - this.options.scrollX, this.options.y - this.options.scrollY, this.options.width, this.options.height);
  6695. }
  6696. stack = parseStackingContexts(element);
  6697. return [4 /*yield*/, this.renderStack(stack)];
  6698. case 1:
  6699. _a.sent();
  6700. this.applyEffects([], 2 /* BACKGROUND_BORDERS */);
  6701. return [2 /*return*/, this.canvas];
  6702. }
  6703. });
  6704. });
  6705. };
  6706. return CanvasRenderer;
  6707. }());
  6708. var isTextInputElement = function (container) {
  6709. if (container instanceof TextareaElementContainer) {
  6710. return true;
  6711. }
  6712. else if (container instanceof SelectElementContainer) {
  6713. return true;
  6714. }
  6715. else if (container instanceof InputElementContainer && container.type !== RADIO && container.type !== CHECKBOX) {
  6716. return true;
  6717. }
  6718. return false;
  6719. };
  6720. var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
  6721. switch (clip) {
  6722. case BACKGROUND_CLIP.BORDER_BOX:
  6723. return calculateBorderBoxPath(curves);
  6724. case BACKGROUND_CLIP.CONTENT_BOX:
  6725. return calculateContentBoxPath(curves);
  6726. case BACKGROUND_CLIP.PADDING_BOX:
  6727. default:
  6728. return calculatePaddingBoxPath(curves);
  6729. }
  6730. };
  6731. var canvasTextAlign = function (textAlign) {
  6732. switch (textAlign) {
  6733. case TEXT_ALIGN.CENTER:
  6734. return 'center';
  6735. case TEXT_ALIGN.RIGHT:
  6736. return 'right';
  6737. case TEXT_ALIGN.LEFT:
  6738. default:
  6739. return 'left';
  6740. }
  6741. };
  6742. var ForeignObjectRenderer = /** @class */ (function () {
  6743. function ForeignObjectRenderer(options) {
  6744. this.canvas = options.canvas ? options.canvas : document.createElement('canvas');
  6745. this.ctx = this.canvas.getContext('2d');
  6746. this.options = options;
  6747. this.canvas.width = Math.floor(options.width * options.scale);
  6748. this.canvas.height = Math.floor(options.height * options.scale);
  6749. this.canvas.style.width = options.width + "px";
  6750. this.canvas.style.height = options.height + "px";
  6751. this.ctx.scale(this.options.scale, this.options.scale);
  6752. this.ctx.translate(-options.x + options.scrollX, -options.y + options.scrollY);
  6753. Logger.getInstance(options.id).debug("EXPERIMENTAL ForeignObject renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale);
  6754. }
  6755. ForeignObjectRenderer.prototype.render = function (element) {
  6756. return __awaiter(this, void 0, void 0, function () {
  6757. var svg, img;
  6758. return __generator(this, function (_a) {
  6759. switch (_a.label) {
  6760. case 0:
  6761. svg = createForeignObjectSVG(Math.max(this.options.windowWidth, this.options.width) * this.options.scale, Math.max(this.options.windowHeight, this.options.height) * this.options.scale, this.options.scrollX * this.options.scale, this.options.scrollY * this.options.scale, element);
  6762. return [4 /*yield*/, loadSerializedSVG$1(svg)];
  6763. case 1:
  6764. img = _a.sent();
  6765. if (this.options.backgroundColor) {
  6766. this.ctx.fillStyle = asString(this.options.backgroundColor);
  6767. this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale);
  6768. }
  6769. this.ctx.drawImage(img, -this.options.x * this.options.scale, -this.options.y * this.options.scale);
  6770. return [2 /*return*/, this.canvas];
  6771. }
  6772. });
  6773. });
  6774. };
  6775. return ForeignObjectRenderer;
  6776. }());
  6777. var loadSerializedSVG$1 = function (svg) {
  6778. return new Promise(function (resolve, reject) {
  6779. var img = new Image();
  6780. img.onload = function () {
  6781. resolve(img);
  6782. };
  6783. img.onerror = reject;
  6784. img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
  6785. });
  6786. };
  6787. var _this = undefined;
  6788. var parseColor$1 = function (value) { return color.parse(Parser.create(value).parseComponentValue()); };
  6789. var html2canvas = function (element, options) {
  6790. if (options === void 0) { options = {}; }
  6791. return renderElement(element, options);
  6792. };
  6793. CacheStorage.setContext(window);
  6794. var renderElement = function (element, opts) { return __awaiter(_this, void 0, void 0, function () {
  6795. var ownerDocument, defaultView, instanceName, _a, width, height, left, top, defaultResourceOptions, resourceOptions, defaultOptions, options, windowBounds, documentCloner, clonedElement, container, documentBackgroundColor, bodyBackgroundColor, bgColor, defaultBackgroundColor, backgroundColor, renderOptions, canvas, renderer, root, renderer;
  6796. return __generator(this, function (_b) {
  6797. switch (_b.label) {
  6798. case 0:
  6799. ownerDocument = element.ownerDocument;
  6800. if (!ownerDocument) {
  6801. throw new Error("Element is not attached to a Document");
  6802. }
  6803. defaultView = ownerDocument.defaultView;
  6804. if (!defaultView) {
  6805. throw new Error("Document is not attached to a Window");
  6806. }
  6807. instanceName = (Math.round(Math.random() * 1000) + Date.now()).toString(16);
  6808. _a = isBodyElement(element) || isHTMLElement(element) ? parseDocumentSize(ownerDocument) : parseBounds(element), width = _a.width, height = _a.height, left = _a.left, top = _a.top;
  6809. defaultResourceOptions = {
  6810. allowTaint: false,
  6811. imageTimeout: 15000,
  6812. proxy: undefined,
  6813. useCORS: false
  6814. };
  6815. resourceOptions = __assign({}, defaultResourceOptions, opts);
  6816. defaultOptions = {
  6817. backgroundColor: '#ffffff',
  6818. cache: opts.cache ? opts.cache : CacheStorage.create(instanceName, resourceOptions),
  6819. logging: true,
  6820. removeContainer: true,
  6821. foreignObjectRendering: false,
  6822. scale: defaultView.devicePixelRatio || 1,
  6823. windowWidth: defaultView.innerWidth,
  6824. windowHeight: defaultView.innerHeight,
  6825. scrollX: defaultView.pageXOffset,
  6826. scrollY: defaultView.pageYOffset,
  6827. x: left,
  6828. y: top,
  6829. width: Math.ceil(width),
  6830. height: Math.ceil(height),
  6831. id: instanceName
  6832. };
  6833. options = __assign({}, defaultOptions, resourceOptions, opts);
  6834. windowBounds = new Bounds(options.scrollX, options.scrollY, options.windowWidth, options.windowHeight);
  6835. Logger.create({ id: instanceName, enabled: options.logging });
  6836. Logger.getInstance(instanceName).debug("Starting document clone");
  6837. documentCloner = new DocumentCloner(element, {
  6838. id: instanceName,
  6839. onclone: options.onclone,
  6840. ignoreElements: options.ignoreElements,
  6841. inlineImages: options.foreignObjectRendering,
  6842. copyStyles: options.foreignObjectRendering
  6843. });
  6844. clonedElement = documentCloner.clonedReferenceElement;
  6845. if (!clonedElement) {
  6846. return [2 /*return*/, Promise.reject("Unable to find element in cloned iframe")];
  6847. }
  6848. return [4 /*yield*/, documentCloner.toIFrame(ownerDocument, windowBounds)];
  6849. case 1:
  6850. container = _b.sent();
  6851. documentBackgroundColor = ownerDocument.documentElement
  6852. ? parseColor$1(getComputedStyle(ownerDocument.documentElement).backgroundColor)
  6853. : COLORS.TRANSPARENT;
  6854. bodyBackgroundColor = ownerDocument.body
  6855. ? parseColor$1(getComputedStyle(ownerDocument.body).backgroundColor)
  6856. : COLORS.TRANSPARENT;
  6857. bgColor = opts.backgroundColor;
  6858. defaultBackgroundColor = typeof bgColor === 'string' ? parseColor$1(bgColor) : bgColor === null ? COLORS.TRANSPARENT : 0xffffffff;
  6859. backgroundColor = element === ownerDocument.documentElement
  6860. ? isTransparent(documentBackgroundColor)
  6861. ? isTransparent(bodyBackgroundColor)
  6862. ? defaultBackgroundColor
  6863. : bodyBackgroundColor
  6864. : documentBackgroundColor
  6865. : defaultBackgroundColor;
  6866. renderOptions = {
  6867. id: instanceName,
  6868. cache: options.cache,
  6869. canvas: options.canvas,
  6870. backgroundColor: backgroundColor,
  6871. scale: options.scale,
  6872. x: options.x,
  6873. y: options.y,
  6874. scrollX: options.scrollX,
  6875. scrollY: options.scrollY,
  6876. width: options.width,
  6877. height: options.height,
  6878. windowWidth: options.windowWidth,
  6879. windowHeight: options.windowHeight
  6880. };
  6881. if (!options.foreignObjectRendering) return [3 /*break*/, 3];
  6882. Logger.getInstance(instanceName).debug("Document cloned, using foreign object rendering");
  6883. renderer = new ForeignObjectRenderer(renderOptions);
  6884. return [4 /*yield*/, renderer.render(clonedElement)];
  6885. case 2:
  6886. canvas = _b.sent();
  6887. return [3 /*break*/, 5];
  6888. case 3:
  6889. Logger.getInstance(instanceName).debug("Document cloned, using computed rendering");
  6890. CacheStorage.attachInstance(options.cache);
  6891. Logger.getInstance(instanceName).debug("Starting DOM parsing");
  6892. root = parseTree(clonedElement);
  6893. CacheStorage.detachInstance();
  6894. if (backgroundColor === root.styles.backgroundColor) {
  6895. root.styles.backgroundColor = COLORS.TRANSPARENT;
  6896. }
  6897. Logger.getInstance(instanceName).debug("Starting renderer");
  6898. renderer = new CanvasRenderer(renderOptions);
  6899. return [4 /*yield*/, renderer.render(root)];
  6900. case 4:
  6901. canvas = _b.sent();
  6902. _b.label = 5;
  6903. case 5:
  6904. if (options.removeContainer === true) {
  6905. if (!DocumentCloner.destroy(container)) {
  6906. Logger.getInstance(instanceName).error("Cannot detach cloned iframe as it is not in the DOM anymore");
  6907. }
  6908. }
  6909. Logger.getInstance(instanceName).debug("Finished rendering");
  6910. Logger.destroy(instanceName);
  6911. CacheStorage.destroy(instanceName);
  6912. return [2 /*return*/, canvas];
  6913. }
  6914. });
  6915. }); };
  6916. export default html2canvas;
  6917. //# sourceMappingURL=html2canvas.esm.js.map