html2canvas.js 366 KB

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